Пример #1
0
 public static InventoryList fetchInventory(MOB seer, MOB mob) {
   final InventoryList lst = new InventoryList();
   Vector<Coins> coinsV = null;
   int insertAt = -1;
   CMLib.beanCounter().getTotalAbsoluteNativeValue(mob);
   for (final Enumeration<Item> i = mob.items(); i.hasMoreElements(); ) {
     final Item thisItem = i.nextElement();
     if (thisItem == null) continue;
     if ((thisItem.container() == null) && (thisItem.amWearingAt(Wearable.IN_INVENTORY))) {
       if (CMLib.flags().canBeSeenBy(thisItem, seer)) lst.foundAndSeen = true;
       else lst.foundButUnseen = true;
       if ((!(thisItem instanceof Coins)) || (((Coins) thisItem).getDenomination() == 0.0))
         lst.viewItems.add(thisItem);
       else {
         coinsV = lst.moneyItems.get(((Coins) thisItem).getCurrency());
         if (coinsV == null) {
           coinsV = new Vector<Coins>();
           lst.moneyItems.put(((Coins) thisItem).getCurrency(), coinsV);
         }
         for (insertAt = 0; insertAt < coinsV.size(); insertAt++)
           if (coinsV.get(insertAt).getDenomination() > ((Coins) thisItem).getDenomination())
             break;
         if (insertAt >= coinsV.size()) coinsV.add((Coins) thisItem);
         else coinsV.insertElementAt((Coins) thisItem, insertAt);
       }
     }
   }
   return lst;
 }
Пример #2
0
  protected final Map<String, Double> getRatesFor(final Environmental affecting, String currency) {
    if (spaceMaxCut <= 0.0) return rates;
    currency = currency.toUpperCase();
    if (rates.containsKey(currency)) return rates;
    String myCurrency = CMLib.beanCounter().getCurrency(affecting);
    if (myCurrency.equalsIgnoreCase(currency)) {
      rates.put(currency, Double.valueOf(cut));
      return rates;
    }
    SpaceObject homeO = CMLib.map().getSpaceObject(affecting, false);
    if (homeO != null) {
      myCurrency = CMLib.beanCounter().getCurrency(homeO);
      if (myCurrency.equalsIgnoreCase(currency)) {
        rates.put(currency, Double.valueOf(cut));
        return rates;
      }
    } else {
      // no space object, wtf? this SHOULD fail
      if (!complainedAboutSpaceError) {
        complainedAboutSpaceError = true;
        Log.errOut(
            "MoneyChanger", affecting.Name() + " is not on a planet, so space rates cannot apply!");
      }
      return rates;
    }
    for (Enumeration<Area> a = CMLib.map().spaceAreas(); a.hasMoreElements(); ) {
      Area A = a.nextElement();
      if ((A != null) && (A != homeO)) {
        myCurrency = CMLib.beanCounter().getCurrency(A);
        if (myCurrency.equalsIgnoreCase(currency)) {
          SpaceObject oA = (SpaceObject) A;
          long distance = CMLib.map().getDistanceFrom(homeO, oA);
          if ((distance < 0) || (distance > spaceMaxDistance)) {
            rates.put(currency, Double.valueOf(spaceMaxCut));
          } else {
            double pct = CMath.div(distance, spaceMaxDistance);
            double amt = spaceMaxCut * pct;
            if (amt < cut) amt = cut;
            rates.put(currency, Double.valueOf(cut));
          }
          return rates;
        }
      }
    }

    return rates;
  }
Пример #3
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }
Пример #4
0
 @Override
 public boolean okMessage(Environmental affecting, CMMsg msg) {
   if (!super.okMessage(affecting, msg)) return false;
   final MOB source = msg.source();
   if (!canFreelyBehaveNormal(affecting)) return true;
   final MOB observer = (MOB) affecting;
   if ((source != observer)
       && (msg.amITarget(observer))
       && (msg.targetMinor() == CMMsg.TYP_GIVE)
       && (!CMSecurity.isAllowed(source, source.location(), CMSecurity.SecFlag.CMDROOMS))
       && (msg.tool() != null)) {
     if (!(msg.tool() instanceof Coins)) {
       CMLib.commands()
           .postSay(observer, source, L("I'm sorry, I can only accept money."), true, false);
       return false;
     } else if (!doIExchangeThisCurrency(affecting, ((Coins) msg.tool()).getCurrency())) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I don't accept that kind of currency."),
               true,
               false);
       return false;
     }
     double value = ((Coins) msg.tool()).getTotalValue();
     final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
     double takeCut = getMyCut(affecting, currency);
     double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
     if ((amountToTake > 0.0)
         && (amountToTake
             < CMLib.beanCounter()
                 .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
       amountToTake =
           CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
     value -= amountToTake;
     observer.recoverPhyStats();
     final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
     if ((value <= 0) || (C == null)) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I can not change such a small amount."),
               true,
               false);
       return false;
     }
   }
   return true;
 }
