Exemplo n.º 1
0
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    try {
      super.executeMsg(myHost, msg);
      if (spy == null) return;
      if (invoker == null) return;

      if ((msg.amISource(spy))
          && ((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
          && (msg.target() != null)
          && ((invoker.location() != spy.location()) || (!(msg.target() instanceof Room)))) {
        disable = true;
        CMMsg newAffect = CMClass.getMsg(invoker, msg.target(), msg.sourceMinor(), null);
        msg.target().executeMsg(invoker, newAffect);
      } else if ((!msg.amISource(invoker))
          && (invoker.location() != spy.location())
          && (msg.source().location() == spy.location())
          && (msg.othersCode() != CMMsg.NO_EFFECT)
          && (msg.othersMessage() != null)
          && (!disable)) {
        disable = true;
        invoker.executeMsg(invoker, msg);
      } else if (msg.amISource(invoker)
          && (!disable)
          && (msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.sourceMessage() != null)
          && ((msg.sourceMajor() & CMMsg.MASK_MAGIC) == 0)) {
        int start = msg.sourceMessage().indexOf("\'");
        int end = msg.sourceMessage().lastIndexOf("\'");
        if ((start > 0) && (end > start)) {
          String msg2 = msg.sourceMessage().substring(start + 1, end).trim();
          if (msg2.length() > 0)
            spy.enqueCommand(CMParms.parse(msg2.trim()), Command.METAFLAG_FORCED, 0);
        }
      }
    } finally {
      disable = false;
      if ((spy != null)
          && ((spy.amFollowing() != invoker)
              || (spy.amDead())
              || (!CMLib.flags().isInTheGame(spy, false))
              || (!CMLib.flags().isInTheGame(invoker, true)))) unInvoke();
    }
  }