/** Method to export data like rooms, capacity and meetings array in json format into a file */
  protected static String exportData(ArrayList<Room> roomList) {

    JSONObject json = new JSONObject();

    for (Room room : roomList) {
      json.put("RoomName", room.getName());
      json.put("Capacity", room.getCapacity());
      JSONArray meetings = new JSONArray();

      for (Meeting m : room.getMeetings()) {
        meetings.add(m.toString());
      }
      json.put("Meetings", meetings);

      // write data to a file
      File fileName = new File("src/File/result.json");
      try (PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true)))) {
        file.write(json.toJSONString());
        file.write("\n");
        file.flush();
        file.close();
      } catch (IOException e) {
        logger.error("Exception in export method:", e);
      }
      logger.info("Data exported successfully");
    }
    return "";
  }
Ejemplo n.º 2
0
 @Override
 protected Item buildMyPlant(MOB mob, Room room) {
   final int code = material & RawMaterial.RESOURCE_MASK;
   final Item newItem = CMClass.getBasicItem("GenItem");
   final String name =
       CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree");
   newItem.setName(name);
   newItem.setDisplayText(L("@x1 grows here.", newItem.name()));
   newItem.setDescription("");
   newItem.basePhyStats().setWeight(10000);
   CMLib.flags().setGettable(newItem, false);
   newItem.setMaterial(material);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   final Chant_SummonTree newChant = new Chant_SummonTree();
   newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob));
   newItem.setExpirationDate(0);
   room.showHappens(
       CMMsg.MSG_OK_ACTION,
       L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase()));
   room.recoverPhyStats();
   newChant.plantsLocationR = room;
   newChant.littlePlantsI = newItem;
   if (CMLib.law().doesOwnThisLand(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Ejemplo n.º 3
0
  public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) {
    // caller is responsible for recovering any env
    // stat changes!

    if (CMLib.flags().isHidden(thisContainer))
      thisContainer
          .baseEnvStats()
          .setDisposition(
              thisContainer.baseEnvStats().disposition()
                  & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN));
    mob.delInventory(thisContainer);
    thisContainer.unWear();
    if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody);
    if (bodyFlag) {
      room.addItem(thisContainer);
      thisContainer.setExpirationDate(0);
    } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP));
    thisContainer.recoverEnvStats();
    boolean nothingDone = true;
    do {
      nothingDone = true;
      for (int i = 0; i < mob.inventorySize(); i++) {
        Item thisItem = mob.fetchInventory(i);
        if ((thisItem != null) && (thisItem.container() == thisContainer)) {
          recursiveDropMOB(mob, room, thisItem, bodyFlag);
          nothingDone = false;
          break;
        }
      }
    } while (!nothingDone);
  }
Ejemplo n.º 4
0
  /**
   * This method create the rooms and analyzes the parameters to determine the instance of the room
   * created
   *
   * @param type Type of the new room
   * @param name Name of the now room
   * @return The room instance
   * @throws IndexOutOfBoundsException If the type isn't recognized
   */
  public static Room createRoom(String type, String name) throws IndexOutOfBoundsException {
    Room current;
    switch (type) {
      case ROOM_NORMAL:
        current = new Room(name);
        break;
      case ROOM_MONSTER:
        current = new RoomWithMonster(name);
        break;
      case ROOM_NORMAL_LOCKED:
        current = new Room(name);
        current.setLock(true);
        break;
      case ROOM_MONSTER_LOCKED:
        current = new RoomWithMonster(name);
        current.setLock(true);
        break;
      case ROOM_EXIT:
        current = new Room(name);
        current.setTheEndOfLevel(true);
        break;

      default:
        throw new IndexOutOfBoundsException("createRoom : room's type not recognized");
    }
    return current;
  }
