Ejemplo n.º 1
0
 public void tryFillInExtraneousExternal(WorldMap.CrossExit EX, Exit ox, Room linkFrom) {
   if (EX == null) return;
   Room linkTo = CMLib.map().getRoom(EX.destRoomID);
   if ((linkTo != null) && (linkTo.getGridParent() != null)) linkTo = linkTo.getGridParent();
   if ((linkTo != null) && (linkFrom.rawDoors()[EX.dir] != linkTo)) {
     if (ox == null) ox = CMClass.getExit("Open");
     linkFrom.rawDoors()[EX.dir] = linkTo;
     linkFrom.setRawExit(EX.dir, ox);
   }
 }
Ejemplo n.º 2
0
 protected void halfLink(Room room, Room loc, int dirCode, Exit o) {
   if (room == null) return;
   if (loc == null) return;
   if (room.rawDoors()[dirCode] != null) {
     if (room.rawDoors()[dirCode].getGridParent() == null) return;
     if (room.rawDoors()[dirCode].getGridParent().isMyGridChild(room.rawDoors()[dirCode])) return;
     room.rawDoors()[dirCode] = null;
   }
   if (o == null) o = CMClass.getExit("Open");
   room.rawDoors()[dirCode] = alternativeLink(room, loc, dirCode);
   room.setRawExit(dirCode, o);
 }
Ejemplo n.º 3
0
 public void unInvoke() {
   if (canBeUninvoked()) {
     if (newRoom != null) {
       newRoom.showHappens(CMMsg.MSG_OK_VISUAL, "The divine gateway closes.");
       newRoom.rawDoors()[Directions.GATE] = null;
       newRoom.setRawExit(Directions.GATE, null);
     }
     if (oldRoom != null) {
       oldRoom.showHappens(CMMsg.MSG_OK_VISUAL, "The divine gateway closes.");
       oldRoom.rawDoors()[Directions.GATE] = null;
       oldRoom.setRawExit(Directions.GATE, null);
     }
   }
   super.unInvoke();
 }
Ejemplo n.º 4
0
 public Room prepareGridLocale(Room fromRoom, Room toRoom, int direction) {
   int x = getGridChildX(fromRoom);
   int y = getGridChildY(fromRoom);
   if ((x >= 0) && (x < xGridSize()) && (y >= 0) && (y < yGridSize()))
     fillExitsOfGridRoom(fromRoom, x, y);
   return fromRoom.rawDoors()[direction];
 }
Ejemplo n.º 5
0
 public void executeMsg(Environmental myHost, CMMsg msg) {
   if ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() instanceof Room)) {
     Room R = (Room) msg.target();
     if (R.getGridParent() == this) {
       if ((roomID().length() > 0) && (getArea() != null))
         getArea().delProperRoomnumber(getGridChildCode(R));
       DVector thisGridRooms = rooms;
       thisGridRooms.removeElement(R);
       Room R2 = null;
       for (int r = thisGridRooms.size() - 1; r >= 0; r--) {
         R2 = (Room) thisGridRooms.elementAt(r, 1);
         for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
           if (R2.rawDoors()[d] == R) {
             R2.rawDoors()[d] = null;
             R2.setRawExit(d, null);
           }
       }
     }
   }
   super.executeMsg(myHost, msg);
 }
Ejemplo n.º 6
0
 protected void linkRoom(Room room, Room loc, int dirCode, Exit o, Exit ao) {
   if (loc == null) return;
   if (room == null) return;
   int opCode = Directions.getOpDirectionCode(dirCode);
   if (room.rawDoors()[dirCode] != null) {
     if (room.rawDoors()[dirCode].getGridParent() == null) return;
     if (room.rawDoors()[dirCode].getGridParent().isMyGridChild(room.rawDoors()[dirCode])) return;
     room.rawDoors()[dirCode] = null;
   }
   if (o == null) o = CMClass.getExit("Open");
   room.rawDoors()[dirCode] = alternativeLink(room, loc, dirCode);
   room.setRawExit(dirCode, o);
   if (loc.rawDoors()[opCode] != null) {
     if (loc.rawDoors()[opCode].getGridParent() == null) return;
     if (loc.rawDoors()[opCode].getGridParent().isMyGridChild(loc.rawDoors()[opCode])) return;
     loc.rawDoors()[opCode] = null;
   }
   if (ao == null) ao = CMClass.getExit("Open");
   loc.rawDoors()[opCode] = alternativeLink(loc, room, opCode);
   loc.setRawExit(opCode, ao);
 }
