use of mage.game.tournament.TournamentPlayer in project mage by magefree.
the class SwissPairingMinimalWeightMatchingTest method PlayerLeftTournamentAfterFirstRound.
@Test
public void PlayerLeftTournamentAfterFirstRound() {
// 1 > 3
// 2 > 4
// 4 left the tournament
TournamentPlayer player1 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player2 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player3 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player4 = new TournamentPlayer(new PlayerStub(), null);
List<TournamentPlayer> players = new ArrayList<>();
// players.add(player4); -- player 4 is not active
players.add(player2);
players.add(player3);
players.add(player1);
player1.setPoints(3);
player2.setPoints(3);
player3.setPoints(0);
player4.setPoints(0);
List<Round> rounds = new ArrayList<>();
Round round = new Round(1, new TournamentStub());
TournamentPairing pair1 = new TournamentPairing(player1, player3);
round.addPairing(pair1);
TournamentPairing pair2 = new TournamentPairing(player4, player2);
round.addPairing(pair2);
rounds.add(round);
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(players, rounds, false);
RoundPairings roundPairings = swissPairing.getRoundPairings();
Assert.assertEquals(1, roundPairings.getPairings().size());
Assert.assertEquals(1, roundPairings.getPlayerByes().size());
CheckPair(roundPairings.getPairings(), player1, player2);
Assert.assertTrue(roundPairings.getPlayerByes().contains(player3));
}
use of mage.game.tournament.TournamentPlayer in project mage by magefree.
the class SwissPairingMinimalWeightMatchingTest method FourPlayersSecondThirdTest.
@Test
public void FourPlayersSecondThirdTest() {
// 1 > 3
// 2 > 4
//
// 1 > 2
// 3 > 4
TournamentPlayer player3 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player2 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player4 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player1 = new TournamentPlayer(new PlayerStub(), null);
List<TournamentPlayer> players = new ArrayList<>();
players.add(player4);
players.add(player2);
players.add(player3);
players.add(player1);
player1.setPoints(6);
player2.setPoints(3);
player3.setPoints(3);
player4.setPoints(0);
List<Round> rounds = new ArrayList<>();
// round 1
Round round = new Round(1, new TournamentStub());
TournamentPairing pair1 = new TournamentPairing(player1, player3);
round.addPairing(pair1);
TournamentPairing pair2 = new TournamentPairing(player4, player2);
round.addPairing(pair2);
rounds.add(round);
// round 2
round = new Round(2, new TournamentStub());
pair1 = new TournamentPairing(player2, player1);
round.addPairing(pair1);
pair2 = new TournamentPairing(player4, player3);
round.addPairing(pair2);
rounds.add(round);
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(players, rounds, true);
RoundPairings roundPairings = swissPairing.getRoundPairings();
Assert.assertEquals(2, roundPairings.getPairings().size());
Assert.assertEquals(0, roundPairings.getPlayerByes().size());
CheckPair(roundPairings.getPairings(), player1, player4);
CheckPair(roundPairings.getPairings(), player2, player3);
Assert.assertEquals(0, roundPairings.getPlayerByes().size());
}
use of mage.game.tournament.TournamentPlayer in project mage by magefree.
the class SwissPairingMinimalWeightMatchingTest method FourPlayersSecondRoundTest.
@Test
public void FourPlayersSecondRoundTest() {
// 1 > 3
// 2 > 4
TournamentPlayer player1 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player2 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player3 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player4 = new TournamentPlayer(new PlayerStub(), null);
List<TournamentPlayer> players = new ArrayList<>();
players.add(player4);
players.add(player2);
players.add(player3);
players.add(player1);
player1.setPoints(3);
player2.setPoints(3);
player3.setPoints(0);
player4.setPoints(0);
List<Round> rounds = new ArrayList<>();
Round round = new Round(1, new TournamentStub());
TournamentPairing pair1 = new TournamentPairing(player1, player3);
round.addPairing(pair1);
TournamentPairing pair2 = new TournamentPairing(player4, player2);
round.addPairing(pair2);
rounds.add(round);
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(players, rounds, false);
RoundPairings roundPairings = swissPairing.getRoundPairings();
Assert.assertEquals(2, roundPairings.getPairings().size());
Assert.assertEquals(0, roundPairings.getPlayerByes().size());
CheckPair(roundPairings.getPairings(), player1, player2);
CheckPair(roundPairings.getPairings(), player3, player4);
Assert.assertEquals(0, roundPairings.getPlayerByes().size());
}
use of mage.game.tournament.TournamentPlayer in project mage by magefree.
the class SwissPairingMinimalWeightMatchingTest method FivePlayersThirdRoundTest.
@Test
public void FivePlayersThirdRoundTest() {
// 1 > 2
// 3 > 4
// 5
//
// 1 > 5
// 2 > 3
// 4
TournamentPlayer player1 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player2 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player3 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player4 = new TournamentPlayer(new PlayerStub(), null);
TournamentPlayer player5 = new TournamentPlayer(new PlayerStub(), null);
List<TournamentPlayer> players = new ArrayList<>();
players.add(player4);
players.add(player2);
players.add(player5);
players.add(player3);
players.add(player1);
player1.setPoints(6);
player2.setPoints(3);
player3.setPoints(3);
player4.setPoints(3);
player5.setPoints(3);
List<Round> rounds = new ArrayList<>();
// first round
Round round = new Round(1, new TournamentStub());
TournamentPairing pair1 = new TournamentPairing(player1, player2);
round.addPairing(pair1);
TournamentPairing pair2 = new TournamentPairing(player3, player4);
round.addPairing(pair2);
round.getPlayerByes().add(player5);
rounds.add(round);
// second round
round = new Round(1, new TournamentStub());
pair1 = new TournamentPairing(player1, player5);
round.addPairing(pair1);
pair2 = new TournamentPairing(player2, player3);
round.addPairing(pair2);
round.getPlayerByes().add(player4);
rounds.add(round);
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(players, rounds, false);
RoundPairings roundPairings = swissPairing.getRoundPairings();
Assert.assertEquals(2, roundPairings.getPairings().size());
Assert.assertEquals(1, roundPairings.getPlayerByes().size());
CheckPair(roundPairings.getPairings(), player1, player4);
CheckPair(roundPairings.getPairings(), player2, player5);
Assert.assertTrue(roundPairings.getPlayerByes().contains(player3));
}
use of mage.game.tournament.TournamentPlayer in project mage by magefree.
the class MatchView method initTournamentTable.
// used for tournaments
private void initTournamentTable(Table table) {
this.matchId = table.getTournament().getId();
this.matchName = table.getName();
this.gameType = table.getGameType();
if (table.getTournament().getOptions().getNumberRounds() > 0) {
this.gameType = new StringBuilder(this.gameType).append(' ').append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
}
StringBuilder sbDeckType = new StringBuilder(table.getDeckType());
if (!table.getTournament().getBoosterInfo().isEmpty()) {
sbDeckType.append(' ').append(table.getTournament().getBoosterInfo());
}
if (table.getName() != null && !table.getName().isEmpty()) {
sbDeckType.append(table.getDeckType()).append(" [").append(table.getName()).append(']');
}
this.deckType = sbDeckType.toString();
StringBuilder sb1 = new StringBuilder();
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
sb1.append(tPlayer.getPlayer().getName()).append(" (").append(tPlayer.getPoints()).append(" P.) ");
}
this.players = sb1.toString();
StringBuilder sb2 = new StringBuilder();
if (!table.getTournament().getRounds().isEmpty()) {
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
sb2.append(tPlayer.getPlayer().getName()).append(": ").append(tPlayer.getResults()).append(' ');
}
} else {
sb2.append("Canceled");
}
this.result = sb2.toString();
this.startTime = table.getTournament().getStartTime();
this.endTime = table.getTournament().getEndTime();
this.replayAvailable = false;
this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
}
Aggregations