예제 #1
0
  public Room getRoom(String roomID) {
    if (!CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return super.getRoom(roomID);

    if (!isRoom(roomID)) return null;
    Room R = super.getRoom(roomID);
    if (((R == null) || (R.amDestroyed())) && (roomID != null)) {
      Area parentA = getParentArea();
      if (parentA == null) return null;

      if (roomID.toUpperCase().startsWith(Name().toUpperCase() + "#"))
        roomID = Name() + roomID.substring(Name().length()); // for case sensitive situations
      R = parentA.getRoom(parentA.Name() + getStrippedRoomID(roomID));
      if (R == null) return null;

      Room origRoom = R;
      R = (Room) R.copyOf();
      R.clearSky();
      if (R instanceof GridLocale) ((GridLocale) R).clearGrid(null);
      for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) R.rawDoors()[d] = null;
      R.setRoomID(roomID);
      R.setArea(this);
      addProperRoom(R);

      synchronized (("SYNC" + roomID).intern()) {
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
          Room dirR = origRoom.rawDoors()[d];
          if (dirR != null) {
            String myRID = dirR.roomID();
            if (dirR.getArea() == parentA) {
              String localDirRID = convertToMyArea(myRID);
              Room localDirR = getProperRoom(localDirRID);
              if (localDirR != null) R.rawDoors()[d] = localDirR;
              else {
                R.rawDoors()[d] = CMClass.getLocale("ThinRoom");
                R.rawDoors()[d].setRoomID(localDirRID);
                R.rawDoors()[d].setArea(this);
              }
            } else R.rawDoors()[d] = dirR;
          }
        }
      }
      fillInAreaRoom(R);
      R.setExpirationDate(System.currentTimeMillis() + WorldMap.ROOM_EXPIRATION_MILLIS);
    }
    return R;
  }
예제 #2
0
  protected Room getMakeSingleGridRoom(int x, int y) {
    if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return null;

    Room R = getGridRoomIfExists(x, y);
    if (R == null) {
      synchronized (rooms) {
        R = getGridRoomIfExists(x, y);
        if (R != null) return R;
        R = CMClass.getLocale(getGridChildLocaleID());
        if (R == null) return null;
        R.setGridParent(this);
        R.setRoomID("");
        R.setDisplayText(displayText());
        R.setDescription(description());
        int c = -1;
        if (displayTexts != null)
          if (displayTexts.size() > 0) {
            c = CMLib.dice().roll(1, displayTexts.size(), -1);
            R.setDisplayText((String) displayTexts.elementAt(c));
          }
        if (descriptions != null)
          if (descriptions.size() > 0) {
            if ((c < 0)
                || (c > descriptions.size())
                || (descriptions.size() != displayTexts.size()))
              c = CMLib.dice().roll(1, descriptions.size(), -1);
            R.setDescription((String) descriptions.elementAt(c));
          }

        for (int a = 0; a < numEffects(); a++) R.addEffect((Ability) fetchEffect(a).copyOf());
        for (int b = 0; b < numBehaviors(); b++)
          R.addBehavior((Behavior) fetchBehavior(b).copyOf());
        R.setExpirationDate(System.currentTimeMillis() + WorldMap.ROOM_EXPIRATION_MILLIS);
        addSortedRoom(R, x, y);
        R.setArea(getArea());
      }
    }
    return R;
  }
예제 #3
0
 protected Room getGridRoomIfExists(int x, int y) {
   Room R = getSortedRoom(x, y);
   if (R != null)
     R.setExpirationDate(System.currentTimeMillis() + WorldMap.ROOM_EXPIRATION_MILLIS);
   return R;
 }