Exemplo n.º 1
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item I =
        getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (I == null) return false;
    if (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_VEGETATION)
        && ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN)) {
      mob.tell(L("Your plant knowledge can tell you nothing about @x1.", I.name(mob)));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (!success) mob.tell(L("Your plant senses fail you."));
    else {
      final CMMsg msg =
          CMClass.getMsg(mob, I, null, CMMsg.MSG_DELICATE_SMALL_HANDS_ACT | CMMsg.MASK_MAGIC, null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final StringBuffer str = new StringBuffer("");
        str.append(
            L(
                "@x1 is a kind of @x2.  ",
                I.name(mob),
                RawMaterial.CODES.NAME(I.material()).toLowerCase()));
        if (isPlant(I)) str.append(L("It was summoned by @x1.", I.rawSecretIdentity()));
        else str.append(L("It is either processed by hand, or grown wild."));
        mob.tell(str.toString());
      }
    }
    return success;
  }
Exemplo n.º 2
0
 protected boolean parsedOutIndividualSkill(MOB mob, String qual, Vector acodes) {
   if ((qual == null) || (qual.length() == 0) || (qual.equalsIgnoreCase("all"))) return false;
   if (qual.length() > 0)
     for (int i = 1; i < Ability.DOMAIN_DESCS.length; i++)
       if (Ability.DOMAIN_DESCS[i].replace('_', ' ').equalsIgnoreCase(qual)) return false;
       else if ((Ability.DOMAIN_DESCS[i].replace('_', ' ').indexOf('/') >= 0)
           && (Ability.DOMAIN_DESCS[i]
               .replace('_', ' ')
               .substring(Ability.DOMAIN_DESCS[i].indexOf('/') + 1)
               .equalsIgnoreCase(qual))) return false;
   final Ability A = CMClass.findAbility(qual);
   if ((A != null)
       && (CMLib.ableMapper().qualifiesByAnyCharClass(A.ID()))
       && (acodes.contains(Integer.valueOf(A.classificationCode() & Ability.ALL_ACODES)))) {
     final Ability A2 = mob.fetchAbility(A.ID());
     if (A2 == null) mob.tell(L("You don't know '@x1'.", A.name()));
     else {
       int level = CMLib.ableMapper().qualifyingLevel(mob, A2);
       if (level < 0) level = 0;
       final StringBuffer line = new StringBuffer("");
       line.append("\n\rLevel ^!" + level + "^?:\n\r");
       line.append(
           "^N[^H"
               + CMStrings.padRight(Integer.toString(A2.proficiency()), 3)
               + "%^?]^N "
               + CMStrings.padRight("^<HELP^>" + A2.name() + "^</HELP^>", 19));
       line.append("^?\n\r");
       if (mob.session() != null) mob.session().wraplessPrintln(line.toString());
     }
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 protected String mobHeader(Faction useFaction) {
   final StringBuffer str = new StringBuffer();
   str.append("\n\r");
   str.append(CMStrings.padRight(L("Name"), 20) + " ");
   str.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   str.append(CMStrings.padRight(L("Att"), 5) + " ");
   str.append(CMStrings.padRight(L("Dmg"), 5) + " ");
   str.append(CMStrings.padRight(L("Armor"), 5) + " ");
   str.append(CMStrings.padRight(L("Speed"), 5) + " ");
   str.append(CMStrings.padRight(L("Rejuv"), 5) + " ");
   if (useFaction != null) str.append(CMStrings.padRight(useFaction.name(), 7) + " ");
   str.append(CMStrings.padRight(L("Money"), 5) + " ");
   str.append(CMStrings.padRight(L("Worn"), 5));
   str.append("\n\r");
   return str.toString();
 }
Exemplo n.º 4
0
 @Override
 public String getNonBaseStatsAsString() {
   final StringBuffer str = new StringBuffer("");
   final CharStats.CODES C = CharStats.CODES.instance();
   for (final int x : C.all()) {
     if ((!C.isBase(x)) && (x != CharStats.STAT_GENDER)) str.append(stats[x] + ";");
   }
   return str.toString();
 }
Exemplo n.º 5
0
 @Override
 public String text() {
   final StringBuffer x = new StringBuffer("");
   for (final Enumeration<String> e = getSongs().keys(); e.hasMoreElements(); ) {
     final String key = e.nextElement();
     final String notkey = getSongs().get(key);
     x.append(key + "|~|" + notkey + "[|]");
   }
   miscText = x.toString();
   return x.toString();
 }
Exemplo n.º 6
0
 public void sortEnumeratedList(
     Enumeration e, List<String> allKnownFields, StringBuffer allFieldsMsg) {
   for (; e.hasMoreElements(); ) {
     final Environmental E = (Environmental) e.nextElement();
     final String[] fields = E.getStatCodes();
     for (int x = 0; x < fields.length; x++)
       if (!allKnownFields.contains(fields[x])) {
         allKnownFields.add(fields[x]);
         allFieldsMsg.append(fields[x] + " ");
       }
   }
 }
Exemplo n.º 7
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((whom != null)
       && (song == null)
       && (msg.amISource(whom))
       && (CMLib.flags().canBeSeenBy(whom, invoker()))) {
     if (trail == null) trail = new StringBuffer("");
     ensureCmds();
     if (cmds.containsKey("" + msg.sourceMinor())) trail.append(msg.sourceMinor() + ";");
   }
   super.executeMsg(myHost, msg);
 }
Exemplo n.º 8
0
 protected String itemHeader() {
   final StringBuffer str = new StringBuffer();
   str.append("\n\r");
   str.append(CMStrings.padRight(L("Name"), 20) + " ");
   str.append(CMStrings.padRight(L("Type"), 10) + " ");
   str.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   str.append(CMStrings.padRight(L("Att"), 5) + " ");
   str.append(CMStrings.padRight(L("Dmg"), 5) + " ");
   str.append(CMStrings.padRight(L("Armor"), 5) + " ");
   str.append(CMStrings.padRight(L("Value"), 5) + " ");
   str.append(CMStrings.padRight(L("Rejuv"), 5) + " ");
   str.append(CMStrings.padRight(L("Wght."), 4) + " ");
   str.append(CMStrings.padRight(L("Size"), 4));
   str.append("\n\r");
   return str.toString();
 }
Exemplo n.º 9
0
 protected void parseDomainInfo(
     MOB mob, Vector commands, Vector acodes, int[] level, int[] domain, String[] domainName) {
   level[0] = parseOutLevel(commands);
   final String qual = CMParms.combine(commands, 1).toUpperCase();
   domain[0] = -1;
   if (qual.length() > 0)
     for (int i = 1; i < Ability.DOMAIN_DESCS.length; i++)
       if (Ability.DOMAIN_DESCS[i].replace('_', ' ').startsWith(qual)) {
         domain[0] = i << 5;
         break;
       } else if ((Ability.DOMAIN_DESCS[i].replace('_', ' ').indexOf('/') >= 0)
           && (Ability.DOMAIN_DESCS[i]
               .replace('_', ' ')
               .substring(Ability.DOMAIN_DESCS[i].indexOf('/') + 1)
               .startsWith(qual))) {
         domain[0] = i << 5;
         break;
       }
   if (domain[0] > 0) domainName[0] = Ability.DOMAIN_DESCS[domain[0] >> 5].toLowerCase();
   if ((domain[0] < 0) && (qual.length() > 0)) {
     StringBuffer domains = new StringBuffer("");
     domains.append("\n\rValid schools/domains are: ");
     for (int i = 1; i < Ability.DOMAIN_DESCS.length; i++) {
       boolean found = false;
       for (int a = 0; a < acodes.size(); a++)
         found =
             found
                 || CMLib.ableMapper()
                     .isDomainIncludedInAnyAbility(i << 5, ((Integer) acodes.get(a)).intValue());
       if (found) domains.append(Ability.DOMAIN_DESCS[i].toLowerCase().replace('_', ' ') + ", ");
     }
     if (domains.toString().endsWith(", "))
       domains = new StringBuffer(domains.substring(0, domains.length() - 2));
     if (!mob.isMonster()) mob.session().wraplessPrintln(domains.toString() + "\n\r");
   } else if (qual.length() > 0) domainName[0] += " ";
 }
Exemplo n.º 10
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if (type.length() == 0) return false;
    if ((mob.getClanID() == null)
        || (mob.getClanID().equalsIgnoreCase(""))
        || (mob.getClanRole() == 0)) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    Clan C = CMLib.clans().getClan(mob.getClanID());
    if (C == null) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    if (C.allowedToDoThis(mob, Clan.FUNC_CLANENCHANT) != 1) {
      mob.tell("You are not authorized to draw from the power of your " + C.typeName() + ".");
      return false;
    }
    String ClanName = C.clanID();
    String ClanType = C.typeName();

    // Invoking will be like:
    //   CAST [CLANEQSPELL] ITEM QUANTITY
    //   -2   -1            0    1
    if (commands.size() < 1) {
      mob.tell("Enchant which spell onto what?");
      return false;
    }
    if (commands.size() < 2) {
      mob.tell("Use how much clan enchantment power?");
      return false;
    }
    Environmental target =
        mob.location()
            .fetchFromMOBRoomFavorsItems(
                mob, null, (String) commands.elementAt(0), Item.WORNREQ_UNWORNONLY);
    if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) {
      mob.tell("You don't see '" + ((String) commands.elementAt(0)) + "' here.");
      return false;
    }
    // Add clan power check start
    int points = CMath.s_int((String) commands.elementAt(1));
    if (points <= 0) {
      mob.tell("You need to use at least 1 enchantment point.");
      return false;
    }
    long exp = points * CMProps.getIntVar(CMProps.SYSTEMI_CLANENCHCOST);
    if ((C.getExp() < exp) || (exp < 0)) {
      mob.tell(
          "You need "
              + exp
              + " to do that, but your "
              + C.typeName()
              + " has only "
              + C.getExp()
              + " experience points.");
      return false;
    }

    // Add clan power check end
    if (target.fetchEffect("Prop_ClanEquipment") != null) {
      mob.tell(target.name() + " is already clan enchanted.");
      return false;
    }

    // lose all the mana!
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    C.setExp(C.getExp() - exp);
    C.update();

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              "^S<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = CMClass.getAbility("Prop_ClanEquipment");
        StringBuffer str = new StringBuffer("");
        str.append(type); // Type of Enchantment
        str.append(" ");
        str.append("" + points); // Power of Enchantment
        str.append(" \"");
        str.append(ClanName); // Clan Name
        str.append("\" \"");
        str.append(ClanType); // Clan Type
        str.append("\"");
        A.setMiscText(str.toString());
        target.addEffect(A);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely, and looking very frustrated.");
    return success;
  }
