Example #1
0
 @Override
 public void setMiscText(String txt) {
   noFollow = false;
   noSneak = false;
   final Vector<String> parms = CMParms.parse(txt.toUpperCase());
   String s;
   for (final Enumeration<String> p = parms.elements(); p.hasMoreElements(); ) {
     s = p.nextElement();
     if ("NOFOLLOW".startsWith(s)) noFollow = true;
     else if (s.startsWith("NOSNEAK")) noSneak = true;
   }
   super.setMiscText(txt);
 }
Example #2
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (mob.location().numInhabitants() == 1) {
      mob.tell("You will need to find someone to teach you first.");
      return false;
    }
    if (commands.size() == 1) {
      mob.tell("Learn what?  Enter QUALIFY or TRAIN to see what you can learn.");
      return false;
    }
    commands.removeElementAt(0);
    String teacherName = "";
    if (commands.size() > 1) {
      teacherName = " " + (String) commands.lastElement();
      if (teacherName.length() > 1) {
        commands.removeElementAt(commands.size() - 1);
        if ((commands.size() > 1) && (((String) commands.lastElement()).equalsIgnoreCase("FROM")))
          commands.removeElementAt(commands.size() - 1);
      } else teacherName = "";
    }

    String what = CMParms.combine(commands, 0);
    Vector V = Train.getAllPossibleThingsToTrainFor();
    if (V.contains(what.toUpperCase().trim())) {
      Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what);
      mob.doCommand(CC, metaFlags);
      if (teacherName.length() > 0) commands.addElement(teacherName.trim());
      Command C = CMClass.getCommand("TRAIN");
      if (C != null) C.execute(mob, commands, metaFlags);
      return true;
    }
    if (CMClass.findAbility(what + teacherName, mob) != null) {
      Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what);
      mob.doCommand(CC, metaFlags);
      return true;
    }
    ExpertiseLibrary.ExpertiseDefinition theExpertise = null;
    Vector V2 = CMLib.expertises().myListableExpertises(mob);
    for (Enumeration e = V2.elements(); e.hasMoreElements(); ) {
      ExpertiseLibrary.ExpertiseDefinition def =
          (ExpertiseLibrary.ExpertiseDefinition) e.nextElement();
      if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what))
          || (def.name.toLowerCase().startsWith((what + teacherName).toLowerCase())
              && (CMath.isRomanNumeral(def.name.substring((what + teacherName).length()).trim())
                  || CMath.isNumber(def.name.substring((what + teacherName).length()).trim())))
          || (def.name.toLowerCase().startsWith((what).toLowerCase())
              && (CMath.isRomanNumeral(def.name.substring((what).length()).trim())
                  || CMath.isNumber(def.name.substring((what).length()).trim())))) {
        theExpertise = def;
        break;
      }
    }
    if (theExpertise == null)
      for (Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) {
        ExpertiseLibrary.ExpertiseDefinition def =
            (ExpertiseLibrary.ExpertiseDefinition) e.nextElement();
        if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what))) {
          theExpertise = def;
          break;
        }
      }
    if (theExpertise != null) {
      Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + theExpertise.name);
      mob.doCommand(CC, metaFlags);
      return true;
    }

    for (int v = 0; v < V.size(); v++)
      if (((String) V.elementAt(v)).startsWith(what.toUpperCase().trim())) {
        Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what);
        mob.doCommand(CC, metaFlags);
        if (teacherName.length() > 0) commands.addElement(teacherName.trim());
        Command C = CMClass.getCommand("TRAIN");
        if (C != null) C.execute(mob, commands, metaFlags);
        return true;
      }
    Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what + teacherName);
    mob.doCommand(CC, metaFlags);
    return false;
  }
Example #3
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 1) {
      mob.tell("Create overgrowth where?");
      return false;
    }

    String areaName = CMParms.combine(commands, 0).trim().toUpperCase();
    Room anyRoom = null;
    Room newRoom = null;
    try {
      Vector rooms = CMLib.map().findRooms(CMLib.map().rooms(), mob, areaName, true, 10);
      for (Enumeration r = rooms.elements(); r.hasMoreElements(); ) {
        Room R = (Room) r.nextElement();
        anyRoom = R;
        if ((R.domainType() & Room.INDOORS) == 0) {
          newRoom = R;
          break;
        }
      }
    } catch (NoSuchElementException e) {
    }

    if (newRoom == null) {
      if (anyRoom == null)
        mob.tell("You don't know of an place called '" + CMParms.combine(commands, 0) + "'.");
      else mob.tell("There IS such a place, but its not outdoors, so your magic would fail.");
      return false;
    }

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

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

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              "^S<S-NAME> chant(s) about a far away place.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Item newItem = null;
        if (newRoom.domainType() == Room.DOMAIN_INDOORS_CAVE)
          newItem = Chant_SummonFungus.buildFungus(mob, newRoom);
        else if ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_UNDERWATER)
            || (newRoom.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE))
          newItem = Chant_SummonSeaweed.buildSeaweed(mob, newRoom);
        else if ((newRoom.domainType() == Room.DOMAIN_INDOORS_STONE)
            || (newRoom.domainType() == Room.DOMAIN_INDOORS_WOOD))
          newItem = Chant_SummonHouseplant.buildHouseplant(mob, newRoom);
        else newItem = Chant_SummonPlants.buildPlant(mob, newRoom);
        mob.tell("You feel a distant connection with " + newItem.name());
      }
    } else
      beneficialWordsFizzle(
          mob, null, "<S-NAME> chant(s) about a far away place, but the magic fades.");

    // return whether it worked
    return success;
  }