Пример #5
0
 protected String getShowableMoney(InventoryList list) {
   final StringBuilder msg = new StringBuilder("");
   if (list.moneyItems.size() > 0) {
     msg.append(L("\n\r^HMoney:^N\n\r"));
     Item I = null;
     for (final Enumeration e = list.moneyItems.keys(); e.hasMoreElements(); ) {
       final String key = (String) e.nextElement();
       final Vector<Coins> V = list.moneyItems.get(key);
       double totalValue = 0.0;
       for (int v = 0; v < V.size(); v++) {
         I = V.get(v);
         if (I != null) {
           if (v > 0) msg.append(", ");
           if (I instanceof Coins) totalValue += ((Coins) I).getTotalValue();
           msg.append(I.name());
         }
       }
       msg.append(" ^N(" + CMLib.beanCounter().abbreviatedPrice(key, totalValue) + ")");
       if (e.hasMoreElements()) msg.append("\n\r");
     }
   }
   return msg.toString();
 }
Пример #6
0
 public String builtPrompt(MOB mob) {
   StringBuffer buf = new StringBuffer("\n\r");
   String prompt = mob.playerStats().getPrompt();
   String promptUp = null;
   int c = 0;
   while (c < prompt.length())
     if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) {
       switch (prompt.charAt(++c)) {
         case '-':
           if (c < (prompt.length() - 2)) {
             if (promptUp == null) promptUp = prompt.toUpperCase();
             String promptSub = promptUp.substring(c + 1);
             Wearable.CODES wcodes = Wearable.CODES.instance();
             boolean isFound = false;
             for (long code : wcodes.all())
               if (promptSub.startsWith(wcodes.nameup(code))) {
                 c += 1 + wcodes.nameup(code).length();
                 Item I = mob.fetchFirstWornItem(code);
                 if (I != null) buf.append(I.name());
                 isFound = true;
                 break;
               }
             if (!isFound) {
               CharStats.CODES ccodes = CharStats.CODES.instance();
               for (int code : ccodes.all())
                 if (promptSub.startsWith(ccodes.name(code))) {
                   c += 1 + ccodes.name(code).length();
                   buf.append(mob.charStats().getStat(code));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (int code : ccodes.all())
                   if (promptSub.startsWith("BASE " + ccodes.name(code))) {
                     buf.append(mob.baseCharStats().getStat(code));
                     c += 6 + ccodes.name(code).length();
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.envStats().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.envStats().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.baseEnvStats().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseEnvStats().getStat(s));
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.curState().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.curState().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.maxState().getStatCodes())
                   if (promptSub.startsWith("MAX " + s)) {
                     c += 5 + s.length();
                     buf.append(mob.maxState().getStat(s));
                     isFound = true;
                     break;
                   }
               if (!isFound)
                 for (String s : mob.baseState().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseState().getStat(s));
                     isFound = true;
                     break;
                   }
             }
           }
           break;
         case 'a':
           {
             buf.append(
                 CMLib.factions()
                         .getRangePercent(
                             CMLib.factions().AlignID(),
                             mob.fetchFaction(CMLib.factions().AlignID()))
                     + "%");
             c++;
             break;
           }
         case 'A':
           {
             Faction.FactionRange FR =
                 CMLib.factions()
                     .getRange(
                         CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID()));
             buf.append(
                 (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID()));
             c++;
             break;
           }
         case 'B':
           {
             buf.append("\n\r");
             c++;
             break;
           }
         case 'c':
           {
             buf.append(mob.inventorySize());
             c++;
             break;
           }
         case 'C':
           {
             buf.append(mob.maxItems());
             c++;
             break;
           }
         case 'd':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget());
             c++;
             break;
           }
         case 'e':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob));
             c++;
             break;
           }
         case 'E':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (!victim.amDead())
                 && (CMLib.flags().canBeSeenBy(victim, mob)))
               buf.append(victim.healthText(mob) + "\n\r");
             c++;
             break;
           }
         case 'g':
           {
             buf.append(
                 (int)
                     Math.round(
                         Math.floor(
                             CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)
                                 / CMLib.beanCounter()
                                     .getLowestDenomination(
                                         CMLib.beanCounter().getCurrency(mob)))));
             c++;
             break;
           }
         case 'G':
           {
             buf.append(
                 CMLib.beanCounter()
                     .nameCurrencyShort(
                         mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)));
             c++;
             break;
           }
         case 'h':
           {
             buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>");
             c++;
             break;
           }
         case 'H':
           {
             buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>");
             c++;
             break;
           }
         case 'I':
           {
             if ((CMLib.flags().isCloaked(mob))
                 && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0)))
               buf.append("Wizinvisible");
             else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked");
             else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable");
             else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob))
               buf.append("Hidden/Invisible");
             else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible");
             else if (CMLib.flags().isHidden(mob)) buf.append("Hidden");
             c++;
             break;
           }
         case 'K':
         case 'k':
           {
             MOB tank = mob;
             if ((tank.getVictim() != null)
                 && (tank.getVictim().getVictim() != null)
                 && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim();
             if (((c + 1) < prompt.length()) && (tank != null))
               switch (prompt.charAt(c + 1)) {
                 case 'h':
                   {
                     buf.append(tank.curState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'H':
                   {
                     buf.append(tank.maxState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'm':
                   {
                     buf.append(tank.curState().getMana());
                     c++;
                     break;
                   }
                 case 'M':
                   {
                     buf.append(tank.maxState().getMana());
                     c++;
                     break;
                   }
                 case 'v':
                   {
                     buf.append(tank.curState().getMovement());
                     c++;
                     break;
                   }
                 case 'V':
                   {
                     buf.append(tank.maxState().getMovement());
                     c++;
                     break;
                   }
                 case 'e':
                   {
                     buf.append(tank.displayName(mob));
                     c++;
                     break;
                   }
                 case 'E':
                   {
                     if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob)))
                       buf.append(tank.healthText(mob) + "\n\r");
                     c++;
                     break;
                   }
               }
             c++;
             break;
           }
         case 'm':
           {
             buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>");
             c++;
             break;
           }
         case 'M':
           {
             buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>");
             c++;
             break;
           }
         case 'r':
           {
             if (mob.location() != null) buf.append(mob.location().displayText());
             c++;
             break;
           }
         case 'R':
           {
             if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS"))
               buf.append(mob.location().roomID());
             c++;
             break;
           }
         case 'v':
           {
             buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>");
             c++;
             break;
           }
         case 'V':
           {
             buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>");
             c++;
             break;
           }
         case 'w':
           {
             buf.append(mob.envStats().weight());
             c++;
             break;
           }
         case 'W':
           {
             buf.append(mob.maxCarry());
             c++;
             break;
           }
         case 'x':
           {
             buf.append(mob.getExperience());
             c++;
             break;
           }
         case 'X':
           {
             if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A");
             else buf.append(mob.getExpNeededLevel());
             c++;
             break;
           }
         case 'z':
           {
             if (mob.location() != null) buf.append(mob.location().getArea().name());
             c++;
             break;
           }
         case 't':
           {
             if (mob.location() != null)
               buf.append(
                   CMStrings.capitalizeAndLower(
                       TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()]
                           .toLowerCase()));
             c++;
             break;
           }
         case 'T':
           {
             if (mob.location() != null)
               buf.append(mob.location().getArea().getTimeObj().getTimeOfDay());
             c++;
             break;
           }
         case '@':
           {
             if (mob.location() != null)
               buf.append(
                   mob.location().getArea().getClimateObj().weatherDescription(mob.location()));
             c++;
             break;
           }
         default:
           {
             buf.append("%" + prompt.charAt(c));
             c++;
             break;
           }
       }
     } else buf.append(prompt.charAt(c++));
   return buf.toString();
 }
