Package mage.game.match

Examples of mage.game.match.MatchPlayer


    /**
     * Called by eliminate tournaments after each match
     */
    public void eliminatePlayers() {
        if (match != null && match.hasEnded()) {
            MatchPlayer mPlayer1 = match.getPlayer(player1.getPlayer().getId());
            MatchPlayer mPlayer2 = match.getPlayer(player2.getPlayer().getId());
            if (mPlayer1.hasQuit() || !mPlayer1.isMatchWinner()) {
                player1.setEliminated();
            }
            if (mPlayer2.hasQuit() || !mPlayer2.isMatchWinner()) {
                player2.setEliminated();
            }
        }
    }
View Full Code Here


            for (TournamentPairing pair: round.getPairs()) {
                Match match = pair.getMatch();
                if (match != null && match.hasEnded()) {
                    TournamentPlayer tp1 = pair.getPlayer1();
                    TournamentPlayer tp2 = pair.getPlayer2();
                    MatchPlayer mp1 = match.getPlayer(pair.getPlayer1().getPlayer().getId());
                    MatchPlayer mp2 = match.getPlayer(pair.getPlayer2().getPlayer().getId());
                    // set player state if he finished the round
                    if (round.getRoundNumber() == rounds.size()) { // for elimination getRoundNumber = 0 so never true here
                        match.setTournamentRound(round.getRoundNumber());
                        if (tp1.getState().equals(TournamentPlayerState.DUELING)) {
                            if (round.getRoundNumber() == getNumberRounds()) {
                                tp1.setState(TournamentPlayerState.FINISHED);
                            } else {
                                tp1.setState(TournamentPlayerState.WAITING);
                            }
                        }
                        if (tp2.getState().equals(TournamentPlayerState.DUELING)) {
                            if (round.getRoundNumber() == getNumberRounds()) {
                                tp2.setState(TournamentPlayerState.FINISHED);
                            } else {
                                tp2.setState(TournamentPlayerState.WAITING);
                            }
                        }
                    }
                    // Add round result
                    tp1.setResults(addRoundResult(round.getRoundNumber(), pair, tp1, tp2));
                    tp2.setResults(addRoundResult(round.getRoundNumber(), pair, tp2, tp1));

                    // Add points
                    if (mp2.hasQuit() || mp1.getWins() > mp2.getWins()) {
                        tp1.setPoints(tp1.getPoints() + 3);
                    } else if (mp1.hasQuit() || mp1.getWins() < mp2.getWins()) {
                        tp2.setPoints(tp2.getPoints() + 3);
                    } else {
                        tp1.setPoints(tp1.getPoints() + 1);
                        tp2.setPoints(tp2.getPoints() + 1);
                    }
View Full Code Here

        playerResult.append(getMatchResultString(tournamentPlayer, opponentPlayer, pair.getMatch()));
        return playerResult.toString();
    }
   
    private static String getMatchResultString(TournamentPlayer p1, TournamentPlayer p2, Match match) {
        MatchPlayer mp1 = match.getPlayer(p1.getPlayer().getId());
        MatchPlayer mp2 = match.getPlayer(p2.getPlayer().getId());
        StringBuilder matchResult = new StringBuilder();
        matchResult.append(p2.getPlayer().getName());
        matchResult.append(" [").append(mp1.getWins());
        if (mp1.hasQuit()) {
            matchResult.append(mp1.getPlayer().hasIdleTimeout()? "I" :(mp1.getPlayer().hasTimerTimeout()?"T":"Q"));
        }
        if (match.getDraws() > 0) {
            matchResult.append("-").append(match.getDraws());
        }
        matchResult.append("-").append(mp2.getWins());
        if (mp2.hasQuit()) {
            matchResult.append(mp2.getPlayer().hasIdleTimeout()? "I" :(mp2.getPlayer().hasTimerTimeout()?"T":"Q"));
        }               
        matchResult.append("] ");
        return matchResult.toString();
    }
View Full Code Here

            if (player == null || player.hasQuit()) {
                return true; // so the construct panel closes after submit
            }
        } else {
            if (table.getMatch() != null) {
                MatchPlayer mPlayer = table.getMatch().getPlayer(playerId);
                if (mPlayer == null || mPlayer.hasQuit()) {
                    return true; // so the construct panel closes after submit
                }
                if (table.isTournamentSubTable()) {
                    TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(mPlayer.getPlayer().getId());
                    if (tournamentPlayer != null) {
                        tournamentPlayer.setStateInfo(""); // reset sideboarding state
                    }
                }
            }
View Full Code Here

                        logger.debug("Quit tournament sub tables for userId: " + userId);
                        TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
                        logger.debug("Quit tournament  Id: " + table.getTournament().getId() + "(" +table.getTournament().getTournamentState() + ")");
                        TournamentManager.getInstance().quit(tournament.getId(), userId);
                    } else {
                        MatchPlayer matchPlayer = match.getPlayer(playerId);
                        if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
                            Game game = match.getGame();
                            if (game != null && !game.hasEnded()){
                                Player player = match.getPlayer(playerId).getPlayer();
                                if (player != null && player.isInGame()) {
                                    GameManager.getInstance().quitMatch(game.getId(), userId);
                                }
                                match.quitMatch(playerId);
                            } else {                               
                                if (table.getState().equals(TableState.SIDEBOARDING)) {
                                    if (!matchPlayer.isDoneSideboarding()) {
                                        // submit deck to finish sideboarding and trigger match start / end
                                        matchPlayer.submitDeck(matchPlayer.getDeck());
                                    }
                                }
                                match.quitMatch(playerId);
                            }
                        }