Exemplo n.º 11
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto)
        && (givenTarget == this)
        && (commands.size() > 0)
        && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    DVector enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          "Knit what? Enter \"knit list\" for a list, \"knit refit <item>\" to resize, \"knit scan\", or \"knit mend <item>\".");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    Vector recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    String startStr = null;
    bundling = false;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      int toggleTop = 2;
      for (int r = 0; r < toggleTop; r++)
        buf.append(CMStrings.padRight("Item", 28) + " Lvl " + CMStrings.padRight("Cloth", 5) + " ");
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        Vector V = (Vector) recipes.elementAt(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.elementAt(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          int wood = CMath.s_int((String) V.elementAt(RCP_WOOD));
          wood = adjustWoodRequired(wood, mob);
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, 28)
                    + " "
                    + CMStrings.padRight("" + level, 3)
                    + " "
                    + CMStrings.padRight("" + wood, 5)
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    }
    if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      building = null;
      mending = false;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, building, false)) return false;
      mending = true;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) mending " + building.name() + ".";
      displayText = "You are mending " + building.name();
      verb = "mending " + building.name();
    } else if (str.equalsIgnoreCase("refit")) {
      building = null;
      mending = false;
      refitting = false;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (building == null) return false;
      if ((building.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_CLOTH) {
        commonTell(mob, "That's not made of cloth.  It can't be refitted.");
        return false;
      }
      if (!(building instanceof Armor)) {
        commonTell(mob, "You don't know how to refit that sort of thing.");
        return false;
      }
      if (building.envStats().height() == 0) {
        commonTell(mob, building.name() + " is already the right size.");
        return false;
      }
      refitting = true;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) refitting " + building.name() + ".";
      displayText = "You are refitting " + building.name();
      verb = "refitting " + building.name();
    } else {
      building = null;
      mending = false;
      messedUp = false;
      refitting = false;
      aborted = false;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
        amount = CMath.s_int((String) commands.lastElement());
        commands.removeElementAt(commands.size() - 1);
      }
      String recipeName = CMParms.combine(commands, 0);
      Vector foundRecipe = null;
      Vector matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        Vector V = (Vector) matches.elementAt(r);
        if (V.size() > 0) {
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          if ((autoGenerate > 0) || (level <= xlevel(mob))) {
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            "You don't know how to knit a '"
                + recipeName
                + "'.  Try \""
                + triggerStrings()[0].toLowerCase()
                + " list\" for a list.");
        return false;
      }
      int woodRequired = CMath.s_int((String) foundRecipe.elementAt(RCP_WOOD));
      woodRequired = adjustWoodRequired(woodRequired, mob);
      if (amount > woodRequired) woodRequired = amount;
      String misctype = (String) foundRecipe.elementAt(RCP_MISCTYPE);
      bundling = misctype.equalsIgnoreCase("BUNDLE");
      int[] pm = {RawMaterial.MATERIAL_CLOTH};
      int[][] data =
          fetchFoundResourceData(
              mob, woodRequired, "cloth", pm, 0, null, null, bundling, autoGenerate, enhancedTypes);
      if (data == null) return false;
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                  .destroyResources(mob.location(), woodRequired, data[0][FOUND_CODE], 0, null);
      building = CMClass.getItem((String) foundRecipe.elementAt(RCP_CLASSTYPE));
      if (building == null) {
        commonTell(
            mob, "There's no such thing as a " + foundRecipe.elementAt(RCP_CLASSTYPE) + "!!!");
        return false;
      }
      duration =
          getDuration(
              CMath.s_int((String) foundRecipe.elementAt(RCP_TICKS)),
              mob,
              CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)),
              4);
      String itemName =
          replacePercent(
                  (String) foundRecipe.elementAt(RCP_FINALNAME),
                  RawMaterial.CODES.NAME(data[0][FOUND_CODE]))
              .toLowerCase();
      if (bundling) itemName = "a " + woodRequired + "# " + itemName;
      else if (itemName.endsWith("s")) itemName = "some " + itemName;
      else itemName = CMLib.english().startWithAorAn(itemName);
      building.setName(itemName);
      startStr = "<S-NAME> start(s) knitting " + building.name() + ".";
      displayText = "You are knitting " + building.name();
      verb = "knitting " + building.name();
      playSound = "scissor.wav";
      building.setDisplayText(itemName + " lies here");
      building.setDescription(itemName + ". ");
      if (bundling) building.baseEnvStats().setWeight(woodRequired);
      else building.baseEnvStats().setWeight(woodRequired / 2);
      int hardness = RawMaterial.CODES.HARDNESS(data[0][FOUND_CODE]) - 1;
      building.setBaseValue(CMath.s_int((String) foundRecipe.elementAt(RCP_VALUE)));
      building.setMaterial(data[0][FOUND_CODE]);
      building.baseEnvStats().setLevel(CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)));
      building.setSecretIdentity("This is the work of " + mob.Name() + ".");
      int capacity = CMath.s_int((String) foundRecipe.elementAt(RCP_CAPACITY));
      int canContain = CMath.s_int((String) foundRecipe.elementAt(RCP_CONTAINMASK));
      int armordmg = CMath.s_int((String) foundRecipe.elementAt(RCP_ARMORDMG));
      String spell =
          (foundRecipe.size() > RCP_SPELL)
              ? ((String) foundRecipe.elementAt(RCP_SPELL)).trim()
              : "";
      if (bundling) building.setBaseValue(lostValue);
      addSpells(building, spell);
      if (building instanceof Weapon) {
        ((Weapon) building).setWeaponClassification(Weapon.CLASS_NATURAL);
        setWeaponTypeClass((Weapon) building, misctype);
        building.baseEnvStats().setDamage(armordmg);
        ((Weapon) building).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) building).setRawLogicalAnd((capacity > 1));
      }
      if (building instanceof Armor) {
        if (capacity > 0) {
          ((Armor) building).setCapacity(capacity + woodRequired);
          ((Armor) building).setContainTypes(canContain);
        }
        ((Armor) building).baseEnvStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) building).baseEnvStats().setArmor(armordmg + (abilityCode() - 1) + hardness);
        setWearLocation(building, misctype, 0);
      }
      if (building instanceof Rideable) {
        setRideBasis((Rideable) building, misctype);
      }
      building.recoverEnvStats();
      building.text();
      building.recoverEnvStats();
    }

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = "bundling " + RawMaterial.CODES.NAME(building.material()).toLowerCase();
      startStr = "<S-NAME> start(s) " + verb + ".";
      displayText = "You are " + verb;
    }

    if (autoGenerate > 0) {
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, building, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
Exemplo n.º 12
0
  @Override
  protected boolean autoGenInvoke(
      final MOB mob,
      List<String> commands,
      Physical givenTarget,
      final boolean auto,
      final int asLevel,
      int autoGenerate,
      boolean forceLevels,
      List<Item> crafted) {
    if (super.checkStop(mob, commands)) return true;

    if (super.checkInfo(mob, commands)) return true;

    final PairVector<EnhancedExpertise, Integer> enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          L(
              "Make what? Enter \"mleatherwork list\" for a list, \"mleatherworkd info <item>\", \"mleatherwork refit <item>\" to resize,"
                  + " \"mleatherwork learn <item>\", \"mleatherwork scan\", \"mleatherwork mend <item>\", or \"mleatherwork stop\" to cancel."));
      return false;
    }
    if ((!auto) && (commands.size() > 0) && ((commands.get(0)).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    final List<List<String>> recipes = addRecipes(mob, loadRecipes());
    final String str = commands.get(0);
    playSound = "scissor.wav";
    String startStr = null;
    bundling = false;
    int multiplier = 4;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      boolean allFlag = false;
      if (mask.equalsIgnoreCase("all")) {
        allFlag = true;
        mask = "";
      }
      final StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      final int toggleTop = 2;
      final int[] cols = {
        CMLib.lister().fixColWidth(30, mob.session()),
        CMLib.lister().fixColWidth(3, mob.session()),
        CMLib.lister().fixColWidth(3, mob.session())
      };
      for (int r = 0; r < toggleTop; r++)
        buf.append(
            (r > 0 ? " " : "")
                + CMStrings.padRight(L("Item"), cols[0])
                + " "
                + CMStrings.padRight(L("Lvl"), cols[1])
                + " "
                + CMStrings.padRight(L("Amt"), cols[2]));
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        final List<String> V = recipes.get(r);
        if (V.size() > 0) {
          final String item = replacePercent(V.get(RCP_FINALNAME), "");
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          final String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (wood.length() > 5) {
            if (toggler > 1) buf.append("\n\r");
            toggler = toggleTop;
          }
          if (((level <= xlevel(mob)) || allFlag)
              && ((mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, cols[0])
                    + " "
                    + CMStrings.padRight("" + (level), cols[1])
                    + " "
                    + CMStrings.padRightPreserve("" + wood, cols[2])
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if (((commands.get(0))).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    } else if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      final Vector<String> newCommands = CMParms.parse(CMParms.combine(commands, 1));
      buildingI =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, buildingI, false)) return false;
      activity = CraftingActivity.MENDING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = L("<S-NAME> start(s) mending @x1.", buildingI.name());
      displayText = L("You are mending @x1", buildingI.name());
      verb = L("mending @x1", buildingI.name());
    } else if (str.equalsIgnoreCase("refit")) {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      final Vector<String> newCommands = CMParms.parse(CMParms.combine(commands, 1));
      buildingI =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (buildingI == null) return false;
      if ((buildingI.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_LEATHER) {
        commonTell(mob, L("That's not made of leather.  That can't be refitted."));
        return false;
      }
      if (!(buildingI instanceof Armor)) {
        commonTell(mob, L("You don't know how to refit that sort of thing."));
        return false;
      }
      if (buildingI.phyStats().height() == 0) {
        commonTell(mob, L("@x1 is already the right size.", buildingI.name(mob)));
        return false;
      }
      activity = CraftingActivity.REFITTING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = L("<S-NAME> start(s) refitting @x1.", buildingI.name());
      displayText = L("You are refitting @x1", buildingI.name());
      verb = L("refitting @x1", buildingI.name());
    } else {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      aborted = false;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber(commands.get(commands.size() - 1)))) {
        amount = CMath.s_int(commands.get(commands.size() - 1));
        commands.remove(commands.size() - 1);
      }
      final String recipeName = CMParms.combine(commands, 0);
      List<String> foundRecipe = null;
      final List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        final List<String> V = matches.get(r);
        if (V.size() > 0) {
          final String name = V.get(RCP_FINALNAME);
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          if (level <= xlevel(mob)) {
            final int x = name.indexOf(' ');
            final Stage stage = Stage.valueOf(name.substring(0, x));
            multiplier = stage.multiplier;
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            L(
                "You don't know how to make a '@x1'.  Try \"mleatherwork list\" for a list.",
                recipeName));
        return false;
      }

      final String woodRequiredStr = foundRecipe.get(RCP_WOOD);
      final int[] compData = new int[CF_TOTAL];
      final List<Object> componentsFoundList =
          getAbilityComponents(
              mob,
              woodRequiredStr,
              "make " + CMLib.english().startWithAorAn(recipeName),
              autoGenerate,
              compData);
      if (componentsFoundList == null) return false;
      int woodRequired = CMath.s_int(woodRequiredStr);
      woodRequired = adjustWoodRequired(woodRequired, mob);

      if (amount > woodRequired) woodRequired = amount;
      final int[] pm = {RawMaterial.MATERIAL_LEATHER};
      final int[] pm1 = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL};
      final String misctype = foundRecipe.get(RCP_MISCTYPE);
      bundling = misctype.equalsIgnoreCase("BUNDLE");
      final int[][] data =
          fetchFoundResourceData(
              mob,
              woodRequired,
              "leather",
              pm,
              (multiplier == 6) ? 1 : 0,
              (multiplier == 6) ? "metal" : null,
              (multiplier == 6) ? pm1 : null,
              bundling,
              autoGenerate,
              enhancedTypes);
      if (data == null) return false;
      fixDataForComponents(data, componentsFoundList);
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      final int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                      .destroyResourcesValue(
                          mob.location(),
                          woodRequired,
                          data[0][FOUND_CODE],
                          data[1][FOUND_CODE],
                          null)
                  + CMLib.ableComponents().destroyAbilityComponents(componentsFoundList);
      buildingI = CMClass.getItem(foundRecipe.get(RCP_CLASSTYPE));
      if (buildingI == null) {
        commonTell(mob, L("There's no such thing as a @x1!!!", foundRecipe.get(RCP_CLASSTYPE)));
        return false;
      }
      duration = getDuration(multiplier * CMath.s_int(foundRecipe.get(RCP_TICKS)), mob, 30, 4);
      buildingI.setMaterial(super.getBuildingMaterial(woodRequired, data, compData));
      String itemName =
          (replacePercent(
                  foundRecipe.get(RCP_FINALNAME), RawMaterial.CODES.NAME(data[0][FOUND_CODE])))
              .toLowerCase();
      if (bundling) itemName = "a " + woodRequired + "# " + itemName;
      else if (itemName.endsWith("s")) itemName = "some " + itemName;
      else itemName = CMLib.english().startWithAorAn(itemName);
      buildingI.setName(itemName);
      startStr = L("<S-NAME> start(s) making @x1.", buildingI.name());
      displayText = L("You are making @x1", buildingI.name());
      verb = L("making @x1", buildingI.name());
      buildingI.setDisplayText(L("@x1 lies here", itemName));
      buildingI.setDescription(itemName + ". ");
      buildingI
          .basePhyStats()
          .setWeight(getStandardWeight(woodRequired + compData[CF_AMOUNT], bundling));
      buildingI.setBaseValue(CMath.s_int(foundRecipe.get(RCP_VALUE)) * multiplier);
      buildingI.setSecretIdentity(getBrand(mob));
      final int hardness = RawMaterial.CODES.HARDNESS(buildingI.material()) - 2;
      buildingI.basePhyStats().setLevel(CMath.s_int(foundRecipe.get(RCP_LEVEL)) + hardness);
      final int capacity = CMath.s_int(foundRecipe.get(RCP_CAPACITY));
      final long canContain = getContainerType(foundRecipe.get(RCP_CONTAINMASK));
      int armordmg = CMath.s_int(foundRecipe.get(RCP_ARMORDMG));
      if (armordmg != 0) armordmg = armordmg + (multiplier - 1);
      if (bundling) buildingI.setBaseValue(lostValue);
      final String spell =
          (foundRecipe.size() > RCP_SPELL) ? foundRecipe.get(RCP_SPELL).trim() : "";
      addSpells(buildingI, spell);
      if (buildingI instanceof Weapon) {
        ((Weapon) buildingI)
            .basePhyStats()
            .setAttackAdjustment(baseYield() + abilityCode() + (hardness * 5) - 1);
        ((Weapon) buildingI).setWeaponClassification(Weapon.CLASS_FLAILED);
        setWeaponTypeClass((Weapon) buildingI, misctype, Weapon.TYPE_SLASHING);
        buildingI.basePhyStats().setDamage(armordmg + hardness);
        ((Weapon) buildingI).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) buildingI).setRawLogicalAnd((capacity > 1));
      }
      if ((buildingI instanceof Armor) && (!(buildingI instanceof FalseLimb))) {
        if ((capacity > 0) && (buildingI instanceof Container)) {
          ((Container) buildingI).setCapacity(capacity + woodRequired);
          ((Container) buildingI).setContainTypes(canContain);
        }
        ((Armor) buildingI).basePhyStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) buildingI)
              .basePhyStats()
              .setArmor(armordmg + (baseYield() + abilityCode() - 1) + hardness);
        setWearLocation(buildingI, misctype, 0);
      }
      if (buildingI instanceof Drink) {
        if (CMLib.flags().isGettable(buildingI)) {
          ((Drink) buildingI).setLiquidRemaining(0);
          ((Drink) buildingI).setLiquidHeld(capacity * 50);
          ((Drink) buildingI).setThirstQuenched(250);
          if ((capacity * 50) < 250) ((Drink) buildingI).setThirstQuenched(capacity * 50);
        }
      }
      buildingI.recoverPhyStats();
      buildingI.text();
      buildingI.recoverPhyStats();
    }

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = L("bundling @x1", RawMaterial.CODES.NAME(buildingI.material()).toLowerCase());
      startStr = L("<S-NAME> start(s) @x1.", verb);
      displayText = L("You are @x1", verb);
    }

    if (autoGenerate > 0) {
      crafted.add(buildingI);
      return true;
    }

    final CMMsg msg = CMClass.getMsg(mob, buildingI, this, getActivityMessageType(), startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      buildingI = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, buildingI, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
Exemplo n.º 13
0
 @Override
 public String getBodyPartsAsString() {
   final StringBuffer str = new StringBuffer("");
   for (int i = 0; i < getMyRace().bodyMask().length; i++) str.append(getBodyPart(i) + ";");
   return str.toString();
 }
Exemplo n.º 14
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;
 }
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto)
        && (givenTarget == this)
        && (commands.size() > 0)
        && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(mob, "Papermake what? Enter \"Papermake list\" for a list.");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    Vector recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    String startStr = null;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf =
          new StringBuffer(CMStrings.padRight("Item", 22) + " Lvl Material required\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        Vector V = (Vector) recipes.elementAt(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.elementAt(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          int wood = CMath.s_int((String) V.elementAt(RCP_WOOD));
          wood = adjustWoodRequired(wood, mob);
          String material = (String) V.elementAt(RCP_WOODTYPE);
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask)))
            buf.append(
                CMStrings.padRight(item, 22)
                    + " "
                    + CMStrings.padRight("" + level, 3)
                    + " "
                    + wood
                    + " "
                    + material.toLowerCase()
                    + "\n\r");
        }
      }
      commonTell(mob, buf.toString());
      return true;
    }
    building = null;
    messedUp = false;
    String materialDesc = "";
    String recipeName = CMParms.combine(commands, 0);
    Vector foundRecipe = null;
    Vector matches = matchingRecipeNames(recipes, recipeName, true);
    for (int r = 0; r < matches.size(); r++) {
      Vector V = (Vector) matches.elementAt(r);
      if (V.size() > 0) {
        int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
        if ((autoGenerate > 0) || (level <= xlevel(mob))) {
          foundRecipe = V;
          materialDesc = (String) foundRecipe.elementAt(RCP_WOODTYPE);
          if (materialDesc.equalsIgnoreCase("WOOD")) materialDesc = "WOODEN";
          break;
        }
      }
    }
    if (materialDesc.length() == 0) materialDesc = "WOODEN";
    if (foundRecipe == null) {
      commonTell(
          mob, "You don't know how to make a '" + recipeName + "'.  Try \"make list\" for a list.");
      return false;
    }
    int woodRequired = CMath.s_int((String) foundRecipe.elementAt(RCP_WOOD));
    woodRequired = adjustWoodRequired(woodRequired, mob);
    int[][] data =
        fetchFoundResourceData(
            mob, woodRequired, materialDesc, null, 0, null, null, false, autoGenerate, null);
    if (data == null) return false;
    woodRequired = data[0][FOUND_AMT];
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    if (autoGenerate <= 0)
      CMLib.materials()
          .destroyResources(mob.location(), woodRequired, data[0][FOUND_CODE], 0, null);
    building = CMClass.getItem((String) foundRecipe.elementAt(RCP_CLASSTYPE));
    if (building == null) {
      commonTell(mob, "There's no such thing as a " + foundRecipe.elementAt(RCP_CLASSTYPE) + "!!!");
      return false;
    }
    duration =
        getDuration(
            CMath.s_int((String) foundRecipe.elementAt(RCP_TICKS)),
            mob,
            CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)),
            4);
    String itemName =
        replacePercent(
                (String) foundRecipe.elementAt(RCP_FINALNAME),
                RawMaterial.RESOURCE_DESCS[(data[0][FOUND_CODE] & RawMaterial.RESOURCE_MASK)])
            .toLowerCase();
    itemName = CMLib.english().startWithAorAn(itemName);
    building.setName(itemName);
    startStr = "<S-NAME> start(s) making " + building.name() + ".";
    displayText = "You are making " + building.name();
    verb = "making " + building.name();
    playSound = "crumple.wav";
    building.setDisplayText(itemName + " lies here");
    building.setDescription(itemName + ". ");
    building.baseEnvStats().setWeight(woodRequired);
    building.setBaseValue(
        CMath.s_int((String) foundRecipe.elementAt(RCP_VALUE))
            + (woodRequired
                * (RawMaterial.RESOURCE_DATA[data[0][FOUND_CODE] & RawMaterial.RESOURCE_MASK][
                    RawMaterial.DATA_VALUE])));
    building.setMaterial(data[0][FOUND_CODE]);
    String spell =
        (foundRecipe.size() > RCP_SPELL) ? ((String) foundRecipe.elementAt(RCP_SPELL)).trim() : "";
    addSpells(building, spell);
    building.setSecretIdentity("This is the work of " + mob.Name() + ".");
    if (((data[0][FOUND_CODE] & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
        || (data[0][FOUND_CODE] == RawMaterial.RESOURCE_RICE))
      building.setMaterial(RawMaterial.RESOURCE_PAPER);
    building.baseEnvStats().setLevel(CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)));
    building.recoverEnvStats();
    building.text();
    building.recoverEnvStats();

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (autoGenerate > 0) {
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
    }
    return true;
  }
