Adding solo drafts starting point

This commit is contained in:
marcin.sciesinski
2017-11-27 06:55:59 -08:00
parent 5f00462048
commit 75bc0183be
18 changed files with 224 additions and 32 deletions

View File

@@ -6,6 +6,7 @@ import com.gempukku.lotro.builder.DaoBuilder;
import com.gempukku.lotro.builder.PacksStorageBuilder;
import com.gempukku.lotro.builder.ServerBuilder;
import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.packs.PacksStorage;
import com.gempukku.lotro.service.LoggedUserHolder;
import com.gempukku.polling.LongPollingSystem;
@@ -28,6 +29,7 @@ public class LotroServerPipelineFactory implements ChannelPipelineFactory {
public LotroServerPipelineFactory() {
Map<Type, Object> objects = new HashMap<Type, Object>();
final CardSets cardSets = new CardSets();
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions();
LoggedUserHolder loggedUserHolder = new LoggedUserHolder();
loggedUserHolder.start();
@@ -38,6 +40,7 @@ public class LotroServerPipelineFactory implements ChannelPipelineFactory {
objects.put(LongPollingSystem.class, longPollingSystem);
objects.put(CardSets.class, cardSets);
objects.put(SoloDraftDefinitions.class, soloDraftDefinitions);
objects.put(PacksStorage.class, PacksStorageBuilder.createPacksStorage(cardSets));
DaoBuilder.fillObjectMap(objects);
ServerBuilder.fillObjectMap(objects);

View File

@@ -9,6 +9,7 @@ import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.LeagueDAO;
import com.gempukku.lotro.db.PlayerDAO;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
@@ -38,6 +39,7 @@ import java.util.List;
import java.util.Map;
public class AdminRequestHandler extends LotroServerRequestHandler implements UriRequestHandler {
private SoloDraftDefinitions _soloDraftDefinitions;
private LeagueService _leagueService;
private TournamentService _tournamentService;
private CacheManager _cacheManager;
@@ -52,6 +54,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
public AdminRequestHandler(Map<Type, Object> context) {
super(context);
_cardSets = extractObject(context, CardSets.class);
_soloDraftDefinitions = extractObject(context, SoloDraftDefinitions.class);
_leagueService = extractObject(context, LeagueService.class);
_tournamentService = extractObject(context, TournamentService.class);
_cacheManager = extractObject(context, CacheManager.class);
@@ -290,7 +293,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));
String parameters = sb.toString();
LeagueData leagueData = new NewConstructedLeagueData(_cardSets, parameters);
LeagueData leagueData = new NewConstructedLeagueData(_cardSets, _soloDraftDefinitions, parameters);
List<LeagueSerieData> series = leagueData.getSeries();
int leagueStart = series.get(0).getStart();
int displayEnd = DateUtils.offsetDate(series.get(series.size() - 1).getEnd(), 2);
@@ -321,7 +324,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));
String parameters = sb.toString();
LeagueData leagueData = new NewConstructedLeagueData(_cardSets, parameters);
LeagueData leagueData = new NewConstructedLeagueData(_cardSets, _soloDraftDefinitions, parameters);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
@@ -371,7 +374,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
String code = String.valueOf(System.currentTimeMillis());
String parameters = format + "," + start + "," + serieDuration + "," + maxMatches + "," + code + "," + name;
LeagueData leagueData = new NewSealedLeagueData(_cardSets, parameters);
LeagueData leagueData = new NewSealedLeagueData(_cardSets, _soloDraftDefinitions, parameters);
List<LeagueSerieData> series = leagueData.getSeries();
int leagueStart = series.get(0).getStart();
int displayEnd = DateUtils.offsetDate(series.get(series.size() - 1).getEnd(), 2);
@@ -397,7 +400,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
String code = String.valueOf(System.currentTimeMillis());
String parameters = format + "," + start + "," + serieDuration + "," + maxMatches + "," + code + "," + name;
LeagueData leagueData = new NewSealedLeagueData(_cardSets, parameters);
LeagueData leagueData = new NewSealedLeagueData(_cardSets, _soloDraftDefinitions, parameters);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.LeagueMatchResult;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.league.LeagueData;
@@ -30,6 +31,7 @@ import java.util.List;
import java.util.Map;
public class LeagueRequestHandler extends LotroServerRequestHandler implements UriRequestHandler {
private final SoloDraftDefinitions _soloDraftDefinitions;
private LeagueService _leagueService;
private LotroFormatLibrary _formatLibrary;
private CardSets _cardSets;
@@ -38,6 +40,7 @@ public class LeagueRequestHandler extends LotroServerRequestHandler implements U
super(context);
_cardSets = extractObject(context, CardSets.class);
_soloDraftDefinitions = extractObject(context, SoloDraftDefinitions.class);
_leagueService = extractObject(context, LeagueService.class);
_formatLibrary = extractObject(context, LotroFormatLibrary.class);
}
@@ -87,7 +90,7 @@ public class LeagueRequestHandler extends LotroServerRequestHandler implements U
if (league == null)
throw new HttpProcessingException(404);
final LeagueData leagueData = league.getLeagueData(_cardSets);
final LeagueData leagueData = league.getLeagueData(_cardSets, _soloDraftDefinitions);
final List<LeagueSerieData> series = leagueData.getSeries();
int end = series.get(series.size() - 1).getEnd();
@@ -97,6 +100,7 @@ public class LeagueRequestHandler extends LotroServerRequestHandler implements U
leagueElem.setAttribute("member", String.valueOf(inLeague));
leagueElem.setAttribute("joinable", String.valueOf(!inLeague && end >= DateUtils.getCurrentDate()));
leagueElem.setAttribute("draftable", String.valueOf(inLeague && leagueData.isDraftLeague()));
leagueElem.setAttribute("type", league.getType());
leagueElem.setAttribute("name", league.getName());
leagueElem.setAttribute("cost", String.valueOf(league.getCost()));
@@ -154,7 +158,7 @@ public class LeagueRequestHandler extends LotroServerRequestHandler implements U
Element leagues = doc.createElement("leagues");
for (League league : _leagueService.getActiveLeagues()) {
final LeagueData leagueData = league.getLeagueData(_cardSets);
final LeagueData leagueData = league.getLeagueData(_cardSets, _soloDraftDefinitions);
final List<LeagueSerieData> series = leagueData.getSeries();
int end = series.get(series.size() - 1).getEnd();

View File

@@ -12,6 +12,7 @@ import com.gempukku.lotro.db.LeagueDAO;
import com.gempukku.lotro.db.LeagueMatchDAO;
import com.gempukku.lotro.db.LeagueParticipationDAO;
import com.gempukku.lotro.db.PlayerDAO;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.AdventureLibrary;
import com.gempukku.lotro.game.DefaultAdventureLibrary;
import com.gempukku.lotro.game.GameHistoryService;
@@ -68,7 +69,8 @@ public class ServerBuilder {
extract(objectMap, LeagueMatchDAO.class),
extract(objectMap, LeagueParticipationDAO.class),
extract(objectMap, CollectionsManager.class),
extract(objectMap, CardSets.class)));
extract(objectMap, CardSets.class),
extract(objectMap, SoloDraftDefinitions.class)));
objectMap.put(AdminService.class,
new AdminService(

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.db.vo;
import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.league.LeagueData;
import java.lang.reflect.Constructor;
@@ -35,12 +36,12 @@ public class League {
return _type;
}
public synchronized LeagueData getLeagueData(CardSets cardSets) {
public synchronized LeagueData getLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions) {
if (_leagueData == null) {
try {
Class<?> aClass = Class.forName(_clazz);
Constructor<?> constructor = aClass.getConstructor(CardSets.class, String.class);
_leagueData = (LeagueData) constructor.newInstance(cardSets, _parameters);
Constructor<?> constructor = aClass.getConstructor(CardSets.class, SoloDraftDefinitions.class, String.class);
_leagueData = (LeagueData) constructor.newInstance(cardSets, soloDraftDefinitions, _parameters);
} catch (Exception exp) {
throw new RuntimeException("Unable to create LeagueData", exp);
}

View File

@@ -0,0 +1,13 @@
package com.gempukku.lotro.draft2;
import com.gempukku.lotro.game.CardCollection;
public interface SoloDraft {
CardCollection initializeNewCollection(long seed);
CardCollection getAvailableChoices(long seed, int stage);
boolean hasNextStage(long seed, int stage);
String getFormat();
}

View File

@@ -0,0 +1,8 @@
package com.gempukku.lotro.draft2;
public class SoloDraftDefinitions {
public SoloDraft getSoloDraft(String draftType) {
// TODO
return null;
}
}

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.Player;
@@ -22,7 +23,7 @@ public class ConstructedLeagueData implements LeagueData {
// serie1 format, serie1 prize pool,
// serie2 format, serie2 prize pool,
// serie3 format, serie3 prize pool,
public ConstructedLeagueData(CardSets cardSets, String parameters) {
public ConstructedLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(cardSets);
String[] params = parameters.split(",");
@@ -41,6 +42,11 @@ public class ConstructedLeagueData implements LeagueData {
}
}
@Override
public boolean isDraftLeague() {
return false;
}
@Override
public List<LeagueSerieData> getSeries() {
return _series;

View File

@@ -0,0 +1,117 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraft;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.DefaultCardCollection;
import com.gempukku.lotro.game.MutableCardCollection;
import com.gempukku.lotro.game.Player;
import java.util.*;
public class DraftLeagueData implements LeagueData {
private SoloDraft _draft;
private CollectionType _collectionType;
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private LeaguePrizes _leaguePrizes;
private LeagueSerieData _serie;
public DraftLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(cardSets);
String[] params = parameters.split(",");
_draft = soloDraftDefinitions.getSoloDraft(params[0]);
int start = Integer.parseInt(params[1]);
int serieDuration = Integer.parseInt(params[2]);
int maxMatches = Integer.parseInt(params[3]);
_collectionType = new CollectionType(params[4], params[5]);
_serie = new DefaultLeagueSerieData(_leaguePrizes, true, "Serie 1",
DateUtils.offsetDate(start, 0), DateUtils.offsetDate(start, serieDuration - 1), maxMatches,
_draft.getFormat(), _collectionType);
}
@Override
public boolean isDraftLeague() {
return true;
}
@Override
public List<LeagueSerieData> getSeries() {
return Collections.singletonList(_serie);
}
private long getSeed(Player player) {
return _collectionType.getCode().hashCode() + player.getId();
}
@Override
public CardCollection joinLeague(CollectionsManager collectionsManager, Player player, int currentTime) {
MutableCardCollection startingCollection = new DefaultCardCollection();
if (currentTime >= _serie.getStart()) {
CardCollection leagueProduct = _draft.initializeNewCollection(getSeed(player));
for (Map.Entry<String, CardCollection.Item> serieCollectionItem : leagueProduct.getAll().entrySet())
startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue().getCount());
}
startingCollection.setExtraInformation(createExtraInformation());
collectionsManager.addPlayerCollection(false, "Sealed league product", player, _collectionType, startingCollection);
return startingCollection;
}
private Map<String, Object> createExtraInformation() {
Map<String, Object> extraInformation = new HashMap<String, Object>();
extraInformation.put("finished", false);
extraInformation.put("stage", 0);
return extraInformation;
}
@Override
public int process(CollectionsManager collectionsManager, List<PlayerStanding> leagueStandings, int oldStatus, int currentTime) {
int status = oldStatus;
if (status == 0) {
if (currentTime >= _serie.getStart()) {
Map<Player, CardCollection> map = collectionsManager.getPlayersCollection(_collectionType.getCode());
for (Map.Entry<Player, CardCollection> playerCardCollectionEntry : map.entrySet()) {
MutableCardCollection startingCollection = new DefaultCardCollection();
Player player = playerCardCollectionEntry.getKey();
CardCollection leagueProduct = _draft.initializeNewCollection(getSeed(player));
for (Map.Entry<String, CardCollection.Item> serieCollectionItem : leagueProduct.getAll().entrySet())
startingCollection.addItem(serieCollectionItem.getKey(), serieCollectionItem.getValue().getCount());
startingCollection.setExtraInformation(createExtraInformation());
collectionsManager.addItemsToPlayerCollection(false, "New sealed league product", player, _collectionType, leagueProduct.getAll().values());
}
status = 1;
}
}
int maxGamesTotal = _serie.getMaxMatches();
if (status == 1) {
if (currentTime > DateUtils.offsetDate(_serie.getEnd(), 1)) {
for (PlayerStanding leagueStanding : leagueStandings) {
CardCollection leaguePrize = _leaguePrizes.getPrizeForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType);
if (leaguePrize != null)
collectionsManager.addItemsToPlayerCollection(true, "End of league prizes", leagueStanding.getPlayerName(), _prizeCollectionType, leaguePrize.getAll().values());
final CardCollection leagueTrophies = _leaguePrizes.getTrophiesForLeague(leagueStanding.getStanding(), leagueStandings.size(), leagueStanding.getGamesPlayed(), maxGamesTotal, _collectionType);
if (leagueTrophies != null)
collectionsManager.addItemsToPlayerCollection(true, "End of league trophies", leagueStanding.getPlayerName(), CollectionType.TROPHY, leagueTrophies.getAll().values());
}
status++;
}
}
return status;
}
}

View File

@@ -8,6 +8,8 @@ import com.gempukku.lotro.game.Player;
import java.util.List;
public interface LeagueData {
public boolean isDraftLeague();
public List<LeagueSerieData> getSeries();
public CardCollection joinLeague(CollectionsManager collecionsManager, Player player, int currentTime);

View File

@@ -11,6 +11,7 @@ import com.gempukku.lotro.db.LeagueParticipationDAO;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.LeagueMatchResult;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.Player;
@@ -28,6 +29,7 @@ public class LeagueService {
private CachedLeagueParticipationDAO _leagueParticipationDAO;
private CollectionsManager _collectionsManager;
private SoloDraftDefinitions _soloDraftDefinitions;
private Map<String, List<PlayerStanding>> _leagueStandings = new ConcurrentHashMap<String, List<PlayerStanding>>();
private Map<String, List<PlayerStanding>> _leagueSerieStandings = new ConcurrentHashMap<String, List<PlayerStanding>>();
@@ -36,12 +38,14 @@ public class LeagueService {
private List<League> _activeLeagues;
public LeagueService(LeagueDAO leagueDao, LeagueMatchDAO leagueMatchDao,
LeagueParticipationDAO leagueParticipationDAO, CollectionsManager collectionsManager, CardSets cardSets) {
LeagueParticipationDAO leagueParticipationDAO, CollectionsManager collectionsManager,
CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions) {
_leagueDao = leagueDao;
_cardSets = cardSets;
_leagueMatchDao = new CachedLeagueMatchDAO(leagueMatchDao);
_leagueParticipationDAO = new CachedLeagueParticipationDAO(leagueParticipationDAO);
_collectionsManager = collectionsManager;
_soloDraftDefinitions = soloDraftDefinitions;
}
public synchronized void clearCache() {
@@ -83,7 +87,7 @@ public class LeagueService {
private void processLoadedLeagues(int currentDate) {
for (League activeLeague : _activeLeagues) {
int oldStatus = activeLeague.getStatus();
int newStatus = activeLeague.getLeagueData(_cardSets).process(_collectionsManager, getLeagueStandings(activeLeague), oldStatus, currentDate);
int newStatus = activeLeague.getLeagueData(_cardSets, _soloDraftDefinitions).process(_collectionsManager, getLeagueStandings(activeLeague), oldStatus, currentDate);
if (newStatus != oldStatus)
_leagueDao.setStatus(activeLeague, newStatus);
}
@@ -99,7 +103,7 @@ public class LeagueService {
int cost = league.getCost();
if (_collectionsManager.removeCurrencyFromPlayerCollection("Joining "+league.getName()+" league", player, CollectionType.MY_CARDS, cost)) {
_leagueParticipationDAO.userJoinsLeague(league.getType(), player, remoteAddr);
league.getLeagueData(_cardSets).joinLeague(_collectionsManager, player, DateUtils.getCurrentDate());
league.getLeagueData(_cardSets, _soloDraftDefinitions).joinLeague(_collectionsManager, player, DateUtils.getCurrentDate());
_leagueStandings.remove(LeagueMapKeys.getLeagueMapKey(league));
@@ -119,7 +123,7 @@ public class LeagueService {
public synchronized CollectionType getCollectionTypeByCode(String collectionTypeCode) {
for (League league : getActiveLeagues()) {
for (LeagueSerieData leagueSerieData : league.getLeagueData(_cardSets).getSeries()) {
for (LeagueSerieData leagueSerieData : league.getLeagueData(_cardSets, _soloDraftDefinitions).getSeries()) {
CollectionType collectionType = leagueSerieData.getCollectionType();
if (collectionType != null && collectionType.getCode().equals(collectionTypeCode))
return collectionType;
@@ -131,7 +135,7 @@ public class LeagueService {
public synchronized LeagueSerieData getCurrentLeagueSerie(League league) {
final int currentDate = DateUtils.getCurrentDate();
for (LeagueSerieData leagueSerieData : league.getLeagueData(_cardSets).getSeries()) {
for (LeagueSerieData leagueSerieData : league.getLeagueData(_cardSets, _soloDraftDefinitions).getSeries()) {
if (currentDate >= leagueSerieData.getStart() && currentDate <= leagueSerieData.getEnd())
return leagueSerieData;
}

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.Player;
@@ -19,7 +20,7 @@ public class NewConstructedLeagueData implements LeagueData {
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
private CollectionType _collectionType;
public NewConstructedLeagueData(CardSets cardSets, String parameters) {
public NewConstructedLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(cardSets);
String[] params = parameters.split(",");
@@ -44,6 +45,11 @@ public class NewConstructedLeagueData implements LeagueData {
}
}
@Override
public boolean isDraftLeague() {
return false;
}
@Override
public List<LeagueSerieData> getSeries() {
return Collections.unmodifiableList(_series);

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.DefaultCardCollection;
import com.gempukku.lotro.game.MutableCardCollection;
@@ -23,7 +24,7 @@ public class NewSealedLeagueData implements LeagueData {
private LeaguePrizes _leaguePrizes;
private SealedLeagueProduct _leagueProduct;
public NewSealedLeagueData(CardSets cardSets, String parameters) {
public NewSealedLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(cardSets);
String[] params = parameters.split(",");
@@ -45,6 +46,11 @@ public class NewSealedLeagueData implements LeagueData {
}
}
@Override
public boolean isDraftLeague() {
return false;
}
@Override
public List<LeagueSerieData> getSeries() {
return Collections.unmodifiableList(_series);

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.DefaultCardCollection;
import com.gempukku.lotro.game.MutableCardCollection;
@@ -23,7 +24,7 @@ public class SealedLeagueData implements LeagueData {
private LeaguePrizes _leaguePrizes;
private SealedLeagueProduct _leagueProduct;
public SealedLeagueData(CardSets cardSets, String parameters) {
public SealedLeagueData(CardSets cardSets, SoloDraftDefinitions soloDraftDefinitions, String parameters) {
_leaguePrizes = new FixedLeaguePrizes(cardSets);
String[] params = parameters.split(",");
@@ -45,6 +46,11 @@ public class SealedLeagueData implements LeagueData {
}
}
@Override
public boolean isDraftLeague() {
return false;
}
@Override
public List<LeagueSerieData> getSeries() {
return Collections.unmodifiableList(_series);

View File

@@ -323,5 +323,13 @@
"set":[30, 31],
"restrictedName":["Gandalf", "Bilbo"],
"hall":true
},
{
"name":"Limited",
"code":"limited_hobbit",
"sites":"HOBBIT",
"cancelRingBearerSkirmish":true,
"set":[30, 31],
"hall":false
}
]

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.league;
import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import org.junit.Test;
import java.util.List;
@@ -11,7 +12,7 @@ import static org.junit.Assert.assertTrue;
public class ConstructedLeagueDataTest {
@Test
public void testParameters() {
ConstructedLeagueData leagueData = new ConstructedLeagueData(new CardSets(), "20120312,fotr_block,0.7,default,All cards,7,10,3,fotr1_block,fotr_block,fotr2_block,fotr_block,fotr_block,fotr_block");
ConstructedLeagueData leagueData = new ConstructedLeagueData(new CardSets(), new SoloDraftDefinitions(), "20120312,fotr_block,0.7,default,All cards,7,10,3,fotr1_block,fotr_block,fotr2_block,fotr_block,fotr_block,fotr_block");
final List<LeagueSerieData> series = leagueData.getSeries();
assertTrue(series.size() == 3);
assertTrue(series.get(0).getStart() == 20120312);

View File

@@ -8,6 +8,7 @@ import com.gempukku.lotro.db.LeagueMatchDAO;
import com.gempukku.lotro.db.LeagueParticipationDAO;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.LeagueMatchResult;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import org.junit.Test;
import org.mockito.Mockito;
@@ -34,7 +35,7 @@ public class LeagueServiceTest {
League league = new League(5000, "League name", "leagueType", NewConstructedLeagueData.class.getName(), sb.toString(), 0);
leagues.add(league);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets).getSeries().get(0);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, new SoloDraftDefinitions()).getSeries().get(0);
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
@@ -47,7 +48,7 @@ public class LeagueServiceTest {
LeagueParticipationDAO leagueParticipationDAO = Mockito.mock(LeagueParticipationDAO.class);
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, new SoloDraftDefinitions());
assertTrue(leagueService.canPlayRankedGame(league, leagueSerie, "player1"));
assertTrue(leagueService.canPlayRankedGameAgainst(league, leagueSerie, "player1", "player2"));
@@ -87,7 +88,7 @@ public class LeagueServiceTest {
League league = new League(5000, "League name", "leagueType", NewConstructedLeagueData.class.getName(), sb.toString(), 0);
leagues.add(league);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets).getSeries().get(0);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, new SoloDraftDefinitions()).getSeries().get(0);
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
@@ -101,7 +102,7 @@ public class LeagueServiceTest {
LeagueParticipationDAO leagueParticipationDAO = Mockito.mock(LeagueParticipationDAO.class);
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, new SoloDraftDefinitions());
assertTrue(leagueService.canPlayRankedGame(league, leagueSerie, "player1"));
assertFalse(leagueService.canPlayRankedGameAgainst(league, leagueSerie, "player1", "player2"));
@@ -133,7 +134,7 @@ public class LeagueServiceTest {
League league = new League(5000, "League name", "leagueType", NewConstructedLeagueData.class.getName(), sb.toString(), 0);
leagues.add(league);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets).getSeries().get(0);
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, new SoloDraftDefinitions()).getSeries().get(0);
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
@@ -151,7 +152,7 @@ public class LeagueServiceTest {
Mockito.when(leagueParticipationDAO.getUsersParticipating(league.getType())).thenReturn(players);
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets);
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, new SoloDraftDefinitions());
leagueService.reportLeagueGameResult(league, leagueSerie, "player1", "player2");
leagueService.reportLeagueGameResult(league, leagueSerie, "player1", "player3");

View File

@@ -3,6 +3,7 @@ package com.gempukku.lotro.league;
import com.gempukku.lotro.cards.CardSets;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.DefaultCardCollection;
import com.gempukku.lotro.game.Player;
@@ -20,7 +21,7 @@ import static org.junit.Assert.assertEquals;
public class SealedLeagueDataTest {
@Test
public void testJoinLeagueFirstWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
CollectionType collectionType = new CollectionType("test", "Test Collection");
for (int i = 20120101; i < 20120108; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
@@ -55,7 +56,7 @@ public class SealedLeagueDataTest {
@Test
public void testJoinLeagueSecondWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
CollectionType collectionType = new CollectionType("test", "Test Collection");
for (int i = 20120108; i < 20120115; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
@@ -96,7 +97,7 @@ public class SealedLeagueDataTest {
@Test
public void testSwitchToFirstWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
for (int i = 20120101; i < 20120108; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());
@@ -109,7 +110,7 @@ public class SealedLeagueDataTest {
@Test
public void testProcessMidFirstWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
for (int i = 20120101; i < 20120108; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());
@@ -121,7 +122,7 @@ public class SealedLeagueDataTest {
@Test
public void testSwitchToSecondWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
CollectionType collectionType = new CollectionType("test", "Test Collection");
for (int i = 20120108; i < 20120115; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
@@ -157,7 +158,7 @@ public class SealedLeagueDataTest {
@Test
public void testProcessMidSecondWeek() {
SealedLeagueData data = new SealedLeagueData(new CardSets(), "fotr_block,20120101,test,Test Collection");
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
for (int i = 20120108; i < 20120115; i++) {
CollectionsManager collectionsManager = Mockito.mock(CollectionsManager.class);
Mockito.when(collectionsManager.getPlayersCollection("test")).thenReturn(new HashMap<Player, CardCollection>());