Ejemplo n.º 5
0
 public void setRank(Player p, String name, int rank) {
   for (Room r : clanRooms) {
     if (r.getName().equalsIgnoreCase(p.clanRoom)) {
       r.setRank(p, name, rank);
     }
   }
 }
Ejemplo n.º 6
0
    public Action step(Set<Action> options) {
      count++;

      if (count == 1) {
        BoolTable newWumpusKB = new BoolTable();
        for (Room room : privateToWorld.keySet()) {
          if (wumpusKB.known(room) && wumpusKB.evaluate(room) == false) {
            newWumpusKB.assign(room, false);
          }
          if (!wumpusKB.known(room)) {
            System.out.format("Suspicious Room: %s!%n", room);
            for (Room adj : room.adjacent) {
              System.out.format("   Resetting: %s!%n", adj);
              room.visited = false;
            }
          }
        }
        wumpusKB = newWumpusKB;
      }
      if (count == 1) {
        return hunter.create(privateToWorld.get(target), WumpusWorld.Arrow.class, options);
      }

      return null;
    }
Ejemplo n.º 7
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);

    if (anyWetWeather(lastWeather)) {
      if (ticking instanceof Room) {
        final Room R = (Room) ticking;
        final Area A = R.getArea();
        if ((!anyWetWeather(A.getClimateObj().weatherType(R)))
            && (!dryWeather(A.getClimateObj().weatherType(R)))
            && (CMLib.dice().rollPercentage() < pct()))
          makePuddle(R, lastWeather, A.getClimateObj().weatherType(R));
      } else if (ticking instanceof Area) {
        final Area A = (Area) ticking;
        if ((!anyWetWeather(A.getClimateObj().weatherType(null)))
            && (!dryWeather(A.getClimateObj().weatherType(null)))) {
          for (final Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            final Room R = e.nextElement();
            if (((R.domainType() & Room.INDOORS) == 0)
                && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
                && (!CMLib.flags().isWateryRoom(R))
                && (CMLib.dice().rollPercentage() < pct()))
              makePuddle(R, lastWeather, A.getClimateObj().weatherType(null));
          }
        }
      }
    }

    if (ticking instanceof Room)
      lastWeather = ((Room) ticking).getArea().getClimateObj().weatherType((Room) ticking);
    else if (ticking instanceof Area)
      lastWeather = ((Area) ticking).getClimateObj().weatherType(null);
    return true;
  }
  @Test
  public void testRoomObservers() {
    beanManager.fireEvent(new CleanEvent());

    Assert.assertTrue(hall.isClean());
    Assert.assertTrue(pit.isClean());
  }
Ejemplo n.º 9
0
  /**
   * Collects the canvas of thief that arrived.
   *
   * @param chiefId the id of the chief
   * @param thiefId the id of the thief that handed the canvas
   */
  @Override
  public void collectCanvas(int chiefId, int thiefId) {
    while (true) {

      HandCanvasMessage message =
          (HandCanvasMessage) this.chiefBroker.readMessage(THIEF_HAND_CANVAS_ACTION, thiefId);
      if (message != null) {

        Team team = (Team) this.teamsHash.get(message.getTeamId());
        if (team == null) {
          throw new IllegalArgumentException("Unknown team with id #" + message.getTeamId());
        }

        synchronized (this.chiefBroker) {
          if (message.rolledCanvas()) this.nrCollectedCanvas++;

          Room room = team.getAssignedRoom();
          if ((boolean) this.roomsStatus.get(room.getId()) && !message.rolledCanvas()) {
            this.roomsStatus.put(room.getId(), false);
            this.nrRoomsToBeRobed--;
          }
        }

        break;
      }
    }
  }