Exemplo n.º 16
0
  @Override
  public boolean invoke(
      final MOB mob, Vector commands, Physical givenTarget, final boolean auto, final int asLevel) {
    final Vector originalCommands = (Vector) commands.clone();
    if (super.checkStop(mob, commands)) return true;

    fireRequired = true;

    final CraftParms parsedVars = super.parseAutoGenerate(auto, givenTarget, commands);
    givenTarget = parsedVars.givenTarget;

    final PairVector<Integer, Integer> enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, parsedVars.autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          L(
              "Make what? Enter \"@x1 list\" for a list, \"@x2 learn <item>\" to gain recipes, or \"@x3 stop\" to cancel.",
              triggerStrings()[0].toLowerCase(),
              triggerStrings()[0].toLowerCase(),
              triggerStrings()[0].toLowerCase()));
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    final List<List<String>> recipes = addRecipes(mob, loadRecipes());
    final String str = (String) commands.elementAt(0);
    String startStr = null;
    bundling = false;
    int duration = 4;
    final int[] cols = {
      ListingLibrary.ColFixer.fixColWidth(16, mob.session()),
      ListingLibrary.ColFixer.fixColWidth(3, mob.session())
    };
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      boolean allFlag = false;
      if (mask.equalsIgnoreCase("all")) {
        allFlag = true;
        mask = "";
      }
      final StringBuffer buf =
          new StringBuffer(
              L(
                  "@x1 @x2 Metals required\n\r",
                  CMStrings.padRight(L("Item"), cols[0]),
                  CMStrings.padRight(L("Lvl"), cols[1])));
      for (int r = 0; r < recipes.size(); r++) {
        final List<String> V = recipes.get(r);
        if (V.size() > 0) {
          final String item = replacePercent(V.get(RCP_FINALNAME), "");
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          final String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (((level <= xlevel(mob)) || allFlag)
              && ((mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask)))
            buf.append(
                CMStrings.padRight(item, cols[0])
                    + " "
                    + CMStrings.padRight("" + level, cols[1])
                    + " "
                    + wood
                    + "\n\r");
        }
      }
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if ((commands.firstElement() instanceof String)
        && (((String) commands.firstElement())).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    }

    activity = CraftingActivity.CRAFTING;
    buildingI = null;
    messedUp = false;
    String statue = null;
    if ((commands.size() > 1) && ((String) commands.lastElement()).startsWith("STATUE=")) {
      statue = (((String) commands.lastElement()).substring(7)).trim();
      if (statue.length() == 0) statue = null;
      else commands.removeElementAt(commands.size() - 1);
    }
    int amount = -1;
    if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
      amount = CMath.s_int((String) commands.lastElement());
      commands.removeElementAt(commands.size() - 1);
    }
    final String recipeName = CMParms.combine(commands, 0);
    List<String> foundRecipe = null;
    final List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
    for (int r = 0; r < matches.size(); r++) {
      final List<String> V = matches.get(r);
      if (V.size() > 0) {
        final int level = CMath.s_int(V.get(RCP_LEVEL));
        if ((parsedVars.autoGenerate > 0) || (level <= xlevel(mob))) {
          foundRecipe = V;
          break;
        }
      }
    }
    if (foundRecipe == null) {
      commonTell(
          mob,
          L(
              "You don't know how to make a '@x1'.  Try \"@x2 list\" for a list.",
              recipeName,
              triggerStrings[0].toLowerCase()));
      return false;
    }

    final String woodRequiredStr = foundRecipe.get(RCP_WOOD);
    final List<Object> componentsFoundList =
        getAbilityComponents(
            mob,
            woodRequiredStr,
            "make " + CMLib.english().startWithAorAn(recipeName),
            parsedVars.autoGenerate);
    if (componentsFoundList == null) return false;
    int woodRequired = CMath.s_int(woodRequiredStr);
    woodRequired = adjustWoodRequired(woodRequired, mob);

    if (amount > woodRequired) woodRequired = amount;
    final String misctype = foundRecipe.get(RCP_MISCTYPE);
    final int[] pm = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL};
    bundling = misctype.equalsIgnoreCase("BUNDLE");
    final int[][] data =
        fetchFoundResourceData(
            mob,
            woodRequired,
            "metal",
            pm,
            0,
            null,
            null,
            bundling,
            parsedVars.autoGenerate,
            enhancedTypes);
    if (data == null) return false;
    fixDataForComponents(data, componentsFoundList);
    woodRequired = data[0][FOUND_AMT];
    if (!bundling) {
      fireRequired = true;
      final Item fire = getRequiredFire(mob, parsedVars.autoGenerate);
      if (fire == null) return false;
    } else fireRequired = false;

    final Session session = mob.session();
    if ((misctype.equalsIgnoreCase("statue"))
        && (session != null)
        && ((statue == null) || (statue.trim().length() == 0))) {
      final Ability me = this;
      final Physical target = givenTarget;
      session.prompt(
          new InputCallback(InputCallback.Type.PROMPT, "", 0) {
            @Override
            public void showPrompt() {
              session.promptPrint(L("What is a statue this of?\n\r: "));
            }

            @Override
            public void timedOut() {}

            @Override
            public void callBack() {
              final String of = this.input;
              if ((of.trim().length() == 0) || (of.indexOf('<') >= 0)) return;
              final Vector newCommands = (Vector) originalCommands.clone();
              newCommands.add("STATUE=" + of);
              me.invoke(mob, newCommands, target, auto, asLevel);
            }
          });
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final int lostValue =
        parsedVars.autoGenerate > 0
            ? 0
            : CMLib.materials()
                    .destroyResourcesValue(
                        mob.location(), data[0][FOUND_AMT], data[0][FOUND_CODE], 0, null)
                + CMLib.ableMapper().destroyAbilityComponents(componentsFoundList);
    buildingI = CMClass.getItem(foundRecipe.get(RCP_CLASSTYPE));
    if (buildingI == null) {
      commonTell(mob, L("There's no such thing as a @x1!!!", foundRecipe.get(RCP_CLASSTYPE)));
      return false;
    }
    duration =
        getDuration(
            CMath.s_int(foundRecipe.get(RCP_TICKS)),
            mob,
            CMath.s_int(foundRecipe.get(RCP_LEVEL)),
            4);
    String itemName =
        replacePercent(foundRecipe.get(RCP_FINALNAME), RawMaterial.CODES.NAME(data[0][FOUND_CODE]))
            .toLowerCase();
    if (bundling) itemName = "a " + woodRequired + "# " + itemName;
    else itemName = CMLib.english().startWithAorAn(itemName);
    buildingI.setName(itemName);
    startStr = L("<S-NAME> start(s) smithing @x1.", buildingI.name());
    displayText = L("You are smithing @x1", buildingI.name());
    verb = L("smithing @x1", buildingI.name());
    playSound = "tinktinktink2.wav";
    buildingI.setDisplayText(L("@x1 lies here", itemName));
    buildingI.setDescription(itemName + ". ");
    buildingI.basePhyStats().setWeight(getStandardWeight(woodRequired, bundling));
    buildingI.setBaseValue(
        CMath.s_int(foundRecipe.get(RCP_VALUE))
            + (woodRequired * (RawMaterial.CODES.VALUE(data[0][FOUND_CODE]))));
    buildingI.setMaterial(data[0][FOUND_CODE]);
    buildingI.basePhyStats().setLevel(CMath.s_int(foundRecipe.get(RCP_LEVEL)));
    buildingI.setSecretIdentity(getBrand(mob));
    final int capacity = CMath.s_int(foundRecipe.get(RCP_CAPACITY));
    final String spell = (foundRecipe.size() > RCP_SPELL) ? foundRecipe.get(RCP_SPELL).trim() : "";
    addSpells(buildingI, spell);

    if ((misctype.equalsIgnoreCase("statue")) && (statue != null) && (statue.trim().length() > 0)) {
      buildingI.setName(L("@x1 of @x2", itemName, statue.trim()));
      buildingI.setDisplayText(L("@x1 of @x2 is here", itemName, statue.trim()));
      buildingI.setDescription(L("@x1 of @x2. ", itemName, statue.trim()));
    } else if (buildingI instanceof Rideable) {
      setRideBasis((Rideable) buildingI, misctype);
      if (capacity == 0) ((Rideable) buildingI).setRiderCapacity(1);
      else if (capacity < 5) ((Rideable) buildingI).setRiderCapacity(capacity);
    } else if (buildingI instanceof Container) {
      ((Container) buildingI).setCapacity(capacity + woodRequired);
      if (misctype.equalsIgnoreCase("LID"))
        ((Container) buildingI).setDoorsNLocks(true, false, true, false, false, false);
      else if (misctype.equalsIgnoreCase("LOCK")) {
        ((Container) buildingI).setDoorsNLocks(true, false, true, true, false, true);
        ((Container) buildingI).setKeyName(Double.toString(Math.random()));
      } else ((Container) buildingI).setContainTypes(getContainerType(misctype));
    }
    if (buildingI instanceof Drink) {
      if (CMLib.flags().isGettable(buildingI)) {
        ((Drink) buildingI).setLiquidHeld(capacity * 50);
        ((Drink) buildingI).setThirstQuenched(250);
        if ((capacity * 50) < 250) ((Drink) buildingI).setThirstQuenched(capacity * 50);
        ((Drink) buildingI).setLiquidRemaining(0);
      }
    }
    if (bundling) buildingI.setBaseValue(lostValue);
    buildingI.recoverPhyStats();
    buildingI.text();
    buildingI.recoverPhyStats();

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = L("bundling @x1", RawMaterial.CODES.NAME(buildingI.material()).toLowerCase());
      startStr = L("<S-NAME> start(s) @x1.", verb);
      displayText = L("You are @x1", verb);
    }

    if (parsedVars.autoGenerate > 0) {
      commands.addElement(buildingI);
      return true;
    }

    final CMMsg msg = CMClass.getMsg(mob, buildingI, this, getActivityMessageType(), startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      buildingI = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, buildingI, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
Exemplo n.º 17
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final boolean noisy = CMSecurity.isDebugging(CMSecurity.DbgFlag.MERGE);
    Vector placesToDo = new Vector();
    commands.remove(0);
    if (commands.size() == 0) {
      mob.tell(L("Merge what? Try DATABASE or a filename"));
      return false;
    }
    if (mob.isMonster()) {
      mob.tell(L("No can do."));
      return false;
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("noprompt"))
      commands.remove(0);

    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("?")) {
      final StringBuffer allFieldsMsg = new StringBuffer("");
      final Vector allKnownFields = new Vector();
      sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
      mob.tell(L("Valid field names are @x1", allFieldsMsg.toString()));
      return false;
    }
    String scope = "WORLD";
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("room")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location());
      scope = "ROOM";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("area")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location().getArea());
      scope = "AREA";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("world")) {
      if (!CMSecurity.isAllowedEverywhere(mob, CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that."));
        return false;
      }
      commands.remove(0);
      placesToDo = new Vector();
      scope = "WORLD";
    }
    if (commands.size() == 0) {
      mob.tell(L("Merge what? DATABASE or filename"));
      return false;
    }
    String firstWord = (String) commands.get(0);
    if (firstWord.equalsIgnoreCase("DATABASE")) {
      commands.remove(0);
      if (commands.size() == 0) {
        mob.tell(L("Merge parameters missing: DBCLASS, DBSERVICE, DBUSER, DBPASS"));
        return false;
      }
      firstWord = (String) commands.get(0);
      return doArchonDBCompare(mob, scope, firstWord, commands);
    }
    final String filename = (String) commands.lastElement();
    commands.remove(filename);
    final StringBuffer buf = new CMFile(filename, mob, CMFile.FLAG_LOGERRORS).text();
    if ((buf == null) || (buf.length() == 0)) {
      mob.tell(L("File not found at: '@x1'!", filename));
      return false;
    }

    final List<String> changes = new Vector();
    final List<String> onfields = new Vector();
    final List<String> ignore = new Vector();
    List<String> use = null;
    final List<String> allKnownFields = new Vector();
    final List things = new Vector();
    boolean aremobs = false;
    if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<MOBS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking mobs from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addMOBsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
      aremobs = true;
    } else if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<ITEMS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking items from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addItemsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
    } else {
      mob.tell(
          L(
              "Files of this type are not yet supported by MERGE.  You must merge an ITEMS or MOBS file at this time."));
      return false;
    }
    if (things.size() == 0) {
      mob.tell(L("Nothing was found in the file to merge!"));
      return false;
    }
    final StringBuffer allFieldsMsg = new StringBuffer("");
    if (aremobs) sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
    else {
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
    }

    allKnownFields.add("REJUV");
    allFieldsMsg.append(L("REJUV "));

    for (int i = 0; i < commands.size(); i++) {
      String str = ((String) commands.get(i)).toUpperCase();
      if (str.startsWith("CHANGE=")) {
        use = changes;
        str = str.substring(7).trim();
      }
      if (str.startsWith("ON=")) {
        use = onfields;
        str = str.substring(3).trim();
      }
      if (str.startsWith("IGNORE=")) {
        use = ignore;
        str = str.substring(7).trim();
      }
      int x = str.indexOf(',');
      while (x >= 0) {
        final String s = str.substring(0, x).trim();
        if (s.length() > 0) {
          if (use == null) {
            mob.tell(L("'@x1' is an unknown parameter!", str));
            return false;
          }
          if (allKnownFields.contains(s)) use.add(s);
          else {
            mob.tell(
                L(
                    "'@x1' is an unknown field name.  Valid fields include: @x2",
                    s,
                    allFieldsMsg.toString()));
            return false;
          }
        }
        str = str.substring(x + 1).trim();
        x = str.indexOf(',');
      }
      if (str.length() > 0) {
        if (use == null) {
          mob.tell(L("'@x1' is an unknown parameter!", str));
          return false;
        }
        if (allKnownFields.contains(str)) use.add(str);
        else {
          mob.tell(
              L(
                  "'@x1' is an unknown field name.  Valid fields include: @x2",
                  str,
                  allFieldsMsg.toString()));
          return false;
        }
      }
    }
    if ((onfields.size() == 0) && (ignore.size() == 0) && (changes.size() == 0)) {
      mob.tell(
          L(
              "You must specify either an ON, CHANGES, or IGNORE parameter for valid matches to be made."));
      return false;
    }
    if (placesToDo.size() == 0)
      for (final Enumeration a = CMLib.map().areas(); a.hasMoreElements(); ) {
        final Area A = (Area) a.nextElement();
        if (A.getCompleteMap().hasMoreElements()
            && CMSecurity.isAllowed(
                mob, (A.getCompleteMap().nextElement()), CMSecurity.SecFlag.MERGE))
          placesToDo.add(A);
      }
    if (placesToDo.size() == 0) {
      mob.tell(L("There are no rooms to merge into!"));
      return false;
    }
    for (int i = placesToDo.size() - 1; i >= 0; i--) {
      if (placesToDo.get(i) instanceof Area) {
        final Area A = (Area) placesToDo.get(i);
        placesToDo.removeElement(A);
        for (final Enumeration r = A.getCompleteMap(); r.hasMoreElements(); ) {
          final Room R = (Room) r.nextElement();
          if (CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) placesToDo.add(R);
        }
      } else if (placesToDo.get(i) instanceof Room)
        if (mob.session() != null) mob.session().rawPrint(".");
        else return false;
    }
    // now do the merge...
    if (mob.session() != null) mob.session().rawPrint(L("Merging and saving..."));
    if (noisy) mergedebugtell(mob, "Rooms to do: " + placesToDo.size());
    if (noisy) mergedebugtell(mob, "Things loaded: " + things.size());
    if (noisy) mergedebugtell(mob, "On fields=" + CMParms.toStringList(onfields));
    if (noisy) mergedebugtell(mob, "Ignore fields=" + CMParms.toStringList(ignore));
    if (noisy) mergedebugtell(mob, "Change fields=" + CMParms.toStringList(changes));
    Log.sysOut("Import", mob.Name() + " merge '" + filename + "'.");
    for (int r = 0; r < placesToDo.size(); r++) {
      Room R = (Room) placesToDo.get(r);
      if (!CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) continue;
      if (R.roomID().length() == 0) continue;
      synchronized (("SYNC" + R.roomID()).intern()) {
        R = CMLib.map().getRoom(R);
        final Area.State oldFlags = R.getArea().getAreaState();
        R.getArea().setAreaState(Area.State.FROZEN);
        CMLib.map().resetRoom(R);
        boolean savemobs = false;
        boolean saveitems = false;
        if (aremobs) {
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable()))
              if (tryMerge(mob, R, M, things, changes, onfields, ignore, noisy)) savemobs = true;
          }
        } else {
          for (int i = 0; i < R.numItems(); i++) {
            final Item I = R.getItem(i);
            if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
              saveitems = true;
          }
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable())) {
              for (int i = 0; i < M.numItems(); i++) {
                final Item I = M.getItem(i);
                if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
                  savemobs = true;
              }
              final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(M);
              if (SK != null) {
                for (final Iterator<Environmental> i = SK.getShop().getStoreInventory();
                    i.hasNext(); ) {
                  final Environmental E = i.next();
                  if (E instanceof Item) {
                    final Item I = (Item) E;
                    if (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy))
                      savemobs = true;
                  }
                }
              }
            }
          }
        }
        if (saveitems) CMLib.database().DBUpdateItems(R);
        if (savemobs) CMLib.database().DBUpdateMOBs(R);
        if (mob.session() != null) mob.session().rawPrint(".");
        R.getArea().setAreaState(oldFlags);
      }
    }

    if (mob.session() != null) mob.session().rawPrintln(L("!\n\rDone!"));
    Area A = null;
    for (int i = 0; i < placesToDo.size(); i++) {
      A = ((Room) placesToDo.get(i)).getArea();
      if ((A != null) && (A.getAreaState() != Area.State.ACTIVE)) A.setAreaState(Area.State.ACTIVE);
    }
    return false;
  }
