Added prizes to tournament.
This commit is contained in:
@@ -21,11 +21,11 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTournament(String tournamentId, String draftType, String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, Date start) {
|
||||
public void addTournament(String tournamentId, String draftType, String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, String prizesScheme, Date start) {
|
||||
try {
|
||||
Connection conn = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = conn.prepareStatement("insert into tournament (tournament_id, draft_type, name, format, collection, stage, pairing, start, round) values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement statement = conn.prepareStatement("insert into tournament (tournament_id, draft_type, name, format, collection, stage, pairing, start, round, prizes) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
try {
|
||||
statement.setString(1, tournamentId);
|
||||
statement.setString(2, draftType);
|
||||
@@ -36,6 +36,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
statement.setString(7, pairingMechanism);
|
||||
statement.setLong(8, start.getTime());
|
||||
statement.setInt(9, 0);
|
||||
statement.setString(10, prizesScheme);
|
||||
statement.execute();
|
||||
} finally {
|
||||
statement.close();
|
||||
@@ -53,7 +54,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
try {
|
||||
Connection connection = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("select draft_type, name, format, collection, stage, pairing, round from tournament where tournament_id=?");
|
||||
PreparedStatement statement = connection.prepareStatement("select draft_type, name, format, collection, stage, pairing, round, prizes from tournament where tournament_id=?");
|
||||
try {
|
||||
statement.setString(1, tournamentId);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
@@ -63,7 +64,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
return new TournamentInfo(
|
||||
tournamentId, rs.getString(1), rs.getString(2), rs.getString(3),
|
||||
new CollectionType(collectionTypeStr[0], collectionTypeStr[1]), Tournament.Stage.valueOf(rs.getString(5)),
|
||||
rs.getString(6), rs.getInt(7));
|
||||
rs.getString(6), rs.getString(8), rs.getInt(7));
|
||||
} else
|
||||
return null;
|
||||
} finally {
|
||||
@@ -85,7 +86,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
try {
|
||||
Connection connection = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("select tournament_id, draft_type, name, format, collection, stage, pairing, round from tournament where stage <> '"+ Tournament.Stage.FINISHED.name()+"'");
|
||||
PreparedStatement statement = connection.prepareStatement("select tournament_id, draft_type, name, format, collection, stage, pairing, round, prizes from tournament where stage <> '"+ Tournament.Stage.FINISHED.name()+"'");
|
||||
try {
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
@@ -94,7 +95,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
String[] collectionTypeStr = rs.getString(5).split(":", 2);
|
||||
result.add(new TournamentInfo(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),
|
||||
new CollectionType(collectionTypeStr[0], collectionTypeStr[1]), Tournament.Stage.valueOf(rs.getString(6)),
|
||||
rs.getString(7), rs.getInt(8)));
|
||||
rs.getString(7), rs.getString(9), rs.getInt(8)));
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
@@ -116,7 +117,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
try {
|
||||
Connection connection = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("select tournament_id, draft_type, name, format, collection, stage, pairing, round from tournament where stage = '"+ Tournament.Stage.FINISHED.name()+"' and start>?");
|
||||
PreparedStatement statement = connection.prepareStatement("select tournament_id, draft_type, name, format, collection, stage, pairing, round, prizes from tournament where stage = '"+ Tournament.Stage.FINISHED.name()+"' and start>?");
|
||||
try {
|
||||
statement.setLong(1, time);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
@@ -126,7 +127,7 @@ public class DbTournamentDAO implements TournamentDAO {
|
||||
String[] collectionTypeStr = rs.getString(5).split(":", 2);
|
||||
result.add(new TournamentInfo(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),
|
||||
new CollectionType(collectionTypeStr[0], collectionTypeStr[1]), Tournament.Stage.valueOf(rs.getString(6)),
|
||||
rs.getString(7), rs.getInt(8)));
|
||||
rs.getString(7), rs.getString(9), rs.getInt(8)));
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
|
||||
@@ -60,13 +60,15 @@ public class HallCommunicationChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTournamentQueue(String tournamentQueueKey, int cost, String collectionName, String formatName, String tournamentQueueName, int playerCount, boolean playerSignedUp) {
|
||||
public void visitTournamentQueue(String tournamentQueueKey, int cost, String collectionName, String formatName, String tournamentQueueName,
|
||||
String tournamentPrizes, int playerCount, boolean playerSignedUp) {
|
||||
Map<String, String> props = new HashMap<String, String>();
|
||||
props.put("cost", String.valueOf(cost));
|
||||
props.put("collection", collectionName);
|
||||
props.put("format", formatName);
|
||||
props.put("queue", tournamentQueueName);
|
||||
props.put("playerCount", String.valueOf(playerCount));
|
||||
props.put("prizes", tournamentPrizes);
|
||||
props.put("signedUp", String.valueOf(playerSignedUp));
|
||||
|
||||
tournamentsOnServer.put(tournamentQueueKey, props);
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface HallInfoVisitor {
|
||||
|
||||
public void visitTable(String tableId, String gameId, boolean watchable, TableStatus status, String statusDescription, String formatName, String tournamentName, List<String> playerIds, String winner);
|
||||
|
||||
public void visitTournamentQueue(String tournamentQueueKey, int cost, String collectionName, String formatName, String tournamentQueueName, int playerCount, boolean playerSignedUp);
|
||||
public void visitTournamentQueue(String tournamentQueueKey, int cost, String collectionName, String formatName, String tournamentQueueName, String tournamentPrizes, int playerCount, boolean playerSignedUp);
|
||||
|
||||
public void runningPlayerGame(String gameId);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class HallServer extends AbstractServer {
|
||||
private LotroFormatLibrary _formatLibrary;
|
||||
private CollectionsManager _collectionsManager;
|
||||
private LotroServer _lotroServer;
|
||||
private TournamentPrizeSchemeRegistry _tournamentPrizeSchemeRegistry;
|
||||
|
||||
private CollectionType _allCardsCollectionType = CollectionType.ALL_CARDS;
|
||||
|
||||
@@ -54,7 +55,7 @@ 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, boolean test) {
|
||||
LotroFormatLibrary formatLibrary, CollectionsManager collectionsManager, TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry, boolean test) {
|
||||
_lotroServer = lotroServer;
|
||||
_chatServer = chatServer;
|
||||
_leagueService = leagueService;
|
||||
@@ -62,11 +63,15 @@ public class HallServer extends AbstractServer {
|
||||
_library = library;
|
||||
_formatLibrary = formatLibrary;
|
||||
_collectionsManager = collectionsManager;
|
||||
_tournamentPrizeSchemeRegistry = tournamentPrizeSchemeRegistry;
|
||||
_hallChat = _chatServer.createChatRoom("Game Hall", 10);
|
||||
|
||||
_tournamentQueues.put("fotr_queue", new SingleEliminationRecurringQueue(0, "fotr_block",
|
||||
CollectionType.ALL_CARDS, "fotrQueue-", "Test Fellowship Block 4-man", 4,
|
||||
true, tournamentService));
|
||||
_tournamentQueues.put("fotr_queue", new SingleEliminationRecurringQueue(635, "fotr_block",
|
||||
CollectionType.MY_CARDS, "fotrQueue-", "Fellowship Block 8-man single-elimination", 8,
|
||||
true, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes("onDemand")));
|
||||
_tournamentQueues.put("movie_queue", new SingleEliminationRecurringQueue(635, "movie",
|
||||
CollectionType.MY_CARDS, "movieQueue-", "Movie Block 8-man single-elimination", 8,
|
||||
true, tournamentService, _tournamentPrizeSchemeRegistry.getTournamentPrizes("onDemand")));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,6 +341,7 @@ public class HallServer extends AbstractServer {
|
||||
TournamentQueue tournamentQueue = tournamentQueueEntry.getValue();
|
||||
visitor.visitTournamentQueue(tournamentQueueKey, tournamentQueue.getCost(), tournamentQueue.getCollectionType().getFullName(),
|
||||
_formatLibrary.getFormat(tournamentQueue.getFormat()).getName(), tournamentQueue.getTournamentQueueName(),
|
||||
tournamentQueue.getPrizesDescription(),
|
||||
tournamentQueue.getPlayerCount(), tournamentQueue.isPlayerSignedUp(player.getName()));
|
||||
}
|
||||
|
||||
@@ -537,7 +543,7 @@ public class HallServer extends AbstractServer {
|
||||
}
|
||||
|
||||
for (Tournament runningTournament : new ArrayList<Tournament>(_runningTournaments.values())) {
|
||||
runningTournament.advanceTournament(new HallTournamentCallback(runningTournament));
|
||||
runningTournament.advanceTournament(new HallTournamentCallback(runningTournament), _collectionsManager);
|
||||
if (runningTournament.getTournamentStage() == Tournament.Stage.FINISHED)
|
||||
_runningTournaments.remove(runningTournament);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.gempukku.lotro.draft.DefaultDraft;
|
||||
import com.gempukku.lotro.draft.Draft;
|
||||
import com.gempukku.lotro.draft.DraftCardChoice;
|
||||
import com.gempukku.lotro.draft.DraftPack;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DeckInvalidException;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import com.gempukku.lotro.packs.PacksStorage;
|
||||
@@ -22,6 +23,7 @@ public class DefaultTournament implements Tournament {
|
||||
private long _waitForPairingsTime = 1000 * 60 * 2;
|
||||
|
||||
private PairingMechanism _pairingMechanism;
|
||||
private TournamentPrizes _tournamentPrizes;
|
||||
private String _tournamentId;
|
||||
private String _tournamentName;
|
||||
private String _format;
|
||||
@@ -49,7 +51,7 @@ public class DefaultTournament implements Tournament {
|
||||
|
||||
public DefaultTournament(CollectionsManager collectionsManager, TournamentService tournamentService,
|
||||
PacksStorage packsStorage, DraftPack draftPack, String tournamentId, String tournamentName, String format, CollectionType collectionType,
|
||||
int tournamentRound, Stage tournamentStage, PairingMechanism pairingMechanism) {
|
||||
int tournamentRound, Stage tournamentStage, PairingMechanism pairingMechanism, TournamentPrizes tournamentPrizes) {
|
||||
_tournamentService = tournamentService;
|
||||
_tournamentId = tournamentId;
|
||||
_tournamentName = tournamentName;
|
||||
@@ -58,6 +60,7 @@ public class DefaultTournament implements Tournament {
|
||||
_tournamentRound = tournamentRound;
|
||||
_tournamentStage = tournamentStage;
|
||||
_pairingMechanism = pairingMechanism;
|
||||
_tournamentPrizes = tournamentPrizes;
|
||||
|
||||
_currentlyPlayingPlayers = new HashSet<String>();
|
||||
|
||||
@@ -210,7 +213,7 @@ public class DefaultTournament implements Tournament {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advanceTournament(TournamentCallback tournamentCallback) {
|
||||
public void advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
_lock.writeLock().lock();
|
||||
try {
|
||||
if (_nextTask == null) {
|
||||
@@ -233,7 +236,7 @@ public class DefaultTournament implements Tournament {
|
||||
if (_tournamentStage == Stage.PLAYING_GAMES) {
|
||||
if (_currentlyPlayingPlayers.size() == 0) {
|
||||
if (_pairingMechanism.isFinished(_tournamentRound, _players, _droppedPlayers)) {
|
||||
finishTournament(tournamentCallback);
|
||||
finishTournament(tournamentCallback, collectionsManager);
|
||||
} else {
|
||||
tournamentCallback.broadcastMessage("Tournament " + _tournamentName + " will start round "+(_tournamentRound+1)+" in 2 minutes");
|
||||
_nextTask = new PairPlayers();
|
||||
@@ -244,7 +247,7 @@ public class DefaultTournament implements Tournament {
|
||||
if (_nextTask != null && _nextTask.getExecuteAfter() <= System.currentTimeMillis()) {
|
||||
TournamentTask task = _nextTask;
|
||||
_nextTask = null;
|
||||
task.executeTask(tournamentCallback);
|
||||
task.executeTask(tournamentCallback, collectionsManager);
|
||||
}
|
||||
} finally {
|
||||
_lock.writeLock().unlock();
|
||||
@@ -266,14 +269,20 @@ public class DefaultTournament implements Tournament {
|
||||
}
|
||||
}
|
||||
|
||||
private void finishTournament(TournamentCallback tournamentCallback) {
|
||||
private void finishTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
_tournamentStage = Stage.FINISHED;
|
||||
_tournamentService.updateTournamentStage(_tournamentId, _tournamentStage);
|
||||
tournamentCallback.broadcastMessage("Tournament " + _tournamentName + " is finished");
|
||||
awardPrizes();
|
||||
awardPrizes(collectionsManager);
|
||||
}
|
||||
|
||||
private void awardPrizes() {
|
||||
private void awardPrizes(CollectionsManager collectionsManager) {
|
||||
List<PlayerStanding> list = getCurrentStandings();
|
||||
for (PlayerStanding playerStanding : list) {
|
||||
CardCollection prizes = _tournamentPrizes.getPrizeForTournament(playerStanding, list.size());
|
||||
if (prizes != null)
|
||||
collectionsManager.addItemsToPlayerCollection(true, "Tournament " +getTournamentName()+" prize", playerStanding.getPlayerName(), CollectionType.MY_CARDS, prizes.getAll().values());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -282,14 +291,14 @@ public class DefaultTournament implements Tournament {
|
||||
playerTwo, _playerDecks.get(playerTwo), allowSpectators);
|
||||
}
|
||||
|
||||
private void doPairing(TournamentCallback tournamentCallback) {
|
||||
private void doPairing(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
_tournamentRound++;
|
||||
_tournamentService.updateTournamentRound(_tournamentId, _tournamentRound);
|
||||
Map<String, String> pairingResults = new HashMap<String, String>();
|
||||
Set<String> byeResults = new HashSet<String>();
|
||||
boolean finished = _pairingMechanism.pairPlayers(_tournamentRound, _players, _droppedPlayers, _playerByes, getCurrentStandings(), pairingResults, byeResults);
|
||||
if (finished) {
|
||||
finishTournament(tournamentCallback);
|
||||
finishTournament(tournamentCallback, collectionsManager);
|
||||
} else {
|
||||
for (Map.Entry<String, String> pairing : pairingResults.entrySet()) {
|
||||
String playerOne = pairing.getKey();
|
||||
@@ -318,8 +327,8 @@ public class DefaultTournament implements Tournament {
|
||||
private long _taskStart = System.currentTimeMillis() + _waitForPairingsTime;
|
||||
|
||||
@Override
|
||||
public void executeTask(TournamentCallback tournamentCallback) {
|
||||
doPairing(tournamentCallback);
|
||||
public void executeTask(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
doPairing(tournamentCallback, collectionsManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,7 +345,7 @@ public class DefaultTournament implements Tournament {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask(TournamentCallback tournamentCallback) {
|
||||
public void executeTask(TournamentCallback tournamentCallback, CollectionsManager collectionsManager) {
|
||||
for (Map.Entry<String, String> pairings : _gamesToCreate.entrySet()) {
|
||||
String playerOne = pairings.getKey();
|
||||
String playerTwo = pairings.getValue();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public class NoPrizes implements TournamentPrizes{
|
||||
@Override
|
||||
public CardCollection getPrizeForTournament(PlayerStanding playerStanding, int playersCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryRepresentation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrizeDescription() {
|
||||
return "No prizes";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.RarityReader;
|
||||
import com.gempukku.lotro.cards.packs.SetRarity;
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class SingleEliminationOnDemandPrizes implements TournamentPrizes{
|
||||
private List<String> _promos = new ArrayList<String>();
|
||||
private String _registryRepresentation;
|
||||
|
||||
public SingleEliminationOnDemandPrizes(String registryRepresentation) {
|
||||
_registryRepresentation = registryRepresentation;
|
||||
RarityReader rarityReader = new RarityReader();
|
||||
|
||||
for (int i = 0; i <= 19; i++) {
|
||||
SetRarity setRarity = rarityReader.getSetRarity(String.valueOf(i));
|
||||
_promos.addAll(setRarity.getCardsOfRarity("P"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getPrizeForTournament(PlayerStanding playerStanding, int playersCount) {
|
||||
DefaultCardCollection tournamentPrize = new DefaultCardCollection();
|
||||
if (playerStanding.getPoints() == 3) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 2);
|
||||
} else if (playerStanding.getPoints() == 2) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 1);
|
||||
tournamentPrize.addItem(getRandom(_promos), 1);
|
||||
} else if (playerStanding.getPoints() == 1) {
|
||||
tournamentPrize.addItem("(S)Booster Choice", 1);
|
||||
}
|
||||
|
||||
if (tournamentPrize.getAll().size() == 0)
|
||||
return null;
|
||||
return tournamentPrize;
|
||||
}
|
||||
|
||||
private String getRandom(List<String> list) {
|
||||
return list.get(new Random().nextInt(list.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistryRepresentation() {
|
||||
return _registryRepresentation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrizeDescription() {
|
||||
return "1st place - 2 boosters, 2nd place - 1 booster and a random promo, 3rd & 4th - 1 booster";
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,14 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
|
||||
private int _playerCap;
|
||||
|
||||
private TournamentService _tournamentService;
|
||||
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) {
|
||||
public SingleEliminationRecurringQueue(int cost, String format, CollectionType collectionType, String tournamentIdPrefix,
|
||||
String tournamentQueueName, int playerCap, boolean requiresDeck,
|
||||
TournamentService tournamentService, TournamentPrizes tournamentPrizes) {
|
||||
_cost = cost;
|
||||
_format = format;
|
||||
_collectionType = collectionType;
|
||||
@@ -34,6 +37,7 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
|
||||
_tournamentIdPrefix = tournamentIdPrefix;
|
||||
_requiresDeck = requiresDeck;
|
||||
_tournamentService = tournamentService;
|
||||
_tournamentPrizes = tournamentPrizes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,6 +60,11 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
|
||||
return _tournamentQueueName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrizesDescription() {
|
||||
return _tournamentPrizes.getPrizeDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiresDeck() {
|
||||
return _requiresDeck;
|
||||
@@ -74,7 +83,8 @@ public class SingleEliminationRecurringQueue implements TournamentQueue {
|
||||
_tournamentService.addPlayer(tournamentId, player, _playerDecks.get(player));
|
||||
}
|
||||
|
||||
Tournament tournament = _tournamentService.addTournament(tournamentId, null, tournamentName, _format, _collectionType, Tournament.Stage.PLAYING_GAMES, "singleElimination", new Date());
|
||||
Tournament tournament = _tournamentService.addTournament(tournamentId, null, tournamentName, _format, _collectionType, Tournament.Stage.PLAYING_GAMES, "singleElimination",
|
||||
_tournamentPrizes.getRegistryRepresentation(), new Date());
|
||||
|
||||
tournamentQueueCallback.createTournament(tournament);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.draft.DraftCardChoice;
|
||||
@@ -31,7 +32,7 @@ public interface Tournament {
|
||||
public Stage getTournamentStage();
|
||||
public int getCurrentRound();
|
||||
|
||||
public void advanceTournament(TournamentCallback tournamentCallback);
|
||||
public void advanceTournament(TournamentCallback tournamentCallback, CollectionsManager collectionsManager);
|
||||
|
||||
public void reportGameFinished(String winner, String loser);
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface TournamentDAO {
|
||||
public void addTournament(String tournamentId, String draftType, String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, Date start);
|
||||
public void addTournament(String tournamentId, String draftType, String tournamentName, String format,
|
||||
CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, String prizeScheme, Date start);
|
||||
|
||||
public List<TournamentInfo> getUnfinishedTournaments();
|
||||
|
||||
|
||||
@@ -8,16 +8,19 @@ public class TournamentInfo {
|
||||
private String _tournamentName;
|
||||
private String _tournamentFormat;
|
||||
private CollectionType _collectionType;
|
||||
private String _prizesScheme;
|
||||
private int _tournamentRound;
|
||||
private String _pairingMechanism;
|
||||
private Tournament.Stage _tournamentStage;
|
||||
|
||||
public TournamentInfo(String tournamentId, String draftType, String tournamentName, String tournamentFormat, CollectionType collectionType, Tournament.Stage tournamentStage, String pairingMechanism, int tournamentRound) {
|
||||
public TournamentInfo(String tournamentId, String draftType, String tournamentName, String tournamentFormat, CollectionType collectionType,
|
||||
Tournament.Stage tournamentStage, String pairingMechanism, String prizesScheme, int tournamentRound) {
|
||||
_tournamentId = tournamentId;
|
||||
_draftType = draftType;
|
||||
_tournamentName = tournamentName;
|
||||
_tournamentFormat = tournamentFormat;
|
||||
_collectionType = collectionType;
|
||||
_prizesScheme = prizesScheme;
|
||||
_tournamentRound = tournamentRound;
|
||||
_pairingMechanism = pairingMechanism;
|
||||
_tournamentStage = tournamentStage;
|
||||
@@ -51,6 +54,10 @@ public class TournamentInfo {
|
||||
return _pairingMechanism;
|
||||
}
|
||||
|
||||
public String getPrizesScheme() {
|
||||
return _prizesScheme;
|
||||
}
|
||||
|
||||
public Tournament.Stage getTournamentStage() {
|
||||
return _tournamentStage;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
public class TournamentPrizeSchemeRegistry {
|
||||
public TournamentPrizes getTournamentPrizes(String prizesScheme) {
|
||||
if (prizesScheme == null)
|
||||
return new NoPrizes();
|
||||
|
||||
if (prizesScheme.equals("onDemand"))
|
||||
return new SingleEliminationOnDemandPrizes("onDemand");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public interface TournamentPrizes {
|
||||
public CardCollection getPrizeForTournament(PlayerStanding playerStanding, int playersCount);
|
||||
public String getRegistryRepresentation();
|
||||
public String getPrizeDescription();
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public interface TournamentQueue {
|
||||
|
||||
public String getTournamentQueueName();
|
||||
|
||||
public String getPrizesDescription();
|
||||
|
||||
public boolean isRequiresDeck();
|
||||
|
||||
public boolean process(TournamentQueueCallback tournamentQueueCallback);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class TournamentService {
|
||||
private PacksStorage _packsStorage;
|
||||
private DraftPackStorage _draftPackStorage;
|
||||
private PairingMechanismRegistry _pairingMechanismRegistry;
|
||||
private TournamentPrizeSchemeRegistry _tournamentPrizeSchemeRegistry;
|
||||
private TournamentDAO _tournamentDao;
|
||||
private TournamentPlayerDAO _tournamentPlayerDao;
|
||||
private TournamentMatchDAO _tournamentMatchDao;
|
||||
@@ -22,12 +23,13 @@ public class TournamentService {
|
||||
private Map<String, Tournament> _tournamentById = new HashMap<String, Tournament>();
|
||||
|
||||
public TournamentService(CollectionsManager collectionsManager, PacksStorage packsStorage, DraftPackStorage draftPackStorage,
|
||||
PairingMechanismRegistry pairingMechanismRegistry,
|
||||
PairingMechanismRegistry pairingMechanismRegistry, TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry,
|
||||
TournamentDAO tournamentDao, TournamentPlayerDAO tournamentPlayerDao, TournamentMatchDAO tournamentMatchDao) {
|
||||
_collectionsManager = collectionsManager;
|
||||
_packsStorage = packsStorage;
|
||||
_draftPackStorage = draftPackStorage;
|
||||
_pairingMechanismRegistry = pairingMechanismRegistry;
|
||||
_tournamentPrizeSchemeRegistry = tournamentPrizeSchemeRegistry;
|
||||
_tournamentDao = tournamentDao;
|
||||
_tournamentPlayerDao = tournamentPlayerDao;
|
||||
_tournamentMatchDao = tournamentMatchDao;
|
||||
@@ -77,9 +79,9 @@ public class TournamentService {
|
||||
return _tournamentMatchDao.getMatches(tournamentId);
|
||||
}
|
||||
|
||||
public Tournament addTournament(String tournamentId, String draftType, String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, Date start) {
|
||||
_tournamentDao.addTournament(tournamentId, draftType, tournamentName, format, collectionType, stage, pairingMechanism, start);
|
||||
return createTournamentAndStoreInCache(tournamentId, new TournamentInfo(tournamentId, draftType, tournamentName, format, collectionType, stage, pairingMechanism, 0));
|
||||
public Tournament addTournament(String tournamentId, String draftType, String tournamentName, String format, CollectionType collectionType, Tournament.Stage stage, String pairingMechanism, String prizeScheme, Date start) {
|
||||
_tournamentDao.addTournament(tournamentId, draftType, tournamentName, format, collectionType, stage, pairingMechanism, prizeScheme, start);
|
||||
return createTournamentAndStoreInCache(tournamentId, new TournamentInfo(tournamentId, draftType, tournamentName, format, collectionType, stage, pairingMechanism, prizeScheme, 0));
|
||||
}
|
||||
|
||||
public void updateTournamentStage(String tournamentId, Tournament.Stage stage) {
|
||||
@@ -135,7 +137,8 @@ public class TournamentService {
|
||||
tournament = new DefaultTournament(_collectionsManager, this, _packsStorage, draftPack,
|
||||
tournamentId, tournamentInfo.getTournamentName(), tournamentInfo.getTournamentFormat(),
|
||||
tournamentInfo.getCollectionType(), tournamentInfo.getTournamentRound(), tournamentInfo.getTournamentStage(),
|
||||
_pairingMechanismRegistry.getPairingMechanism(tournamentInfo.getPairingMechanism()));
|
||||
_pairingMechanismRegistry.getPairingMechanism(tournamentInfo.getPairingMechanism()),
|
||||
_tournamentPrizeSchemeRegistry.getTournamentPrizes(tournamentInfo.getPrizesScheme()));
|
||||
|
||||
} catch (Exception exp) {
|
||||
throw new RuntimeException("Unable to create Tournament", exp);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
|
||||
public interface TournamentTask {
|
||||
public void executeTask(TournamentCallback tournamentCallback);
|
||||
public void executeTask(TournamentCallback tournamentCallback, CollectionsManager collectionsManager);
|
||||
|
||||
public long getExecuteAfter();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class StorageBasedMerchantTest {
|
||||
public void cardPriceLowersAfterMerchantBuys() {
|
||||
_merchant.cardBought("1_1", new Date(0), 700);
|
||||
int cardInitialPrice = _merchant.getCardSellPrice("1_1", new Date(0));
|
||||
assertEqualsMoreOrLess((int) (1000 / 1.1f), cardInitialPrice);
|
||||
assertEqualsMoreOrLess((int) (1000 / 1.15f), cardInitialPrice);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +57,7 @@ public class StorageBasedMerchantTest {
|
||||
|
||||
_merchant.cardSold("1_1", new Date(0), 1000);
|
||||
int cardInitialPrice = _merchant.getCardSellPrice("1_1", new Date(0));
|
||||
assertEqualsMoreOrLess((int) (1000*1.1f), cardInitialPrice);
|
||||
assertEqualsMoreOrLess((int) (1000*1.15f), cardInitialPrice);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.competitive.PlayerStanding;
|
||||
import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
@@ -40,8 +41,10 @@ public class DefaultTournamentTest {
|
||||
PairingMechanism pairingMechanism = Mockito.mock(PairingMechanism.class);
|
||||
Mockito.when(pairingMechanism.shouldDropLoser()).thenReturn(true);
|
||||
|
||||
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
|
||||
|
||||
DefaultTournament tournament = new DefaultTournament(null, tournamentService, null, null, tournamentId, "Name", "format",
|
||||
CollectionType.ALL_CARDS, 0, Tournament.Stage.PLAYING_GAMES, pairingMechanism);
|
||||
CollectionType.ALL_CARDS, 0, Tournament.Stage.PLAYING_GAMES, pairingMechanism, new SingleEliminationOnDemandPrizes("onDemand"));
|
||||
tournament.setWaitForPairingsTime(_waitForPairingsTime);
|
||||
|
||||
Mockito.when(pairingMechanism.isFinished(Mockito.eq(3), Mockito.eq(allPlayers), Mockito.eq(droppedAfterRoundThree)))
|
||||
@@ -99,88 +102,94 @@ public class DefaultTournamentTest {
|
||||
}
|
||||
).when(tournamentCallback).broadcastMessage(Mockito.anyString());
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
|
||||
Mockito.verify(tournamentCallback).broadcastMessage(Mockito.anyString());
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
Thread.sleep(_waitForPairingsTime);
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p1", playerDecks.get("p1"), "p2", playerDecks.get("p2"), false);
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p3", playerDecks.get("p3"), "p4", playerDecks.get("p4"), false);
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p5", playerDecks.get("p5"), "p6", playerDecks.get("p6"), false);
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p7", playerDecks.get("p7"), "p8", playerDecks.get("p8"), false);
|
||||
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
assertEquals(1, tournament.getCurrentRound());
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p1", "p2");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p3", "p4");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p5", "p6");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p7", "p8");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verify(tournamentCallback, new Times(2)).broadcastMessage(Mockito.anyString());
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
Thread.sleep(_waitForPairingsTime);
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p1", playerDecks.get("p1"), "p3", playerDecks.get("p3"), false);
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p5", playerDecks.get("p5"), "p7", playerDecks.get("p7"), false);
|
||||
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
assertEquals(2, tournament.getCurrentRound());
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p1", "p3");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p5", "p7");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verify(tournamentCallback, new Times(3)).broadcastMessage(Mockito.anyString());
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
Thread.sleep(_waitForPairingsTime);
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
|
||||
Mockito.verify(tournamentCallback, new Times(1)).createGame("p1", playerDecks.get("p1"), "p5", playerDecks.get("p5"), false);
|
||||
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
assertEquals(3, tournament.getCurrentRound());
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
tournament.reportGameFinished("p1", "p5");
|
||||
|
||||
tournament.advanceTournament(tournamentCallback);
|
||||
tournament.advanceTournament(tournamentCallback, collectionsManager);
|
||||
Mockito.verify(tournamentCallback, new Times(4)).broadcastMessage(Mockito.anyString());
|
||||
Mockito.verifyNoMoreInteractions(tournamentCallback);
|
||||
|
||||
Mockito.verify(collectionsManager).addItemsToPlayerCollection(Mockito.eq(true), Mockito.anyString(), Mockito.eq("p1"), Mockito.eq(CollectionType.MY_CARDS), Mockito.anyCollection());
|
||||
Mockito.verify(collectionsManager).addItemsToPlayerCollection(Mockito.eq(true), Mockito.anyString(), Mockito.eq("p5"), Mockito.eq(CollectionType.MY_CARDS), Mockito.anyCollection());
|
||||
Mockito.verify(collectionsManager).addItemsToPlayerCollection(Mockito.eq(true), Mockito.anyString(), Mockito.eq("p3"), Mockito.eq(CollectionType.MY_CARDS), Mockito.anyCollection());
|
||||
Mockito.verify(collectionsManager).addItemsToPlayerCollection(Mockito.eq(true), Mockito.anyString(), Mockito.eq("p7"), Mockito.eq(CollectionType.MY_CARDS), Mockito.anyCollection());
|
||||
|
||||
Mockito.verifyNoMoreInteractions(collectionsManager, tournamentCallback);
|
||||
|
||||
assertEquals(3, tournament.getCurrentRound());
|
||||
assertEquals(Tournament.Stage.FINISHED, tournament.getTournamentStage());
|
||||
|
||||
@@ -16,7 +16,7 @@ public class SingleEliminationRecurringQueueTest {
|
||||
TournamentService tournamentService = Mockito.mock(TournamentService.class);
|
||||
|
||||
SingleEliminationRecurringQueue queue = new SingleEliminationRecurringQueue(10, "format", CollectionType.MY_CARDS,
|
||||
"id-", "name-", 2, false, tournamentService);
|
||||
"id-", "name-", 2, false, tournamentService, new NoPrizes());
|
||||
|
||||
Player player = new Player(1, "p1", "u", null);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SingleEliminationRecurringQueueTest {
|
||||
TournamentService tournamentService = Mockito.mock(TournamentService.class);
|
||||
|
||||
SingleEliminationRecurringQueue queue = new SingleEliminationRecurringQueue(10, "format", CollectionType.MY_CARDS,
|
||||
"id-", "name-", 2, false, tournamentService);
|
||||
"id-", "name-", 2, false, tournamentService, new NoPrizes());
|
||||
|
||||
Player player = new Player(1, "p1", "u", null);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SingleEliminationRecurringQueueTest {
|
||||
TournamentService tournamentService = Mockito.mock(TournamentService.class);
|
||||
|
||||
SingleEliminationRecurringQueue queue = new SingleEliminationRecurringQueue(10, "format", CollectionType.MY_CARDS,
|
||||
"id-", "name-", 2, false, tournamentService);
|
||||
"id-", "name-", 2, false, tournamentService, new NoPrizes());
|
||||
|
||||
Player player = new Player(1, "p1", "u", null);
|
||||
|
||||
@@ -89,11 +89,11 @@ public class SingleEliminationRecurringQueueTest {
|
||||
|
||||
TournamentService tournamentService = Mockito.mock(TournamentService.class);
|
||||
Mockito.when(tournamentService.addTournament(Mockito.anyString(), Mockito.<String>eq(null), Mockito.anyString(), Mockito.eq("format"),
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.<Date>any()))
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.anyString(), Mockito.<Date>any()))
|
||||
.thenReturn(tournament);
|
||||
|
||||
SingleEliminationRecurringQueue queue = new SingleEliminationRecurringQueue(10, "format", CollectionType.MY_CARDS,
|
||||
"id-", "name-", 2, false, tournamentService);
|
||||
"id-", "name-", 2, false, tournamentService, new NoPrizes());
|
||||
|
||||
|
||||
Player player1 = new Player(1, "p1", "u", null);
|
||||
@@ -121,7 +121,7 @@ public class SingleEliminationRecurringQueueTest {
|
||||
assertFalse(queue.isPlayerSignedUp("p2"));
|
||||
|
||||
Mockito.verify(tournamentService).addTournament(Mockito.anyString(), Mockito.<String>eq(null), Mockito.anyString(), Mockito.eq("format"),
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.<Date>any());
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.anyString(), Mockito.<Date>any());
|
||||
|
||||
Mockito.verify(tournamentService).addPlayer(Mockito.anyString(), Mockito.eq("p1"), Mockito.<LotroDeck>eq(null));
|
||||
Mockito.verify(tournamentService).addPlayer(Mockito.anyString(), Mockito.eq("p2"), Mockito.<LotroDeck>eq(null));
|
||||
@@ -136,11 +136,11 @@ public class SingleEliminationRecurringQueueTest {
|
||||
|
||||
TournamentService tournamentService = Mockito.mock(TournamentService.class);
|
||||
Mockito.when(tournamentService.addTournament(Mockito.anyString(), Mockito.<String>eq(null), Mockito.anyString(), Mockito.eq("format"),
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.<Date>any()))
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.anyString(), Mockito.<Date>any()))
|
||||
.thenReturn(tournament);
|
||||
|
||||
SingleEliminationRecurringQueue queue = new SingleEliminationRecurringQueue(10, "format", CollectionType.MY_CARDS,
|
||||
"id-", "name-", 2, false, tournamentService);
|
||||
"id-", "name-", 2, false, tournamentService, new NoPrizes());
|
||||
|
||||
Player player1 = new Player(1, "p1", "u", null);
|
||||
Player player2 = new Player(2, "p2", "u", null);
|
||||
@@ -170,7 +170,7 @@ public class SingleEliminationRecurringQueueTest {
|
||||
assertTrue(queue.isPlayerSignedUp("p3"));
|
||||
|
||||
Mockito.verify(tournamentService).addTournament(Mockito.anyString(), Mockito.<String>eq(null), Mockito.anyString(), Mockito.eq("format"),
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.<Date>any());
|
||||
Mockito.eq(CollectionType.MY_CARDS), Mockito.eq(Tournament.Stage.PLAYING_GAMES), Mockito.eq("singleElimination"), Mockito.anyString(), Mockito.<Date>any());
|
||||
|
||||
Mockito.verify(tournamentService).addPlayer(Mockito.anyString(), Mockito.eq("p1"), Mockito.<LotroDeck>eq(null));
|
||||
Mockito.verify(tournamentService).addPlayer(Mockito.anyString(), Mockito.eq("p2"), Mockito.<LotroDeck>eq(null));
|
||||
|
||||
@@ -46,12 +46,15 @@ public class ServerBuilder {
|
||||
extract(objectMap, LeagueParticipationDAO.class),
|
||||
extract(objectMap, CollectionsManager.class)));
|
||||
|
||||
TournamentPrizeSchemeRegistry tournamentPrizeSchemeRegistry = new TournamentPrizeSchemeRegistry();
|
||||
|
||||
objectMap.put(TournamentService.class,
|
||||
new TournamentService(
|
||||
extract(objectMap, CollectionsManager.class),
|
||||
extract(objectMap, PacksStorage.class),
|
||||
new DraftPackStorage(),
|
||||
new PairingMechanismRegistry(),
|
||||
tournamentPrizeSchemeRegistry,
|
||||
extract(objectMap, TournamentDAO.class),
|
||||
extract(objectMap, TournamentPlayerDAO.class),
|
||||
extract(objectMap, TournamentMatchDAO.class)));
|
||||
@@ -80,6 +83,7 @@ public class ServerBuilder {
|
||||
extract(objectMap, LotroCardBlueprintLibrary.class),
|
||||
extract(objectMap, LotroFormatLibrary.class),
|
||||
extract(objectMap, CollectionsManager.class),
|
||||
tournamentPrizeSchemeRegistry,
|
||||
false));
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ var GempLotrHallUI = Class.extend({
|
||||
header.append(" Tournament queues");
|
||||
|
||||
var table = $("<table class='tables queues'></table>");
|
||||
table.append("<tr><th width='20%'>Format</th><th width='20%'>Collection</th><th width='30%'>Queue name</th><th width='10%'>Players</th><th width='10%'>Cost</th><th width='10%'>Actions</th></tr>");
|
||||
table.append("<tr><th width='20%'>Format</th><th width='10%'>Collection</th><th width='20%'>Queue name</th><th width='10%'>Players</th><th width='10%'>Cost</th><th width='20%'>Prizes</th><th width='10%'>Actions</th></tr>");
|
||||
content.append(table);
|
||||
|
||||
this.tablesDiv.append(header);
|
||||
@@ -357,6 +357,7 @@ var GempLotrHallUI = Class.extend({
|
||||
"<td>" + queue.getAttribute("queue") + "</td>" +
|
||||
"<td>" + queue.getAttribute("playerCount") + "</td>" +
|
||||
"<td>" + formatPrice(queue.getAttribute("cost")) + "</td>" +
|
||||
"<td>" + queue.getAttribute("prizes") + "</td>" +
|
||||
"</tr>");
|
||||
|
||||
row.append(actionsField);
|
||||
|
||||
Reference in New Issue
Block a user