Ejemplo n.º 10
0
 // tears down a wall or door between two rooms
 public void buildCorridor(int x1, int y1, int x2, int y2) {
   Room room1 = Stable.instance().getRoom(x1, y1);
   Room room2 = Stable.instance().getRoom(x2, y2);
   room1.setSide(room2);
   room2.setSide(room1);
   return;
 }
  /**
   * Method that allows the Manager to view room availability by date.
   *
   * @param date date that Manager chooses to view
   * @author Aishwarya Borkar
   */
  public void updateViewByDay(Calendar date) {
    String roomInformation = "";
    for (int i = 0; i < roomList.size(); i++) {
      Room room = roomList.get(i);

      for (int j = 0; j < room.reservations.size(); j++) {

        Reservation r = room.reservations.get(j);

        if (r.occupied(date)) {
          room.setAvailable(false);
          for (ChangeListener l : listeners) {
            l.stateChanged(new ChangeEvent(this));
          }
          String email = r.getGuestEmail();
          AccountList al = new AccountList();

          if (al.accountFoundInList(email)) {
            roomInformation =
                "Guest "
                    + email
                    + "Price: "
                    + room.getRate()
                    + "Room number: "
                    + room.getRoomNumber();
          }
        } else {
          room.setAvailable(true);
          for (ChangeListener l : listeners) {
            l.stateChanged(new ChangeEvent(this));
          }
        }
      }
    }
  }
Ejemplo n.º 12
0
  public String renderMap(Room nextRoom) {
    Room currentRoom;
    Map currentMap = nextRoom.getMap();
    String[] roomDrawing;
    Room[] roomsArray = currentMap.getRooms();
    String mapDrawing = "\n";

    for (int[] row : currentMap.getMapCoordinates()) {
      //            mapDrawing = mapDrawing + "\n";
      for (int x = 0; x < 7; x++) {
        mapDrawing = mapDrawing + "\n";
        for (int mapCoordinates : row) {
          if (mapCoordinates == -1) {
            mapDrawing = mapDrawing + Wall.empty.getWall();
          } else {
            currentRoom = roomsArray[mapCoordinates];
            if (currentRoom.getRoomDrawing() == null) {
              mapDrawing = mapDrawing + Wall.empty.getWall();
            } else {
              mapDrawing = mapDrawing + currentRoom.getRoomDrawing()[x];
            }
          }
        }
      }
    }
    return mapDrawing;
  }
Ejemplo n.º 13
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Ejemplo n.º 14
0
 /** codes: -1=do nothing, 1=wind, 2=rain, 4=hot, 8=cold, 16=calm */
 public int weatherQue(Room R) {
   if (R == null) return WEATHERQUE_NADA;
   if ((R.domainType() & Room.INDOORS) > 0) return WEATHERQUE_NADA;
   switch (R.getArea().getClimateObj().weatherType(R)) {
     case Climate.WEATHER_BLIZZARD:
     case Climate.WEATHER_THUNDERSTORM:
     case Climate.WEATHER_HEAT_WAVE:
       return WEATHERQUE_NADA;
     case Climate.WEATHER_CLEAR:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN | WEATHERQUE_HOT | WEATHERQUE_COLD;
     case Climate.WEATHER_CLOUDY:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN;
     case Climate.WEATHER_DROUGHT:
       return WEATHERQUE_RAIN | WEATHERQUE_COLD;
     case Climate.WEATHER_DUSTSTORM:
       return WEATHERQUE_RAIN | WEATHERQUE_CALM | WEATHERQUE_COLD;
     case Climate.WEATHER_HAIL:
       return WEATHERQUE_HOT | WEATHERQUE_CALM;
     case Climate.WEATHER_RAIN:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN;
     case Climate.WEATHER_SLEET:
       return WEATHERQUE_HOT;
     case Climate.WEATHER_SNOW:
       return WEATHERQUE_WIND;
     case Climate.WEATHER_WINDY:
       return WEATHERQUE_RAIN;
     case Climate.WEATHER_WINTER_COLD:
       return WEATHERQUE_RAIN;
     default:
       return WEATHERQUE_CALM;
   }
 }
