Search in sources :

Example 6 with PlayerStub

use of org.mage.test.stub.PlayerStub 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));
}
Also used : PlayerStub(org.mage.test.stub.PlayerStub) RoundPairings(mage.game.tournament.pairing.RoundPairings) TournamentPlayer(mage.game.tournament.TournamentPlayer) ArrayList(java.util.ArrayList) TournamentStub(org.mage.test.stub.TournamentStub) Round(mage.game.tournament.Round) TournamentPairing(mage.game.tournament.TournamentPairing) SwissPairingMinimalWeightMatching(mage.game.tournament.pairing.SwissPairingMinimalWeightMatching) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)6 Round (mage.game.tournament.Round)6 TournamentPairing (mage.game.tournament.TournamentPairing)6 TournamentPlayer (mage.game.tournament.TournamentPlayer)6 RoundPairings (mage.game.tournament.pairing.RoundPairings)6 SwissPairingMinimalWeightMatching (mage.game.tournament.pairing.SwissPairingMinimalWeightMatching)6 PlayerStub (org.mage.test.stub.PlayerStub)6 TournamentStub (org.mage.test.stub.TournamentStub)6 Test (org.junit.Test)5 HashSet (java.util.HashSet)1