Пример #1
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + hasALock();
     case 1:
       return "" + hasADoor();
     case 2:
       return "" + capacity();
     case 3:
       return "" + containTypes();
     case 4:
       return "" + openDelayTicks();
     case 5:
       return "" + getClothingLayer();
     case 6:
       return "" + getLayerAttributes();
     case 7:
       return "" + defaultsClosed();
     case 8:
       return "" + defaultsLocked();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #2
0
 public DVector parseLootPolicyFor(MOB mob) {
   if (mob == null) return new DVector(3);
   Vector lootPolicy =
       (!mob.isMonster())
           ? new Vector()
           : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true);
   DVector policies = new DVector(3);
   for (int p = 0; p < lootPolicy.size(); p++) {
     String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim();
     if (s.length() == 0) continue;
     Vector compiledMask = null;
     int maskDex = s.indexOf("MASK=");
     if (maskDex >= 0) {
       s = s.substring(0, maskDex).trim();
       compiledMask =
           CMLib.masking()
               .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim());
     } else compiledMask = new Vector();
     Vector parsed = CMParms.parse(s);
     int pct = 100;
     for (int x = 0; x < parsed.size(); x++)
       if (CMath.isInteger((String) parsed.elementAt(x)))
         pct = CMath.s_int((String) parsed.elementAt(x));
       else if (CMath.isPct((String) parsed.elementAt(x)))
         pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0);
     int flags = 0;
     if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN;
     else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN;
     else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN;
     policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask);
   }
   return policies;
 }
Пример #3
0
  @Override
  public void run() {

    nextTickTime = System.currentTimeMillis() + tickTime;
    // final String oldThreadName=Thread.currentThread().getName();
    try {
      currentThread = Thread.currentThread();
      lastStart = System.currentTimeMillis();
      lastClient = null;
      final boolean allSuspended = CMLib.threads().isAllSuspended();
      if ((CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) && (!allSuspended)) {
        for (final Iterator<TickClient> i = tickers(); i.hasNext(); ) {
          final TickClient client = i.next();
          lastClient = client;
          // if(client.getCurrentTickDown()<=1)
          // currentThread.setName(oldThreadName+":"+getName()+":"+client.getName());
          if (client.tickTicker(false)) {
            delTicker(client); // cant do i.remove, its an streeset
          }
        }
      }
    } finally {
      lastStop = System.currentTimeMillis();
      milliTotal += (lastStop - lastStart);
      tickTotal++;
      currentThread = null;
      // Thread.currentThread().setName(oldThreadName);
    }
    if (tickers.size() == 0) {
      if (CMLib.threads() instanceof ServiceEngine)
        ((ServiceEngine) CMLib.threads()).delTickGroup(this);
    }
  }
Пример #4
0
 @Override
 public String text() {
   if (CMProps.getBoolVar(CMProps.Bool.MOBCOMPRESS))
     miscText = CMLib.encoder().compressString(CMLib.coffeeMaker().getPropertiesStr(this, false));
   else miscText = CMLib.coffeeMaker().getPropertiesStr(this, false);
   return super.text();
 }
