Пример #1
0
  public String runMacro(ExternalHTTPRequests httpReq, String parm) {
    if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED))
      return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS);

    Hashtable parms = parseParms(parm);
    String last = httpReq.getRequestParameter("PLAYER");
    if (last == null) return " @break@";
    if (last.length() > 0) {
      MOB M = CMLib.players().getLoadPlayer(last);
      if (M == null) {
        MOB authM = Authenticate.getAuthenticatedMob(httpReq);
        if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM;
        else return " @break@";
      }

      boolean firstTime =
          (!httpReq.isRequestParameter("ACTION"))
              || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME");
      StringBuffer str = new StringBuffer("");
      for (int i = 0; i < MOB.AUTODESC.length; i++) {
        if (parms.containsKey(MOB.AUTODESC[i])) {
          boolean set = CMath.isSet(M.getBitmap(), i);
          if (MOB.AUTOREV[i]) set = !set;
          str.append((set ? "ON" : "OFF") + ",");
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.charStats();
          if (parms.containsKey(stat)) {
            String old = httpReq.getRequestParameter(stat);
            if ((firstTime) || (old.length() == 0)) {
              if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER))
                old = "" + C.getSave(i);
              else old = "" + C.getStat(i);
            }
            str.append(old + ", ");
          }
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.baseCharStats();
          if (parms.containsKey("BASE" + stat)) {
            String old = httpReq.getRequestParameter("BASE" + stat);
            if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i);
            str.append(old + ", ");
          }
        }
      }
      for (int i = 0; i < BASICS.length; i++) {
        if (parms.containsKey(BASICS[i])) {
          if (httpReq.isRequestParameter(BASICS[i]))
            str.append(httpReq.getRequestParameter(BASICS[i]) + ", ");
          else str.append(getBasic(M, i));
        }
      }
      if (parms.containsKey("RACE")) {
        String old = httpReq.getRequestParameter("RACE");
        if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID();
        for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) {
          Race R2 = (Race) r.nextElement();
          str.append("<OPTION VALUE=\"" + R2.ID() + "\"");
          if (R2.ID().equals(old)) str.append(" SELECTED");
          str.append(">" + R2.name());
        }
      }
      if (parms.containsKey("DEITY")) {
        String old = httpReq.getRequestParameter("DEITY");
        if (firstTime) old = M.getWorshipCharID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless");
        for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) {
          Deity E = (Deity) e.nextElement();
          str.append("<OPTION VALUE=\"" + E.Name() + "\"");
          if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + E.Name());
        }
      }
      if (parms.containsKey("TITLELIST")) {
        if (M.playerStats() != null) {
          int b = 0;
          Vector titles = new Vector();
          if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles);
          else
            while (httpReq.isRequestParameter("TITLE" + b)) {
              String B = httpReq.getRequestParameter("TITLE" + b);
              if ((B != null) && (B.trim().length() > 0)) titles.addElement(B);
              b++;
            }
          for (b = 0; b < titles.size(); b++) {
            String B = (String) titles.elementAt(b);
            if (B != null)
              str.append(
                  "<INPUT TYPE=TEXT NAME=TITLE"
                      + b
                      + " SIZE="
                      + B.length()
                      + " VALUE=\""
                      + CMStrings.replaceAll(B, "\"", "&quot;")
                      + "\"><BR>");
          }
          str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">");
        }
      }
      if (parms.containsKey("CLAN")) {
        String old = httpReq.getRequestParameter("CLAN");
        if (firstTime) old = M.getClanID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless");
        for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) {
          Clan C = (Clan) e.nextElement();
          str.append("<OPTION VALUE=\"" + C.clanID() + "\"");
          if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + C.getName());
        }
      }
      if (parms.containsKey("ALIGNMENT")) {
        String old = httpReq.getRequestParameter("ALIGNMENT");
        if ((firstTime) || (old.length() == 0))
          old = "" + M.fetchFaction(CMLib.factions().AlignID());
        if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) {
          for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) {
            str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]);
            if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED");
            str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase()));
          }
        }
      }
      if (parms.containsKey("BASEGENDER")) {
        String old = httpReq.getRequestParameter("BASEGENDER");
        if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER);
        str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M");
        str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F");
        str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N");
      }
      str.append(MobData.expertiseList(M, httpReq, parms));
      str.append(MobData.classList(M, httpReq, parms));
      str.append(MobData.itemList(M, M, httpReq, parms, 0));
      str.append(MobData.abilities(M, httpReq, parms, 0));
      str.append(MobData.factions(M, httpReq, parms, 0));
      str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0));
      str.append(ExitData.dispositions(M, firstTime, httpReq, parms));
      str.append(MobData.senses(M, firstTime, httpReq, parms));
      String strstr = str.toString();
      if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
      return clearWebMacros(strstr);
    }
    return "";
  }
Пример #2
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 "";
  }