Ejemplo n.º 1
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    String memberStr = (commands.size() > 1) ? (String) commands.get(commands.size() - 1) : "";
    String clanName =
        (commands.size() > 2) ? CMParms.combine(commands, 1, commands.size() - 1) : "";

    Clan C = null;
    boolean skipChecks = mob.getClanRole(mob.Name()) != null;
    if (skipChecks) C = mob.getClanRole(mob.Name()).first;

    if (C == null)
      for (Pair<Clan, Integer> c : mob.clans())
        if ((clanName.length() == 0)
            || (CMLib.english().containsString(c.first.getName(), clanName))
                && (c.first.getAuthority(c.second.intValue(), Clan.Function.EXILE)
                    != Authority.CAN_NOT_DO)) {
          C = c.first;
          break;
        }

    commands.clear();
    commands.addElement(getAccessWords()[0]);
    commands.addElement(memberStr);

    StringBuffer msg = new StringBuffer("");
    boolean found = false;
    if (memberStr.length() > 0) {
      if (C == null) {
        mob.tell(
            "You aren't allowed to exile anyone from "
                + ((clanName.length() == 0) ? "anything" : clanName)
                + ".");
        return false;
      }
      if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, false)) {
        List<MemberRecord> apps = C.getMemberList();
        if (apps.size() < 1) {
          mob.tell("There are no members in your " + C.getGovernmentName() + ".");
          return false;
        }
        for (MemberRecord member : apps) {
          if (member.name.equalsIgnoreCase(memberStr)) {
            found = true;
          }
        }
        if (found) {
          MOB M = CMLib.players().getLoadPlayer(memberStr);
          if (M == null) {
            mob.tell(
                memberStr + " was not found.  Could not exile from " + C.getGovernmentName() + ".");
            return false;
          }
          if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, true)) {
            if (C.getGovernment().getExitScript().trim().length() > 0) {
              Pair<Clan, Integer> curClanRole = M.getClanRole(C.clanID());
              if (curClanRole != null) M.setClan(C.clanID(), curClanRole.second.intValue());
              ScriptingEngine S = (ScriptingEngine) CMClass.getCommon("DefaultScriptingEngine");
              S.setSavable(false);
              S.setVarScope("*");
              S.setScript(C.getGovernment().getExitScript());
              CMMsg msg2 = CMClass.getMsg(M, M, null, CMMsg.MSG_OK_VISUAL, null, null, "CLANEXIT");
              S.executeMsg(M, msg2);
              S.dequeResponses();
              S.tick(M, Tickable.TICKID_MOB);
            }
            CMLib.clans()
                .clanAnnounce(
                    mob,
                    "Member exiled from "
                        + C.getGovernmentName()
                        + " "
                        + C.name()
                        + ": "
                        + M.Name());
            mob.tell(
                M.Name()
                    + " has been exiled from "
                    + C.getGovernmentName()
                    + " '"
                    + C.clanID()
                    + "'.");
            if ((M.session() != null) && (M.session().mob() == M))
              M.tell(
                  "You have been exiled from " + C.getGovernmentName() + " '" + C.clanID() + "'.");
            C.delMember(M);
            return false;
          }
        } else {
          msg.append(memberStr + " isn't a member of your " + C.getGovernmentName() + ".");
        }
      } else {
        msg.append(
            "You aren't in the right position to exile anyone from your "
                + C.getGovernmentName()
                + ".");
      }
    } else {
      msg.append("You haven't specified which member you are exiling.");
    }
    mob.tell(msg.toString());
    return false;
  }
Ejemplo n.º 2
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;
  }