Пример #5
0
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setLidsNLocks(hasALid(), isOpen(), CMath.s_bool(val), false);
         break;
       case 1:
         setLidsNLocks(CMath.s_bool(val), isOpen(), hasALock(), false);
         break;
       case 2:
         setCapacity(CMath.s_parseIntExpression(val));
         break;
       case 3:
         setContainTypes(CMath.s_parseBitLongExpression(Container.CONTAIN_DESCS, val));
         break;
       case 4:
         {
           int x = CMath.s_parseListIntExpression(RawMaterial.CODES.NAMES(), val);
           x = ((x >= 0) && (x < RawMaterial.RESOURCE_MASK)) ? RawMaterial.CODES.GET(x) : x;
           setFuelType(x);
           break;
         }
       case 5:
         setPowerCapacity(CMath.s_parseLongExpression(val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #6
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenMobStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setClericRequirements(val);
         break;
       case 1:
         setClericRitual(val);
         break;
       case 2:
         setWorshipRequirements(val);
         break;
       case 3:
         setWorshipRitual(val);
         break;
       case 4:
         setServiceRitual(val);
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #7
0
  public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) {
    // caller is responsible for recovering any env
    // stat changes!

    if (CMLib.flags().isHidden(thisContainer))
      thisContainer
          .baseEnvStats()
          .setDisposition(
              thisContainer.baseEnvStats().disposition()
                  & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN));
    mob.delInventory(thisContainer);
    thisContainer.unWear();
    if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody);
    if (bodyFlag) {
      room.addItem(thisContainer);
      thisContainer.setExpirationDate(0);
    } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP));
    thisContainer.recoverEnvStats();
    boolean nothingDone = true;
    do {
      nothingDone = true;
      for (int i = 0; i < mob.inventorySize(); i++) {
        Item thisItem = mob.fetchInventory(i);
        if ((thisItem != null) && (thisItem.container() == thisContainer)) {
          recursiveDropMOB(mob, room, thisItem, bodyFlag);
          nothingDone = false;
          break;
        }
      }
    } while (!nothingDone);
  }
Пример #8
0
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setLidsNLocks(hasALid(), isOpen(), CMath.s_bool(val), false);
         break;
       case 1:
         setLidsNLocks(CMath.s_bool(val), isOpen(), hasALock(), false);
         break;
       case 2:
         setCapacity(CMath.s_parseIntExpression(val));
         break;
       case 3:
         setContainTypes(CMath.s_parseBitLongExpression(Container.CONTAIN_DESCS, val));
         break;
       case 4:
         setRideBasis(CMath.s_parseListIntExpression(Rideable.RIDEABLE_DESCS, val));
         break;
       case 5:
         setRiderCapacity(CMath.s_parseIntExpression(val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #9
0
 @Override
 public void setPermanentStat(int abilityCode, int value) {
   setStat(abilityCode, value);
   if (CharStats.CODES.isBASE(abilityCode))
     setStat(
         CharStats.CODES.toMAXBASE(abilityCode),
         value - CMProps.getIntVar(CMProps.Int.BASEMAXSTAT));
 }
Пример #10
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   mob.tell(L("CoffeeMud v@x1", CMProps.getVar(CMProps.Str.MUDVER)));
   mob.tell(L("(C) 2000-2015 Bo Zimmerman"));
   mob.tell(L("^<A HREF=\"mailto:[email protected]\"^>[email protected]^</A^>"));
   mob.tell(L("^<A HREF=\"http://www.coffeemud.org\"^>http://www.coffeemud.org^</A^>"));
   return false;
 }
Пример #11
0
 @Override
 public String[] getStatCodes() {
   if (codes == null)
     codes =
         CMProps.getStatCodesList(
             CMParms.toStringArray(GenericBuilder.GenItemCode.values()), this);
   return codes;
 }
Пример #12
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;
 }