Ejemplo n.º 7
0
  @Override
  protected void fillExitsOfGridRoom(Room R, int x, int y) {
    super.fillExitsOfGridRoom(R, x, y);

    if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return;
    // the adjacent rooms created by this method should also take
    // into account the possibility that they are on the edge.
    // it does NOT
    if (ox == null) ox = CMClass.getExit("Open");
    Room R2 = null;

    if ((y == 0) && (R.rawDoors()[Directions.NORTH] == null)) {
      R2 = getMakeSingleGridRoom(x, yGridSize() / 2);
      if (R2 != null) linkRoom(R, R2, Directions.NORTH, ox, ox);
    } else if ((y == yGridSize() - 1) && (R.rawDoors()[Directions.SOUTH] == null)) {
      R2 = getMakeSingleGridRoom(x, yGridSize() / 2);
      if (R2 != null) linkRoom(R, R2, Directions.SOUTH, ox, ox);
    }
    if ((x == 0) && (R.rawDoors()[Directions.WEST] == null)) {
      R2 = getMakeSingleGridRoom(xGridSize() / 2, y);
      if (R2 != null) linkRoom(R, R2, Directions.WEST, ox, ox);
    } else if ((x == xGridSize() - 1) && (R.rawDoors()[Directions.EAST] == null)) {
      R2 = getMakeSingleGridRoom(xGridSize() / 2, y);
      if (R2 != null) linkRoom(R, R2, Directions.EAST, ox, ox);
    }
    if (Directions.NORTHEAST < Directions.NUM_DIRECTIONS()) {
      if (((x == 0) || (y == 0)) && (R.rawDoors()[Directions.NORTHWEST] == null)) {
        R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2);
        if (R2 != null) linkRoom(R, R2, Directions.NORTHWEST, ox, ox);
      } else if (((x == xGridSize() - 1) || (y == yGridSize() - 1))
          && (R.rawDoors()[Directions.SOUTHEAST] == null)) {
        R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2);
        if (R2 != null) linkRoom(R, R2, Directions.SOUTHEAST, ox, ox);
      }
      if (((x == xGridSize() - 1) || (y == 0)) && (R.rawDoors()[Directions.NORTHEAST] == null)) {
        R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2);
        if (R2 != null) linkRoom(R, R2, Directions.NORTHEAST, ox, ox);
      } else if (((x == 0) || (y == yGridSize() - 1))
          && (R.rawDoors()[Directions.SOUTHWEST] == null)) {
        R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2);
        if (R2 != null) linkRoom(R, R2, Directions.SOUTHWEST, ox, ox);
      }
    }
  }
Ejemplo n.º 8
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;
  }
Ejemplo n.º 9
0
  public static int updateLotWithThisData(
      Room R,
      LandTitle T,
      boolean resetRoomName,
      boolean clearAllItems,
      List optPlayerList,
      int lastNumItems) {
    boolean updateItems = false;
    boolean updateExits = false;
    boolean updateRoom = false;
    synchronized (("SYNC" + R.roomID()).intern()) {
      R = CMLib.map().getRoom(R);
      if (T.getOwnerName().length() == 0) {
        Item I = null;
        for (int i = R.numItems() - 1; i >= 0; i--) {
          I = R.getItem(i);
          if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue;
          CMLib.catalog().updateCatalogIntegrity(I);
          if (clearAllItems) {
            I.destroy();
            updateItems = true;
          } else {
            if (I.expirationDate() == 0) {
              long now = System.currentTimeMillis();
              now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP));
              I.setExpirationDate(now);
            }
            if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) {
              I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
              I.recoverPhyStats();
            }
          }
        }
        Ability A = null;
        if (clearAllItems)
          for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) {
            A = a.nextElement();
            if (((A != null)
                && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) {
              A.unInvoke();
              R.delEffect(A);
              updateRoom = true;
            }
          }
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
          final Room R2 = R.rawDoors()[d];
          Exit E = R.getRawExit(d);
          if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
            E.setKeyName("");
            E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
            updateExits = true;
            if (R2 != null) {
              E = R2.getRawExit(Directions.getOpDirectionCode(d));
              if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
                E.setKeyName("");
                E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
                CMLib.database().DBUpdateExits(R2);
                R2.getArea().fillInAreaRoom(R2);
              }
            }
          }
        }
        if (updateExits) {
          CMLib.database().DBUpdateExits(R);
          R.getArea().fillInAreaRoom(R);
        }
        if (updateItems) CMLib.database().DBUpdateItems(R);
        if (updateRoom) CMLib.database().DBUpdateRoom(R);
        colorForSale(R, T.rentalProperty(), resetRoomName);
        return -1;
      }

      if ((lastNumItems < 0)
          && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS))
          && (optPlayerList != null)) {
        boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null);
        if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null);
        if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName());
        if (!playerExists)
          for (int i = 0; i < optPlayerList.size(); i++)
            if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) {
              playerExists = true;
              break;
            }
        if (!playerExists) {
          T.setOwnerName("");
          T.updateLot(null);
          return -1;
        }
      }

      int x = R.description().indexOf(SALESTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }
      x = R.description().indexOf(RENTSTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }

      // this works on the priciple that
      // 1. if an item has ONLY been removed, the lastNumItems will be != current # items
      // 2. if an item has ONLY been added, the dispossessiontime will be != null
      // 3. if an item has been added AND removed, the dispossession time will be != null on the
      // added
      if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true;

      for (int i = 0; i < R.numItems(); i++) {
        final Item I = R.getItem(i);
        if ((I.expirationDate() != 0)
            && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id")))
            && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) {
          I.setExpirationDate(0);
          updateItems = true;
        }

        if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) {
          I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
          I.recoverPhyStats();
          updateItems = true;
        }
      }
      lastNumItems = R.numItems();
      if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems))
        CMLib.database().DBUpdateItems(R);
    }
    return lastNumItems;
  }
