Example #1
0
 public static Item buildPlant(MOB mob, Room room) {
   Item newItem = CMClass.getItem("GenItem");
   newItem.setMaterial(RawMaterial.RESOURCE_GREENS);
   switch (CMLib.dice().roll(1, 5, 0)) {
     case 1:
       newItem.setName("some happy flowers");
       newItem.setDisplayText("some happy flowers are growing here.");
       newItem.setDescription("Happy flowers with little red and yellow blooms.");
       break;
     case 2:
       newItem.setName("some happy weeds");
       newItem.setDisplayText("some happy weeds are growing here.");
       newItem.setDescription("Long stalked little plants with tiny bulbs on top.");
       break;
     case 3:
       newItem.setName("a pretty fern");
       newItem.setDisplayText("a pretty fern is growing here.");
       newItem.setDescription("Like a tiny bush, this dark green plant is lovely.");
       break;
     case 4:
       newItem.setName("a patch of sunflowers");
       newItem.setDisplayText("a patch of sunflowers is growing here.");
       newItem.setDescription("Happy flowers with little yellow blooms.");
       break;
     case 5:
       newItem.setName("a patch of bluebonnets");
       newItem.setDisplayText("a patch of bluebonnets is growing here.");
       newItem.setDescription("Happy flowers with little blue and purple blooms.");
       break;
   }
   Chant_SummonPlants newChant = new Chant_SummonPlants();
   newItem.basePhyStats().setLevel(10 + (10 * newChant.getX1Level(mob)));
   newItem.basePhyStats().setWeight(1);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   newItem.setExpirationDate(0);
   room.showHappens(CMMsg.MSG_OK_ACTION, "Suddenly, " + newItem.name() + " sprout(s) up here.");
   newChant.PlantsLocation = room;
   newChant.littlePlants = newItem;
   if (CMLib.law().doesOwnThisProperty(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Example #2
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;
  }