Пример #13
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
Пример #14
0
 public String[] getStatCodes() {
   if (codes != null) return codes;
   String[] MYCODES = CMProps.getStatCodesList(GenRideable.MYCODES, this);
   String[] superCodes = GenericBuilder.GENITEMCODES;
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Пример #15
0
 @Override
 public String[] getStatCodes() {
   if (codes != null) return codes;
   final String[] MYCODES = CMProps.getStatCodesList(GenShopkeeper.MYCODES, this);
   final String[] superCodes = GenericBuilder.GENMOBCODES;
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Пример #16
0
 @Override
 public String[] getStatCodes() {
   if (codes != null) return codes;
   final String[] MYCODES = CMProps.getStatCodesList(GenThinArmor.MYCODES, this);
   final String[] superCodes = CMParms.toStringArray(GenericBuilder.GenItemCode.values());
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Пример #17
0
  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);
  }
Пример #18
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setDoorsNLocks(
             hasADoor(),
             isOpen(),
             defaultsClosed(),
             CMath.s_bool(val),
             false,
             CMath.s_bool(val) && defaultsLocked());
         break;
       case 1:
         setDoorsNLocks(
             CMath.s_bool(val),
             isOpen(),
             CMath.s_bool(val) && defaultsClosed(),
             hasALock(),
             false,
             defaultsLocked());
         break;
       case 2:
         setCapacity(CMath.s_parseIntExpression(val));
         break;
       case 3:
         setContainTypes(CMath.s_parseBitLongExpression(Container.CONTAIN_DESCS, val));
         break;
       case 4:
         setOpenDelayTicks(CMath.s_parseIntExpression(val));
         break;
       case 5:
         setClothingLayer((short) CMath.s_parseIntExpression(val));
         break;
       case 6:
         setLayerAttributes((short) CMath.s_parseListLongExpression(Armor.LAYERMASK_DESCS, val));
         break;
       case 7:
         setDoorsNLocks(
             hasADoor(), isOpen(), CMath.s_bool(val), hasALock(), isLocked(), defaultsLocked());
         break;
       case 8:
         setDoorsNLocks(
             hasADoor(), isOpen(), defaultsClosed(), hasALock(), isLocked(), CMath.s_bool(val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #19
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   final Trap T = (Trap) copyOf();
   T.setInvoker(mob);
   P.addEffect(T);
   CMLib.threads()
       .startTickDown(
           T,
           Tickable.TICKID_TRAP_DESTRUCTION,
           CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) + (2 * getXLEVELLevel(mob)));
   return T;
 }
Пример #20
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + getClothingLayer();
     case 1:
       return "" + getLayerAttributes();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #21
0
 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);
     }
   }
 }
Пример #22
0
 public boolean shutdown() {
   // int numTicks=tickGroup.size();
   int which = 0;
   while (ticks.size() > 0) {
     // Log.sysOut("ServiceEngine","Shutting down all tick "+which+"/"+numTicks+"...");
     Tick tock = ticks.getFirst();
     if (tock != null) {
       CMProps.setUpAllLowVar(
           CMProps.SYSTEM_MUDSTATUS,
           "Shutting down...shutting down Service Engine: killing Tick#"
               + tock.getCounter()
               + ": "
               + tock.getStatus());
       tock.shutdown();
     }
     try {
       Thread.sleep(100);
     } catch (Exception e) {
     }
     which++;
   }
   CMProps.setUpAllLowVar(
       CMProps.SYSTEM_MUDSTATUS,
       "Shutting down...shutting down Service Engine: " + ID() + ": thread shutdown");
   thread.shutdown();
   // force final time tick!
   Vector timeObjects = new Vector();
   for (Enumeration e = CMLib.map().areas(); e.hasMoreElements(); ) {
     Area A = ((Area) e.nextElement());
     if (!timeObjects.contains(A.getTimeObj())) timeObjects.addElement(A.getTimeObj());
   }
   CMProps.setUpAllLowVar(
       CMProps.SYSTEM_MUDSTATUS,
       "Shutting down...shutting down Service Engine: " + ID() + ": saving time objects");
   for (int t = 0; t < timeObjects.size(); t++) ((TimeClock) timeObjects.elementAt(t)).save();
   Log.sysOut("ServiceEngine", "Shutdown complete.");
   return true;
 }
