Beispiel #1
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String s = CMParms.combine(commands, 0);
    StringBuffer buf = new StringBuffer("Seed types known:\n\r");
    int material = 0;
    String foundShortName = null;
    int col = 0;
    List<Integer> codes = RawMaterial.CODES.COMPOSE_RESOURCES(RawMaterial.MATERIAL_VEGETATION);
    for (Integer code : codes) {
      if (!CMParms.contains(Chant_SummonSeed.NON_SEEDS, code)) {
        String str = RawMaterial.CODES.NAME(code.intValue());
        if (str.toUpperCase().equalsIgnoreCase(s)) {
          material = code.intValue();
          foundShortName = CMStrings.capitalizeAndLower(str);
          break;
        }
        if (col == 4) {
          buf.append("\n\r");
          col = 0;
        }
        col++;
        buf.append(CMStrings.padRight(CMStrings.capitalizeAndLower(str), 15));
      }
    }
    if (s.equalsIgnoreCase("list")) {
      mob.tell(buf.toString() + "\n\r\n\r");
      return true;
    }
    if (s.length() == 0) {
      mob.tell("Summon what kind of seed?  Try LIST as a parameter...");
      return false;
    }
    if (foundShortName == null) {
      mob.tell("'" + s + "' is an unknown type of vegetation.");
      return false;
    }

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

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto ? "" : "^S<S-NAME> chant(s) to <S-HIS-HER> hands.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        for (int i = 2; i < (2 + (adjustedLevel(mob, asLevel) / 4)); i++) {
          Item newItem = CMClass.getBasicItem("GenResource");
          String name = foundShortName.toLowerCase();
          if (name.endsWith("ies")) name = name.substring(0, name.length() - 3) + "y";
          if (name.endsWith("s")) name = name.substring(0, name.length() - 1);
          newItem.setName(CMLib.english().startWithAorAn(name + " seed"));
          newItem.setDisplayText(newItem.name() + " is here.");
          newItem.setDescription("");
          newItem.setMaterial(material);
          newItem.basePhyStats().setWeight(0);
          newItem.recoverPhyStats();
          newItem.setMiscText(newItem.text());
          mob.addItem(newItem);
        }
        mob.location().showHappens(CMMsg.MSG_OK_ACTION, "Some seeds appear!");
        mob.location().recoverPhyStats();
      }
    } else
      return beneficialWordsFizzle(
          mob, null, "<S-NAME> chant(s) to <S-HIS-HER> hands, but nothing happens.");

    // return whether it worked
    return success;
  }