Esempio n. 1
0
 @Override
 public String displayText() {
   final StringBuilder str = new StringBuilder("");
   for (final Object[] A : affects)
     if (A[0] instanceof Ability) str.append(((Ability) A[0]).displayText());
   return str.toString();
 }
Esempio n. 2
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   final StringBuilder msg = new StringBuilder("");
   final Vector V = new Vector();
   V.add(Integer.valueOf(Ability.ACODE_THIEF_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_COMMON_SKILL));
   final String qual = CMParms.combine(commands, 1).toUpperCase();
   if (parsedOutIndividualSkill(mob, qual, V)) return true;
   final int[] level = new int[1];
   final int[] domain = new int[1];
   final String[] domainName = new String[1];
   domainName[0] = "";
   level[0] = -1;
   parseDomainInfo(mob, commands, V, level, domain, domainName);
   int mask = Ability.ALL_ACODES;
   if (domain[0] >= 0) {
     mask = mask | Ability.ALL_DOMAINS;
     for (int v = 0; v < V.size(); v++)
       V.setElementAt(Integer.valueOf(((Integer) V.get(v)).intValue() + domain[0]), v);
   }
   if ((domain[0] >= 0) || (qual.length() == 0))
     msg.append(
         L(
             "\n\r^HYour @x1skills:^? @x2",
             domainName[0].replace('_', ' '),
             getAbilities(mob, mob, V, mask, true, level[0]).toString()));
   if (!mob.isMonster()) mob.session().wraplessPrintln(msg.toString());
   return false;
 }
Esempio n. 3
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   if ((commands.size() == 1) && (commands.get(0) instanceof MOB)) {
     commands.add(getInventory((MOB) commands.get(0), mob, null));
     return true;
   }
   final StringBuilder msg = getInventory(mob, mob, CMParms.combine(commands, 1));
   if (msg.length() == 0) mob.tell(L("^HYou are carrying:\n\r^!Nothing!^?\n\r"));
   else if (!mob.isMonster())
     mob.session().wraplessPrintln(L("^HYou are carrying:^?\n\r@x1", msg.toString()));
   return false;
 }
Esempio n. 4
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);
   }
 }
 @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);
   }
 }
Esempio n. 6
0
  public StringBuilder getInventory(MOB seer, MOB mob, String mask) {
    final StringBuilder msg = new StringBuilder("");
    final InventoryList list = fetchInventory(seer, mob);
    if (((list.viewItems.size() > 0) || (list.moneyItems.size() > 0)) && (!list.foundAndSeen)) {
      list.viewItems.clear();
      list.moneyItems.clear();
      list.foundButUnseen = true;
    } else if ((mask != null) && (mask.trim().length() > 0)) {
      mask = mask.trim().toUpperCase();
      if (!mask.startsWith("all")) mask = "all " + mask;
      final Vector<Item> V = (Vector<Item>) list.viewItems.clone();
      list.viewItems.clear();
      Item I = (V.size() > 0) ? (Item) V.get(0) : null;
      while (I != null) {
        I = (Item) CMLib.english().fetchEnvironmental(V, mask, false);
        if (I != null) {
          list.viewItems.add(I);
          V.remove(I);
        }
      }
    }
    if ((list.viewItems.size() == 0) && (list.moneyItems.size() == 0)) {
      if ((mask != null) && (mask.trim().length() > 0))
        msg.append(L("(nothing like that you can see right now)"));
      else msg.append(L("(nothing you can see right now)"));
    } else {
      if (list.viewItems.size() > 0)
        msg.append(
            CMLib.lister()
                .lister(
                    seer,
                    list.viewItems,
                    true,
                    "MItem",
                    "",
                    false,
                    seer.isAttribute(MOB.Attrib.COMPRESS)));
      if (list.foundButUnseen) msg.append(L("(stuff you can't see right now)"));

      msg.append(getShowableMoney(list));
    }
    return msg;
  }
Esempio n. 7
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();
 }
Esempio n. 8
0
 protected StringBuilder getAbilities(
     MOB viewerM, MOB ableM, Vector ofTypes, int mask, boolean addQualLine, int maxLevel) {
   final int COL_LEN1 = ListingLibrary.ColFixer.fixColWidth(3.0, viewerM);
   final int COL_LEN2 = ListingLibrary.ColFixer.fixColWidth(18.0, viewerM);
   final int COL_LEN3 = ListingLibrary.ColFixer.fixColWidth(19.0, viewerM);
   int highestLevel = 0;
   final int lowestLevel = ableM.phyStats().level() + 1;
   final StringBuilder msg = new StringBuilder("");
   for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
     final Ability A = a.nextElement();
     int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
     if (level < 0) level = 0;
     if ((A != null)
         && (level > highestLevel)
         && (level < lowestLevel)
         && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask))))
       highestLevel = level;
   }
   if ((maxLevel >= 0) && (maxLevel < highestLevel)) highestLevel = maxLevel;
   for (int l = 0; l <= highestLevel; l++) {
     final StringBuilder thisLine = new StringBuilder("");
     int col = 0;
     for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
       if (level < 0) level = 0;
       if ((A != null)
           && (level == l)
           && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask)))) {
         if (thisLine.length() == 0) thisLine.append("\n\rLevel ^!" + l + "^?:\n\r");
         if ((++col) > 3) {
           thisLine.append("\n\r");
           col = 1;
         }
         thisLine.append(
             "^N[^H"
                 + CMStrings.padRight(Integer.toString(A.proficiency()), COL_LEN1)
                 + "%^?]^N"
                 + " " // +(A.isAutoInvoked()?"^H.^N":" ")
                 + CMStrings.padRight(
                     "^<HELP^>" + A.name() + "^</HELP^>", (col == 3) ? COL_LEN2 : COL_LEN3));
       }
     }
     if (thisLine.length() > 0) msg.append(thisLine);
   }
   if (msg.length() == 0) msg.append(L("^!None!^?"));
   else if (addQualLine)
     msg.append(
         L(
             "\n\r\n\rUse QUALIFY to see additional skills you can GAIN.")); // ^H.^N =
                                                                             // passive/auto-invoked."));
   return msg;
 }