Пример #7
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(L("Pay Off Whom?"));
      return false;
    }
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((target.charStats().getStat(CharStats.STAT_INTELLIGENCE) < 3) || (!target.isMonster())) {
      mob.tell(L("You can't pay off @x1.", target.name(mob)));
      return false;
    }

    final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location());
    final Area A = (B == null) ? null : CMLib.law().getLegalObject(mob.location());
    if ((A == null) || (B == null)) {
      mob.tell(L("There's no point in paying off @x1.", target.name(mob)));
      return false;
    }

    boolean isJudge = B.isJudge(A, target);
    if ((!isJudge) && (!B.isAnyOfficer(A, target))) {
      mob.tell(L("Paying off @x1 won't help you.", target.name(mob)));
      return false;
    }

    final List<LegalWarrant> warrants = B.getWarrantsOf(A, mob);
    if ((warrants == null) || (warrants.size() == 0)) {
      mob.tell(L("Pay off @x1? Why? You aren't in any trouble.", target.name(mob)));
      return false;
    }

    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("@x1 is already paid off.", target.name(mob)));
      return false;
    }

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

    double amountRequired =
        CMLib.beanCounter().getTotalAbsoluteNativeValue(target)
            + ((double)
                    ((100l
                        - ((mob.charStats().getStat(CharStats.STAT_CHARISMA)
                                + (2l * getXLEVELLevel(mob)))
                            * 2)))
                * target.phyStats().level());
    if (isJudge) amountRequired *= 2;

    final String currency = CMLib.beanCounter().getCurrency(target);
    boolean success = proficiencyCheck(mob, 0, auto);

    if ((!success) || (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired)) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_SPEAK,
              L(
                  "^T<S-NAME> attempt(s) to pay off <T-NAMESELF> to '@x1', but no deal is reached.^?",
                  CMParms.combine(commands, 0)));
      if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
      if (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired) {
        final String costWords = CMLib.beanCounter().nameCurrencyShort(currency, amountRequired);
        mob.tell(L("@x1 requires @x2 to do this.", target.charStats().HeShe(), costWords));
      }
      success = false;
    } else {
      final String costWords = CMLib.beanCounter().nameCurrencyShort(target, amountRequired);
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_THIEF_ACT,
              L("^T<S-NAME> pay(s) off <T-NAMESELF>.^?", CMParms.combine(commands, 0), costWords));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.beanCounter().subtractMoney(mob, currency, amountRequired);
        CMLib.beanCounter().addMoney(mob, currency, amountRequired);
        if (isJudge) {
          for (LegalWarrant W : warrants) {
            if (W.punishment() > 0) W.setPunishment(W.punishment() - 1);
          }
        } else {
          clearWarrants(target, mob, mob.location(), A, B);
          super.beneficialAffect(mob, target, asLevel, 0);
        }
      }
      target.recoverPhyStats();
    }
    return success;
  }