Ejemplo n.º 15
0
 public boolean processFollow(MOB mob, MOB tofollow, boolean quiet) {
   if (mob == null) return false;
   Room R = mob.location();
   if (R == null) return false;
   if (tofollow != null) {
     if (tofollow == mob) {
       return nofollow(mob, true, false);
     }
     if (mob.getGroupMembers(new HashSet<MOB>()).contains(tofollow)) {
       if (!quiet) mob.tell("You are already a member of " + tofollow.name() + "'s group!");
       return false;
     }
     if (nofollow(mob, false, false)) {
       CMMsg msg =
           CMClass.getMsg(
               mob,
               tofollow,
               null,
               CMMsg.MSG_FOLLOW,
               quiet ? null : "<S-NAME> follow(s) <T-NAMESELF>.");
       if (R.okMessage(mob, msg)) R.send(mob, msg);
       else return false;
     } else return false;
   } else return nofollow(mob, !quiet, quiet);
   return true;
 }
Ejemplo n.º 16
0
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null) {
     Room room = affected.location();
     if (affected.charStats().getClassLevel(this) >= 5) {
       if (CMLib.flags().isInDark(room)) {
         affectableState.setMana(affectableState.getMana() - (affectableState.getMana() / 4));
         affectableState.setMovement(
             affectableState.getMovement() - (affectableState.getMovement() / 4));
       } else if ((room.domainType() & Room.INDOORS) == 0)
         switch (room.getArea().getClimateObj().weatherType(room)) {
           case Climate.WEATHER_BLIZZARD:
           case Climate.WEATHER_CLOUDY:
           case Climate.WEATHER_DUSTSTORM:
           case Climate.WEATHER_HAIL:
           case Climate.WEATHER_RAIN:
           case Climate.WEATHER_SLEET:
           case Climate.WEATHER_SNOW:
           case Climate.WEATHER_THUNDERSTORM:
             break;
           default:
             affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 4));
             affectableState.setMovement(
                 affectableState.getMovement() + (affectableState.getMovement() / 4));
             break;
         }
     }
   }
 }
Ejemplo n.º 17
0
  /**
   * Try to in to one direction. If there is an exit, enter the new room, otherwise print an error
   * message.
   */
  private void goRoom(Command command) {
    if (!command.hasSecondWord()) {
      // if there is no second word, we don't know where to go...
      System.out.println("Go where?");
      return;
    }

    String direction =
        command.getSecondWord(); // direction is a string that is the second word, such as "east" or
    // "up"

    // Try to leave current room.
    Room currentRoom = roomList.get(currentRoomName);
    String nextRoomName = currentRoom.getExit(direction);
    Room nextRoom = roomList.get(nextRoomName);

    if (nextRoom == null) {
      System.out.println("There is no door!");
    } else {
      currentRoomName =
          nextRoomName; // The name of the current room is set to the name of the room we're going
      // into, which sets the current room to the next room.
      System.out.println(nextRoom.getLongDescription());
    }
  }
Ejemplo n.º 18
0
  public void affectEnvStats(Environmental affected, EnvStats affectableStats) {
    super.affectEnvStats(affected, affectableStats);
    if ((affected instanceof MOB) && (((MOB) affected).location() != null)) {
      MOB mob = (MOB) affected;
      Room room = mob.location();
      int classLevel = mob.charStats().getClassLevel(this);
      if ((CMLib.flags().isHidden(mob))
          && (classLevel >= 30)
          && ((room.domainType() & Room.INDOORS) == 0)
          && (room.domainType() != Room.DOMAIN_OUTDOORS_CITY))
        affectableStats.setDisposition(affectableStats.disposition() | EnvStats.IS_NOT_SEEN);

      if (classLevel >= 5) {
        if (CMLib.flags().isInDark(room))
          affectableStats.setAttackAdjustment(
              affectableStats.attackAdjustment() - ((classLevel / 5) + 1));
        else if ((room.domainType() & Room.INDOORS) == 0)
          switch (room.getArea().getClimateObj().weatherType(room)) {
            case Climate.WEATHER_BLIZZARD:
            case Climate.WEATHER_CLOUDY:
            case Climate.WEATHER_DUSTSTORM:
            case Climate.WEATHER_HAIL:
            case Climate.WEATHER_RAIN:
            case Climate.WEATHER_SLEET:
            case Climate.WEATHER_SNOW:
            case Climate.WEATHER_THUNDERSTORM:
              break;
            default:
              affectableStats.setAttackAdjustment(
                  affectableStats.attackAdjustment() + ((classLevel / 5) + 1));
              break;
          }
      }
    }
  }
