Ejemplo n.º 1
0
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    super.unInvoke();

    if ((canBeUninvoked()) && (clan1 != null) && (clan2 != null)) {
      final Clan C1 = clan1;
      final Clan C2 = clan2;
      if ((C1 != null) && (C2 != null)) {
        if (C1.getClanRelations(C2.clanID()) == Clan.REL_WAR) {
          C1.setClanRelations(C2.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis());
          C1.update();
        }
        if (C2.getClanRelations(C1.clanID()) == Clan.REL_WAR) {
          C2.setClanRelations(C1.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis());
          C2.update();
        }
        List<String> channels =
            CMLib.channels().getFlaggedChannelNames(ChannelsLibrary.ChannelFlag.CLANINFO);
        for (int i = 0; i < channels.size(); i++)
          CMLib.commands()
              .postChannel(
                  channels.get(i),
                  CMLib.clans().clanRoles(),
                  "There is now peace between " + C1.name() + " and " + C2.name() + ".",
                  false);
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((clanID().length() > 0) && (msg.amITarget(this))) {
      if (msg.source().getClanRole(clanID()) == null) {
        if ((msg.targetMinor() == CMMsg.TYP_GET)
            || (msg.targetMinor() == CMMsg.TYP_PUSH)
            || (msg.targetMinor() == CMMsg.TYP_PULL)
            || (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)) {
          final Room R = CMLib.map().roomLocation(this);
          if (CMLib.clans().findRivalrousClan(msg.source()) == null) {
            msg.source().tell(L("You must belong to an elligible clan to take a clan item."));
            return false;
          } else if (R != null) {
            for (int i = 0; i < R.numInhabitants(); i++) {
              final MOB M = R.fetchInhabitant(i);
              if ((M != null)
                  && (M.isMonster())
                  && (M.getClanRole(clanID()) != null)
                  && (CMLib.flags().aliveAwakeMobileUnbound(M, true))
                  && (CMLib.flags().canBeSeenBy(this, M))
                  && (!CMLib.flags().isAnimalIntelligence(M))) {
                R.show(
                    M, null, CMMsg.MSG_QUIETMOVEMENT, L("<S-NAME> guard(s) @x1 closely.", name()));
                return false;
              }
            }
            String rulingClan = "";
            final LegalBehavior B = CMLib.law().getLegalBehavior(R);
            if (B != null) rulingClan = B.rulingOrganization();
            if (msg.source().getClanRole(rulingClan) == null) {
              msg.source()
                  .tell(L("You must conquer and fully control this area to take the clan flag."));
              return false;
            }
            if ((B != null) && (!B.isFullyControlled())) {
              msg.source().tell(L("Your clan does not yet fully control the area."));
              return false;
            }
          }
        } else if ((msg.targetMinor() == CMMsg.TYP_DROP)
            && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_INTERMSG))) {
          final Room R = msg.source().location();
          LandTitle T = null;
          Area A = null;
          LegalBehavior B = null;
          if (R != null) {
            A = R.getArea();
            T = CMLib.law().getLandTitle(R);
          }
          if ((T == null)
              || ((!T.getOwnerName().equals(clanID()))
                  && ((!T.getOwnerName().equals(msg.source().getLiegeID()))
                      || (!msg.source().isMarriedToLiege()))
                  && (!T.getOwnerName().equals(msg.source().Name())))) {
            boolean ok = false;
            if (A != null) {
              B = CMLib.law().getLegalBehavior(R);
              if (B != null) ok = B.controlPoints() > 0;
            }
            if (!ok) {
              msg.source()
                  .tell(
                      L("You can not place a flag here, this place is controlled by the Archons."));
              return false;
            }
          }
        }
      } else if ((msg.targetMinor() == CMMsg.TYP_GET)
          && (msg.source().location() != null)
          && (msg.source().isMonster())) {
        boolean foundOne = false;
        for (int i = 0; i < msg.source().location().numInhabitants(); i++) {
          final MOB M = msg.source().location().fetchInhabitant(i);
          if ((M != null) && (!M.isMonster()) && (M.getClanRole(clanID()) != null)) {
            foundOne = true;
            break;
          }
        }
        if (!foundOne) {
          msg.source().tell(L("You are guarding @x1 too closely.", name()));
          return false;
        }
      }
    }

    if (StdClanItem.stdOkMessage(this, msg)) {
      if ((clanID().length() > 0)
          && (msg.amITarget(this))
          && (msg.targetMinor() == CMMsg.TYP_DROP)) {
        final LegalBehavior B = CMLib.law().getLegalBehavior(msg.source().location());
        final String rulingClan = (B != null) ? B.rulingOrganization() : "";
        if (rulingClan.length() == 0)
          msg.source()
              .tell(
                  L("Area '@x1' is presently neutral.", msg.source().location().getArea().name()));
        else {
          msg.source()
              .tell(
                  L(
                      "Area '@x1' is presently controlled by @x2.",
                      msg.source().location().getArea().name(),
                      rulingClan));
          if (!rulingClan.equals(clanID())) {
            int relation = Clan.REL_WAR;
            final Clan C = CMLib.clans().getClan(clanID());
            if (C == null) {
              msg.source().tell(L("This ancient relic from a lost clan fades out of existence."));
              this.destroy();
              return false;
            }
            relation = C.getClanRelations(rulingClan);
            if (relation != Clan.REL_WAR) {
              msg.source()
                  .tell(
                      L("You must be at war with this clan to put down your flag on their area."));
              return false;
            }
          }
        }
      }
      return super.okMessage(myHost, msg);
    }
    return false;
  }
Ejemplo n.º 3
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;
  }