Exemplo n.º 18
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    timeOut = 0;
    if (auto) return false;

    final Hashtable<String, String> H = getSongs();
    if (commands.size() == 0) {
      final Song_Ode A = (Song_Ode) mob.fetchEffect(ID());
      if ((A != null) && (A.whom != null) && (A.song == null)) {
        final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf());
        final CMMsg msg =
            CMClass.getMsg(
                mob,
                null,
                this,
                (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
                str);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(mob, msg);
          mob.delEffect(A);
          getSongs().put(A.whom.name(), A.composition());
          whom = null;
          return true;
        }
        return false;
      }

      final StringBuffer str = new StringBuffer("");
      for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); )
        str.append(e.nextElement() + " ");
      mob.tell(L("Compose or sing an ode about whom?"));
      if (str.length() > 0)
        mob.tell(L("You presently have odes written about: @x1.", str.toString().trim()));
      return false;
    }
    String name = CMParms.combine(commands, 0);
    for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) {
      final String key = e.nextElement();
      if (CMLib.english().containsString(key, name)) {
        invoker = mob;
        originRoom = mob.location();
        commonRoomSet = getInvokerScopeRoomSet(null);
        name = key;
        song = H.get(name);
        benefits = null;
        whom = mob.location().fetchInhabitant(name);
        if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name);
        if ((whom == null) || (!whom.name().equals(name))) {
          whom = CMClass.getMOB("StdMOB");
          whom.setName(name);
          whom.setLocation(mob.location());
        }
        return super.invoke(mob, commands, givenTarget, auto, asLevel);
      }
    }

    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if (target == mob) {
      mob.tell(L("You may not compose an ode about yourself!"));
      return false;
    }

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      unsingAll(mob, mob);
      invoker = mob;
      originRoom = mob.location();
      commonRoomSet = getInvokerScopeRoomSet(null);
      whom = target;
      final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf());
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
              str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        final Song_Ode newOne = (Song_Ode) copyOf();
        newOne.whom = target;
        newOne.trail = new StringBuffer("");
        newOne.song = null;
        mob.addEffect(newOne);
      }
    } else
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration."));
    return success;
  }
