private boolean notOtherGroupInTheNextRoom() { boolean retValue = false; if (actRoom.isEmptyNextRoom()) { retValue = true; } else if (actRoom.isSameNextRoomGroup(group)) { retValue = true; } return retValue; }
public boolean isSameNextRoomGroup(Group group) { boolean ret = true; synchronized (group) { if (!nextRoom.getPlayers().isEmpty()) { for (Player player : nextRoom.getPlayers()) { if (!player.getGroup().equals(group)) { ret = false; } } } } return ret; }
public synchronized void playerOut(Player player) { players.remove(player); if (nextRoom != null) { nextRoom.getPlayers().add(player); } if (players.size() == 0) { scares.set(0); } }
public synchronized boolean isAnyBodyInTheNextRoomWithMyGroup(Group group) { boolean retValue = false; for (Player player : group.getPlayers()) { if (nextRoom.getPlayers().contains(player)) { retValue = true; } } return retValue; }
public void run() { // System.out.println("name: " + this.name); while (!(this.getActRoom().equals(House.poison))) { try { if (scary.get() <= 0) { shocking(); } if (group.isEveryBodyInTheRoom(actRoom)) { if (notOtherGroupInTheNextRoom()) { if (isBoring) { gotoNextRoom(); NotBoring(); } else { moveBoring(); } } } else if (actRoom.isAnyBodyInTheNextRoomWithMyGroup(group)) { if (isBoring) { gotoNextRoom(); NotBoring(); } else { moveBoring(); } } else { moveBoring(); // System.out.println("Unatkozom: " + name); } } catch (Exception e) { e.printStackTrace(); } // System.out.println(this.getName()+" szoba: "+this.actRoom.getName()); } actRoom.playerOut(this); // System.out.println("WIN: " + name); }
public void gotoNextRoom() { Room temp = actRoom; temp.playerOut(this); if (temp.getPlayers().size() == 0) { temp.setScares(new AtomicInteger(0)); } actRoom = temp.getNextRoom(); actRoom.playerIn(this); }
private void killAllRoom() { for (Room room : house.getRooms()) { room.setIsScary(new AtomicBoolean(false)); room.shutdownHorrorPlayers(); } }
public synchronized void playerIn(Player player) { if (previousRoom != null) { previousRoom.getPlayers().remove(player); } players.add(player); }
public boolean isEmptyNextRoom() { return (nextRoom.getPlayers().size() == 0); }