use of mage.game.result.ResultProtos.TourneyProto in project mage by magefree.
the class TournamentImpl method toProto.
@Override
public TourneyProto toProto() {
TourneyProto.Builder tourneyBuilder = TourneyProto.newBuilder().setBoosterInfo(this.getBoosterInfo());
for (TournamentPlayer player : players.values()) {
TournamentPlayer replacedPlayer = player.getReplacedTournamentPlayer();
if (replacedPlayer != null) {
player = replacedPlayer;
}
tourneyBuilder.addPlayersBuilder().mergeFrom(player.toProto());
}
for (Round round : rounds) {
TourneyRoundProto.Builder roundBuilder = tourneyBuilder.addRoundsBuilder().setRound(round.getRoundNumber());
for (TournamentPairing pair : round.getPairs()) {
Match match = pair.getMatch();
if (match != null && match.hasEnded()) {
MatchProto.Builder matchBuilder = roundBuilder.addMatchesBuilder().setName(match.getName()).setGameType(match.getOptions().getGameType()).setDeckType(match.getOptions().getDeckType()).setGames(match.getNumGames()).setDraws(match.getDraws()).addPlayers(matchToProto(match, pair.getPlayer1())).addPlayers(matchToProto(match, pair.getPlayer2())).setMatchOptions(match.getOptions().toProto()).setEndTimeMs((match.getEndTime() != null ? match.getEndTime() : new Date()).getTime());
}
}
for (TournamentPlayer tp : round.getPlayerByes()) {
roundBuilder.addByes(tp.getPlayer().getName());
}
}
return tourneyBuilder.build();
}
Aggregations