Exemplo n.º 19
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();
 }
Exemplo n.º 20
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    Room target = mob.location();
    if ((auto) && (givenTarget != null) && (givenTarget instanceof Room))
      target = (Room) givenTarget;
    Ability A = target.fetchEffect(ID());
    if (A != null) {
      mob.tell("This place is already a safehouse.");
      return false;
    }
    if ((!auto) && (CMLib.law().getLegalBehavior(target) == null)) {
      mob.tell("There is no law here!");
      return false;
    }
    if (!isGoodSafehouse(target)) {
      TrackingLibrary.TrackingFlags flags;
      flags =
          new TrackingLibrary.TrackingFlags()
              .add(TrackingLibrary.TrackingFlag.OPENONLY)
              .add(TrackingLibrary.TrackingFlag.AREAONLY)
              .add(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS)
              .add(TrackingLibrary.TrackingFlag.NOAIR)
              .add(TrackingLibrary.TrackingFlag.NOWATER);
      Vector V = CMLib.tracking().getRadiantRooms(target, flags, 50 + (2 * getXLEVELLevel(mob)));
      Room R = null;
      int v = 0;
      for (; v < V.size(); v++) {
        R = (Room) V.elementAt(v);
        if ((isGoodSafehouse(R)) && (!isLawHere(R))) break;
      }
      mob.tell("A place like this can't be a safehouse.");
      if ((isGoodSafehouse(R)) && (!isLawHere(R))) {
        V =
            CMLib.tracking()
                .findBastardTheBestWay(
                    target, CMParms.makeVector(R), flags, 50 + (2 * getXLEVELLevel(mob)));
        StringBuffer trail = new StringBuffer("");
        int dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true);
        while (target != R) {
          if ((dir < 0) || (dir >= Directions.NUM_DIRECTIONS()) || (target == null)) break;
          trail.append(Directions.getDirectionName(dir));
          if (target.getRoomInDir(dir) != R) trail.append(", ");
          target = target.getRoomInDir(dir);
          dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true);
        }
        if (target == R)
          mob.tell("You happen to know of one nearby though.  Go: " + trail.toString());
      }
      return false;
    }

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

    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MASK_ALWAYS : CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_VISUAL,
            CMMsg.MSG_OK_VISUAL,
            auto ? "" : "<S-NAME> hide(s) out from the law here.");
    if (!success)
      return beneficialVisualFizzle(
          mob,
          null,
          auto
              ? ""
              : "<S-NAME> attempt(s) hide out from the law here, but things are just too hot.");
    else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      beneficialAffect(mob, target, asLevel, (CMProps.getIntVar(CMProps.SYSTEMI_TICKSPERMUDMONTH)));
    }
    return success;
  }
