Ejemplo 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();
 }
Ejemplo 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;
 }
Ejemplo n.º 3
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);
   }
 }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 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();
 }
Ejemplo n.º 6
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;
 }