Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
0
 public static void colorForSale(Room R, boolean rental, boolean reset) {
   synchronized (("SYNC" + R.roomID()).intern()) {
     R = CMLib.map().getRoom(R);
     final String theStr = rental ? RENTSTR : SALESTR;
     final String otherStr = rental ? SALESTR : RENTSTR;
     int x = R.description().indexOf(otherStr);
     while (x >= 0) {
       R.setDescription(R.description().substring(0, x));
       CMLib.database().DBUpdateRoom(R);
       x = R.description().indexOf(otherStr);
     }
     final String oldDescription = R.description();
     x = R.description().indexOf(theStr.trim());
     if ((x < 0)
         || (reset
             && (!R.displayText()
                 .equals(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR)))) {
       if (reset) {
         R.setDescription("");
         R.setDisplayText(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR);
         x = -1;
       }
       if (x < 0) R.setDescription(R.description() + theStr);
       else if (!reset) R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     } else {
       R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     }
     Item I = R.findItem(null, "$id$");
     if ((I == null) || (!I.ID().equals("GenWallpaper"))) {
       I = CMClass.getItem("GenWallpaper");
       CMLib.flags().setReadable(I, true);
       I.setName(("id"));
       I.setReadableText(CMLib.lang().L("This room is " + CMLib.map().getExtendedRoomID(R)));
       I.setDescription(CMLib.lang().L("This room is @x1", CMLib.map().getExtendedRoomID(R)));
       R.addItem(I);
       CMLib.database().DBUpdateItems(R);
     }
   }
 }