Пример #8
0
 public static boolean doRentalProperty(Area A, String ID, String owner, int rent) {
   if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false;
   final int month = A.getTimeObj().getMonth();
   final int day = A.getTimeObj().getDayOfMonth();
   final int year = A.getTimeObj().getYear();
   final Object O = Resources.getResource("RENTAL INFO/" + owner);
   List<PlayerData> pDataV = null;
   if (O instanceof List) pDataV = (List<PlayerData>) O;
   else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO");
   if (pDataV == null) pDataV = new Vector();
   DatabaseEngine.PlayerData pData = null;
   if (pDataV.size() == 0) {
     pData = new DatabaseEngine.PlayerData();
     pData.who = owner;
     pData.section = "RENTAL INFO";
     pData.key = "RENTAL INFO/" + owner;
     pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|";
     CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml);
     pDataV.add(pData);
     Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     return false;
   } else if (pDataV.get(0) != null) {
     pData = pDataV.get(0);
     String parse = pData.xml;
     int x = parse.indexOf("|~;|");
     final StringBuffer reparse = new StringBuffer("");
     boolean changesMade = false;
     boolean needsToPay = false;
     while (x >= 0) {
       String thisOne = parse.substring(0, x);
       if (thisOne.startsWith(ID + "|~>|")) {
         thisOne = thisOne.substring((ID + "|~>|").length());
         final Vector dateV = CMParms.parse(thisOne);
         if (dateV.size() == 3) {
           int lastYear = CMath.s_int((String) dateV.lastElement());
           int lastMonth = CMath.s_int((String) dateV.elementAt(1));
           final int lastDay = CMath.s_int((String) dateV.firstElement());
           while (!needsToPay) {
             if (lastYear < year) needsToPay = true;
             else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay))
               needsToPay = true;
             if (needsToPay) {
               if (CMLib.beanCounter()
                   .modifyLocalBankGold(
                       A,
                       owner,
                       CMLib.utensils().getFormattedDate(A)
                           + ":Withdrawal of "
                           + rent
                           + ": Rent for "
                           + ID,
                       CMLib.beanCounter().getCurrency(A),
                       (-rent))) {
                 lastMonth++;
                 if (lastMonth > A.getTimeObj().getMonthsInYear()) {
                   lastMonth = 1;
                   lastYear++;
                 }
                 changesMade = true;
                 needsToPay = false;
               }
             } else break;
           }
           if (changesMade)
             reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|");
           if (needsToPay && (!changesMade)) return true;
         }
       } else reparse.append(thisOne + "|~;|");
       parse = parse.substring(x + 4);
       x = parse.indexOf("|~;|");
     }
     if (changesMade) {
       CMLib.database()
           .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString());
       pData = new DatabaseEngine.PlayerData();
       pData.who = owner;
       pData.section = "RENTAL INFO";
       pData.key = "RENTAL INFO/" + owner;
       pData.xml = reparse.toString();
       pDataV.set(0, pData);
       Resources.removeResource("RENTAL INFO/" + owner);
       Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     }
     return needsToPay;
   }
   return false;
 }
