Пример #1
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.clans().iterator().hasNext()) {
      mob.tell(L("You aren't even a member of a clan."));
      return false;
    }
    final Pair<Clan, Integer> clanPair =
        CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS);
    if (clanPair == null) {
      mob.tell(L("You are not authorized to draw from the power of your clan."));
      return false;
    }
    final Clan C = clanPair.first;
    Room clanHomeRoom = null;
    clanHomeRoom = CMLib.map().getRoom(C.getRecall());
    if (clanHomeRoom == null) {
      mob.tell(L("Your clan does not have a clan home."));
      return false;
    }
    if (!CMLib.flags().canAccess(mob, clanHomeRoom)) {
      mob.tell(L("You can't use this magic to get there from here."));
      return false;
    }
    if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) {
      mob.tell(L("Your clan no longer owns that room."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto),
              L("^S<S-NAME> invoke(s) a teleportation spell.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Set<MOB> h = properTargets(mob, givenTarget, false);
        if (h == null) return false;

        final Room thisRoom = mob.location();
        for (final Object element : h) {
          final MOB follower = (MOB) element;
          final CMMsg enterMsg =
              CMClass.getMsg(
                  follower,
                  clanHomeRoom,
                  this,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  L("<S-NAME> appears in a puff of red smoke."));
          final CMMsg leaveMsg =
              CMClass.getMsg(
                  follower,
                  thisRoom,
                  this,
                  CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC,
                  L("<S-NAME> disappear(s) in a puff of red smoke."));
          if (thisRoom.okMessage(follower, leaveMsg)
              && clanHomeRoom.okMessage(follower, enterMsg)) {
            if (follower.isInCombat()) {
              CMLib.commands().postFlee(follower, ("NOWHERE"));
              follower.makePeace(false);
            }
            thisRoom.send(follower, leaveMsg);
            clanHomeRoom.bringMobHere(follower, false);
            clanHomeRoom.send(follower, enterMsg);
            follower.tell(L("\n\r\n\r"));
            CMLib.commands().postLook(follower, true);
          }
        }
      }

    } else
      beneficialWordsFizzle(
          mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell."));

    // return whether it worked
    return success;
  }