Ejemplo n.º 10
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if ((auto || mob.isMonster()) && (commands.size() == 0))
      commands.addElement(CMLib.map().getRandomRoom().displayText());
    if (commands.size() < 1) {
      mob.tell("Pray for a gateway to where?");
      return false;
    }
    if ((mob.location().getRoomInDir(Directions.GATE) != null)
        || (mob.location().getExitInDir(Directions.GATE) != null)) {
      mob.tell("A gateway cannot be created here.");
      return false;
    }
    String areaName = CMParms.combine(commands, 0).trim().toUpperCase();
    oldRoom = null;
    newRoom = null;
    try {
      Vector rooms = CMLib.map().findRooms(CMLib.map().rooms(), mob, areaName, true, 10);
      if (rooms.size() > 0)
        newRoom = (Room) rooms.elementAt(CMLib.dice().roll(1, rooms.size(), -1));
    } catch (NoSuchElementException e) {
    }

    if (newRoom == null) {
      mob.tell("You don't know of an place called '" + CMParms.combine(commands, 0) + "'.");
      return false;
    }

    int profNeg = 0;
    for (int i = 0; i < newRoom.numInhabitants(); i++) {
      MOB t = newRoom.fetchInhabitant(i);
      if (t != null) {
        int adjustment =
            t.envStats().level() - (mob.envStats().level() + (2 * super.getXLEVELLevel(mob)));
        if (t.isMonster()) adjustment = adjustment * 3;
        profNeg += adjustment;
      }
    }
    profNeg += newRoom.numItems() * 20;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, -profNeg, auto);

    if ((success)
        && ((newRoom.getRoomInDir(Directions.GATE) == null)
            && (newRoom.getExitInDir(Directions.GATE) == null))) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              mob.location(),
              this,
              verbalCastCode(mob, mob.location(), auto),
              "^S<S-NAME> " + prayWord(mob) + " for a blinding, divine gateway here.^?");
      CMMsg msg2 =
          CMClass.getMsg(
              mob,
              newRoom,
              this,
              verbalCastCode(mob, newRoom, auto),
              "A blinding, divine gateway appears here.");
      if ((mob.location().okMessage(mob, msg)) && (newRoom.okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        newRoom.send(mob, msg2);
        Exit e = CMClass.getExit("GenExit");
        e.setDescription("A divine gateway to somewhere");
        e.setDisplayText("A divine gateway to somewhere");
        e.setDoorsNLocks(false, true, false, false, false, false);
        e.setExitParams("gateway", "close", "open", "closed.");
        e.setName("a divine gateway");
        mob.location().rawDoors()[Directions.GATE] = newRoom;
        newRoom.rawDoors()[Directions.GATE] = mob.location();
        mob.location().setRawExit(Directions.GATE, e);
        newRoom.setRawExit(Directions.GATE, e);
        oldRoom = mob.location();
        beneficialAffect(mob, e, asLevel, 5);
      }
    } else
      beneficialWordsFizzle(
          mob, null, "<S-NAME> " + prayWord(mob) + " for a gateway, but nothing happens.");

    // return whether it worked
    return success;
  }