Пример #9
0
 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();
 }
Пример #10
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (target == mob) {
      mob.tell(L("@x1 doesn't look dead yet.", target.name(mob)));
      return false;
    }
    if (!(target instanceof DeadBody)) {
      mob.tell(L("You can't animate that."));
      return false;
    }

    final DeadBody body = (DeadBody) target;
    if (body.isPlayerCorpse()
        || (body.getMobName().length() == 0)
        || ((body.charStats() != null)
            && (body.charStats().getMyRace() != null)
            && (body.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")))) {
      mob.tell(L("You can't animate that."));
      return false;
    }
    String race = "a";
    if ((body.charStats() != null) && (body.charStats().getMyRace() != null))
      race = CMLib.english().startWithAorAn(body.charStats().getMyRace().name()).toLowerCase();

    String description = body.getMobDescription();
    if (description.trim().length() == 0) description = "It looks dead.";
    else description += "\n\rIt also looks dead.";

    if (body.basePhyStats().level() < 7) {
      mob.tell(L("This creature is too weak to create a ghast from."));
      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("^S<S-NAME> @x1 to animate <T-NAMESELF> as a ghast.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        int undeadLevel = this.getUndeadLevel(mob, 6, body.phyStats().level());
        final MOB newMOB = CMClass.getMOB("GenUndead");
        newMOB.setName(L("@x1 ghast", race));
        newMOB.setDescription(description);
        newMOB.setDisplayText(L("@x1 ghast is here", race));
        newMOB.basePhyStats().setLevel(undeadLevel);
        newMOB
            .baseCharStats()
            .setStat(CharStats.STAT_GENDER, body.charStats().getStat(CharStats.STAT_GENDER));
        newMOB.baseCharStats().setMyRace(CMClass.getRace("Undead"));
        newMOB
            .baseCharStats()
            .setBodyPartsFromStringAfterRace(body.charStats().getBodyPartsAsString());
        final Ability P = CMClass.getAbility("Prop_StatTrainer");
        if (P != null) {
          P.setMiscText("NOTEACH STR=20 INT=10 WIS=10 CON=10 DEX=15 CHA=2");
          newMOB.addNonUninvokableEffect(P);
        }
        newMOB.recoverCharStats();
        newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB));
        newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB));
        newMOB.basePhyStats().setSensesMask(PhyStats.CAN_SEE_DARK);
        CMLib.factions().setAlignment(newMOB, Faction.Align.EVIL);
        newMOB.baseState().setHitPoints(25 * newMOB.basePhyStats().level());
        newMOB.baseState().setMovement(CMLib.leveler().getLevelMove(newMOB));
        newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB));
        newMOB.baseState().setMana(100);
        newMOB.recoverCharStats();
        newMOB.recoverPhyStats();
        newMOB.recoverMaxState();
        newMOB.resetToMaxState();
        newMOB.addAbility(CMClass.getAbility("Paralysis"));
        Behavior B = CMClass.getBehavior("CombatAbilities");
        if (B != null) newMOB.addBehavior(B);
        B = CMClass.getBehavior("Aggressive");
        if (B != null) {
          B.setParms("+NAMES \"-" + mob.Name() + "\" -LEVEL +>" + newMOB.basePhyStats().level());
          newMOB.addBehavior(B);
        }
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Spell_CauseStink"));
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience"));
        newMOB.text();
        newMOB.bringToLife(mob.location(), true);
        CMLib.beanCounter().clearZeroMoney(newMOB, null);
        // newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> appears!"));
        int it = 0;
        while (it < newMOB.location().numItems()) {
          final Item item = newMOB.location().getItem(it);
          if ((item != null) && (item.container() == body)) {
            final CMMsg msg2 = CMClass.getMsg(newMOB, body, item, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg2);
            final CMMsg msg4 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg4);
            final CMMsg msg3 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_WEAR, null);
            newMOB.location().send(newMOB, msg3);
            if (!newMOB.isMine(item)) it++;
            else it = 0;
          } else it++;
        }
        body.destroy();
        mob.location().show(newMOB, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> begin(s) to rise!"));
        newMOB.setStartRoom(null);
        beneficialAffect(mob, newMOB, 0, 0);
        mob.location().recoverRoomStats();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L("<S-NAME> @x1 to animate <T-NAMESELF>, but fail(s) miserably.", prayForWord(mob)));

    // return whether it worked
    return success;
  }