View Full Code Here

                            }
                            opponent.append(user.getName());
                        }
                    } else {
                        logger.error("Unable to find user: " + entry.getKey() + "  playerId: " + entry.getValue());
                        MatchPlayer matchPlayer = match.getPlayer(entry.getValue());
                        if (matchPlayer != null && !matchPlayer.hasQuit()) {
                            matchPlayer.setQuit(true);
                        }
                    }
                }
            }
            // Append AI opponents to the log file
View Full Code Here

    }

    private void matchEnd() {
        if (match != null) {
            for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
                MatchPlayer matchPlayer = match.getPlayer(entry.getValue());
                // opponent(s) left during sideboarding
                if (matchPlayer != null) {
                    if(!matchPlayer.hasQuit()) {
                        User user = UserManager.getInstance().getUser(entry.getKey());
                        if (user != null) {
                            if (table.getState().equals(TableState.SIDEBOARDING)) {
                                StringBuilder sb = new StringBuilder();
                                if (table.isTournamentSubTable()) {
View Full Code Here

                    }
                }
            }
            // check for active players
            for(Map.Entry<UUID, UUID> userPlayerEntry: userPlayerMap.entrySet()) {
                MatchPlayer matchPlayer = match.getPlayer(userPlayerEntry.getValue());
                if (matchPlayer == null) {
                    logger.debug("- Match player not found:");
                    logger.debug("-- matchId:" + match.getId());
                    logger.debug("-- userId:" + userPlayerEntry.getKey());
                    logger.debug("-- playerId:" + userPlayerEntry.getValue());
                    continue;
                }
                if (matchPlayer.getPlayer().isHuman()) {
                    humanPlayers++;                   
                    if ((table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START)) ||
                            !match.isDoneSideboarding() ||
                            (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
                        User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
                        if (user == null) {
                            logger.debug("- Active user of match is missing: " + matchPlayer.getName());
                            logger.debug("-- matchId:" + match.getId());
                            logger.debug("-- userId:" + userPlayerEntry.getKey());
                            logger.debug("-- playerId:" + userPlayerEntry.getValue());
                            return false;
                        }
View Full Code Here

            }
        }
        matchView = new MatchView(table);

        Match match = table.getMatch();
        MatchPlayer matchWinner = null;
        winsNeeded = match.getOptions().getWinsNeeded();
        StringBuilder additonalText = new StringBuilder();
        for (MatchPlayer matchPlayer: match.getPlayers()) {
            if (matchPlayer.getPlayer().equals(you)) {
                wins = matchPlayer.getWins();
            }
            if (matchPlayer.isMatchWinner()) {
                matchWinner = matchPlayer;
            }
            if (matchPlayer.getPlayer().hasTimerTimeout()) {
                if (matchPlayer.getPlayer().equals(you)) {
                    additonalText.append("You run out of time. ");
                } else {
                    additonalText.append(matchPlayer.getName()).append(" runs out of time. ");
                }
            } else if (matchPlayer.getPlayer().hasIdleTimeout()) {
                if (matchPlayer.getPlayer().equals(you)) {
                    additonalText.append("You lost the match for beeing idle. ");
                } else {
                    additonalText.append(matchPlayer.getName()).append(" lost for beeing idle. ");
                }
            } else if (matchPlayer.hasQuit()) {
                if (matchPlayer.getPlayer().equals(you)) {
                    additonalText.append("You have quit the match. ");
                } else {
                    additonalText.append(matchPlayer.getName()).append(" has quit the match. ");
                }
            }
        }

        if (matchWinner != null) {
            if (matchWinner.getPlayer().equals(you)) {
                matchInfo = "You won the match!";
            } else {
                matchInfo = new StringBuilder(matchWinner.getName()).append(" won the match!").toString();
            }
        } else {
            matchInfo = new StringBuilder("You need ").append(winsNeeded - wins == 1 ? "one more win ":winsNeeded - wins + " more wins ").append("to win the match.").toString();
        }
        additionalInfo = additonalText.toString();
View Full Code Here

TOP

Related Classes of mage.game.match.MatchPlayer

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.