Exemplo n.º 21
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) {
      DATA.clear();
      IPS.clear();
      final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>();
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.getAddress().length() > 0) && (S.mob() != null)) {
          List V = ipes.get(S.getAddress());
          if (V == null) {
            V = new Vector();
            ipes.put(S.getAddress(), V);
          }
          if (!V.contains(S.mob())) V.add(S.mob());
        }
      }
      final StringBuffer rpt = new StringBuffer("");
      for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) {
        final String addr = (String) e.nextElement();
        final List<MOB> names = ipes.get(addr);
        if (names.size() > 1) {
          IPS.put(addr, names);
          rpt.append("Watch #" + (IPS.size()) + " added: ");
          for (int n = 0; n < names.size(); n++) {
            final MOB MN = names.get(n);
            if (MN.fetchEffect(ID()) == null) {
              final Ability A = (Ability) copyOf();
              MN.addNonUninvokableEffect(A);
              A.setSavable(false);
            }
            rpt.append(MN.Name() + " ");
          }
          rpt.append("\n\r");
        }
      }
      if (rpt.length() == 0)
        rpt.append("No users with duplicate IDs found.  Try MULTIWATCH ADD name1 name2 ... ");
      mob.tell(rpt.toString());
      return true;
    } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) {
      boolean foundLegacy = false;
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) {
          foundLegacy = true;
          break;
        }
      }
      if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) {
        mob.tell(L("Multiwatch is already off."));
        return false;
      }
      for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) {
        final List<MOB> V = e.nextElement();
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null)) {
          final MOB M = S.mob();
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      mob.tell(L("Multiplay watcher is now turned off."));
      DATA.clear();
      IPS.clear();
      return true;
    } else if ((commands.size() > 1)
        && ((String) commands.firstElement()).equalsIgnoreCase("add")) {
      final Vector V = new Vector();
      for (int i = 1; i < commands.size(); i++) {
        final String name = (String) commands.elementAt(i);
        final MOB M = CMLib.players().getPlayer(name);
        if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M);
        else mob.tell(L("'@x1' is not online.", name));
      }
      if (V.size() > 1) {
        for (int n = 0; n < V.size(); n++) {
          final MOB MN = (MOB) V.elementAt(n);
          if (MN.fetchEffect(ID()) == null) {
            final Ability A = (Ability) copyOf();
            MN.addNonUninvokableEffect(A);
            A.setSavable(false);
          }
        }
        IPS.put("MANUAL" + (IPS.size() + 1), V);
        mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size()));
      }
      return true;
    } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) {
      final StringBuffer report = new StringBuffer("");
      for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) {
        final String key = e.nextElement();
        int sync = 0;
        final List<MOB> V = IPS.get(key);
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final int data[] = DATA.get(M);
          if (data != null) sync += data[DATA_SYNCHROFOUND];
        }
        report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r");
        report.append(
            CMStrings.padRight(L("Name"), 25)
                + CMStrings.padRight(L("Speech"), 15)
                + CMStrings.padRight(L("Socials"), 15)
                + CMStrings.padRight(L("CMD"), 10)
                + CMStrings.padRight(L("ORDERS"), 10)
                + "\n\r");
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          int data[] = DATA.get(M);
          if (data == null) data = new int[DATA_TOTAL];
          report.append(CMStrings.padRight(M.Name(), 25));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH],
                  15));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL],
                  15));
          report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10));
          report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10));
          report.append("\n\r");
        }
        report.append("\n\r");
      }

      mob.tell(report.toString());
      return true;
    } else {
      mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2.."));
      return false;
    }
  }
