示例#1
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;
 }
示例#2
0
  @Override
  public void setMiscText(String txt) {
    super.setMiscText("");
    if (txt.startsWith("-")) {
      txt = txt.substring(1).toLowerCase().trim();
      for (final Object[] A : affects)
        if (((CMObject) A[0]).ID().toLowerCase().equals(txt)) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Ability)
            && (((Environmental) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Behavior)
            && (((Behavior) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
    } else if (txt.trim().length() > 0) {
      if (txt.startsWith("+")) txt = txt.substring(1);
      else for (final Object[] A : affects) unAffectAffected(A);

      int x = txt.indexOf(' ');
      if (x < 0) return;
      final String abilityStr = txt.substring(0, x).trim();
      String numTicksStr = txt.substring(x + 1).trim();
      String parms = "";
      x = numTicksStr.indexOf(' ');
      if (x > 0) {
        parms = numTicksStr.substring(x + 1).trim();
        numTicksStr = numTicksStr.substring(0, x);
      }
      CMObject A = CMClass.getAbility(abilityStr);
      if (A == null) A = CMClass.getBehavior(abilityStr);
      if (A == null) A = CMClass.findAbility(abilityStr);
      if (A == null) A = CMClass.findBehavior(abilityStr);
      if (A != null) {
        affects.addElement(new Object[] {A, new int[] {CMath.s_int(numTicksStr)}});
        if (A instanceof Ability) ((Ability) A).setMiscText(parms);
        if ((A instanceof Behavior) && (affected instanceof PhysicalAgent))
          ((Behavior) A).setParms(parms);
        finishInit(A);
      }
    }
  }
示例#3
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 3) {
      mob.tell(
          L("Specify a target, a property, number of ticks, and (optionally) some misc text!"));
      return false;
    }
    final Vector V = new XVector(commands.firstElement());
    final Physical target = getAnyTarget(mob, V, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;
    commands.removeElementAt(0);

    final String abilityStr = (String) commands.firstElement();
    CMObject A = CMClass.getAbility(abilityStr);
    if (A == null) A = CMClass.getBehavior(abilityStr);
    if (A == null) A = CMClass.findAbility(abilityStr);
    if (A == null) A = CMClass.findBehavior(abilityStr);
    if (A == null) {
      mob.tell(L("No such ability or behavior as @x1!", abilityStr));
      return false;
    }
    final String numTicks = ((String) commands.elementAt(1)).trim();
    if ((!CMath.isInteger(numTicks)) || (CMath.s_int(numTicks) <= 0)) {
      mob.tell(L("'@x1' is not a number of ticks!", numTicks));
      return false;
    }
    final String parms = CMParms.combine(commands, 2);

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

    TemporaryAffects T = (TemporaryAffects) target.fetchEffect(ID());
    if (T == null) {
      T = (TemporaryAffects) this.newInstance();
      T.affects = new SVector<Object[]>();
      T.startTickDown(mob, target, 10);
      T = (TemporaryAffects) target.fetchEffect(ID());
    }
    if (T != null) {
      T.setMiscText("+" + A.ID() + " " + numTicks.trim() + " " + parms.trim());
      T.makeLongLasting();
    }
    return true;
  }
示例#4
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;
  }