Пример #23
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setClothingLayer((short) CMath.s_parseIntExpression(val));
         break;
       case 1:
         setLayerAttributes((short) CMath.s_parseListLongExpression(Armor.LAYERMASK_DESCS, val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #24
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + hasALock();
     case 1:
       return "" + hasADoor();
     case 2:
       return "" + capacity();
     case 3:
       return "" + containTypes();
     case 4:
       return "" + openDelayTicks();
     case 5:
       return "" + powerCapacity();
     case 6:
       {
         final StringBuilder str = new StringBuilder("");
         for (int i = 0; i < getConsumedFuelTypes().length; i++) {
           if (i > 0) str.append(", ");
           str.append(RawMaterial.CODES.NAME(getConsumedFuelTypes()[i]));
         }
         return str.toString();
       }
     case 7:
       return "" + powerRemaining();
     case 8:
       return "" + getGeneratedAmountPerTick();
     case 9:
       return "" + activated();
     case 10:
       return "" + getManufacturerName();
     case 11:
       return "" + getInstalledFactor();
     case 12:
       return "" + defaultsClosed();
     case 13:
       return "" + defaultsLocked();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #25
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenMobStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return getClericRequirements();
     case 1:
       return getClericRitual();
     case 2:
       return getWorshipRequirements();
     case 3:
       return getWorshipRitual();
     case 4:
       return getServiceRitual();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #26
0
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + hasALock();
     case 1:
       return "" + hasALid();
     case 2:
       return "" + capacity();
     case 3:
       return "" + containTypes();
     case 4:
       return "" + rideBasis();
     case 5:
       return "" + riderCapacity();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #27
0
 @Override
 public void setRacialStat(final int abilityCode, final int racialMax) {
   if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT))
     setPermanentStat(abilityCode, racialMax);
   else {
     final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT);
     int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax;
     if (currMax <= 0) currMax = 1;
     int curStat = getStat(abilityCode);
     if (curStat > currMax * 7) {
       final String errorMsg =
           "Detected mob with "
               + curStat
               + "/"
               + currMax
               + " "
               + CharStats.CODES.ABBR(abilityCode);
       @SuppressWarnings({"unchecked", "rawtypes"})
       Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS");
       if (errs == null) {
         errs = new TreeSet<String>();
         Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs);
       }
       if (!errs.contains(errorMsg)) {
         errs.add(errorMsg);
         final StringBuilder str = new StringBuilder(errorMsg);
         // ByteArrayOutputStream stream=new ByteArrayOutputStream();
         // new Exception().printStackTrace(new PrintStream(stream));
         // str.append("\n\r"+new String(stream.toByteArray()));
         Log.errOut("DefCharStats", str.toString());
       }
       curStat = currMax * 7;
     }
     final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax);
     final int stdMaxAdj =
         Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax);
     final int racialStat = pctOfMax + stdMaxAdj;
     setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat);
     setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax);
   }
 }
Пример #28
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenMobStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         {
           if ((val.length() == 0) || (CMath.isLong(val))) setWhatIsSoldMask(CMath.s_long(val));
           else if (CMParms.containsIgnoreCase(ShopKeeper.DEAL_DESCS, val))
             setWhatIsSoldMask(CMParms.indexOfIgnoreCase(ShopKeeper.DEAL_DESCS, val));
           break;
         }
       case 1:
         setPrejudiceFactors(val);
         break;
       case 2:
         setBudget(val);
         break;
       case 3:
         setDevalueRate(val);
         break;
       case 4:
         setInvResetRate(CMath.s_parseIntExpression(val));
         break;
       case 5:
         setIgnoreMask(val);
         break;
       case 6:
         setItemPricingAdjustments(
             (val.trim().length() == 0)
                 ? new String[0]
                 : CMParms.toStringArray(CMParms.parseCommas(val, true)));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Пример #29
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenMobStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + getWhatIsSoldMask();
     case 1:
       return prejudiceFactors();
     case 2:
       return budget();
     case 3:
       return devalueRate();
     case 4:
       return "" + invResetRate();
     case 5:
       return ignoreMask();
     case 6:
       return CMParms.toStringList(itemPricingAdjustments());
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Пример #30
0
 // update lot, since its called by the savethread, ONLY worries about itself
 @Override
 public void updateLot(List optPlayerList) {
   if (affected instanceof Room) {
     Room R = (Room) affected;
     synchronized (("SYNC" + R.roomID()).intern()) {
       R = CMLib.map().getRoom(R);
       lastItemNums =
           updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
       if ((lastDayDone != R.getArea().getTimeObj().getDayOfMonth())
           && (CMProps.getBoolVar(CMProps.Bool.MUDSTARTED))) {
         lastDayDone = R.getArea().getTimeObj().getDayOfMonth();
         if ((getOwnerName().length() > 0) && rentalProperty() && (R.roomID().length() > 0))
           if (doRentalProperty(R.getArea(), R.roomID(), getOwnerName(), getPrice())) {
             setOwnerName("");
             CMLib.database().DBUpdateRoom(R);
             lastItemNums =
                 updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
           }
       }
       scheduleReset = false;
     }
   }
 }