Ejemplo n.º 19
0
 public void makePuddle(Room R, int oldWeather, int newWeather) {
   for (int i = 0; i < R.numItems(); i++) {
     final Item I = R.getItem(i);
     if ((I instanceof Drink)
         && (!CMLib.flags().isGettable(I))
         && ((I.name().toLowerCase().indexOf("puddle") >= 0)
             || (I.name().toLowerCase().indexOf("snow") >= 0))) return;
   }
   final Item I = CMClass.getItem("GenLiquidResource");
   CMLib.flags().setGettable(I, false);
   ((Drink) I).setLiquidHeld(100);
   ((Drink) I).setLiquidRemaining(100);
   ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER);
   I.setMaterial(RawMaterial.RESOURCE_FRESHWATER);
   I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE);
   CMLib.materials().addEffectsToResource(I);
   I.recoverPhyStats();
   if (coldWetWeather(oldWeather)) {
     I.setName(L("some snow"));
     I.setDisplayText(L("some snow rests on the ground here."));
     I.setDescription(L("the snow is white and still quite cold!"));
   } else {
     I.setName(L("a puddle of water"));
     I.setDisplayText(L("a puddle of water has formed here."));
     I.setDescription(L("It looks drinkable."));
   }
   R.addItem(I, ItemPossessor.Expire.Monster_EQ);
   R.recoverRoomStats();
 }
Ejemplo n.º 20
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

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

    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> speak(s) and gesture(s) to <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) much more likeable!"));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialVisualFizzle(
          mob,
          target,
          L("<S-NAME> incant(s) gracefully to <T-NAMESELF>, but nothing more happens."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 21
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (affected == null) return true;
   MOB mob = (MOB) affected;
   if ((msg.amISource(mob))
       && (mob.location() != null)
       && (msg.target() != null)
       && (msg.target() instanceof Room)) {
     if ((msg.sourceMinor() == CMMsg.TYP_ENTER)
         && ((mob.location().domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
             || (mob.location().domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))
         && (msg.target() == mob.location().getRoomInDir(Directions.UP))) {
       msg.source()
           .tell("Your water walking magic prevents you from ascending from the water surface.");
       return false;
     } else if ((msg.sourceMinor() == CMMsg.TYP_LEAVE)
         && (mob.location().domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
         && (mob.location().domainType() != Room.DOMAIN_INDOORS_WATERSURFACE)
         && (msg.tool() != null)
         && (msg.tool() instanceof Exit)) {
       for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
         Room R = mob.location().getRoomInDir(d);
         if ((R != null)
             && (mob.location().getReverseExit(d) == msg.tool())
             && ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
                 || (R.domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))) {
           triggerNow = true;
           msg.source().recoverEnvStats();
           return true;
         }
       }
     }
   }
   return true;
 }
Ejemplo n.º 22
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

      final MOB mob = (MOB) ticking;
      final Room thisRoom = mob.location();
      if (thisRoom.numItems() == 0) return true;

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
Ejemplo n.º 23
0
 public void kick(Player p, String name) {
   for (Room r : clanRooms) {
     if (r.getName().equalsIgnoreCase(p.clanRoom)) {
       r.kick(p, name);
     }
   }
 }
