예제 #1
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = mob;
    if ((auto) && (givenTarget != null)) target = givenTarget;
    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(mob, target, null, "<T-NAME> <T-IS-ARE> already affected by " + name() + ".");
      return false;
    }
    clan1 = CMLib.clans().findRivalrousClan(mob);
    if (clan1 == null) {
      mob.tell("You must belong to a clan to use this prayer.");
      return false;
    }
    if (commands.size() < 1) {
      mob.tell("You must specify the clan you wish to see peace with.");
      return false;
    }
    String clan2Name = CMParms.combine(commands, 0);
    clan2 = CMLib.clans().findClan(clan2Name);
    if ((clan2 == null)
        || ((clan1.getClanRelations(clan2.clanID()) != Clan.REL_WAR)
            && (clan2.getClanRelations(clan1.clanID()) != Clan.REL_WAR))) {
      mob.tell("Your " + clan1.getGovernmentName() + " is not at war with " + clan2 + "!");
      return false;
    }
    boolean found = false;
    for (Enumeration e = CMLib.players().players(); e.hasMoreElements(); ) {
      MOB M = (MOB) e.nextElement();
      if (M.getClanRole(clan2.clanID()) != null) {
        found = true;
        break;
      }
    }
    if (!found) {
      mob.tell(
          "You must wait until a member of " + clan2 + " is online before beginning the ritual.");
      return false;
    }

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

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

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> begin(s) a peace ritual."
                  : "^S<S-NAME> "
                      + prayWord(mob)
                      + " for peace between "
                      + clan1.name()
                      + " and "
                      + clan2.name()
                      + ".^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, (int) CMProps.getTicksPerMinute() * 5);
      }
    } else
      return beneficialWordsFizzle(
          mob,
          null,
          "<S-NAME> "
              + prayWord(mob)
              + " for peace between "
              + clan1.name()
              + " and "
              + clan2.name()
              + ", but there is no answer.");

    // return whether it worked
    return success;
  }