Пример #11
0
  public StringBuffer deviations(MOB mob, String rest) {
    final Vector<String> V = CMParms.parse(rest);
    if ((V.size() == 0)
        || ((!V.get(0).equalsIgnoreCase("mobs"))
            && (!V.get(0).equalsIgnoreCase("items"))
            && (!V.get(0).equalsIgnoreCase("both"))))
      return new StringBuffer(
          "You must specify whether you want deviations on MOBS, ITEMS, or BOTH.");

    final String type = V.get(0).toLowerCase();
    if (V.size() == 1)
      return new StringBuffer(
          "You must also specify a mob or item name, or the word room, or the word area.");

    final Room mobR = mob.location();
    Faction useFaction = null;
    for (final Enumeration<Faction> e = CMLib.factions().factions(); e.hasMoreElements(); ) {
      final Faction F = e.nextElement();
      if (F.showInSpecialReported()) useFaction = F;
    }
    final String where = V.get(1).toLowerCase();
    final Environmental E = mobR.fetchFromMOBRoomFavorsItems(mob, null, where, Wearable.FILTER_ANY);
    final Vector<Environmental> check = new Vector<Environmental>();
    if (where.equalsIgnoreCase("room")) fillCheckDeviations(mobR, type, check);
    else if (where.equalsIgnoreCase("area")) {
      for (final Enumeration<Room> r = mobR.getArea().getFilledCompleteMap();
          r.hasMoreElements(); ) {
        final Room R = r.nextElement();
        fillCheckDeviations(R, type, check);
      }
    } else if (where.equalsIgnoreCase("world")) {
      for (final Enumeration<Room> r = CMLib.map().roomsFilled(); r.hasMoreElements(); ) {
        final Room R = r.nextElement();
        fillCheckDeviations(R, type, check);
      }
    } else if (E == null)
      return new StringBuffer("'" + where + "' is an unknown item or mob name.");
    else if (type.equals("items") && (!(E instanceof Weapon)) && (!(E instanceof Armor)))
      return new StringBuffer("'" + where + "' is not a weapon or armor item.");
    else if (type.equals("mobs") && (!(E instanceof MOB)))
      return new StringBuffer("'" + where + "' is not a MOB.");
    else if ((!(E instanceof Weapon)) && (!(E instanceof Armor)) && (!(E instanceof MOB)))
      return new StringBuffer("'" + where + "' is not a MOB, or Weapon, or Item.");
    else check.add(E);
    final StringBuffer str = new StringBuffer("");
    str.append(L("Deviations Report:\n\r"));
    final StringBuffer itemResults = new StringBuffer();
    final StringBuffer mobResults = new StringBuffer();
    for (int c = 0; c < check.size(); c++) {
      if (check.get(c) instanceof Item) {
        final Item I = (Item) check.get(c);
        Weapon W = null;
        if (I instanceof Weapon) W = (Weapon) I;
        final Map<String, String> vals =
            CMLib.itemBuilder()
                .timsItemAdjustments(
                    I,
                    I.phyStats().level(),
                    I.material(),
                    I.rawLogicalAnd() ? 2 : 1,
                    (W == null) ? 0 : W.weaponClassification(),
                    I.maxRange(),
                    I.rawProperLocationBitmap());
        itemResults.append(CMStrings.padRight(I.name(), 20) + " ");
        itemResults.append(CMStrings.padRight(I.ID(), 10) + " ");
        itemResults.append(CMStrings.padRight("" + I.phyStats().level(), 4) + " ");
        itemResults.append(
            CMStrings.padRight(
                    "" + getDeviation(I.basePhyStats().attackAdjustment(), vals, "ATTACK"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "DAMAGE"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "ARMOR"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.baseGoldValue(), vals, "VALUE"), 5) + " ");
        itemResults.append(
            CMStrings.padRight(
                    ""
                        + ((I.phyStats().rejuv() == PhyStats.NO_REJUV)
                            ? " MAX"
                            : "" + I.phyStats().rejuv()),
                    5)
                + " ");
        if (I instanceof Weapon)
          itemResults.append(CMStrings.padRight("" + I.basePhyStats().weight(), 4));
        else
          itemResults.append(
              CMStrings.padRight("" + getDeviation(I.basePhyStats().weight(), vals, "WEIGHT"), 4)
                  + " ");
        if (I instanceof Armor)
          itemResults.append(CMStrings.padRight("" + ((Armor) I).phyStats().height(), 4));
        else itemResults.append(CMStrings.padRight(" - ", 4) + " ");
        itemResults.append("\n\r");
      } else {
        final MOB M = (MOB) check.get(c);
        mobResults.append(CMStrings.padRight(M.name(), 20) + " ");
        mobResults.append(CMStrings.padRight("" + M.phyStats().level(), 4) + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().attackAdjustment(), CMLib.leveler().getLevelAttack(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().damage(),
                            (int)
                                Math.round(
                                    CMath.div(
                                        CMLib.leveler().getLevelMOBDamage(M),
                                        M.basePhyStats().speed()))),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().armor(), CMLib.leveler().getLevelMOBArmor(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().speed(), CMLib.leveler().getLevelMOBSpeed(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + ((M.phyStats().rejuv() == PhyStats.NO_REJUV)
                            ? " MAX"
                            : "" + M.phyStats().rejuv()),
                    5)
                + " ");
        if (useFaction != null)
          mobResults.append(
              CMStrings.padRight(
                      ""
                          + (M.fetchFaction(useFaction.factionID()) == Integer.MAX_VALUE
                              ? "N/A"
                              : "" + M.fetchFaction(useFaction.factionID())),
                      7)
                  + " ");
        double value = CMLib.beanCounter().getTotalAbsoluteNativeValue(M);
        double[] range = CMLib.leveler().getLevelMoneyRange(M);
        if (value < range[0])
          mobResults.append(CMStrings.padRight("" + getDeviation(value, range[0]), 5) + " ");
        else if (value > range[1])
          mobResults.append(CMStrings.padRight("" + getDeviation(value, range[1]), 5) + " ");
        else mobResults.append(CMStrings.padRight("0%", 5) + " ");
        int reallyWornCount = 0;
        for (int j = 0; j < M.numItems(); j++) {
          final Item Iw = M.getItem(j);
          if (!(Iw.amWearingAt(Wearable.IN_INVENTORY))) reallyWornCount++;
        }
        mobResults.append(CMStrings.padRight("" + reallyWornCount, 5) + " ");
        mobResults.append("\n\r");
      }
    }
    if (itemResults.length() > 0) str.append(itemHeader() + itemResults.toString());
    if (mobResults.length() > 0) str.append(mobHeader(useFaction) + mobResults.toString());
    return str;
  }