public UUID createGameSession(Game game, ConcurrentHashMap<UUID, UUID> userPlayerMap, UUID tableId, UUID choosingPlayerId, GameOptions gameOptions) { GameController gameController = new GameController(game, userPlayerMap, tableId, choosingPlayerId, gameOptions); final Lock w = gameControllersLock.writeLock(); w.lock(); try { gameControllers.put(game.getId(), gameController); } finally { w.unlock(); } return gameController.getSessionId(); }
public void gameError(final String message) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ERROR, game.getId(), message))); } }
public void chooseAbility(final AbilityPickerView abilities) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_ABILITY, game.getId(), abilities))); } }
public boolean init() { if (!killed) { Optional<User> user = UserManager.instance.getUser(userId); if (user.isPresent()) { user.get().fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INIT, game.getId(), getGameView())); return true; } } return false; }
public void endGameInfo(Table table) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.END_GAME_INFO, game.getId(), getGameEndView(playerId, table)))); } }
public void update() { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_UPDATE, game.getId(), getGameView()))); } }
public void getAmount(final String message, final int min, final int max) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> { user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_AMOUNT, game.getId(), new GameClientMessage(message, min, max))); }); } }
public void chooseChoice(final Choice choice) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_CHOICE, game.getId(), new GameClientMessage(choice)))); } }
public void choosePile(final String message, final CardsView pile1, final CardsView pile2) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_PILE, game.getId(), new GameClientMessage(message, pile1, pile2)))); } }
public void select(final String message, final Map<String, Serializable> options) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_SELECT, game.getId(), new GameClientMessage(getGameView(), message, options)))); } }
public void playXMana(final String message) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_XMANA, game.getId(), new GameClientMessage(getGameView(), message)))); } }
public void informPersonal(final String message) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM_PERSONAL, game.getId(), new GameClientMessage(getGameView(), message)))); } }
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> { user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options))); }); } }
public void playMana(final String message, final Map<String, Serializable> options) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_MANA, game.getId(), new GameClientMessage(getGameView(), message, options)))); } }
public void inform(final String message) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM, game.getId(), new GameClientMessage(getGameView(), message)))); } }
public void ask(final String question, final Map<String, Serializable> options) { if (!killed) { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ASK, game.getId(), new GameClientMessage(getGameView(), question, options))) ); } }
private void updateGame(final GameState state, Game game) { if (state == null) { gameResult("game ended"); } else { UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_UPDATE, replay.getGame().getId(), new GameView(state, game, null, null)))); } }
public void replay() { replay.start(); UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_INIT, replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null)))); }