Exemplo n.º 22
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;
 }
Exemplo n.º 23
0
  public String runMacro(ExternalHTTPRequests httpReq, String parm) {
    if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED))
      return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS);

    Hashtable parms = parseParms(parm);
    String last = httpReq.getRequestParameter("PLAYER");
    if (last == null) return " @break@";
    if (last.length() > 0) {
      MOB M = CMLib.players().getLoadPlayer(last);
      if (M == null) {
        MOB authM = Authenticate.getAuthenticatedMob(httpReq);
        if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM;
        else return " @break@";
      }

      boolean firstTime =
          (!httpReq.isRequestParameter("ACTION"))
              || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME");
      StringBuffer str = new StringBuffer("");
      for (int i = 0; i < MOB.AUTODESC.length; i++) {
        if (parms.containsKey(MOB.AUTODESC[i])) {
          boolean set = CMath.isSet(M.getBitmap(), i);
          if (MOB.AUTOREV[i]) set = !set;
          str.append((set ? "ON" : "OFF") + ",");
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.charStats();
          if (parms.containsKey(stat)) {
            String old = httpReq.getRequestParameter(stat);
            if ((firstTime) || (old.length() == 0)) {
              if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER))
                old = "" + C.getSave(i);
              else old = "" + C.getStat(i);
            }
            str.append(old + ", ");
          }
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.baseCharStats();
          if (parms.containsKey("BASE" + stat)) {
            String old = httpReq.getRequestParameter("BASE" + stat);
            if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i);
            str.append(old + ", ");
          }
        }
      }
      for (int i = 0; i < BASICS.length; i++) {
        if (parms.containsKey(BASICS[i])) {
          if (httpReq.isRequestParameter(BASICS[i]))
            str.append(httpReq.getRequestParameter(BASICS[i]) + ", ");
          else str.append(getBasic(M, i));
        }
      }
      if (parms.containsKey("RACE")) {
        String old = httpReq.getRequestParameter("RACE");
        if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID();
        for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) {
          Race R2 = (Race) r.nextElement();
          str.append("<OPTION VALUE=\"" + R2.ID() + "\"");
          if (R2.ID().equals(old)) str.append(" SELECTED");
          str.append(">" + R2.name());
        }
      }
      if (parms.containsKey("DEITY")) {
        String old = httpReq.getRequestParameter("DEITY");
        if (firstTime) old = M.getWorshipCharID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless");
        for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) {
          Deity E = (Deity) e.nextElement();
          str.append("<OPTION VALUE=\"" + E.Name() + "\"");
          if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + E.Name());
        }
      }
      if (parms.containsKey("TITLELIST")) {
        if (M.playerStats() != null) {
          int b = 0;
          Vector titles = new Vector();
          if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles);
          else
            while (httpReq.isRequestParameter("TITLE" + b)) {
              String B = httpReq.getRequestParameter("TITLE" + b);
              if ((B != null) && (B.trim().length() > 0)) titles.addElement(B);
              b++;
            }
          for (b = 0; b < titles.size(); b++) {
            String B = (String) titles.elementAt(b);
            if (B != null)
              str.append(
                  "<INPUT TYPE=TEXT NAME=TITLE"
                      + b
                      + " SIZE="
                      + B.length()
                      + " VALUE=\""
                      + CMStrings.replaceAll(B, "\"", "&quot;")
                      + "\"><BR>");
          }
          str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">");
        }
      }
      if (parms.containsKey("CLAN")) {
        String old = httpReq.getRequestParameter("CLAN");
        if (firstTime) old = M.getClanID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless");
        for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) {
          Clan C = (Clan) e.nextElement();
          str.append("<OPTION VALUE=\"" + C.clanID() + "\"");
          if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + C.getName());
        }
      }
      if (parms.containsKey("ALIGNMENT")) {
        String old = httpReq.getRequestParameter("ALIGNMENT");
        if ((firstTime) || (old.length() == 0))
          old = "" + M.fetchFaction(CMLib.factions().AlignID());
        if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) {
          for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) {
            str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]);
            if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED");
            str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase()));
          }
        }
      }
      if (parms.containsKey("BASEGENDER")) {
        String old = httpReq.getRequestParameter("BASEGENDER");
        if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER);
        str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M");
        str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F");
        str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N");
      }
      str.append(MobData.expertiseList(M, httpReq, parms));
      str.append(MobData.classList(M, httpReq, parms));
      str.append(MobData.itemList(M, M, httpReq, parms, 0));
      str.append(MobData.abilities(M, httpReq, parms, 0));
      str.append(MobData.factions(M, httpReq, parms, 0));
      str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0));
      str.append(ExitData.dispositions(M, firstTime, httpReq, parms));
      str.append(MobData.senses(M, firstTime, httpReq, parms));
      String strstr = str.toString();
      if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
      return clearWebMacros(strstr);
    }
    return "";
  }
Exemplo n.º 24
0
  @Override
  public String runMacro(HTTPRequest httpReq, String parm) {
    final java.util.Map<String, String> parms = parseParms(parm);
    final String last = httpReq.getUrlParameter("JOURNAL");
    if (last == null) return " @break@";
    boolean securityOverride = false;
    if ((Thread.currentThread() instanceof CWThread)
        && CMath.s_bool(((CWThread) Thread.currentThread()).getConfig().getMiscProp("ADMIN"))
        && parms.containsKey("ALLFORUMJOURNALS")) securityOverride = true;

    final MOB M = Authenticate.getAuthenticatedMob(httpReq);
    if ((!securityOverride)
        && (CMLib.journals().isArchonJournalName(last))
        && ((M == null) || (!CMSecurity.isASysOp(M)))) return " @break@";

    final Clan setClan = CMLib.clans().getClan(httpReq.getUrlParameter("CLAN"));
    final JournalsLibrary.ForumJournal journal = CMLib.journals().getForumJournal(last, setClan);
    if (journal == null) return " @break@";

    final StringBuffer str = new StringBuffer("");
    if (parms.containsKey("ISSMTPFORWARD")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      final String email =
          ((M != null) && (M.playerStats() != null) && (M.playerStats().getEmail() != null))
              ? M.playerStats().getEmail()
              : "";
      str.append(
              ((entry != null) && (email.length() > 0)) ? Boolean.toString(entry.forward) : "false")
          .append(", ");
    }

    if (parms.containsKey("ISSMTPSUBSCRIBER")) {
      final Map<String, List<String>> lists =
          Resources.getCachedMultiLists("mailinglists.txt", true);
      final List<String> mylist = lists.get(last);
      str.append(
              ((mylist != null) && (M != null))
                  ? Boolean.toString(mylist.contains(M.Name()))
                  : "false")
          .append(", ");
    }

    if (parms.containsKey("SMTPADDRESS")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      if ((entry != null) && (entry.forward)) {
        str.append(entry.name.replace(' ', '_') + "@" + CMProps.getVar(CMProps.Str.MUDDOMAIN))
            .append(", ");
      }
    }

    if (parms.containsKey("CANADMIN") || parms.containsKey("ISADMIN"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.ADMIN)).append(", ");

    if (parms.containsKey("CANPOST"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.POST)).append(", ");

    if (parms.containsKey("CANREAD"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.READ)).append(", ");

    if (parms.containsKey("CANREPLY"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.REPLY)).append(", ");

    if (parms.containsKey("ADMINMASK")) str.append("" + journal.adminMask()).append(", ");

    if (parms.containsKey("READMASK")) str.append("" + journal.readMask()).append(", ");

    if (parms.containsKey("POSTMASK")) str.append("" + journal.postMask()).append(", ");

    if (parms.containsKey("REPLYMASK")) str.append("" + journal.replyMask()).append(", ");

    if (parms.containsKey("ID")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("NAME")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("EXPIRE")) str.append("").append(", ");

    final JournalsLibrary.JournalSummaryStats stats = CMLib.journals().getJournalStats(journal);
    if (stats == null) return " @break@";

    if (parms.containsKey("POSTS")) str.append("" + stats.posts).append(", ");

    if (parms.containsKey("THREADS")) str.append("" + stats.threads).append(", ");

    if (parms.containsKey("SHORTDESC")) str.append("" + stats.shortIntro).append(", ");

    if (parms.containsKey("LONGDESC")) str.append("" + stats.longIntro).append(", ");

    if (parms.containsKey("IMAGEPATH")) {
      if ((stats.imagePath == null) || (stats.imagePath.trim().length() == 0))
        str.append(L("images/lilcm.jpg")).append(", ");
      else str.append("" + stats.threads).append(", ");
    }

    String strstr = str.toString();
    if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
    return clearWebMacros(strstr);
  }
