First test draft fully working
This commit is contained in:
@@ -29,7 +29,6 @@ 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();
|
||||
@@ -40,7 +39,6 @@ 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);
|
||||
|
||||
@@ -37,6 +37,18 @@ var LeagueResultsUI = Class.extend({
|
||||
});
|
||||
},
|
||||
|
||||
loadResultsWithLeague:function (type) {
|
||||
var that = this;
|
||||
this.communication.getLeagues(
|
||||
function (xml) {
|
||||
that.loadedLeagueResults(xml);
|
||||
that.communication.getLeague(type,
|
||||
function (xml) {
|
||||
that.loadedLeague(xml);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
loadedLeague:function (xml) {
|
||||
var that = this;
|
||||
log(xml);
|
||||
@@ -81,7 +93,7 @@ var LeagueResultsUI = Class.extend({
|
||||
that.displayBuyAction("Do you want to join the league by paying " + costString + "?",
|
||||
function () {
|
||||
that.communication.joinLeague(leagueCode, function () {
|
||||
that.loadResults();
|
||||
that.loadResultsWithLeague(leagueCode);
|
||||
}, {
|
||||
"409":function () {
|
||||
alert("You don't have enough funds to join this league.");
|
||||
|
||||
@@ -114,7 +114,7 @@ var GempLotrSoloDraftUI = Class.extend({
|
||||
}
|
||||
});
|
||||
|
||||
this.comm.getCollection(this.leagueType, null, 0, 1000,
|
||||
this.comm.getCollection(this.leagueType, "sort:cardType,culture,name", 0, 1000,
|
||||
function (xml) {
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == "collection") {
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
Start (YYYYMMDD): <input type="text" name="start"><br/>
|
||||
Format:
|
||||
<select name="format">
|
||||
<option value="hobbit_draft">Hobbit Draft</option>
|
||||
<option value="test_draft">Test Draft</option>
|
||||
</select><br/>
|
||||
Series duration in days: <input type="text" name="serieDuration"><br/>
|
||||
Maximum matches in series: <input type="text" name="maxMatches"><br/>
|
||||
|
||||
@@ -64,6 +64,13 @@ public class ServerBuilder {
|
||||
extract(objectMap, LotroCardBlueprintLibrary.class),
|
||||
extract(objectMap, CardSets.class)));
|
||||
|
||||
objectMap.put(SoloDraftDefinitions.class,
|
||||
new SoloDraftDefinitions(
|
||||
extract(objectMap, CollectionsManager.class),
|
||||
extract(objectMap, LotroCardBlueprintLibrary.class),
|
||||
extract(objectMap, LotroFormatLibrary.class),
|
||||
extract(objectMap, CardSets.class).getSetDefinitions()));
|
||||
|
||||
objectMap.put(LeagueService.class,
|
||||
new LeagueService(
|
||||
extract(objectMap, LeagueDAO.class),
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.gempukku.lotro.draft2;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.SetDefinition;
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.draft2.builder.CardCollectionProducer;
|
||||
import com.gempukku.lotro.draft2.builder.DraftChoiceBuilder;
|
||||
import com.gempukku.lotro.draft2.builder.StartingPoolBuilder;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -16,9 +19,11 @@ import java.util.*;
|
||||
public class SoloDraftDefinitions {
|
||||
private Map<String, SoloDraft> draftTypes = new HashMap<String, SoloDraft>();
|
||||
private StartingPoolBuilder startingPoolBuilder = new StartingPoolBuilder();
|
||||
private DraftChoiceBuilder draftChoiceBuilder = new DraftChoiceBuilder();
|
||||
private DraftChoiceBuilder draftChoiceBuilder;
|
||||
|
||||
public SoloDraftDefinitions() {
|
||||
public SoloDraftDefinitions(CollectionsManager collectionsManager, LotroCardBlueprintLibrary cardLibrary,
|
||||
LotroFormatLibrary formatLibrary, Map<String, SetDefinition> rarities) {
|
||||
draftChoiceBuilder = new DraftChoiceBuilder(collectionsManager, cardLibrary, formatLibrary, rarities);
|
||||
try {
|
||||
final InputStreamReader reader = new InputStreamReader(LotroFormatLibrary.class.getResourceAsStream("/lotrDrafts.json"), "UTF-8");
|
||||
try {
|
||||
|
||||
@@ -1,15 +1,36 @@
|
||||
package com.gempukku.lotro.draft2.builder;
|
||||
|
||||
import com.gempukku.lotro.cards.packs.SetDefinition;
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.draft2.DraftChoiceDefinition;
|
||||
import com.gempukku.lotro.draft2.SoloDraft;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.DefaultCardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.SortAndFilterCards;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class DraftChoiceBuilder {
|
||||
public static final int HIGH_ENOUGH_PRIME_NUMBER = 9497;
|
||||
private CollectionsManager _collectionsManager;
|
||||
private LotroCardBlueprintLibrary _cardLibrary;
|
||||
private LotroFormatLibrary _formatLibrary;
|
||||
private Map<String, SetDefinition> _rarities;
|
||||
private SortAndFilterCards _sortAndFilterCards;
|
||||
|
||||
public DraftChoiceBuilder(CollectionsManager collectionsManager, LotroCardBlueprintLibrary cardLibrary,
|
||||
LotroFormatLibrary formatLibrary, Map<String, SetDefinition> rarities) {
|
||||
_collectionsManager = collectionsManager;
|
||||
_cardLibrary = cardLibrary;
|
||||
_formatLibrary = formatLibrary;
|
||||
_rarities = rarities;
|
||||
_sortAndFilterCards = new SortAndFilterCards();
|
||||
}
|
||||
|
||||
public DraftChoiceDefinition buildDraftChoiceDefinition(JSONObject choiceDefinition) {
|
||||
return constructDraftChoiceDefinition(choiceDefinition);
|
||||
}
|
||||
@@ -19,14 +40,71 @@ public class DraftChoiceBuilder {
|
||||
JSONObject data = (JSONObject) choiceDefinition.get("data");
|
||||
if (choiceDefinitionType.equals("singleCollectionPick"))
|
||||
return buildSingleCollectionPickDraftChoiceDefinition(data);
|
||||
else if (choiceDefinitionType.equals("weightedSwitch"))
|
||||
return buildWeightedSwitchDraftChoiceDefinition(data);
|
||||
else if (choiceDefinitionType.equals("multipleCardPick"))
|
||||
return buildMultipleCardPickDraftChoiceDefinition(data);
|
||||
else if (choiceDefinitionType.equals("randomSwitch"))
|
||||
return buildRandomSwitchDraftChoiceDeifinition(data);
|
||||
else if (choiceDefinitionType.equals("filterPick"))
|
||||
return buildFilterPickDraftChoiceDefinition(data);
|
||||
else
|
||||
throw new RuntimeException("Unknown choiceDefinitionType: " + choiceDefinitionType);
|
||||
}
|
||||
|
||||
private DraftChoiceDefinition buildFilterPickDraftChoiceDefinition(JSONObject data) {
|
||||
final int optionCount = ((Number) data.get("optionCount")).intValue();
|
||||
String filter = (String) data.get("filter");
|
||||
|
||||
Collection<CardCollection.Item> items = _collectionsManager.getDefaultCollection().getAll().values();
|
||||
|
||||
final List<CardCollection.Item> possibleCards = _sortAndFilterCards.process(filter, items, _cardLibrary, _formatLibrary, _rarities);
|
||||
|
||||
return new DraftChoiceDefinition() {
|
||||
@Override
|
||||
public Iterable<SoloDraft.DraftChoice> getDraftChoice(long seed, int stage) {
|
||||
final List<CardCollection.Item> cards = getCards(seed, stage);
|
||||
|
||||
List<SoloDraft.DraftChoice> draftChoices = new ArrayList<SoloDraft.DraftChoice>(optionCount);
|
||||
for (int i = 0; i < Math.min(optionCount, possibleCards.size()); i++) {
|
||||
final int finalI = i;
|
||||
draftChoices.add(
|
||||
new SoloDraft.DraftChoice() {
|
||||
@Override
|
||||
public String getChoiceId() {
|
||||
return cards.get(finalI).getBlueprintId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlueprintId() {
|
||||
return cards.get(finalI).getBlueprintId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChoiceUrl() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
return draftChoices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getCardsForChoiceId(String choiceId, long seed, int stage) {
|
||||
DefaultCardCollection cardCollection = new DefaultCardCollection();
|
||||
cardCollection.addItem(choiceId, 1);
|
||||
return cardCollection;
|
||||
}
|
||||
|
||||
private List<CardCollection.Item> getCards(long seed, int stage) {
|
||||
Random rnd = getRandom(seed, stage);
|
||||
final List<CardCollection.Item> cards = new ArrayList<CardCollection.Item>(possibleCards);
|
||||
Collections.shuffle(cards, rnd);
|
||||
return cards;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private DraftChoiceDefinition buildSingleCollectionPickDraftChoiceDefinition(JSONObject data) {
|
||||
JSONArray switchResult = (JSONArray) data.get("possiblePicks");
|
||||
|
||||
@@ -82,7 +160,6 @@ public class DraftChoiceBuilder {
|
||||
}
|
||||
|
||||
private DraftChoiceDefinition buildMultipleCardPickDraftChoiceDefinition(JSONObject data) {
|
||||
final long selectionSeed = ((Number) data.get("seed")).longValue();
|
||||
final int count = ((Number) data.get("count")).intValue();
|
||||
JSONArray availableCards = (JSONArray) data.get("availableCards");
|
||||
|
||||
@@ -135,7 +212,7 @@ public class DraftChoiceBuilder {
|
||||
}
|
||||
|
||||
private List<String> getShuffledCards(long seed, int stage) {
|
||||
Random rnd = new Random(seed + selectionSeed + stage);
|
||||
Random rnd = getRandom(seed, stage);
|
||||
final List<String> shuffledCards = new ArrayList<String>(cards);
|
||||
Collections.shuffle(shuffledCards, rnd);
|
||||
return shuffledCards;
|
||||
@@ -144,7 +221,6 @@ public class DraftChoiceBuilder {
|
||||
}
|
||||
|
||||
private DraftChoiceDefinition buildRandomSwitchDraftChoiceDeifinition(JSONObject data) {
|
||||
final long selectionSeed = ((Number) data.get("seed")).longValue();
|
||||
JSONArray switchResult = (JSONArray) data.get("switchResult");
|
||||
|
||||
final List<DraftChoiceDefinition> draftChoiceDefinitionList = new ArrayList<DraftChoiceDefinition>();
|
||||
@@ -154,15 +230,57 @@ public class DraftChoiceBuilder {
|
||||
return new DraftChoiceDefinition() {
|
||||
@Override
|
||||
public Iterable<SoloDraft.DraftChoice> getDraftChoice(long seed, int stage) {
|
||||
Random rnd = new Random(seed + selectionSeed);
|
||||
Random rnd = getRandom(seed, stage);
|
||||
return draftChoiceDefinitionList.get(rnd.nextInt(draftChoiceDefinitionList.size())).getDraftChoice(seed, stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getCardsForChoiceId(String choiceId, long seed, int stage) {
|
||||
Random rnd = new Random(seed + selectionSeed);
|
||||
Random rnd = getRandom(seed, stage);
|
||||
return draftChoiceDefinitionList.get(rnd.nextInt(draftChoiceDefinitionList.size())).getCardsForChoiceId(choiceId, seed, stage);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private DraftChoiceDefinition buildWeightedSwitchDraftChoiceDefinition(JSONObject data) {
|
||||
JSONArray switchResult = (JSONArray) data.get("switchResult");
|
||||
|
||||
final Map<Float, DraftChoiceDefinition> draftChoiceDefinitionMap = new LinkedHashMap<Float, DraftChoiceDefinition>();
|
||||
float weightTotal = 0;
|
||||
for (JSONObject switchResultObject : (Iterable<JSONObject>) switchResult) {
|
||||
float weight = ((Number) switchResultObject.get("weight")).floatValue();
|
||||
weightTotal += weight;
|
||||
draftChoiceDefinitionMap.put(weightTotal, constructDraftChoiceDefinition(switchResultObject));
|
||||
}
|
||||
|
||||
return new DraftChoiceDefinition() {
|
||||
@Override
|
||||
public Iterable<SoloDraft.DraftChoice> getDraftChoice(long seed, int stage) {
|
||||
Random rnd = getRandom(seed, stage);
|
||||
float result = rnd.nextFloat();
|
||||
for (Map.Entry<Float, DraftChoiceDefinition> weightEntry : draftChoiceDefinitionMap.entrySet()) {
|
||||
if (result < weightEntry.getKey())
|
||||
return weightEntry.getValue().getDraftChoice(seed, stage);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getCardsForChoiceId(String choiceId, long seed, int stage) {
|
||||
Random rnd = getRandom(seed, stage);
|
||||
float result = rnd.nextFloat();
|
||||
for (Map.Entry<Float, DraftChoiceDefinition> weightEntry : draftChoiceDefinitionMap.entrySet()) {
|
||||
if (result < weightEntry.getKey())
|
||||
return weightEntry.getValue().getCardsForChoiceId(choiceId, seed, stage);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Random getRandom(long seed, int stage) {
|
||||
return new Random(seed + stage * HIGH_ENOUGH_PRIME_NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ public class StartingPoolBuilder {
|
||||
}
|
||||
|
||||
private CardCollectionProducer buildRandomCardPool(JSONObject randomCardPool) {
|
||||
final long selectionSeed = ((Number) randomCardPool.get("seed")).longValue();
|
||||
JSONArray cardPools = (JSONArray) randomCardPool.get("randomResult");
|
||||
|
||||
final List<CardCollection> cardCollections = new ArrayList<CardCollection>();
|
||||
@@ -39,7 +38,7 @@ public class StartingPoolBuilder {
|
||||
return new CardCollectionProducer() {
|
||||
@Override
|
||||
public CardCollection getCardCollection(long seed) {
|
||||
Random rnd = new Random(seed+selectionSeed);
|
||||
Random rnd = new Random(seed);
|
||||
return cardCollections.get(rnd.nextInt(cardCollections.size()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SortAndFilterCards {
|
||||
|
||||
Side side = getSideFilter(filterParams);
|
||||
String type = getTypeFilter(filterParams);
|
||||
String rarity = getRarityFilter(filterParams);
|
||||
String[] rarity = getRarityFilter(filterParams);
|
||||
String[] sets = getSetFilter(filterParams);
|
||||
List<String> words = getWords(filterParams);
|
||||
Set<CardType> cardTypes = getEnumFilter(CardType.values(), CardType.class, "cardType", null, filterParams);
|
||||
@@ -76,7 +76,7 @@ public class SortAndFilterCards {
|
||||
}
|
||||
|
||||
private boolean acceptsFilters(
|
||||
LotroCardBlueprintLibrary library, Map<String, LotroCardBlueprint> cardBlueprint, LotroFormatLibrary formatLibrary, Map<String, SetDefinition> rarities, String blueprintId, Side side, String type, String rarity, String[] sets,
|
||||
LotroCardBlueprintLibrary library, Map<String, LotroCardBlueprint> cardBlueprint, LotroFormatLibrary formatLibrary, Map<String, SetDefinition> rarities, String blueprintId, Side side, String type, String[] rarity, String[] sets,
|
||||
Set<CardType> cardTypes, Set<Culture> cultures, Set<Keyword> keywords, List<String> words, Integer siteNumber) {
|
||||
if (isPack(blueprintId)) {
|
||||
if (type == null || type.equals("pack"))
|
||||
@@ -118,10 +118,10 @@ public class SortAndFilterCards {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getRarityFilter(String[] filterParams) {
|
||||
private String[] getRarityFilter(String[] filterParams) {
|
||||
for (String filterParam : filterParams) {
|
||||
if (filterParam.startsWith("rarity:"))
|
||||
return filterParam.substring("rarity:".length());
|
||||
return filterParam.substring("rarity:".length()).split(",");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -134,11 +134,16 @@ public class SortAndFilterCards {
|
||||
return sets;
|
||||
}
|
||||
|
||||
private boolean isRarity(String blueprintId, String rarity, LotroCardBlueprintLibrary library, Map<String, SetDefinition> rarities) {
|
||||
private boolean isRarity(String blueprintId, String[] rarity, LotroCardBlueprintLibrary library, Map<String, SetDefinition> rarities) {
|
||||
if (blueprintId.contains("_")) {
|
||||
SetDefinition setRarity = rarities.get(blueprintId.substring(0, blueprintId.indexOf("_")));
|
||||
if (setRarity != null && setRarity.getCardRarity(library.stripBlueprintModifiers(blueprintId)).equals(rarity))
|
||||
return true;
|
||||
if (setRarity != null) {
|
||||
String cardRarity = setRarity.getCardRarity(library.stripBlueprintModifiers(blueprintId));
|
||||
for (String r : rarity) {
|
||||
if (cardRarity.equals(r))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.gempukku.lotro.game.Player;
|
||||
import java.util.*;
|
||||
|
||||
public class SoloDraftLeagueData implements LeagueData {
|
||||
public static final int HIGH_ENOUGH_PRIME_NUMBER = 8963;
|
||||
private SoloDraft _draft;
|
||||
private CollectionType _collectionType;
|
||||
private CollectionType _prizeCollectionType = CollectionType.MY_CARDS;
|
||||
@@ -56,7 +57,7 @@ public class SoloDraftLeagueData implements LeagueData {
|
||||
}
|
||||
|
||||
private long getSeed(Player player) {
|
||||
return _collectionType.getCode().hashCode() + player.getId();
|
||||
return _collectionType.getCode().hashCode() + player.getId() * HIGH_ENOUGH_PRIME_NUMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
{
|
||||
"format": "limited_fotr",
|
||||
"startingPool": {
|
||||
"type": "randomCardPool",
|
||||
"data": {
|
||||
"randomResult": [
|
||||
["1_2", "1_290"],
|
||||
["1_2", "1_290"]
|
||||
]
|
||||
}
|
||||
},
|
||||
"choices": [
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "side:FREE_PEOPLE cardType:POSSESSION,ARTIFACT set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "weightedSwitch",
|
||||
"repeat": 4,
|
||||
"data": {
|
||||
"switchResult": [
|
||||
{
|
||||
"weight": 0.1,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "side:FREE_PEOPLE cardType:COMPANION set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.3,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 4,
|
||||
"filter": "side:FREE_PEOPLE cardType:COMPANION set:1 rarity:U,P"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.6,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 5,
|
||||
"filter": "side:FREE_PEOPLE cardType:COMPANION set:1 rarity:C"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "weightedSwitch",
|
||||
"repeat": 30,
|
||||
"data": {
|
||||
"switchResult": [
|
||||
{
|
||||
"weight": 0.1,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 5,
|
||||
"filter": "side:FREE_PEOPLE set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.3,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 8,
|
||||
"filter": "side:FREE_PEOPLE set:1 rarity:U,P"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.6,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 10,
|
||||
"filter": "side:FREE_PEOPLE set:1 rarity:C"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "side:SHADOW cardType:MINION set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "weightedSwitch",
|
||||
"repeat": 14,
|
||||
"data": {
|
||||
"switchResult": [
|
||||
{
|
||||
"weight": 0.1,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "side:SHADOW cardType:MINION set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.3,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 4,
|
||||
"filter": "side:SHADOW cardType:MINION set:1 rarity:U,P"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.6,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 5,
|
||||
"filter": "side:SHADOW cardType:MINION set:1 rarity:C"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "weightedSwitch",
|
||||
"repeat": 20,
|
||||
"data": {
|
||||
"switchResult": [
|
||||
{
|
||||
"weight": 0.1,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 5,
|
||||
"filter": "side:SHADOW set:1 rarity:R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.3,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 8,
|
||||
"filter": "side:SHADOW set:1 rarity:U,P"
|
||||
}
|
||||
},
|
||||
{
|
||||
"weight": 0.6,
|
||||
"type": "filterPick",
|
||||
"data": {
|
||||
"optionCount": 10,
|
||||
"filter": "side:SHADOW set:1 rarity:C"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "filterPick",
|
||||
"repeat": 1,
|
||||
"data": {
|
||||
"optionCount": 3,
|
||||
"filter": "cardType:SITE set:1 siteNumber:9"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"type": "hobbit_draft",
|
||||
"location": "/draft/hobbit.json"
|
||||
"type": "test_draft",
|
||||
"location": "/draft/testDraft.json"
|
||||
}
|
||||
]
|
||||
@@ -8,12 +8,12 @@ import static org.junit.Assert.*;
|
||||
public class SoloDraftDefinitionsTest {
|
||||
@Test
|
||||
public void loadSoloDraftDefinitions() {
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions();
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions(null, null, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void playerDrafting() {
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions();
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions(null, null, null, null);
|
||||
SoloDraft soloDraft = soloDraftDefinitions.getSoloDraft("hobbit_draft");
|
||||
assertTrue(soloDraft.hasNextStage(0, 0));
|
||||
Iterable<SoloDraft.DraftChoice> availableChoices = soloDraft.getAvailableChoices(0, 0);
|
||||
|
||||
@@ -10,9 +10,11 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ConstructedLeagueDataTest {
|
||||
private SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions(null, null, null, null);
|
||||
|
||||
@Test
|
||||
public void testParameters() {
|
||||
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");
|
||||
ConstructedLeagueData leagueData = new ConstructedLeagueData(new CardSets(), 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);
|
||||
|
||||
@@ -20,9 +20,11 @@ import java.util.Set;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class LeagueServiceTest {
|
||||
private SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions(null, null, null, null);
|
||||
private CardSets _cardSets = new CardSets();
|
||||
@Test
|
||||
public void testJoiningLeagueAfterMaxGamesPlayed() throws Exception {
|
||||
|
||||
LeagueDAO leagueDao = Mockito.mock(LeagueDAO.class);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -35,7 +37,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, new SoloDraftDefinitions()).getSeries().get(0);
|
||||
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, soloDraftDefinitions).getSeries().get(0);
|
||||
|
||||
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
|
||||
|
||||
@@ -48,7 +50,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, new SoloDraftDefinitions());
|
||||
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, soloDraftDefinitions);
|
||||
|
||||
assertTrue(leagueService.canPlayRankedGame(league, leagueSerie, "player1"));
|
||||
assertTrue(leagueService.canPlayRankedGameAgainst(league, leagueSerie, "player1", "player2"));
|
||||
@@ -88,7 +90,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, new SoloDraftDefinitions()).getSeries().get(0);
|
||||
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, soloDraftDefinitions).getSeries().get(0);
|
||||
|
||||
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
|
||||
|
||||
@@ -102,7 +104,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, new SoloDraftDefinitions());
|
||||
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, soloDraftDefinitions);
|
||||
|
||||
assertTrue(leagueService.canPlayRankedGame(league, leagueSerie, "player1"));
|
||||
assertFalse(leagueService.canPlayRankedGameAgainst(league, leagueSerie, "player1", "player2"));
|
||||
@@ -134,7 +136,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, new SoloDraftDefinitions()).getSeries().get(0);
|
||||
LeagueSerieData leagueSerie = league.getLeagueData(_cardSets, soloDraftDefinitions).getSeries().get(0);
|
||||
|
||||
Mockito.when(leagueDao.loadActiveLeagues(Mockito.anyInt())).thenReturn(leagues);
|
||||
|
||||
@@ -152,7 +154,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, new SoloDraftDefinitions());
|
||||
LeagueService leagueService = new LeagueService(leagueDao, leagueMatchDAO, leagueParticipationDAO, collectionsManager, _cardSets, soloDraftDefinitions);
|
||||
|
||||
leagueService.reportLeagueGameResult(league, leagueSerie, "player1", "player2");
|
||||
leagueService.reportLeagueGameResult(league, leagueSerie, "player1", "player3");
|
||||
|
||||
@@ -19,9 +19,11 @@ import java.util.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SealedLeagueDataTest {
|
||||
private SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions(null, null, null, null);
|
||||
|
||||
@Test
|
||||
public void testJoinLeagueFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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);
|
||||
@@ -56,7 +58,7 @@ public class SealedLeagueDataTest {
|
||||
|
||||
@Test
|
||||
public void testJoinLeagueSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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);
|
||||
@@ -97,7 +99,7 @@ public class SealedLeagueDataTest {
|
||||
|
||||
@Test
|
||||
public void testSwitchToFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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>());
|
||||
@@ -110,7 +112,7 @@ public class SealedLeagueDataTest {
|
||||
|
||||
@Test
|
||||
public void testProcessMidFirstWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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>());
|
||||
@@ -122,7 +124,7 @@ public class SealedLeagueDataTest {
|
||||
|
||||
@Test
|
||||
public void testSwitchToSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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);
|
||||
@@ -158,7 +160,7 @@ public class SealedLeagueDataTest {
|
||||
|
||||
@Test
|
||||
public void testProcessMidSecondWeek() {
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), new SoloDraftDefinitions(), "fotr_block,20120101,test,Test Collection");
|
||||
SealedLeagueData data = new SealedLeagueData(new CardSets(), 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>());
|
||||
|
||||
Reference in New Issue
Block a user