コード例 #1
0
  private void parseExitLine(String line) {
    if (line.startsWith(EXITTOT_KEYWORD)) {
      _log.debug("Found the " + EXITTOT_KEYWORD + " section");
      return;
    }
    String data = line.substring(EXIT_KEYWORD.length());
    String[] split = data.split(" ");
    int roomVnum = new Integer(split[0]);
    Room room = getOrCreateRoom(roomVnum);

    String[] exitSplit = getData(data);

    for (int count = 0; count < exitSplit.length - 1; count++) {
      int exitRoomVnum = Integer.valueOf(exitSplit[count]);
      if (exitRoomVnum != 0) {
        ExitDirectionEnum exitDir = getExitDirectionEnum(count);
        room.addExit(new DefaultExit(exitDir, exitRoomVnum));
        // If the destination room is negative, it must go to a town.  Create the other end.
        if (exitRoomVnum < 0) {
          ExitDirectionEnum oppositeExitDir = GameUtil.getOppositeExit(exitDir);
          _townArea.getEntry(exitRoomVnum).addExit(new DefaultExit(oppositeExitDir, roomVnum));
        }
      }
    }

    room.setDefaultDescription(Integer.valueOf(exitSplit[10]).intValue());
    room.setAltDescription(Integer.valueOf(exitSplit[10]).intValue());

    _area.getRoomMap().put(room.getRoomNumber(), room);
  }
コード例 #2
0
  private void parseDoorLine(String line) {
    if (line.startsWith(DOORTOT_KEYWORD)) {
      _log.debug("Found the " + DOORTOT_KEYWORD + " section");
      return;
    }

    String data = line.substring(DOOR_KEYWORD.length());
    String[] doorDataSplit = getData(data);

    int fromRoom = Integer.valueOf(doorDataSplit[1]);
    int toRoom = Integer.valueOf(doorDataSplit[2]);

    Room room = _area.getEntry(fromRoom);
    if (room == null) {
      room = _townArea.getEntry(fromRoom);
    }

    Exit exit = room.getExit(toRoom);
    if (exit == null) {
      _log.info(
          "Exit from room "
              + room.getRoomNumber()
              + " to room "
              + toRoom
              + " does not exist!  Skipping");
      return;
    }

    int doorTypeInt = Integer.valueOf(doorDataSplit[0]).intValue();
    Door door = new NullDoor();

    if (doorTypeInt >= 0) {
      door = new ItemKeyDoor();
    } else {
      DoorType doorType = DoorType.getDoorType(doorTypeInt);
      if (doorType.equals(DoorType.HAS_RUNE)) {
        door = new HasRuneDoor();
      } else if (doorType.equals(DoorType.MINIMUM_RUNE)) {
        door = new MinimumRuneDoor();
      } else if (doorType.equals(DoorType.PRIVATE_ROOM)) {
        door = new PrivateRoomDoor();
      } else if (doorType.equals(DoorType.PUZZLE)) {
        door = new PuzzleDoor();
      } else if (doorType.equals(DoorType.PROMOTE_DOOR)) {
        door = new PromoteDoor();
      }
    }
    door.setV0(Integer.valueOf(doorDataSplit[0]).intValue());
    door.setV3(Integer.valueOf(doorDataSplit[3]).intValue());
    door.setV4(Integer.valueOf(doorDataSplit[4]).intValue());
    door.setV5(Integer.valueOf(doorDataSplit[5]).intValue());
    door.setV6(Integer.valueOf(doorDataSplit[6]).intValue());

    exit.setDoor(door);
  }