Fixed multiple tournament issues and added scheduled tournaments.

This commit is contained in:
marcins78@gmail.com
2013-01-03 03:01:48 +00:00
parent 2980672ea7
commit 77aa58de45
20 changed files with 366 additions and 89 deletions

View File

@@ -24,6 +24,12 @@ public class DateUtils {
return format.format(new Date());
}
public static String formatDateWithHour(Date date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
return format.format(date);
}
public static int offsetDate(int start, int dayOffset) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");

View File

@@ -4,6 +4,7 @@ import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.tournament.Tournament;
import com.gempukku.lotro.tournament.TournamentDAO;
import com.gempukku.lotro.tournament.TournamentInfo;
import com.gempukku.lotro.tournament.TournamentQueueInfo;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -185,4 +186,57 @@ public class DbTournamentDAO implements TournamentDAO {
throw new RuntimeException(exp);
}
}
@Override
public List<TournamentQueueInfo> getUnstartedScheduledTournamentQueues() {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
PreparedStatement statement = connection.prepareStatement("select tournament_id, name, format, start, cost, playoff, prizes, minimum_players from scheduled_tournament where started = 0");
try {
ResultSet rs = statement.executeQuery();
try {
List<TournamentQueueInfo> result = new ArrayList<TournamentQueueInfo>();
while (rs.next()) {
result.add(new TournamentQueueInfo(rs.getString(1), rs.getString(2), rs.getString(3), rs.getLong(4),
rs.getInt(5), rs.getString(6), rs.getString(7), rs.getInt(8)));
}
return result;
} finally {
rs.close();
}
} finally {
statement.close();
}
} finally {
connection.close();
}
} catch (SQLException exp) {
throw new RuntimeException(exp);
}
}
@Override
public void updateScheduledTournamentStarted(String scheduledTournamentId) {
try {
Connection conn = _dbAccess.getDataSource().getConnection();
try {
PreparedStatement statement = conn.prepareStatement("update scheduled_tournament set started=1 where tournament_id=?");
try {
statement.setString(1, scheduledTournamentId);
statement.executeUpdate();
} finally {
statement.close();
}
} finally {
conn.close();
}
} catch (SQLException exp) {
throw new RuntimeException(exp);
}
}
public static void main(String[] args) {
System.out.println(System.currentTimeMillis()+2*60*1000);
}
}

View File

