spjspj - Add option of 'Number of Seats'. This is for Tournaments so that you can draft say a 4 way draft and then have a 4 way game at the end of it.

This commit is contained in:
spjspj 2016-09-25 00:46:16 +10:00
parent 101a1db649
commit 16bb17e5bb
14 changed files with 366 additions and 60 deletions

View file

@ -56,13 +56,19 @@ public abstract class TournamentSwiss extends TournamentImpl {
}
}
while (this.getActivePlayers().size() > 1 && this.getNumberRounds() > this.getRounds().size()) {
// check if some player got killed / disconnected meanwhile and update their state
tableEventSource.fireTableEvent(TableEvent.EventType.CHECK_STATE_PLAYERS);
// Swiss pairing
Round round = createRoundSwiss();
playRound(round);
if (options.matchOptions.getNumSeats() == 2) {
while (this.getActivePlayers().size() > 1 && this.getNumberRounds() > this.getRounds().size()) {
// check if some player got killed / disconnected meanwhile and update their state
tableEventSource.fireTableEvent(TableEvent.EventType.CHECK_STATE_PLAYERS);
// Swiss pairing
Round round = createRoundSwiss();
playRound(round);
}
} else {
MultiplayerRound round = createMultiplayerRound();
playMultiplayerRound(round);
}
nextStep();
}
@ -70,33 +76,60 @@ public abstract class TournamentSwiss extends TournamentImpl {
List<TournamentPlayer> roundPlayers = getActivePlayers();
boolean isLastRound = (rounds.size() + 1 == getNumberRounds());
RoundPairings roundPairings;
if (roundPlayers.size() <= 16) {
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(roundPlayers, rounds, isLastRound);
roundPairings = swissPairing.getRoundPairings();
} else {
SwissPairingSimple swissPairing = new SwissPairingSimple(roundPlayers, rounds);
roundPairings = swissPairing.getRoundPairings();
}
Round round = new Round(rounds.size() + 1, this);
rounds.add(round);
for (TournamentPairing pairing : roundPairings.getPairings()) {
round.addPairing(pairing);
}
for (TournamentPlayer playerBye : roundPairings.getPlayerByes()) {
// player free round - add to bye players of this round
round.getPlayerByes().add(playerBye);
if (isLastRound) {
playerBye.setState(TournamentPlayerState.FINISHED);
Round round = null;
if (options.matchOptions.getNumSeats() == 2) {
RoundPairings roundPairings;
if (roundPlayers.size() <= 16) {
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(roundPlayers, rounds, isLastRound);
roundPairings = swissPairing.getRoundPairings();
} else {
playerBye.setState(TournamentPlayerState.WAITING);
SwissPairingSimple swissPairing = new SwissPairingSimple(roundPlayers, rounds);
roundPairings = swissPairing.getRoundPairings();
}
round = new Round(rounds.size() + 1, this);
rounds.add(round);
for (TournamentPairing pairing : roundPairings.getPairings()) {
round.addPairing(pairing);
}
for (TournamentPlayer playerBye : roundPairings.getPlayerByes()) {
// player free round - add to bye players of this round
round.getPlayerByes().add(playerBye);
if (isLastRound) {
playerBye.setState(TournamentPlayerState.FINISHED);
} else {
playerBye.setState(TournamentPlayerState.WAITING);
}
playerBye.setStateInfo("Round Bye");
updateResults();
}
playerBye.setStateInfo("Round Bye");
updateResults();
}
return round;
}
public MultiplayerRound createMultiplayerRound() {
List<TournamentPlayer> roundPlayers = getActivePlayers();
boolean isLastRound = (rounds.size() + 1 == getNumberRounds());
MultiplayerRound round = null;
if (options.matchOptions.getNumSeats() > 2) {
RoundPairings roundPairings;
if (roundPlayers.size() <= 16) {
SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(roundPlayers, rounds, isLastRound);
roundPairings = swissPairing.getRoundPairings();
} else {
SwissPairingSimple swissPairing = new SwissPairingSimple(roundPlayers, rounds);
roundPairings = swissPairing.getRoundPairings();
}
round = new MultiplayerRound(rounds.size() + 1, this, options.matchOptions.getNumSeats());
for (TournamentPairing pairing : roundPairings.getPairings()) {
round.addPairing(pairing);
}
}
return round;
}
}