Пример #1
0
 @Override
 public void setMyClasses(String classes) {
   int x = classes.indexOf(';');
   final ArrayList<CharClass> classV = new ArrayList<CharClass>();
   CharClass C = null;
   while (x >= 0) {
     final String theClass = classes.substring(0, x).trim();
     classes = classes.substring(x + 1);
     if (theClass.length() > 0) {
       C = CMClass.getCharClass(theClass);
       if (C == null) C = CMClass.getCharClass("StdCharClass");
       classV.add(C);
     }
     x = classes.indexOf(';');
   }
   if (classes.trim().length() > 0) {
     C = CMClass.getCharClass(classes.trim());
     if (C == null) C = CMClass.getCharClass("StdCharClass");
     classV.add(C);
   }
   myClasses = classV.toArray(new CharClass[0]);
 }
Пример #2
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((!built) && (affected instanceof MOB)) {
      built = true;
      CharClass C = null;
      final Vector allowedClasses = new Vector();
      final Vector allowedExpertises = new Vector();
      final Vector<String> V = CMParms.parse(text());
      String s = null;
      for (int v = 0; v < V.size(); v++) {
        s = V.elementAt(v);
        if (s.equalsIgnoreCase("all")) continue;
        C = CMClass.getCharClass(s);
        if (C != null) {
          if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) {
            final String baseClass = C.baseClass();
            for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) {
              C = (CharClass) c.nextElement();
              if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C)))
                allowedClasses.addElement(C);
            }
          } else allowedClasses.addElement(C);
        } else {
          final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s);
          if (def != null) allowedExpertises.addElement(def);
        }
      }
      if (allowedClasses.size() == 0)
        for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); )
          allowedClasses.addElement(c.nextElement());
      if (allowedExpertises.size() == 0)
        for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); )
          allowedExpertises.addElement(e.nextElement());

      final MOB mob = (MOB) affected;
      for (int c = 0; c < allowedClasses.size(); c++) {
        C = (CharClass) allowedClasses.elementAt(c);
        addCharClassIfNotFound(mob, C);
      }
      for (int e = 0; e < allowedExpertises.size(); e++)
        mob.addExpertise(
            ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID);
      mob.recoverCharStats();
      mob.recoverPhyStats();
      mob.recoverMaxState();
    }
    return super.tick(ticking, tickID);
  }
Пример #3
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final StringBuffer head = new StringBuffer("");
   final boolean isArchonLooker = CMSecurity.isASysOp(mob);
   head.append("^x[");
   head.append(CMStrings.padRight(L("Class"), 16) + " ");
   head.append(CMStrings.padRight(L("Race"), 8) + " ");
   head.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   if (isArchonLooker) head.append(CMStrings.padRight(L("Last"), 18) + " ");
   head.append("] Character Name^.^?\n\r");
   mob.tell(
       "^x["
           + CMStrings.centerPreserve(
               L("The Administrators of @x1", CMProps.getVar(CMProps.Str.MUDNAME)),
               head.length() - 10)
           + "]^.^?");
   final java.util.List<PlayerLibrary.ThinPlayer> allUsers =
       CMLib.database().getExtendedUserList();
   String mask = CMProps.getVar(CMProps.Str.WIZLISTMASK);
   if (mask.length() == 0) mask = "-ANYCLASS +Archon";
   final MaskingLibrary.CompiledZMask compiledMask = CMLib.masking().maskCompile(mask);
   for (final PlayerLibrary.ThinPlayer U : allUsers) {
     CharClass C;
     final MOB player = CMLib.players().getPlayer(U.name());
     if (player != null) C = player.charStats().getCurrentClass();
     else C = CMClass.getCharClass(U.charClass());
     if (C == null) C = CMClass.findCharClass(U.charClass());
     if (((player != null) && (CMLib.masking().maskCheck(compiledMask, player, true)))
         || (CMLib.masking().maskCheck(compiledMask, U))) {
       head.append("[");
       if (C != null) head.append(CMStrings.padRight(C.name(), 16) + " ");
       else head.append(CMStrings.padRight(L("Unknown"), 16) + " ");
       head.append(CMStrings.padRight(U.race(), 8) + " ");
       if ((C == null) || (!C.leveless()))
         head.append(CMStrings.padRight("" + U.level(), 4) + " ");
       else head.append(CMStrings.padRight("    ", 4) + " ");
       if (isArchonLooker)
         head.append(CMStrings.padRight(CMLib.time().date2String(U.last()), 18) + " ");
       head.append("] " + U.name());
       head.append("\n\r");
     }
   }
   mob.tell(head.toString());
   return false;
 }
Пример #4
0
 @Override
 public void reset() {
   setAllBaseValues(VALUE_ALLSTATS_DEFAULT);
   stats[STAT_GENDER] = 'M';
   // myClasses;  // never null
   myLevels = null;
   // myRace; // never null
   raceName = null;
   genderName = null;
   displayClassName = null;
   displayClassLevel = null;
   bodyAlterations = null;
   unwearableBitmap = 0;
   breathables = null;
   arriveStr = null;
   leaveStr = null;
   profAdj = null;
   proficiencies = emptyFiltererArray;
   setMyRace(CMClass.getRace("StdRace"));
   setCurrentClass(CMClass.getCharClass("StdCharClass"));
 }
Пример #5
0
 @Override
 public CharClass getMyClass(int i) {
   if ((myClasses == null) || (i < 0) || (i >= myClasses.length))
     return CMClass.getCharClass("StdCharClass");
   return myClasses[i];
 }
