示例#1
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (msg.targetMinor() == CMMsg.TYP_ENTER) {
      if (msg.target() == this) {
        MOB mob = msg.source();
        if ((mob.location() != null) && (mob.location().roomID().length() > 0)) {
          int direction = -1;
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
            if (mob.location().getRoomInDir(d) == this) direction = d;
          }
          if (direction < 0) {
            mob.tell("Some great evil is preventing your movement that way.");
            return false;
          }
          msg.modify(
              msg.source(),
              getAltRoomFrom(mob.location(), direction),
              msg.tool(),
              msg.sourceCode(),
              msg.sourceMessage(),
              msg.targetCode(),
              msg.targetMessage(),
              msg.othersCode(),
              msg.othersMessage());
        }
      }
    }
    return true;
  }