@@ -30,6 +30,7 @@ public class HallServer extends AbstractServer {
private LotroFormatLibrary _formatLibrary;
private CollectionsManager _collectionsManager;
private LotroServer _lotroServer;
private PairingMechanismRegistry _pairingMechanismRegistry;
private TournamentPrizeSchemeRegistry _tournamentPrizeSchemeRegistry;
private CollectionType _allCardsCollectionType = CollectionType.ALL_CARDS;
@@ -55,7 +56,8 @@ public class HallServer extends AbstractServer {
private final ChatRoomMediator _hallChat;
public HallServer(LotroServer lotroServer, ChatServer chatServer, LeagueService leagueService, TournamentService tournamentService, LotroCardBlueprintLibrary library,
LotroFormatLibrary formatLibrary, CollectionsManager collectionsManager, TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry, boolean test) {
LotroFormatLibrary formatLibrary, CollectionsManager collectionsManager, TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry,
PairingMechanismRegistry pairingMechanismRegistry, boolean test) {
_lotroServer = lotroServer;
_chatServer = chatServer;
_leagueService = leagueService;
@@ -64,6 +66,7 @@ public class HallServer extends AbstractServer {
_formatLibrary = formatLibrary;
_collectionsManager = collectionsManager;
_tournamentPrizeSchemeRegistry = tournamentPrizeSchemeRegistry;
_pairingMechanismRegistry = pairingMechanismRegistry;
_hallChat = _chatServer.createChatRoom("Game Hall", 10);
_tournamentQueues.put("fotr_queue", new SingleEliminationRecurringQueue(635, "fotr_block",
@@ -275,19 +278,6 @@ public class HallServer extends AbstractServer {
}
}
public boolean processTournament(String tournamentId, Player player, TournamentVisitor tournamentVisitor) {
_hallDataAccessLock.readLock().lock();
try {
Tournament tournament = _runningTournaments.get(tournamentId);
if (tournament == null)
return false;
return true;
} finally {
_hallDataAccessLock.readLock().unlock();
}
}
public void signupUserForHall(Player player, HallChannelVisitor hallChannelVisitor) {
_hallDataAccessLock.readLock().lock();
try {
@@ -543,6 +533,8 @@ public class HallServer extends AbstractServer {
return false;
}
private int _tickCounter = 60;
@Override
protected void cleanup() {
_hallDataAccessLock.writeLock().lock();
@@ -570,16 +562,34 @@ public class HallServer extends AbstractServer {
TournamentQueue tournamentQueue = runningTournamentQueue.getValue();
HallTournamentQueueCallback queueCallback = new HallTournamentQueueCallback();
// If it's finished, remove it
if (tournamentQueue.process(queueCallback))
if (tournamentQueue.process(queueCallback, _collectionsManager))
_tournamentQueues.remove(tournamentQueueKey);
}
for (Tournament runningTournament : new ArrayList<Tournament>(_runningTournaments.values())) {
for (Map.Entry<String, Tournament> tournamentEntry : new HashMap<String, Tournament>(_runningTournaments).entrySet()) {
Tournament runningTournament = tournamentEntry.getValue();
runningTournament.advanceTournament(new HallTournamentCallback(runningTournament), _collectionsManager);
if (runningTournament.getTournamentStage() == Tournament.Stage.FINISHED)
_runningTournaments.remove(runningTournament);
_runningTournaments.remove(tournamentEntry.getKey());
}
if (_tickCounter == 60) {
_tickCounter =0;
List<TournamentQueueInfo> unstartedTournamentQueues = _tournamentService.getUnstartedScheduledTournamentQueues();
for (TournamentQueueInfo unstartedTournamentQueue : unstartedTournamentQueues) {
String scheduledTournamentId = unstartedTournamentQueue.getScheduledTournamentId();
if (!_tournamentQueues.containsKey(scheduledTournamentId)) {
ScheduledTournamentQueue scheduledQueue = new ScheduledTournamentQueue(scheduledTournamentId, unstartedTournamentQueue.getCost(),
true, _tournamentService, unstartedTournamentQueue.getStartTime(), unstartedTournamentQueue.getTournamentName(),
unstartedTournamentQueue.getFormat(), CollectionType.ALL_CARDS, Tournament.Stage.PLAYING_GAMES,
_pairingMechanismRegistry.getPairingMechanism(unstartedTournamentQueue.getPlayOffSystem()),
_tournamentPrizeSchemeRegistry.getTournamentPrizes(unstartedTournamentQueue.getPrizeScheme()), unstartedTournamentQueue.getMinimumPlayers());
_tournamentQueues.put(scheduledTournamentId, scheduledQueue);
}
}
}
_tickCounter++;
} finally {
_hallDataAccessLock.writeLock().unlock();
}

View File

@@ -0,0 +1,66 @@
package com.gempukku.lotro.tournament;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
public abstract class AbstractTournamentQueue implements TournamentQueue {
protected int _cost;
protected Queue<String> _players = new LinkedList<String>();
protected Map<String, LotroDeck> _playerDecks = new HashMap<String, LotroDeck>();
protected boolean _requiresDeck;
private CollectionType _currencyCollection = CollectionType.MY_CARDS;
public AbstractTournamentQueue(int cost, boolean requiresDeck) {
_cost = cost;
_requiresDeck = requiresDeck;
}
@Override
public synchronized void joinPlayer(CollectionsManager collectionsManager, Player player, LotroDeck deck) {
if (!_players.contains(player.getName())) {
if (_cost <= 0 || collectionsManager.removeCurrencyFromPlayerCollection("Joined "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost)) {
_players.add(player.getName());
if (_requiresDeck)
_playerDecks.put(player.getName(), deck);
}
}
}
@Override
public synchronized void leavePlayer(CollectionsManager collectionsManager, Player player) {
if (_players.contains(player.getName())) {
if (_cost > 0)
collectionsManager.addCurrencyToPlayerCollection(true, "Return for leaving "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost);
_players.remove(player.getName());
_playerDecks.remove(player.getName());
}
}
@Override
public synchronized void leaveAllPlayers(CollectionsManager collectionsManager) {
if (_cost > 0) {
for (String player : _players)
collectionsManager.addCurrencyToPlayerCollection(false, "Return for leaving "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost);
}
_players.clear();
_playerDecks.clear();
}
@Override
public synchronized int getPlayerCount() {
return _players.size();
}
@Override
public synchronized boolean isPlayerSignedUp(String player) {
return _players.contains(player);
}
}

View File

@@ -15,4 +15,6 @@ public interface PairingMechanism {
List<PlayerStanding> currentStandings, Map<String, Set<String>> previouslyPaired, Map<String, String> pairingResults, Set<String> byeResults);
public String getPlayOffSystem();
public String getRegistryRepresentation();
}

View File

@@ -3,9 +3,9 @@ package com.gempukku.lotro.tournament;
public class PairingMechanismRegistry {
public PairingMechanism getPairingMechanism(String pairingType) {
if (pairingType.equals("singleElimination"))
return new SingleEliminationPairing();
return new SingleEliminationPairing("singleElimination");
if (pairingType.equals("swiss"))
return new SwissPairingMechanism();
return new SwissPairingMechanism("swiss");
return null;
}

View File

@@ -0,0 +1,100 @@
package com.gempukku.lotro.tournament;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import java.util.Date;
public class ScheduledTournamentQueue extends AbstractTournamentQueue implements TournamentQueue {
private long _startTime;
private int _minimumPlayers;
private String _startCondition;
private TournamentService _tournamentService;
private String _tournamentName;
private String _format;
private CollectionType _collectionType;
private Tournament.Stage _stage;
private PairingMechanism _pairingMechanism;
private TournamentPrizes _prizeScheme;
private String _scheduledTournamentId;
public ScheduledTournamentQueue(String scheduledTournamentId, int cost, boolean requiresDeck, TournamentService tournamentService, long startTime,
String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage,
PairingMechanism pairingMechanism, TournamentPrizes prizeScheme, int minimumPlayers) {
super(cost, requiresDeck);
_scheduledTournamentId = scheduledTournamentId;
_tournamentService = tournamentService;
_startTime = startTime;
_minimumPlayers = minimumPlayers;
_startCondition = DateUtils.formatDateWithHour(new Date(_startTime));
_tournamentName = tournamentName;
_format = format;
_collectionType = collectionType;
_stage = stage;
_pairingMechanism = pairingMechanism;
_prizeScheme = prizeScheme;
}
@Override
public int getCost() {
return _cost;
}
@Override
public String getFormat() {
return _format;
}
@Override
public CollectionType getCollectionType() {
return _collectionType;
}
@Override
public String getTournamentQueueName() {
return _tournamentName;
}
@Override
public String getPrizesDescription() {
return _prizeScheme.getPrizeDescription();
}
@Override
public String getPairingDescription() {
return _pairingMechanism.getPlayOffSystem() + ", minimum players: " + _minimumPlayers;
}
@Override
public String getStartCondition() {
return _startCondition;
}
@Override
public boolean isRequiresDeck() {
return _requiresDeck;
}
@Override
public synchronized boolean process(TournamentQueueCallback tournamentQueueCallback, CollectionsManager collectionsManager) {
long now = System.currentTimeMillis();
if (now > _startTime) {
if (_players.size() >= _minimumPlayers) {
for (String player : _players)
_tournamentService.addPlayer(_scheduledTournamentId, player, _playerDecks.get(player));
Tournament tournament = _tournamentService.addTournament(_scheduledTournamentId, null, _tournamentName, _format, _collectionType, _stage,
_pairingMechanism.getRegistryRepresentation(), _prizeScheme.getRegistryRepresentation(), new Date());
tournamentQueueCallback.createTournament(tournament);
} else {
_tournamentService.updateScheduledTournamentStarted(_scheduledTournamentId);
leaveAllPlayers(collectionsManager);
}
return true;
}
return false;
}
}

View File

@@ -5,6 +5,17 @@ import com.gempukku.lotro.competitive.PlayerStanding;
import java.util.*;
public class SingleEliminationPairing implements PairingMechanism {
private String _registryRepresentation;
public SingleEliminationPairing(String registryRepresentation) {
_registryRepresentation = registryRepresentation;
}
@Override
public String getRegistryRepresentation() {
return _registryRepresentation;
}
@Override
public boolean isFinished(int round, Set<String> players, Set<String> droppedPlayers) {
return players.size() - droppedPlayers.size() < 2;

View File

@@ -3,20 +3,13 @@ package com.gempukku.lotro.tournament;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.*;
import java.util.Date;
public class SingleEliminationRecurringQueue implements TournamentQueue {
private int _cost;
public class SingleEliminationRecurringQueue extends AbstractTournamentQueue implements TournamentQueue {
private String _format;
private CollectionType _collectionType;
private String _tournamentQueueName;
private CollectionType _currencyCollection = CollectionType.MY_CARDS;
private Queue<String> _players = new LinkedList<String>();
private Map<String, LotroDeck> _playerDecks = new HashMap<String, LotroDeck>();
private int _playerCap;
@@ -24,18 +17,15 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
private TournamentPrizes _tournamentPrizes;
private String _tournamentIdPrefix;
private boolean _requiresDeck;
public SingleEliminationRecurringQueue(int cost, String format, CollectionType collectionType, String tournamentIdPrefix,
String tournamentQueueName, int playerCap, boolean requiresDeck,
TournamentService tournamentService, TournamentPrizes tournamentPrizes) {
_cost = cost;
super(cost, requiresDeck);
_format = format;
_collectionType = collectionType;
_tournamentQueueName = tournamentQueueName;
_playerCap = playerCap;
_tournamentIdPrefix = tournamentIdPrefix;
_requiresDeck = requiresDeck;
_tournamentService = tournamentService;
_tournamentPrizes = tournamentPrizes;
}
@@ -81,16 +71,16 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
}
@Override
public synchronized boolean process(TournamentQueueCallback tournamentQueueCallback) {
while (_players.size() >= _playerCap) {
public synchronized boolean process(TournamentQueueCallback tournamentQueueCallback, CollectionsManager collectionsManager) {
if (_players.size() >= _playerCap) {
String tournamentId = _tournamentIdPrefix + System.currentTimeMillis();
String tournamentName = _tournamentQueueName + " - " + DateUtils.getStringDateWithHour();
for (int i=0; i<_playerCap; i++) {
String player = _players.poll();
_playerDecks.remove(player);
_tournamentService.addPlayer(tournamentId, player, _playerDecks.get(player));
_playerDecks.remove(player);
}
Tournament tournament = _tournamentService.addTournament(tournamentId, null, tournamentName, _format, _collectionType, Tournament.Stage.PLAYING_GAMES, "singleElimination",
@@ -101,44 +91,4 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
return false;
}
@Override
public synchronized void joinPlayer(CollectionsManager collectionsManager, Player player, LotroDeck deck) {
if (!_players.contains(player.getName())) {
if (_cost <= 0 || collectionsManager.removeCurrencyFromPlayerCollection("Joined "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost)) {
_players.add(player.getName());
if (_requiresDeck)
_playerDecks.put(player.getName(), deck);
}
}
}
@Override
public synchronized int getPlayerCount() {
return _players.size();
}
@Override
public synchronized void leavePlayer(CollectionsManager collectionsManager, Player player) {
if (_players.contains(player.getName())) {
if (_cost > 0)
collectionsManager.addCurrencyToPlayerCollection(true, "Return for leaving "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost);
_players.remove(player.getName());
_playerDecks.remove(player.getName());
}
}
@Override
public synchronized void leaveAllPlayers(CollectionsManager collectionsManager) {
if (_cost > 0) {
for (String player : _players)
collectionsManager.addCurrencyToPlayerCollection(false, "Return for leaving "+getTournamentQueueName()+" queue", player, _currencyCollection, _cost);
}
_players.clear();
_playerDecks.clear();
}
@Override
public synchronized boolean isPlayerSignedUp(String player) {
return _players.contains(player);
}
}

View File

@@ -5,6 +5,17 @@ import com.gempukku.lotro.competitive.PlayerStanding;
import java.util.*;
public class SwissPairingMechanism implements PairingMechanism {
private String _registryRepresentation;
public SwissPairingMechanism(String registryRepresentation) {
_registryRepresentation = registryRepresentation;
}
@Override
public String getRegistryRepresentation() {
return _registryRepresentation;
}
@Override
public String getPlayOffSystem() {
return "Swiss";

View File

@@ -9,8 +9,6 @@ public interface TournamentDAO {
public void addTournament(String tournamentId, String draftType, String tournamentName, String format,
CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, String prizeScheme, Date start);
// public List<TournamentQueueInfo> getFutureScheduledTournaments();
public List<TournamentInfo> getUnfinishedTournaments();
public List<TournamentInfo> getFinishedTournamentsSince(long time);
@@ -20,4 +18,8 @@ public interface TournamentDAO {
public void updateTournamentStage(String tournamentId, Tournament.Stage stage);
public void updateTournamentRound(String tournamentId, int round);
public List<TournamentQueueInfo> getUnstartedScheduledTournamentQueues();
public void updateScheduledTournamentStarted(String scheduledTournamentId);
}

View File

@@ -2,7 +2,7 @@ package com.gempukku.lotro.tournament;
public class TournamentPrizeSchemeRegistry {
public TournamentPrizes getTournamentPrizes(String prizesScheme) {
if (prizesScheme == null)
if (prizesScheme == null || prizesScheme.equals("none"))
return new NoPrizes();
if (prizesScheme.equals("onDemand"))

View File

@@ -22,7 +22,7 @@ public interface TournamentQueue {
public boolean isRequiresDeck();
public boolean process(TournamentQueueCallback tournamentQueueCallback);
public boolean process(TournamentQueueCallback tournamentQueueCallback, CollectionsManager collectionsManager);
public void joinPlayer(CollectionsManager collectionsManager, Player player, LotroDeck deck);

View File

@@ -0,0 +1,55 @@
package com.gempukku.lotro.tournament;
public class TournamentQueueInfo {
private int _cost;
private long _startTime;
private String _tournamentName;
private String _scheduledTournamentId;
private String _format;
private String _playOffSystem;
private String _prizeScheme;
private int _minimumPlayers;
public TournamentQueueInfo(String scheduledTournamentId, String tournamentName, String format, long startTime, int cost, String playOffSystem, String prizeScheme, int minimumPlayers) {
_scheduledTournamentId = scheduledTournamentId;
_tournamentName = tournamentName;
_format = format;
_startTime = startTime;
_cost = cost;
_playOffSystem = playOffSystem;
_prizeScheme = prizeScheme;
_minimumPlayers = minimumPlayers;
}
public String getScheduledTournamentId() {
return _scheduledTournamentId;
}
public int getCost() {
return _cost;
}
public long getStartTime() {
return _startTime;
}
public String getTournamentName() {
return _tournamentName;
}
public String getFormat() {
return _format;
}
public String getPlayOffSystem() {
return _playOffSystem;
}
public String getPrizeScheme() {
return _prizeScheme;
}
public int getMinimumPlayers() {
return _minimumPlayers;
}
}

View File

@@ -154,4 +154,12 @@ public class TournamentService {
public Map<String, Integer> getPlayerByes(String tournamentId) {
return _tournamentMatchDao.getPlayerByes(tournamentId);
}
public List<TournamentQueueInfo> getUnstartedScheduledTournamentQueues() {
return _tournamentDao.getUnstartedScheduledTournamentQueues();
}
public void updateScheduledTournamentStarted(String scheduledTournamentId) {
_tournamentDao.updateScheduledTournamentStarted(scheduledTournamentId);
}
}

View File

@@ -57,7 +57,7 @@ public class DefaultTournamentTest {
new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[5];
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[6];
pairings.put("p1", "p2");
pairings.put("p3", "p4");
pairings.put("p5", "p6");
@@ -73,7 +73,7 @@ public class DefaultTournamentTest {
new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[5];
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[6];
pairings.put("p1", "p3");
pairings.put("p5", "p7");
@@ -87,7 +87,7 @@ public class DefaultTournamentTest {
new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable {
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[5];
Map<String, String> pairings = (Map<String, String>) invocationOnMock.getArguments()[6];
pairings.put("p1", "p5");
return false;

View File

@@ -6,7 +6,7 @@ import org.junit.Test;
import java.util.*;
public class SingleEliminationPairingTest {
private SingleEliminationPairing _pairing = new SingleEliminationPairing();
private SingleEliminationPairing _pairing = new SingleEliminationPairing("singleElimination");
@Test
public void correctlyDetectsFinishedTournament() {

View File

@@ -106,7 +106,7 @@ public class SingleEliminationRecurringQueueTest {
queue.joinPlayer(collectionsManager, player1, null);
TournamentQueueCallback queueCallback = Mockito.mock(TournamentQueueCallback.class);
assertFalse(queue.process(queueCallback));
assertFalse(queue.process(queueCallback, collectionsManager));
Mockito.verifyNoMoreInteractions(queueCallback);
@@ -114,7 +114,7 @@ public class SingleEliminationRecurringQueueTest {
assertEquals(2, queue.getPlayerCount());
assertFalse(queue.process(queueCallback));
assertFalse(queue.process(queueCallback, collectionsManager));
assertEquals(0, queue.getPlayerCount());
assertFalse(queue.isPlayerSignedUp("p1"));
@@ -153,7 +153,7 @@ public class SingleEliminationRecurringQueueTest {
queue.joinPlayer(collectionsManager, player1, null);
TournamentQueueCallback queueCallback = Mockito.mock(TournamentQueueCallback.class);
assertFalse(queue.process(queueCallback));
assertFalse(queue.process(queueCallback, collectionsManager));
Mockito.verifyNoMoreInteractions(queueCallback);
@@ -162,7 +162,7 @@ public class SingleEliminationRecurringQueueTest {
assertEquals(3, queue.getPlayerCount());
assertFalse(queue.process(queueCallback));
assertFalse(queue.process(queueCallback, collectionsManager));
assertEquals(1, queue.getPlayerCount());
assertFalse(queue.isPlayerSignedUp("p1"));

View File

@@ -62,7 +62,7 @@ public class SwissPairingMechanismTest {
for (String player : players)
previouslyPaired.put(player, new HashSet<String>());
SwissPairingMechanism pairing = new SwissPairingMechanism();
SwissPairingMechanism pairing = new SwissPairingMechanism("swiss");
for (int i = 1; i < 20; i++) {
if (!pairing.isFinished(i - 1, players, droppedPlayers)) {
System.out.println("Pairing round " + i);

View File

@@ -47,13 +47,14 @@ public class ServerBuilder {
extract(objectMap, CollectionsManager.class)));
TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry = new TournamentPrizeSchemeRegistry();
PairingMechanismRegistry pairingMechanismRegistry = new PairingMechanismRegistry();
objectMap.put(TournamentService.class,
new TournamentService(
extract(objectMap, CollectionsManager.class),
extract(objectMap, PacksStorage.class),
new DraftPackStorage(),
new PairingMechanismRegistry(),
pairingMechanismRegistry,
tournamentPrizeSchemeRegistry,
extract(objectMap, TournamentDAO.class),
extract(objectMap, TournamentPlayerDAO.class),
@@ -84,6 +85,7 @@ public class ServerBuilder {
extract(objectMap, LotroFormatLibrary.class),
extract(objectMap, CollectionsManager.class),
tournamentPrizeSchemeRegistry,
pairingMechanismRegistry,
false));
}