Exemplo n.º 25
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (mob.session() == null) return true;
    PlayerStats pstats = mob.playerStats();
    if (pstats == null) return true;

    if ((commands != null)
        && (commands.size() > 1)
        && (commands.elementAt(1) instanceof String)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String name = CMParms.combine(commands, 1);
      if (name.equalsIgnoreCase("BOX")) {
        String journalName = CMProps.getVar(CMProps.SYSTEM_MAILBOX);
        Vector<JournalsLibrary.JournalEntry> msgs = CMLib.database().DBReadJournalMsgs(journalName);
        while ((mob.session() != null) && (!mob.session().killFlag())) {
          Vector mymsgs = new Vector();
          StringBuffer messages =
              new StringBuffer(
                  "^X" + CMStrings.padCenter(mob.Name() + "'s MailBox", 48) + "^?^.\n\r");
          messages.append(
              "^X### "
                  + CMStrings.padRight("From", 15)
                  + " "
                  + CMStrings.padRight("Date", 20)
                  + " Subject^?^.\n\r");
          for (int num = 0; num < msgs.size(); num++) {
            JournalsLibrary.JournalEntry thismsg = msgs.elementAt(num);
            String to = (String) thismsg.to;
            if (to.equalsIgnoreCase("ALL")
                || to.equalsIgnoreCase(mob.Name())
                || (to.toUpperCase().trim().startsWith("MASK=")
                    && CMLib.masking().maskCheck(to.trim().substring(5), mob, true))) {
              mymsgs.addElement(thismsg);
              messages.append(
                  CMStrings.padRight("" + mymsgs.size(), 4)
                      + CMStrings.padRight((thismsg.from), 16)
                      + CMStrings.padRight(CMLib.time().date2String(thismsg.date), 21)
                      + (thismsg.subj)
                      + "\n\r");
            }
          }
          if ((mymsgs.size() == 0)
              || (CMath.bset(metaFlags, Command.METAFLAG_POSSESSED))
              || (CMath.bset(metaFlags, Command.METAFLAG_AS))) {
            if (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOFORWARD))
              mob.tell(
                  "You have no email waiting, but then, it's probably been forwarded to you already.");
            else mob.tell("You have no email waiting.");
            return false;
          }
          Session S = mob.session();
          try {
            if (S != null) S.snoopSuspension(1);
            mob.tell(messages.toString());
          } finally {
            if (S != null) S.snoopSuspension(-1);
          }
          String s = mob.session().prompt("Enter a message #", "");
          if ((!CMath.isInteger(s)) || (mob.session().killFlag())) return false;
          int num = CMath.s_int(s);
          if ((num <= 0) || (num > mymsgs.size())) mob.tell("That is not a valid number.");
          else
            while ((mob.session() != null) && (!mob.session().killFlag())) {
              JournalsLibrary.JournalEntry thismsg =
                  (JournalsLibrary.JournalEntry) mymsgs.elementAt(num - 1);
              String key = thismsg.key;
              String from = thismsg.from;
              String date = CMLib.time().date2String(thismsg.date);
              String subj = thismsg.subj;
              String message = thismsg.msg;
              messages = new StringBuffer("");
              messages.append("^XMessage :^?^." + num + "\n\r");
              messages.append("^XFrom    :^?^." + from + "\n\r");
              messages.append("^XDate    :^?^." + date + "\n\r");
              messages.append("^XSubject :^?^." + subj + "\n\r");
              messages.append("^X------------------------------------------------^?^.\n\r");
              messages.append(message + "\n\r\n\r");
              try {
                if (S != null) S.snoopSuspension(1);
                mob.tell(messages.toString());
              } finally {
                if (S != null) S.snoopSuspension(-1);
              }
              s =
                  mob.session()
                      .choose("Would you like to D)elete, H)old, or R)eply (D/H/R)? ", "DHR", "H");
              if (s.equalsIgnoreCase("H")) break;
              if (s.equalsIgnoreCase("R")) {
                if ((from.length() > 0)
                    && (!from.equals(mob.Name()))
                    && (!from.equalsIgnoreCase("BOX"))
                    && (CMLib.players().getLoadPlayer(from) != null))
                  execute(mob, CMParms.makeVector(getAccessWords()[0], from), metaFlags);
                else mob.tell("You can not reply to this email.");
              } else if (s.equalsIgnoreCase("D")) {
                CMLib.database().DBDeleteJournal(journalName, key);
                msgs.remove(thismsg);
                mob.tell("Deleted.");
                break;
              }
            }
        }
      } else {
        MOB M = CMLib.players().getLoadPlayer(name);
        if (M == null) {
          mob.tell(
              "There is no player called '"
                  + name
                  + "' to send email to.  If you were trying to read your mail, try EMAIL BOX.  If you were trying to change your email address, just enter EMAIL without any parameters.");
          return false;
        }
        if (!CMath.bset(M.getBitmap(), MOB.ATT_AUTOFORWARD)) {
          if (!mob.session().confirm("Send email to '" + M.Name() + "' (Y/n)?", "Y")) return false;
        } else {
          if (!mob.session()
              .confirm(
                  "Send email to '"
                      + M.Name()
                      + "', even though their AUTOFORWARD is turned off (y/N)?",
                  "N")) return false;
        }
        if (CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX) > 0) {
          int count =
              CMLib.database()
                  .DBCountJournal(CMProps.getVar(CMProps.SYSTEM_MAILBOX), null, M.Name());
          if (count >= CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX)) {
            mob.tell(M.Name() + "'s mailbox is full.");
            return false;
          }
        }
        String subject = mob.session().prompt("Email Subject: ", "").trim();
        if (subject.length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        String message = mob.session().prompt("Enter your message\n\r: ", "").trim();
        if (message.trim().length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        message +=
            "\n\r\n\rThis message was sent through the "
                + CMProps.getVar(CMProps.SYSTEM_MUDNAME)
                + " mail server at "
                + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                + ", port"
                + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                + ".  Please contact the administrators regarding any abuse of this system.\n\r";
        CMLib.database()
            .DBWriteJournal(
                CMProps.getVar(CMProps.SYSTEM_MAILBOX), mob.Name(), M.Name(), subject, message);
        mob.tell("Your email has been sent.");
        return true;
      }
    }
    if ((pstats.getEmail() == null) || (pstats.getEmail().length() == 0))
      mob.session().println("\n\rYou have no email address on file for this character.");
    else {
      if (commands == null) return true;
      String change =
          mob.session()
              .prompt(
                  "You currently have '"
                      + pstats.getEmail()
                      + "' set as the email address for this character.\n\rChange it (y/N)?",
                  "N");
      if (change.toUpperCase().startsWith("N")) return false;
    }
    if ((CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0))
      mob.session()
          .println(
              "\n\r** Changing your email address will cause you to be logged off, and a new password to be generated and emailed to the new address. **\n\r");
    String newEmail = mob.session().prompt("New E-mail Address:");
    if (newEmail == null) return false;
    newEmail = newEmail.trim();
    if (!CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("OPTION")) {
      if (newEmail.length() < 6) return false;
      if (newEmail.indexOf("@") < 0) return false;
      String confirmEmail =
          mob.session()
              .prompt("Confirm that '" + newEmail + "' is correct by re-entering.\n\rRe-enter:");
      if (confirmEmail == null) return false;
      confirmEmail = confirmEmail.trim();
      if (confirmEmail.length() == 0) return false;
      if (!(newEmail.equalsIgnoreCase(confirmEmail))) return false;
    }
    pstats.setEmail(newEmail);
    CMLib.database().DBUpdateEmail(mob);
    if ((commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String password = "";
      for (int i = 0; i < 6; i++) password += (char) ('a' + CMLib.dice().roll(1, 26, -1));
      pstats.setPassword(password);
      CMLib.database().DBUpdatePassword(mob.Name(), password);
      CMLib.database()
          .DBWriteJournal(
              CMProps.getVar(CMProps.SYSTEM_MAILBOX),
              mob.Name(),
              mob.Name(),
              "Password for " + mob.Name(),
              "Your new password for "
                  + mob.Name()
                  + " is: "
                  + pstats.password()
                  + "\n\rYou can login by pointing your mud client at "
                  + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                  + " port(s):"
                  + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                  + ".\n\rYou may use the PASSWORD command to change it once you are online.");
      mob.tell("You will receive an email with your new password shortly.  Goodbye.");
      if (mob.session() != null) {
        try {
          Thread.sleep(1000);
        } catch (Exception e) {
        }
        mob.session().kill(false, false, false);
      }
    }
    return true;
  }
Exemplo n.º 26
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();
 }
Exemplo n.º 27
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;
  }