Ejemplo n.º 24
0
  /**
   * Given a configuration file, load the rooms, spawn points and players.
   *
   * @param filename - name of configuration file
   */
  public void loadRooms(String filename) {

    rooms.clear();
    // System.out.println("Loading level");
    try {
      Scanner sc;

      if (StealthGame.EXPORT) sc = new Scanner(ResourceLoader.load(filename));
      else sc = new Scanner(new File(filename));

      // int roomNum = 0;

      // Load rooms
      while (sc.hasNext()) {
        String roomFile = sc.nextLine();
        rooms.add(new Room("res/levels/" + roomFile));
      }

      sc.close();
    } catch (IOException e) {
      System.out.println("Level - Error loading file - IOException : " + e.getMessage());
    }

    // Initilise door destinations
    for (Room r : rooms) {
      r.initilizeDoors(rooms);
      spawns.addAll(r.getSpawns());
    }

    System.out.println("*** Done Loading level ***");
  }
  static Room newRoom(RoomType type, int capacity) {

    Room room = new Room();
    room.setType(type);
    room.setCapacity(capacity);
    return room;
  }
Ejemplo n.º 26
0
 public SortedSet<User> users() throws IOException {
   SortedSet<User> users = new ConcurrentSkipListSet<User>();
   for (Room room : rooms()) {
     users.addAll(room.users());
   }
   return users;
 }
Ejemplo n.º 27
0
  @Test
  public void testRoomExists() throws Exception {

    // create room in shape of '+' with five total
    // rooms ; one in center and one at each extremity
    Room base = new Room("test");
    Room up = new Room("test1");
    Room down = new Room("test2");
    Room left = new Room("test3");
    Room right = new Room("test4");

    // set base
    base.setLocation(up, down, left, right);

    // set up
    up.setLocation(Direction.NORTH, null);
    up.setLocation(Direction.SOUTH, base);
    up.setLocation(Direction.EAST, null);
    up.setLocation(Direction.WEST, null);

    // are there rooms around base?
    assertTrue(base.roomExists(Direction.NORTH));
    assertTrue(base.roomExists(Direction.SOUTH));
    assertTrue(base.roomExists(Direction.EAST));
    assertTrue(base.roomExists(Direction.WEST));

    // are there rooms around up?
    assertFalse(up.roomExists(Direction.NORTH));
    assertTrue(up.roomExists(Direction.SOUTH));
    assertFalse(up.roomExists(Direction.EAST));
    assertFalse(up.roomExists(Direction.WEST));
  }
Ejemplo n.º 28
0
 public List<Room> rooms() throws IOException {
   List<Room> rooms = connection.get("/rooms.json").parseAs(RoomList.class).rooms;
   for (Room room : rooms) {
     room.setConnection(connection);
   }
   return rooms;
 }
Ejemplo n.º 29
0
 public void reloadCharClasses(CharClass oldC) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
   }
 }
Ejemplo n.º 30
0
 public Set<MOB> getDeadMOBsFrom(Environmental whoE) {
   if (whoE instanceof MOB) {
     final MOB mob = (MOB) whoE;
     final Room room = mob.location();
     if (room != null) return getEveryoneHere(mob, room);
   } else if (whoE instanceof Item) {
     final Item item = (Item) whoE;
     final Environmental E = item.owner();
     if (E != null) {
       final Room room = getTickersRoom(whoE);
       if (room != null) {
         if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false))))
           return new XHashSet<MOB>((MOB) E);
         else if (E instanceof Room) return getEveryoneHere(null, (Room) E);
         room.recoverRoomStats();
       }
     }
   } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE);
   else if (whoE instanceof Area) {
     final Set<MOB> allMobs = new HashSet<MOB>();
     for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) {
       final Room R = (Room) r.nextElement();
       allMobs.addAll(getEveryoneHere(null, R));
     }
   }
   return new HashSet<MOB>();
 }