Search in sources :

Example 1 with MatchQuitStatus

use of mage.game.result.ResultProtos.MatchQuitStatus in project mage by magefree.

the class MatchImpl method toProto.

@Override
public MatchProto toProto() {
    MatchProto.Builder builder = MatchProto.newBuilder().setName(this.getName()).setGameType(this.getOptions().getGameType()).setDeckType(this.getOptions().getDeckType()).setGames(this.getNumGames()).setDraws(this.getDraws()).setMatchOptions(this.getOptions().toProto()).setEndTimeMs((this.getEndTime() != null ? this.getEndTime() : new Date()).getTime());
    for (MatchPlayer matchPlayer : this.getPlayers()) {
        MatchQuitStatus status = !matchPlayer.hasQuit() ? MatchQuitStatus.NO_MATCH_QUIT : matchPlayer.getPlayer().hasTimerTimeout() ? MatchQuitStatus.TIMER_TIMEOUT : matchPlayer.getPlayer().hasIdleTimeout() ? MatchQuitStatus.IDLE_TIMEOUT : MatchQuitStatus.QUIT;
        builder.addPlayersBuilder().setName(matchPlayer.getName()).setHuman(matchPlayer.getPlayer().isHuman()).setQuit(status).setWins(matchPlayer.getWins());
    }
    return builder.build();
}
Also used : MatchQuitStatus(mage.game.result.ResultProtos.MatchQuitStatus) MatchProto(mage.game.result.ResultProtos.MatchProto)

Example 2 with MatchQuitStatus

use of mage.game.result.ResultProtos.MatchQuitStatus in project mage by magefree.

the class TournamentImpl method matchToProto.

private MatchPlayerProto matchToProto(Match match, TournamentPlayer player) {
    MatchPlayer matchPlayer = match.getPlayer(player.getPlayer().getId());
    MatchQuitStatus quit = !matchPlayer.hasQuit() ? MatchQuitStatus.NO_MATCH_QUIT : matchPlayer.getPlayer().hasIdleTimeout() ? MatchQuitStatus.IDLE_TIMEOUT : matchPlayer.getPlayer().hasTimerTimeout() ? MatchQuitStatus.TIMER_TIMEOUT : MatchQuitStatus.QUIT;
    return MatchPlayerProto.newBuilder().setName(player.getPlayer().getName()).setHuman(player.getPlayer().isHuman()).setWins(matchPlayer.getWins()).setQuit(quit).build();
}
Also used : MatchQuitStatus(mage.game.result.ResultProtos.MatchQuitStatus) MatchPlayer(mage.game.match.MatchPlayer)

Aggregations

MatchQuitStatus (mage.game.result.ResultProtos.MatchQuitStatus)2 MatchPlayer (mage.game.match.MatchPlayer)1 MatchProto (mage.game.result.ResultProtos.MatchProto)1