Package mage.game

Examples of mage.game.Table


    }
  }

  @Override
  public TableView createTable(UUID sessionId, String gameType, String deckType, List<String> playerTypes, MultiplayerAttackOption attackOption, RangeOfInfluence range) {
    Table table = TableManager.getInstance().createTable(sessionId, gameType, deckType, playerTypes, attackOption, range);
    tables.put(table.getId(), table);
    return new TableView(table);
  }
View Full Code Here


  public TableController(UUID sessionId, String gameType, String deckType, List<String> playerTypes, MultiplayerAttackOption attackOption, RangeOfInfluence range) {
    this.sessionId = sessionId;
    chatId = ChatManager.getInstance().createChatSession();
    game = GameFactory.getInstance().createGame(gameType, attackOption, range);
    gameId = game.getId();
    table = new Table(gameType, DeckValidatorFactory.getInstance().createDeckValidator(deckType), playerTypes);
  }
View Full Code Here

                if (session == null) {
                    logger.error("Session not found sessionId: "+ sessionId + "  draftId:" + draftId);
                    return;
                }
                UUID tableId = DraftManager.getInstance().getControllerByDraftId(draftId).getTableId();
                Table table = TableManager.getInstance().getTable(tableId);
                if (table.isTournament()) {
                    UUID tournamentId = table.getTournament().getId();
                    TournamentManager.getInstance().quit(tournamentId, session.getUserId());
                }
            }
        });
    }
View Full Code Here

            gameWatcher.update();
        }
    }

    private synchronized void endGameInfo() {
        Table table = TableManager.getInstance().getTable(tableId);
        if (table != null) {
            if (table.getMatch() != null) {
                for (final GameSession gameSession: gameSessions.values()) {
                    gameSession.endGameInfo(table);
                }
            }
        }
View Full Code Here

            controllerName = user.getName();
        }
        else {
            controllerName = "System";
        }
        table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
        chatId = ChatManager.getInstance().createChatSession("Match Table " + table.getId());       
        init();
    }
View Full Code Here

            }
        }
        else {
            controllerName = "System";
        }
        table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
        chatId = ChatManager.getInstance().createChatSession("Tourn. table " + table.getId());       
    }
View Full Code Here

        tables.remove(tableId);
    }

    @Override
    public void removeTable(UUID tableId) {
        Table table = tables.get(tableId);
        if (table != null) {
            table.cleanUp();
            tables.remove(tableId);
            if (logger.isDebugEnabled()) {
                logger.debug("Table removed: " + tableId);
            }
        }
View Full Code Here

        TableController tableController = controllers.get(tableId);           
        if (tableController != null) {
            controllers.remove(tableId);
            tableController.cleanUp()// deletes the table chat and references to users          
           
            Table table = tables.get(tableId);
            tables.remove(tableId);
            Match match = table.getMatch();
            Game game = null;
            if (match != null) {
                game = match.getGame();
                if (game != null && !game.hasEnded()) {
                    game.end();
                }               
            }
                       
            // If table is not finished, the table has to be removed completly because it's not a normal state (if finished it will be removed in GamesRoomImpl.Update())
            if (!table.getState().equals(TableState.FINISHED)) {
                if (game != null) {
                    GameManager.getInstance().removeGame(game.getId());
                }
                GamesRoomManager.getInstance().removeTable(tableId);
            }
View Full Code Here

        int draft = 0, match = 0, sideboard = 0, tournament = 0, construct = 0, waiting = 0;

        for (Map.Entry<UUID, Table> tableEntry : tables.entrySet()) {
            if (tableEntry != null) {
                Table table = tableEntry.getValue();
                if (table != null) {
                    if (table.isTournament()) {
                        if (tableEntry.getKey() != null) {
                            TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(tableEntry.getKey());
                            if (tournamentPlayer != null) {
                                if (!tournamentPlayer.isEliminated()) {
                                    switch (table.getState()) {
                                        case WAITING:
                                        case STARTING:
                                        case READY_TO_START:
                                            waiting++;
                                            break;
                                        case CONSTRUCTING:
                                            construct++;
                                            break;
                                        case DRAFTING:
                                            draft++;
                                            break;
                                        case DUELING:
                                            tournament++;
                                            break;
                                    }

                                    if (!isConnected()) {
                                        tournamentPlayer.setDisconnectInfo(" (discon. "+ getDisconnectDuration() + ")");
                                    } else {
                                        tournamentPlayer.setDisconnectInfo("");
                                    }
                                }
                            } else {
                                // can happen if tournamet has just ended
                                logger.debug(getName() + " tournament player missing - tableId:" + table.getId(), null);
                            }
                        } else {
                            logger.error(getName() + " tournament key missing - tableId: " + table.getId(), null);
                        }
                    } else {
                        switch (table.getState()) {
                            case WAITING:
                            case STARTING:
                            case READY_TO_START:
                                waiting++;
                                break;
View Full Code Here

        }
    }

    @Override
    public TableView createTable(UUID userId, MatchOptions options) {
        Table table = TableManager.getInstance().createTable(this.getRoomId(), userId, options);
        tables.put(table.getId(), table);
        return new TableView(table);
    }
View Full Code Here

TOP

Related Classes of mage.game.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.