Пример #6
0
  public String runMacro(HTTPRequest httpReq, String parm) {
    java.util.Map<String, String> parms = parseParms(parm);
    String last = httpReq.getUrlParameter("DEITY");
    if (last == null) return " @break@";
    if (last.length() > 0) {
      Deity D = CMLib.map().getDeity(last);
      if (D != null) {
        StringBuffer str = new StringBuffer("");
        if (parms.containsKey("DESCRIPTION")) str.append(D.description() + ", ");
        if (parms.containsKey("NAME")) str.append(D.Name() + ", ");
        if (parms.containsKey("LOCATION")) {
          if (D.getStartRoom() == null) str.append("Nowhere, ");
          else
            str.append(
                CMLib.map().getExtendedRoomID(D.getStartRoom())
                    + ": "
                    + D.getStartRoom().displayText()
                    + ", ");
        }
        if (parms.containsKey("AREA") && (D.getStartRoom() != null))
          if (parms.containsKey("ENCODED"))
            try {
              str.append(URLEncoder.encode(D.getStartRoom().getArea().Name(), "UTF-8") + ", ");
            } catch (Exception e) {
            }
          else str.append(D.getStartRoom().getArea().Name() + ", ");
        if (parms.containsKey("ROOM") && (D.getStartRoom() != null))
          if (parms.containsKey("ENCODED"))
            try {
              str.append(URLEncoder.encode(D.getStartRoom().roomID(), "UTF-8") + ", ");
            } catch (Exception e) {
            }
          else str.append(D.getStartRoom().roomID() + ", ");
        if (parms.containsKey("MOBCODE")) {
          String roomID = D.getStartRoom().roomID();
          List classes = (List) httpReq.getRequestObjects().get("DEITYLIST-" + roomID);
          if (classes == null) {
            classes = new Vector();
            Room R = (Room) httpReq.getRequestObjects().get(roomID);
            if (R == null) {
              R = CMLib.map().getRoom(roomID);
              if (R == null) return "No Room?!";
              Vector restoreDeities = new Vector();
              for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) {
                Deity D2 = (Deity) e.nextElement();
                if ((D2.getStartRoom() != null)
                    && (CMLib.map()
                        .getExtendedRoomID(D2.getStartRoom())
                        .equalsIgnoreCase(CMLib.map().getExtendedRoomID(R))))
                  restoreDeities.addElement(D2);
              }
              CMLib.map().resetRoom(R);
              R = CMLib.map().getRoom(roomID);
              for (int d = restoreDeities.size() - 1; d >= 0; d--) {
                Deity D2 = (Deity) restoreDeities.elementAt(d);
                if (CMLib.map().getDeity(D2.Name()) != null) restoreDeities.removeElementAt(d);
              }
              for (Enumeration e = restoreDeities.elements(); e.hasMoreElements(); ) {
                Deity D2 = (Deity) e.nextElement();
                for (int i = 0; i < R.numInhabitants(); i++) {
                  MOB M = R.fetchInhabitant(i);
                  if ((M instanceof Deity) && (M.Name().equals(D2.Name())))
                    CMLib.map().registerWorldObjectLoaded(R.getArea(), R, M);
                }
              }
              httpReq.getRequestObjects().put(roomID, R);
              D = CMLib.map().getDeity(last);
            }
            synchronized (("SYNC" + roomID).intern()) {
              R = CMLib.map().getRoom(R);
              for (int m = 0; m < R.numInhabitants(); m++) {
                MOB M = R.fetchInhabitant(m);
                if (M.isSavable()) classes.add(M);
              }
              RoomData.contributeMOBs(classes);
            }
            httpReq.getRequestObjects().put("DEITYLIST-" + roomID, classes);
          }
          if (parms.containsKey("ENCODED"))
            try {
              str.append(URLEncoder.encode(RoomData.getMOBCode(classes, D), "UTF-8") + ", ");
            } catch (Exception e) {
            }
          else str.append(RoomData.getMOBCode(classes, D) + ", ");
        }
        if (parms.containsKey("WORSHIPREQ")) str.append(D.getWorshipRequirementsDesc() + ", ");
        if (parms.containsKey("CLERICREQ")) str.append(D.getClericRequirementsDesc() + ", ");
        if (parms.containsKey("SERVICETRIG")) str.append(D.getServiceTriggerDesc() + ", ");
        if (D.numCurses() > 0) {
          if (parms.containsKey("WORSHIPSINTRIG")) str.append(D.getWorshipSinDesc() + ", ");
          if (parms.containsKey("CLERICSINTRIG")) str.append(D.getClericSinDesc() + ", ");
        }

        if (D.numPowers() > 0)
          if (parms.containsKey("POWERTRIG")) str.append(D.getClericPowerupDesc() + ", ");
        if (D.numBlessings() > 0) {
          if (parms.containsKey("WORSHIPTRIG")) str.append(D.getWorshipTriggerDesc() + ", ");
          if (parms.containsKey("CLERICTRIG")) str.append(D.getClericTriggerDesc() + ", ");
        }
        if (parms.containsKey("NUMFOLLOWERS")) {
          DVector data = getDeityData(httpReq, D.Name());
          int num = data.size();
          str.append(num + ", ");
        }
        if (parms.containsKey("NUMPRIESTS")) {
          DVector data = getDeityData(httpReq, D.Name());
          int num = 0;
          // DV.addElement(username, cclass, ""+level, race);
          for (int d = 0; d < data.size(); d++) {
            CharClass C = CMClass.getCharClass((String) data.elementAt(d, 2));
            if ((C != null) && (C.baseClass().equalsIgnoreCase("CLERIC"))) num++;
          }
          str.append(num + ", ");
        }
        String strstr = str.toString();
        if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
        return clearWebMacros(strstr);
      }
    }
    return "";
  }