@Override public String getMyClassesStr() { if (myClasses == null) return "StdCharClass"; String classStr = ""; for (final CharClass myClasse : myClasses) classStr += ";" + myClasse.ID(); if (classStr.length() > 0) classStr = classStr.substring(1); return classStr; }
private void addCharClassIfNotFound(MOB mob, CharClass C) { boolean found = false; for (int n = 0; n < mob.baseCharStats().numClasses(); n++) if (mob.baseCharStats().getMyClass(n).ID().equals(C.ID())) { found = true; break; } if ((!found) && (C.availabilityCode() != 0)) { mob.baseCharStats().setCurrentClass(C); mob.baseCharStats().setClassLevel(C, 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); }
public static void doAnimalFollowerLevelingCheck(CharClass C, Environmental host, CMMsg msg) { if ((msg.sourceMessage() == null) && (msg.sourceMinor() == CMMsg.TYP_LEVEL) && (msg.source().isMonster())) { final MOB druidM = msg.source().amUltimatelyFollowing(); if ((druidM != null) && (!druidM.isMonster()) && (druidM.charStats().getCurrentClass().ID().equals(C.ID())) && (CMLib.flags().isAnimalIntelligence(msg.source()) || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Vegetation") || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Stone Golem"))) { final int xp = msg.source().phyStats().level() * 5; if (xp > 0) { druidM.tell( CMLib.lang().L("Your stewardship has benefitted @x1.", msg.source().name(druidM))); CMLib.leveler().postExperience(druidM, null, null, xp, false); } } } }
@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; }
@Override public int getClassLevel(CharClass aClass) { if ((myClasses == null) || (aClass == null)) return -1; for (int i = 0; i < myClasses.length; i++) { if ((myClasses[i] != null) && (myClasses[i].ID().equals(aClass.ID())) && (i < myLevels.length)) return myLevels[i].intValue(); } return -1; }
public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) { if ((msg.source() != host) && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW) && (msg.source().isMonster()) && (host instanceof MOB) && (!((MOB) host).isMonster()) && (msg.target() == host) && (msg.source().getStartRoom() != null) && (CMLib.law().isACity(msg.source().getStartRoom().getArea())) && (((MOB) host).charStats().getCurrentClass().ID().equals(C.ID())) && (CMLib.flags().isAnimalIntelligence(msg.source()) || msg.source().charStats().getMyRace().racialCategory().equalsIgnoreCase("Vegetation") || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Stone Golem")) && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0) && (msg.source().location() != null) && (!msg.source().amDestroyed()) && (CMLib.flags().isInTheGame((MOB) host, true)) && (!CMLib.law().isACity(msg.source().location().getArea()))) { Object[] stuff = (Object[]) animalChecking.get(host); final Room room = msg.source().location(); if ((stuff == null) || (System.currentTimeMillis() - ((Long) stuff[0]).longValue() > (room.getArea().getTimeObj().getDaysInMonth() * room.getArea().getTimeObj().getHoursInDay() * CMProps.getMillisPerMudHour()))) { stuff = new Object[3]; stuff[0] = Long.valueOf(System.currentTimeMillis()); animalChecking.remove(host); animalChecking.put(host, stuff); stuff[1] = Integer.valueOf(0); stuff[2] = new Vector(); } if ((((Integer) stuff[1]).intValue() < 19) && (!((List) stuff[2]).contains("" + msg.source()))) { stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1); ((MOB) host) .tell( CMLib.lang() .L( "You have freed @x1 from @x2.", msg.source().name((MOB) host), (msg.source().getStartRoom().getArea().name()))); CMLib.leveler() .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false); } } }
public void startCharacter(MOB mob, boolean isBorrowedClass, boolean verifyOnly) { if (!loaded()) { setLoaded(true); LinkedList<CharClass> charClassesOrder = new LinkedList<CharClass>(); HashSet<String> names = new HashSet<String>(); for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) { CharClass C = c.nextElement(); if (C.baseClass().equals(C.ID()) && (!C.baseClass().equalsIgnoreCase("Archon")) && (!C.baseClass().equalsIgnoreCase("PlayerClass")) && (!C.baseClass().equalsIgnoreCase("Qualifier")) && (!C.baseClass().equalsIgnoreCase("StdCharClass"))) { names.add(C.ID()); charClassesOrder.add(C); } } for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) { CharClass C = c.nextElement(); if (!names.contains(C.ID()) && names.contains(C.baseClass())) charClassesOrder.add(C); } for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) { CharClass C = c.nextElement(); if (C.baseClass().equals("Commoner") && (!names.contains(C.ID()))) charClassesOrder.add(C); } for (CharClass C : charClassesOrder) { LinkedList<List<String>> prevSets = new LinkedList<List<String>>(); for (int lvl = 1; lvl < CMProps.getIntVar(CMProps.Int.LASTPLAYERLEVEL); lvl++) { List<String> curSet = CMLib.ableMapper().getLevelListings(C.ID(), false, lvl); for (String ID : curSet) { String defaultParam = CMLib.ableMapper().getDefaultParm(C.ID(), true, ID); if (CMLib.ableMapper().getQualifyingLevel(ID(), false, ID) < 0) { Ability A = CMClass.getAbility(ID); if (A == null) { Log.errOut("Unknonwn class: " + ID); continue; } List<String> reqSet = makeRequirements(prevSets, A); if (reqSet.size() > 0) reqSet = new XVector<String>(CMParms.toStringList(reqSet)); int level = 0; if (!this.leveless() && (!CMSecurity.isDisabled(DisFlag.LEVELS))) level = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if (level < 0) level = 0; CMLib.ableMapper() .addCharAbilityMapping(ID(), 0, ID, 0, defaultParam, false, false, reqSet, ""); } } if (curSet.size() > 0) prevSets.add(curSet); } } } super.startCharacter(mob, false, verifyOnly); }
@Override public boolean isLevelCapped(CharClass C) { if ((C == null) || (C.getLevelCap() < 0) || (C.getLevelCap() == Integer.MAX_VALUE)) return false; return getClassLevel(C) >= C.getLevelCap(); }
public static String getBasic(MOB M, int i) { StringBuffer str = new StringBuffer(""); switch (i) { case 0: str.append(M.Name() + ", "); break; case 1: str.append(M.description() + ", "); break; case 2: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().lastDateTime()) + ", "); break; case 3: if (M.playerStats() != null) str.append(M.playerStats().getEmail() + ", "); break; case 4: str.append(M.baseCharStats().getMyRace().name() + ", "); break; case 5: str.append( M.baseCharStats().getCurrentClass().name(M.baseCharStats().getCurrentClassLevel()) + ", "); break; case 6: str.append(M.baseEnvStats().level() + ", "); break; case 7: str.append(M.baseCharStats().displayClassLevel(M, true) + ", "); break; case 8: str.append(M.baseCharStats().getClassLevel(M.baseCharStats().getCurrentClass()) + ", "); break; case 9: { for (int c = M.charStats().numClasses() - 1; c >= 0; c--) { CharClass C = M.charStats().getMyClass(c); str.append( C.name(M.baseCharStats().getCurrentClassLevel()) + " (" + M.charStats().getClassLevel(C) + ") "); } str.append(", "); break; } case 10: if (M.maxCarry() > (Integer.MAX_VALUE / 3)) str.append("NA, "); else str.append(M.maxCarry() + ", "); break; case 11: str.append(CMStrings.capitalizeAndLower(CMLib.combat().fightingProwessStr(M)) + ", "); break; case 12: str.append(CMStrings.capitalizeAndLower(CMLib.combat().armorStr(M)) + ", "); break; case 13: str.append(CMLib.combat().adjustedDamage(M, null, null) + ", "); break; case 14: str.append(Math.round(CMath.div(M.getAgeHours(), 60.0)) + ", "); break; case 15: str.append(M.getPractices() + ", "); break; case 16: str.append(M.getExperience() + ", "); break; case 17: if (M.getExpNeededLevel() == Integer.MAX_VALUE) str.append("N/A, "); else str.append(M.getExpNextLevel() + ", "); break; case 18: str.append(M.getTrains() + ", "); break; case 19: str.append(CMLib.beanCounter().getMoney(M) + ", "); break; case 20: str.append(M.getWorshipCharID() + ", "); break; case 21: str.append(M.getLiegeID() + ", "); break; case 22: str.append(M.getClanID() + ", "); break; case 23: if (M.getClanID().length() > 0) { Clan C = CMLib.clans().getClan(M.getClanID()); if (C != null) str.append( CMLib.clans().getRoleName(C.getGovernment(), M.getClanRole(), true, false) + ", "); } break; case 24: str.append(M.fetchFaction(CMLib.factions().AlignID()) + ", "); break; case 25: { Faction.FactionRange FR = CMLib.factions() .getRange(CMLib.factions().AlignID(), M.fetchFaction(CMLib.factions().AlignID())); if (FR != null) str.append(FR.name() + ", "); else str.append(M.fetchFaction(CMLib.factions().AlignID())); break; } case 26: str.append(M.getWimpHitPoint() + ", "); break; case 27: if (M.getStartRoom() != null) str.append(M.getStartRoom().displayText() + ", "); break; case 28: if (M.location() != null) str.append(M.location().displayText() + ", "); break; case 29: if (M.getStartRoom() != null) str.append(M.getStartRoom().roomID() + ", "); break; case 30: if (M.location() != null) str.append(M.location().roomID() + ", "); break; case 31: { for (int inv = 0; inv < M.inventorySize(); inv++) { Item I = M.fetchInventory(inv); if ((I != null) && (I.container() == null)) str.append(I.name() + ", "); } break; } case 32: str.append(M.baseEnvStats().weight() + ", "); break; case 33: str.append(M.envStats().weight() + ", "); break; case 34: str.append(CMStrings.capitalizeAndLower(M.baseCharStats().genderName()) + ", "); break; case 35: if (M.playerStats() != null) str.append(M.playerStats().lastDateTime() + ", "); break; case 36: str.append(M.curState().getHitPoints() + ", "); break; case 37: str.append(M.curState().getMana() + ", "); break; case 38: str.append(M.curState().getMovement() + ", "); break; case 39: if (M.riding() != null) str.append(M.riding().name() + ", "); break; case 40: str.append(M.baseEnvStats().height() + ", "); break; case 41: if (!M.isMonster()) str.append(M.session().getAddress() + ", "); else if (M.playerStats() != null) str.append(M.playerStats().lastIP() + ", "); break; case 42: str.append(M.getQuestPoint() + ", "); break; case 43: str.append(M.maxState().getHitPoints() + ", "); break; case 44: str.append(M.maxState().getMana() + ", "); break; case 45: str.append(M.maxState().getMovement() + ", "); break; case 46: str.append(M.rawImage() + ", "); break; case 47: str.append(M.maxItems() + ", "); break; case 48: { String[] paths = CMProps.mxpImagePath(M.image()); if (paths[0].length() > 0) str.append(paths[0] + paths[1] + ", "); break; } case 49: if (CMProps.mxpImagePath(M.image())[0].length() > 0) str.append("true, "); else str.append("false, "); break; case 50: if (M.playerStats() != null) str.append(M.playerStats().notes() + ", "); break; case 51: if (M.playerStats() != null) { long lastDateTime = -1; for (int level = 0; level <= M.envStats().level(); level++) { long dateTime = M.playerStats().leveledDateTime(level); if ((dateTime > 1529122205) && (dateTime != lastDateTime)) { str.append("<TR>"); if (level == 0) str.append("<TD><FONT COLOR=WHITE>Created</FONT></TD>"); else str.append("<TD><FONT COLOR=WHITE>" + level + "</FONT></TD>"); str.append( "<TD><FONT COLOR=WHITE>" + CMLib.time().date2String(dateTime) + "</FONT></TD></TR>"); } } str.append(", "); } break; case 52: str.append(M.baseEnvStats().attackAdjustment() + ", "); break; case 53: str.append(M.baseEnvStats().damage() + ", "); break; case 54: str.append(M.baseEnvStats().armor() + ", "); break; case 55: str.append(M.envStats().speed() + ", "); break; case 56: str.append(M.baseEnvStats().speed() + ", "); break; case 57: { for (int e = 0; e < M.numExpertises(); e++) { String E = M.fetchExpertise(e); ExpertiseLibrary.ExpertiseDefinition X = CMLib.expertises().getDefinition(E); if (X == null) str.append(E + ", "); else str.append(X.name + ", "); } break; } case 58: { for (int t = 0; t < M.numTattoos(); t++) { String E = M.fetchTattoo(t); str.append(E + ", "); } break; } case 59: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getSecurityGroups().size(); b++) { String B = (String) M.playerStats().getSecurityGroups().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 60: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getTitles().size(); b++) { String B = (String) M.playerStats().getTitles().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 61: { for (Enumeration e = M.fetchFactions(); e.hasMoreElements(); ) { String FID = (String) e.nextElement(); Faction F = CMLib.factions().getFaction(FID); int value = M.fetchFaction(FID); if (F != null) str.append(F.name() + " (" + value + "), "); } break; } case 62: str.append(CMProps.getBoolVar(CMProps.SYSTEMB_ACCOUNTEXPIRATION) ? "true" : "false"); break; case 63: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().getAccountExpiration())); break; case 64: { for (int f = 0; f < M.numFollowers(); f++) str.append(M.fetchFollower(f).name()).append(", "); // Vector V=CMLib.database().DBScanFollowers(M); // for(int v=0;v<V.size();v++) // str.append(((MOB)V.elementAt(v)).name()).append(", "); break; } case 65: if ((M.playerStats() != null) && (M.playerStats().getAccount() != null)) str.append(M.playerStats().getAccount().accountName()); break; } return str.toString(); }
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 ""; }