mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Working over booster generation - BoosterGenerator became more universal, moved to forge.card for a while, this is still WIP.
Limited game classes have been cleaned (code moved to utility functions in draft, CustomLimited class contains setting to start with custom cardpool or boosters) Closure introduced to utilities
This commit is contained in:
12
.gitattributes
vendored
12
.gitattributes
vendored
@@ -9565,7 +9565,6 @@ src/main/java/forge/AIPlayer.java svneol=native#text/plain
|
|||||||
src/main/java/forge/AllZone.java svneol=native#text/plain
|
src/main/java/forge/AllZone.java svneol=native#text/plain
|
||||||
src/main/java/forge/AllZoneUtil.java svneol=native#text/plain
|
src/main/java/forge/AllZoneUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/Base64Coder.java svneol=native#text/plain
|
src/main/java/forge/Base64Coder.java svneol=native#text/plain
|
||||||
src/main/java/forge/BoosterGenerator.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/ButtonUtil.java svneol=native#text/plain
|
src/main/java/forge/ButtonUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/Card.java svneol=native#text/plain
|
src/main/java/forge/Card.java svneol=native#text/plain
|
||||||
src/main/java/forge/CardContainer.java svneol=native#text/plain
|
src/main/java/forge/CardContainer.java svneol=native#text/plain
|
||||||
@@ -9642,8 +9641,6 @@ src/main/java/forge/PlayerUtil.java svneol=native#text/plain
|
|||||||
src/main/java/forge/PlayerZone.java svneol=native#text/plain
|
src/main/java/forge/PlayerZone.java svneol=native#text/plain
|
||||||
src/main/java/forge/PlayerZone_ComesIntoPlay.java svneol=native#text/plain
|
src/main/java/forge/PlayerZone_ComesIntoPlay.java svneol=native#text/plain
|
||||||
src/main/java/forge/Quest_Assignment.java svneol=native#text/plain
|
src/main/java/forge/Quest_Assignment.java svneol=native#text/plain
|
||||||
src/main/java/forge/ReadBoosterPack.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/ReadDraftBoosterPack.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/ReadPriceList.java svneol=native#text/plain
|
src/main/java/forge/ReadPriceList.java svneol=native#text/plain
|
||||||
src/main/java/forge/ReadQuest_Assignment.java svneol=native#text/plain
|
src/main/java/forge/ReadQuest_Assignment.java svneol=native#text/plain
|
||||||
src/main/java/forge/SetInfo.java svneol=native#text/plain
|
src/main/java/forge/SetInfo.java svneol=native#text/plain
|
||||||
@@ -9656,6 +9653,7 @@ src/main/java/forge/Time.java svneol=native#text/plain
|
|||||||
src/main/java/forge/UndoCommand.java svneol=native#text/plain
|
src/main/java/forge/UndoCommand.java svneol=native#text/plain
|
||||||
src/main/java/forge/Upkeep.java svneol=native#text/plain
|
src/main/java/forge/Upkeep.java svneol=native#text/plain
|
||||||
src/main/java/forge/ZCTrigger.java svneol=native#text/plain
|
src/main/java/forge/ZCTrigger.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/CardBlock.java -text
|
src/main/java/forge/card/CardBlock.java -text
|
||||||
src/main/java/forge/card/CardColor.java -text
|
src/main/java/forge/card/CardColor.java -text
|
||||||
src/main/java/forge/card/CardCoreType.java -text
|
src/main/java/forge/card/CardCoreType.java -text
|
||||||
@@ -9669,6 +9667,9 @@ src/main/java/forge/card/CardSet.java -text
|
|||||||
src/main/java/forge/card/CardSuperType.java -text
|
src/main/java/forge/card/CardSuperType.java -text
|
||||||
src/main/java/forge/card/CardType.java -text
|
src/main/java/forge/card/CardType.java -text
|
||||||
src/main/java/forge/card/MtgDataParser.java -text
|
src/main/java/forge/card/MtgDataParser.java -text
|
||||||
|
src/main/java/forge/card/QuestBoosterPack.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/ReadBoosterPack.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/ReadDraftBoosterPack.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/abilityFactory/AbilityFactory.java svneol=native#text/plain
|
src/main/java/forge/card/abilityFactory/AbilityFactory.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/abilityFactory/AbilityFactory_AlterLife.java svneol=native#text/plain
|
src/main/java/forge/card/abilityFactory/AbilityFactory_AlterLife.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/abilityFactory/AbilityFactory_Animate.java svneol=native#text/plain
|
src/main/java/forge/card/abilityFactory/AbilityFactory_Animate.java svneol=native#text/plain
|
||||||
@@ -9822,7 +9823,7 @@ src/main/java/forge/game/limited/BoosterDraft.java svneol=native#text/plain
|
|||||||
src/main/java/forge/game/limited/BoosterDraftAI.java svneol=native#text/plain
|
src/main/java/forge/game/limited/BoosterDraftAI.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/BoosterDraft_1.java svneol=native#text/plain
|
src/main/java/forge/game/limited/BoosterDraft_1.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/CCnt.java svneol=native#text/plain
|
src/main/java/forge/game/limited/CCnt.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/CustomDraft.java svneol=native#text/plain
|
src/main/java/forge/game/limited/CustomLimited.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
|
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/SealedDeck.java svneol=native#text/plain
|
src/main/java/forge/game/limited/SealedDeck.java svneol=native#text/plain
|
||||||
src/main/java/forge/game/limited/package-info.java -text svneol=native#text/plain
|
src/main/java/forge/game/limited/package-info.java -text svneol=native#text/plain
|
||||||
@@ -9893,7 +9894,6 @@ src/main/java/forge/properties/Preferences.java svneol=native#text/plain
|
|||||||
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
|
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
|
||||||
src/main/java/forge/properties/package-info.java svneol=native#text/plain
|
src/main/java/forge/properties/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestBattleManager.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestBattleManager.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestBoosterPack.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestEvent.java -text
|
src/main/java/forge/quest/data/QuestEvent.java -text
|
||||||
@@ -9961,7 +9961,6 @@ src/main/java/net/slightlymagic/braids/util/lambda/Lambda.java svneol=native#tex
|
|||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda1.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/lambda/Lambda1.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda2.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/lambda/Lambda2.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Lambda3.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/lambda/Lambda3.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Null.java svneol=native#text/plain
|
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/Thunk.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/lambda/Thunk.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/lambda/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/lambda/package-info.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
||||||
@@ -9969,6 +9968,7 @@ src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor
|
|||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java svneol=native#text/plain
|
||||||
|
src/main/java/net/slightlymagic/maxmtg/Closure1.java -text
|
||||||
src/main/java/net/slightlymagic/maxmtg/Predicate.java -text
|
src/main/java/net/slightlymagic/maxmtg/Predicate.java -text
|
||||||
src/main/java/net/slightlymagic/maxmtg/PredicateString.java -text
|
src/main/java/net/slightlymagic/maxmtg/PredicateString.java -text
|
||||||
src/main/java/net/slightlymagic/maxmtg/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/maxmtg/package-info.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package forge;
|
package forge.card;
|
||||||
|
|
||||||
|
import forge.Constant;
|
||||||
|
import forge.FileUtil;
|
||||||
|
import forge.MyRandom;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckManager;
|
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPoolView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
import net.slightlymagic.maxmtg.Closure1;
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,24 +23,37 @@ import net.slightlymagic.maxmtg.Predicate;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class BoosterGenerator {
|
public class BoosterGenerator {
|
||||||
private List<CardPrinted> commons = new ArrayList<CardPrinted>();
|
|
||||||
private List<CardPrinted> uncommons = new ArrayList<CardPrinted>();
|
|
||||||
private List<CardPrinted> rares = new ArrayList<CardPrinted>();
|
|
||||||
private List<CardPrinted> mythics = new ArrayList<CardPrinted>();
|
|
||||||
private List<CardPrinted> specials = new ArrayList<CardPrinted>();
|
|
||||||
|
|
||||||
|
// Function to open a booster as it is.
|
||||||
|
public static final Lambda1<List<CardPrinted>, BoosterGenerator> IDENTITY_PICK = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
|
||||||
|
@Override public List<CardPrinted> apply(BoosterGenerator arg1) {
|
||||||
|
return arg1.getBoosterPack();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Closure which will hold both the booster and the way we want to pick from it - holds default options
|
||||||
|
public static Closure1<List<CardPrinted>, BoosterGenerator> getSimplePicker(BoosterGenerator source) {
|
||||||
|
return new Closure1<List<CardPrinted>, BoosterGenerator>(IDENTITY_PICK, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
// These lists are to hold cards grouped by rarity in advance.
|
||||||
|
private final List<CardPrinted> allNoLands = new ArrayList<CardPrinted>();
|
||||||
|
private final List<CardPrinted> commons = new ArrayList<CardPrinted>();
|
||||||
|
private final List<CardPrinted> uncommons = new ArrayList<CardPrinted>();
|
||||||
|
private final List<CardPrinted> rares = new ArrayList<CardPrinted>();
|
||||||
|
private final List<CardPrinted> mythics = new ArrayList<CardPrinted>();
|
||||||
|
private final List<CardPrinted> specials = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
|
private List<CardPrinted> commonCreatures;
|
||||||
|
private List<CardPrinted> commonNonCreatures;
|
||||||
|
|
||||||
|
private static final List<CardPrinted> emptyList = Collections.unmodifiableList( new ArrayList<CardPrinted>(0) );
|
||||||
|
|
||||||
|
// This set of cards
|
||||||
private int numCommons = 0;
|
private int numCommons = 0;
|
||||||
private int numUncommons = 0;
|
private int numUncommons = 0;
|
||||||
// these two used when numbers of rares/myths is specified explicitly
|
|
||||||
private int numRares = 0;
|
|
||||||
private int numMythics = 0;
|
|
||||||
// this is used to specify number of slots for a rare - generator will decide by itself which to take
|
|
||||||
private int numRareSlots = 0;
|
private int numRareSlots = 0;
|
||||||
|
|
||||||
private int numSpecials = 0;
|
private int numSpecials = 0;
|
||||||
|
|
||||||
//private Random r = new Random();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for BoosterGenerator.</p>
|
* <p>Constructor for BoosterGenerator.</p>
|
||||||
*/
|
*/
|
||||||
@@ -53,39 +68,17 @@ public class BoosterGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public BoosterGenerator(Deck dPool)
|
||||||
*
|
|
||||||
* TODO Write javadoc for Constructor.
|
|
||||||
* @param deckFile a String
|
|
||||||
* @param nCommons an int
|
|
||||||
* @param nUncommons an int
|
|
||||||
* @param nRares an int
|
|
||||||
* @param nMythics an int
|
|
||||||
* @param nSpecials an int
|
|
||||||
* @param ignoreRarity a boolean
|
|
||||||
*/
|
|
||||||
public BoosterGenerator(final String deckFile, final int nCommons, final int nUncommons, final int nRares,
|
|
||||||
final int nMythics, final int nSpecials, final boolean ignoreRarity)
|
|
||||||
{
|
{
|
||||||
numCommons = nCommons;
|
/*
|
||||||
numUncommons = nUncommons;
|
|
||||||
numRares = nRares;
|
|
||||||
numSpecials = nSpecials;
|
|
||||||
numMythics = nMythics;
|
|
||||||
|
|
||||||
//DeckManager dio = new DeckManager(ForgeProps.getFile(NewConstants.NEW_DECKS));
|
//DeckManager dio = new DeckManager(ForgeProps.getFile(NewConstants.NEW_DECKS));
|
||||||
DeckManager dio = AllZone.getDeckManager();
|
DeckManager dio = AllZone.getDeckManager();
|
||||||
Deck dPool = dio.getDeck(deckFile);
|
Deck dPool = dio.getDeck(deckFile);
|
||||||
if (dPool == null) {
|
if (dPool == null) {
|
||||||
throw new RuntimeException("BoosterGenerator : deck not found - " + deckFile);
|
throw new RuntimeException("BoosterGenerator : deck not found - " + deckFile);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
ItemPoolView<CardPrinted> tList = dPool.getMain();
|
|
||||||
for (Entry<CardPrinted, Integer> e : tList) {
|
|
||||||
if (ignoreRarity) { commons.add(e.getKey()); }
|
|
||||||
else { addToRarity(e.getKey()); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (Entry<CardPrinted, Integer> e : dPool.getMain()) { addToRarity(e.getKey()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +89,7 @@ public class BoosterGenerator {
|
|||||||
public BoosterGenerator(final String setCode) {
|
public BoosterGenerator(final String setCode) {
|
||||||
numCommons = 0;
|
numCommons = 0;
|
||||||
numUncommons = 0;
|
numUncommons = 0;
|
||||||
numRares = 0;
|
numRareSlots = 0;
|
||||||
numSpecials = 0;
|
numSpecials = 0;
|
||||||
|
|
||||||
List<String> setsList = Arrays.asList(new String[]{setCode});
|
List<String> setsList = Arrays.asList(new String[]{setCode});
|
||||||
@@ -125,7 +118,7 @@ public class BoosterGenerator {
|
|||||||
if (Constant.Runtime.DevMode[0]) {
|
if (Constant.Runtime.DevMode[0]) {
|
||||||
System.out.println("numCommons: " + numCommons);
|
System.out.println("numCommons: " + numCommons);
|
||||||
System.out.println("numUncommons: " + numUncommons);
|
System.out.println("numUncommons: " + numUncommons);
|
||||||
System.out.println("numRares: " + numRares);
|
System.out.println("numRares: " + numRareSlots);
|
||||||
System.out.println("numSpecials: " + numSpecials);
|
System.out.println("numSpecials: " + numSpecials);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,10 +126,10 @@ public class BoosterGenerator {
|
|||||||
|
|
||||||
private List<CardPrinted> pickRandomCards(List<CardPrinted> source, int count)
|
private List<CardPrinted> pickRandomCards(List<CardPrinted> source, int count)
|
||||||
{
|
{
|
||||||
|
int listSize = source == null ? 0 : source.size();
|
||||||
|
if (count <= 0 || listSize == 0) { return emptyList; }
|
||||||
List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
||||||
if (count <= 0 || source == null || source.isEmpty()) { return result; }
|
|
||||||
|
|
||||||
int listSize = source.size();
|
|
||||||
int index = Integer.MAX_VALUE;
|
int index = Integer.MAX_VALUE;
|
||||||
for (int iCard = 0; iCard < count; iCard++) {
|
for (int iCard = 0; iCard < count; iCard++) {
|
||||||
if (index >= listSize) {
|
if (index >= listSize) {
|
||||||
@@ -151,10 +144,11 @@ public class BoosterGenerator {
|
|||||||
|
|
||||||
private List<CardPrinted> pickRandomRaresOrMythics(List<CardPrinted> rares, List<CardPrinted> mythics, int count)
|
private List<CardPrinted> pickRandomRaresOrMythics(List<CardPrinted> rares, List<CardPrinted> mythics, int count)
|
||||||
{
|
{
|
||||||
List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
|
||||||
int raresSize = rares == null ? 0 : rares.size();
|
int raresSize = rares == null ? 0 : rares.size();
|
||||||
int mythicsSize = mythics == null ? 0 : mythics.size();
|
int mythicsSize = mythics == null ? 0 : mythics.size();
|
||||||
if (count <= 0 || raresSize == 0) { return result; }
|
if (count <= 0 || raresSize == 0) { return emptyList; }
|
||||||
|
|
||||||
|
List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
||||||
|
|
||||||
int indexRares = Integer.MAX_VALUE;
|
int indexRares = Integer.MAX_VALUE;
|
||||||
int indexMythics = Integer.MAX_VALUE;
|
int indexMythics = Integer.MAX_VALUE;
|
||||||
@@ -181,26 +175,42 @@ public class BoosterGenerator {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final List<CardPrinted> getBoosterPack() {
|
||||||
|
return getBoosterPack(numCommons, 0, 0, numUncommons, numRareSlots, 0, 0, numSpecials, 0);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* <p>getBoosterPack.</p>
|
* <p>getBoosterPack.</p>
|
||||||
*
|
*
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public final List<CardPrinted> getBoosterPack() {
|
public final List<CardPrinted> getBoosterPack(final int nCom, final int nComCreat, final int nComNonCr, final int nUnc,
|
||||||
|
final int nRareSlots, final int nRares, final int nMythics, final int nSpecs, final int nAnyCard) {
|
||||||
|
|
||||||
List<CardPrinted> temp = new ArrayList<CardPrinted>();
|
List<CardPrinted> temp = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
temp.addAll(pickRandomCards(commons, numCommons));
|
temp.addAll(pickRandomCards(commons, nCom));
|
||||||
temp.addAll(pickRandomCards(uncommons, numUncommons));
|
if( nComCreat > 0 || nComNonCr > 0) {
|
||||||
// You can specify number of rare-slots or number of rares and mythics explicitly... or both, but they'll sum up
|
if (commonNonCreatures.isEmpty()) {
|
||||||
if (numRareSlots > 0) {
|
CardRules.Predicates.Presets.isCreature.split(commons, CardPrinted.fnGetRules, commonCreatures, commonNonCreatures);
|
||||||
temp.addAll(pickRandomRaresOrMythics(rares, mythics, numRareSlots));
|
}
|
||||||
}
|
temp.addAll(pickRandomCards(commonCreatures, nComCreat));
|
||||||
if (numRares > 0 || numMythics > 0) {
|
temp.addAll(pickRandomCards(commonNonCreatures, nComNonCr));
|
||||||
temp.addAll(pickRandomCards(rares, numRares));
|
|
||||||
temp.addAll(pickRandomCards(mythics, numMythics));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.addAll(pickRandomCards(specials, numSpecials));
|
temp.addAll(pickRandomCards(uncommons, nUnc));
|
||||||
|
|
||||||
|
if (nRareSlots > 0) {
|
||||||
|
temp.addAll(pickRandomRaresOrMythics(rares, mythics, nRareSlots));
|
||||||
|
}
|
||||||
|
if (nRares > 0 || nMythics > 0) {
|
||||||
|
temp.addAll(pickRandomCards(rares, nRares));
|
||||||
|
temp.addAll(pickRandomCards(mythics, nMythics));
|
||||||
|
}
|
||||||
|
|
||||||
|
temp.addAll(pickRandomCards(specials, nSpecs));
|
||||||
|
|
||||||
|
temp.addAll(pickRandomCards(allNoLands, nAnyCard));
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
@@ -211,7 +221,7 @@ public class BoosterGenerator {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public final int getBoosterPackSize() {
|
public final int getBoosterPackSize() {
|
||||||
return numCommons + numUncommons + numRares + numSpecials;
|
return numCommons + numUncommons + numRareSlots + numSpecials;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToRarity(final CardPrinted c) {
|
private void addToRarity(final CardPrinted c) {
|
||||||
@@ -223,6 +233,9 @@ public class BoosterGenerator {
|
|||||||
case Special: specials.add(c); break;
|
case Special: specials.add(c); break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
if (!c.getCard().getType().isBasicLand()) {
|
||||||
|
allNoLands.add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,7 @@ public final class CardType implements Comparable<CardType> {
|
|||||||
|
|
||||||
public boolean isBasic() { return superType.contains(CardSuperType.Basic); }
|
public boolean isBasic() { return superType.contains(CardSuperType.Basic); }
|
||||||
public boolean isLegendary() { return superType.contains(CardSuperType.Legendary); }
|
public boolean isLegendary() { return superType.contains(CardSuperType.Legendary); }
|
||||||
|
public boolean isBasicLand() { return isBasic() && isLand(); }
|
||||||
|
|
||||||
public String getTypesBeforeDash() {
|
public String getTypesBeforeDash() {
|
||||||
ArrayList<String> types = new ArrayList<String>();
|
ArrayList<String> types = new ArrayList<String>();
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package forge.quest.data;
|
package forge.card;
|
||||||
|
|
||||||
import forge.card.CardRarity;
|
|
||||||
import forge.card.CardRules;
|
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
package forge;
|
package forge.card;
|
||||||
|
|
||||||
|
|
||||||
//import java.io.BufferedReader;
|
//import java.io.BufferedReader;
|
||||||
//import java.io.File;
|
//import java.io.File;
|
||||||
//import java.io.FileReader;
|
//import java.io.FileReader;
|
||||||
|
|
||||||
import forge.card.CardRules;
|
import forge.Constant;
|
||||||
|
import forge.MyRandom;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package forge;
|
package forge.card;
|
||||||
|
|
||||||
|
|
||||||
import forge.card.CardRules;
|
import forge.Constant;
|
||||||
|
import forge.MyRandom;
|
||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -45,37 +46,6 @@ public class ReadDraftBoosterPack implements NewConstants {
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemPoolView<CardPrinted> getBoosterPack5() {
|
|
||||||
ItemPool<CardPrinted> list = new ItemPool<CardPrinted>(CardPrinted.class);
|
|
||||||
for (int i = 0; i < 5; i++) { list.addAll(getBoosterPack()); }
|
|
||||||
|
|
||||||
addBasicLands(list, 20);
|
|
||||||
addBasicSnowLands(list, 20);
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
list.add(CardDb.instance().getCard("Terramorphic Expanse", "M10"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
} //getBoosterPack5()
|
|
||||||
|
|
||||||
public static final void addBasicLands(final ItemPool<CardPrinted> pool, final int count) {
|
|
||||||
CardDb db = CardDb.instance();
|
|
||||||
pool.add(db.getCard("Forest", "M10"), count);
|
|
||||||
pool.add(db.getCard("Island", "M10"), count);
|
|
||||||
pool.add(db.getCard("Plains", "M10"), count);
|
|
||||||
pool.add(db.getCard("Mountain", "M10"), count);
|
|
||||||
pool.add(db.getCard("Swamp", "M10"), count);
|
|
||||||
|
|
||||||
}
|
|
||||||
public static final void addBasicSnowLands(final ItemPool<CardPrinted> pool, final int count) {
|
|
||||||
CardDb db = CardDb.instance();
|
|
||||||
pool.add(db.getCard("Snow-Covered Forest", "ICE"), count);
|
|
||||||
pool.add(db.getCard("Snow-Covered Island", "ICE"), count);
|
|
||||||
pool.add(db.getCard("Snow-Covered Plains", "ICE"), count);
|
|
||||||
pool.add(db.getCard("Snow-Covered Mountain", "ICE"), count);
|
|
||||||
pool.add(db.getCard("Snow-Covered Swamp", "ICE"), count);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* <p>getBoosterPack.</p>
|
* <p>getBoosterPack.</p>
|
||||||
*
|
*
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package forge.game.limited;
|
package forge.game.limited;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.BoosterGenerator;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.FileUtil;
|
import forge.FileUtil;
|
||||||
import forge.SetUtils;
|
import forge.SetUtils;
|
||||||
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardSet;
|
import forge.card.CardSet;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -23,6 +23,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
import net.slightlymagic.maxmtg.Closure1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TODO Write javadoc for this type.
|
* TODO Write javadoc for this type.
|
||||||
@@ -37,8 +40,8 @@ public class BoosterDraft_1 implements BoosterDraft {
|
|||||||
private int currentCount = 0;
|
private int currentCount = 0;
|
||||||
private List<List<CardPrinted>> pack; //size 8
|
private List<List<CardPrinted>> pack; //size 8
|
||||||
//private BoosterGenerator packs[] = {new BoosterGenerator(), new BoosterGenerator(), new BoosterGenerator()};
|
//private BoosterGenerator packs[] = {new BoosterGenerator(), new BoosterGenerator(), new BoosterGenerator()};
|
||||||
private ArrayList<BoosterGenerator> packs = new ArrayList<BoosterGenerator>();
|
private ArrayList<Closure1<List<CardPrinted>, BoosterGenerator>> packs = new ArrayList<Closure1<List<CardPrinted>, BoosterGenerator>>();
|
||||||
private int packNum = 0;
|
private int currentBoosterPack = 0;
|
||||||
|
|
||||||
//helps the computer choose which booster packs to pick from
|
//helps the computer choose which booster packs to pick from
|
||||||
//the first row says "pick from boosters 1-7, skip 0" since the players picks from 0
|
//the first row says "pick from boosters 1-7, skip 0" since the players picks from 0
|
||||||
@@ -73,8 +76,9 @@ public class BoosterDraft_1 implements BoosterDraft {
|
|||||||
|
|
||||||
if (draftType.equals("Full")) { // Draft from all cards in Forge
|
if (draftType.equals("Full")) { // Draft from all cards in Forge
|
||||||
BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getAllUniqueCards());
|
BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getAllUniqueCards());
|
||||||
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpFull);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
packs.add(bpFull);
|
packs.add(picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
LandSetCode[0] = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer()).getMostRecentSet();
|
LandSetCode[0] = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer()).getMostRecentSet();
|
||||||
@@ -110,13 +114,15 @@ public class BoosterDraft_1 implements BoosterDraft {
|
|||||||
String[] pp = p.toString().split("/");
|
String[] pp = p.toString().split("/");
|
||||||
for (int i = 0; i < nPacks; i++) {
|
for (int i = 0; i < nPacks; i++) {
|
||||||
BoosterGenerator bpMulti = new BoosterGenerator(pp[i]);
|
BoosterGenerator bpMulti = new BoosterGenerator(pp[i]);
|
||||||
packs.add(bpMulti);
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpMulti);
|
||||||
|
packs.add(picker);
|
||||||
sumCards += bpMulti.getBoosterPackSize();
|
sumCards += bpMulti.getBoosterPackSize();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BoosterGenerator bpOne = new BoosterGenerator(sets[0]);
|
BoosterGenerator bpOne = new BoosterGenerator(sets[0]);
|
||||||
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpOne);
|
||||||
for (int i = 0; i < nPacks; i++) {
|
for (int i = 0; i < nPacks; i++) {
|
||||||
packs.add(bpOne);
|
packs.add(picker);
|
||||||
sumCards += bpOne.getBoosterPackSize();
|
sumCards += bpOne.getBoosterPackSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,116 +130,77 @@ public class BoosterDraft_1 implements BoosterDraft {
|
|||||||
LandSetCode[0] = block.getLandSet().getCode();
|
LandSetCode[0] = block.getLandSet().getCode();
|
||||||
|
|
||||||
} else if (draftType.equals("Custom")) { // Draft from user-defined cardpools
|
} else if (draftType.equals("Custom")) { // Draft from user-defined cardpools
|
||||||
String[] dList;
|
List<CustomLimited> myDrafts = loadCustomDrafts("res/draft/", ".draft");
|
||||||
ArrayList<CustomDraft> customs = new ArrayList<CustomDraft>();
|
|
||||||
ArrayList<String> customList = new ArrayList<String>();
|
|
||||||
|
|
||||||
// get list of custom draft files
|
if (myDrafts.size() < 1) {
|
||||||
File dFolder = new File("res/draft/");
|
|
||||||
if (!dFolder.exists()) {
|
|
||||||
throw new RuntimeException("BoosterDraft : folder not found -- folder is " + dFolder.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dFolder.isDirectory()) {
|
|
||||||
throw new RuntimeException("BoosterDraft : not a folder -- " + dFolder.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
dList = dFolder.list();
|
|
||||||
|
|
||||||
for (int i = 0; i < dList.length; i++) {
|
|
||||||
if (dList[i].endsWith(".draft")) {
|
|
||||||
ArrayList<String> dfData = FileUtil.readFile("res/draft/" + dList[i]);
|
|
||||||
|
|
||||||
CustomDraft cd = new CustomDraft();
|
|
||||||
|
|
||||||
for (int j = 0; j < dfData.size(); j++) {
|
|
||||||
|
|
||||||
String dfd = dfData.get(j);
|
|
||||||
|
|
||||||
if (dfd.startsWith("Name:")) {
|
|
||||||
cd.Name = dfd.substring(5);
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("Type:")) {
|
|
||||||
cd.Type = dfd.substring(5);
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("DeckFile:")) {
|
|
||||||
cd.DeckFile = dfd.substring(9);
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("IgnoreRarity:")) {
|
|
||||||
cd.IgnoreRarity = dfd.substring(13).equals("True");
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("LandSetCode:")) {
|
|
||||||
cd.LandSetCode = dfd.substring(12);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dfd.startsWith("NumCards:")) {
|
|
||||||
cd.NumCards = Integer.parseInt(dfd.substring(9));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumSpecials:")) {
|
|
||||||
cd.NumSpecials = Integer.parseInt(dfd.substring(12));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumMythics:")) {
|
|
||||||
cd.NumMythics = Integer.parseInt(dfd.substring(11));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumRares:")) {
|
|
||||||
cd.NumRares = Integer.parseInt(dfd.substring(9));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumUncommons:")) {
|
|
||||||
cd.NumUncommons = Integer.parseInt(dfd.substring(13));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumCommons:")) {
|
|
||||||
cd.NumCommons = Integer.parseInt(dfd.substring(11));
|
|
||||||
}
|
|
||||||
if (dfd.startsWith("NumPacks:")) {
|
|
||||||
cd.NumPacks = Integer.parseInt(dfd.substring(9));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
customs.add(cd);
|
|
||||||
customList.add(cd.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
CustomDraft chosenDraft = null;
|
|
||||||
|
|
||||||
// present list to user
|
|
||||||
if (customs.size() < 1) {
|
|
||||||
JOptionPane.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "No custom draft files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
Object p = GuiUtils.getChoice("Choose Custom Draft", customList.toArray());
|
CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Draft", myDrafts.toArray());
|
||||||
|
setupCustomDraft(draft);
|
||||||
for (int i = 0; i < customs.size(); i++) {
|
|
||||||
CustomDraft cd = customs.get(i);
|
|
||||||
|
|
||||||
if (cd.Name.equals(p.toString())) {
|
|
||||||
chosenDraft = cd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chosenDraft.IgnoreRarity) {
|
|
||||||
chosenDraft.NumCommons = chosenDraft.NumCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
BoosterGenerator bpCustom = new BoosterGenerator(chosenDraft.DeckFile, chosenDraft.NumCommons,
|
|
||||||
chosenDraft.NumUncommons, chosenDraft.NumRares, chosenDraft.NumMythics, chosenDraft.NumSpecials,
|
|
||||||
chosenDraft.IgnoreRarity);
|
|
||||||
int n = 0;
|
|
||||||
for (int i = 0; i < chosenDraft.NumPacks; i++) {
|
|
||||||
packs.add(bpCustom);
|
|
||||||
n += chosenDraft.NumCards; //bpCustom.getBoosterPackSize();
|
|
||||||
}
|
|
||||||
stopCount = n;
|
|
||||||
|
|
||||||
LandSetCode[0] = chosenDraft.LandSetCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = get8BoosterPack();
|
pack = get8BoosterPack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupCustomDraft(final CustomLimited draft)
|
||||||
|
{
|
||||||
|
DeckManager dio = AllZone.getDeckManager();
|
||||||
|
Deck dPool = dio.getDeck(draft.DeckFile);
|
||||||
|
if (dPool == null) {
|
||||||
|
throw new RuntimeException("BoosterGenerator : deck not found - " + draft.DeckFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
BoosterGenerator bpCustom = new BoosterGenerator(dPool);
|
||||||
|
Lambda1<List<CardPrinted>, BoosterGenerator> fnPick = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
|
||||||
|
@Override public List<CardPrinted> apply(BoosterGenerator pack) {
|
||||||
|
if ( draft.IgnoreRarity ) {
|
||||||
|
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, 0, draft.NumCards);
|
||||||
|
}
|
||||||
|
return pack.getBoosterPack(draft.NumCommons, 0, 0, draft.NumUncommons, 0, draft.NumRares, draft.NumMythics, draft.NumSpecials, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = new Closure1<List<CardPrinted>, BoosterGenerator>(fnPick, bpCustom);
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
|
for (int i = 0; i < draft.NumPacks; i++) {
|
||||||
|
packs.add(picker);
|
||||||
|
n += draft.NumCards; //bpCustom.getBoosterPackSize();
|
||||||
|
}
|
||||||
|
stopCount = n;
|
||||||
|
|
||||||
|
LandSetCode[0] = draft.LandSetCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Looks for res/draft/*.draft files, reads them, returns a list */
|
||||||
|
private List<CustomLimited> loadCustomDrafts(String lookupFolder, String fileExtension)
|
||||||
|
{
|
||||||
|
String[] dList;
|
||||||
|
ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||||
|
|
||||||
|
// get list of custom draft files
|
||||||
|
File dFolder = new File(lookupFolder);
|
||||||
|
if (!dFolder.exists()) {
|
||||||
|
throw new RuntimeException("BoosterDraft : folder not found -- folder is " + dFolder.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dFolder.isDirectory()) {
|
||||||
|
throw new RuntimeException("BoosterDraft : not a folder -- " + dFolder.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
dList = dFolder.list();
|
||||||
|
|
||||||
|
for (int i = 0; i < dList.length; i++) {
|
||||||
|
if (dList[i].endsWith(fileExtension)) {
|
||||||
|
List<String> dfData = FileUtil.readFile(lookupFolder + dList[i]);
|
||||||
|
customs.add(CustomLimited.parse(dfData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return customs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>nextChoice.</p>
|
* <p>nextChoice.</p>
|
||||||
*
|
*
|
||||||
@@ -256,13 +223,13 @@ public class BoosterDraft_1 implements BoosterDraft {
|
|||||||
public final List<List<CardPrinted>> get8BoosterPack() {
|
public final List<List<CardPrinted>> get8BoosterPack() {
|
||||||
List<List<CardPrinted>> list = new ArrayList<List<CardPrinted>>();
|
List<List<CardPrinted>> list = new ArrayList<List<CardPrinted>>();
|
||||||
|
|
||||||
if (packNum < packs.size()) {
|
if (currentBoosterPack < packs.size()) {
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
list.add(packs.get(packNum).getBoosterPack());
|
list.add(packs.get(currentBoosterPack).apply());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packNum++;
|
currentBoosterPack++;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
} //get8BoosterPack()
|
} //get8BoosterPack()
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package forge.game.limited;
|
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>CustomDraft class.</p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
class CustomDraft {
|
|
||||||
public String Name;
|
|
||||||
public String Type;
|
|
||||||
public String DeckFile;
|
|
||||||
public Boolean IgnoreRarity;
|
|
||||||
public int NumCards = 15;
|
|
||||||
public int NumSpecials = 0;
|
|
||||||
public int NumMythics = 1;
|
|
||||||
public int NumRares = 1;
|
|
||||||
public int NumUncommons = 3;
|
|
||||||
public int NumCommons = 11;
|
|
||||||
public int NumPacks = 3;
|
|
||||||
public String LandSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer()).getMostRecentSet();
|
|
||||||
}
|
|
||||||
54
src/main/java/forge/game/limited/CustomLimited.java
Normal file
54
src/main/java/forge/game/limited/CustomLimited.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package forge.game.limited;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>CustomDraft class.</p>
|
||||||
|
*
|
||||||
|
* @author Forge
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
class CustomLimited {
|
||||||
|
public String Name;
|
||||||
|
public String Type;
|
||||||
|
public String DeckFile;
|
||||||
|
public Boolean IgnoreRarity;
|
||||||
|
public int NumCards = 15;
|
||||||
|
public int NumSpecials = 0;
|
||||||
|
public int NumMythics = 1;
|
||||||
|
public int NumRares = 1;
|
||||||
|
public int NumUncommons = 3;
|
||||||
|
public int NumCommons = 11;
|
||||||
|
public int NumPacks = 3;
|
||||||
|
public String LandSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer()).getMostRecentSet();
|
||||||
|
|
||||||
|
@Override public String toString() { return Name; }
|
||||||
|
|
||||||
|
public static CustomLimited parse(List<String> dfData)
|
||||||
|
{
|
||||||
|
CustomLimited cd = new CustomLimited();
|
||||||
|
|
||||||
|
for (String dd : dfData) {
|
||||||
|
String[] v = dd.split(":", 2);
|
||||||
|
String key = v[0];
|
||||||
|
String value = v.length > 1 ? v[1].trim() : "";
|
||||||
|
|
||||||
|
if (key.equalsIgnoreCase("Name")) { cd.Name = value; }
|
||||||
|
if (key.equalsIgnoreCase("Type")) { cd.Type = value; }
|
||||||
|
if (key.equalsIgnoreCase("DeckFile")) { cd.DeckFile = value; }
|
||||||
|
if (key.equalsIgnoreCase("IgnoreRarity")) { cd.IgnoreRarity = value.equals("True"); }
|
||||||
|
if (key.equalsIgnoreCase("LandSetCode")) { cd.LandSetCode = value; }
|
||||||
|
|
||||||
|
if (key.equalsIgnoreCase("NumCards")) { cd.NumCards = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumSpecials")) { cd.NumSpecials = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumMythics")) { cd.NumMythics = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumRares")) { cd.NumRares = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumUncommons")) { cd.NumUncommons = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumCommons")) { cd.NumCommons = Integer.parseInt(value); }
|
||||||
|
if (key.equalsIgnoreCase("NumPacks")) { cd.NumPacks = Integer.parseInt(value); }
|
||||||
|
}
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package forge.game.limited;
|
package forge.game.limited;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.BoosterGenerator;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.CardListFilter;
|
import forge.CardListFilter;
|
||||||
@@ -10,10 +9,12 @@ import forge.Constant;
|
|||||||
import forge.FileUtil;
|
import forge.FileUtil;
|
||||||
import forge.MyRandom;
|
import forge.MyRandom;
|
||||||
import forge.SetUtils;
|
import forge.SetUtils;
|
||||||
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardSet;
|
import forge.card.CardSet;
|
||||||
import forge.card.spellability.Ability_Mana;
|
import forge.card.spellability.Ability_Mana;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
|
import forge.deck.DeckManager;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -21,6 +22,10 @@ import forge.item.CardPrinted;
|
|||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
import net.slightlymagic.maxmtg.Closure1;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -33,7 +38,7 @@ import java.util.List;
|
|||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public class SealedDeck {
|
public class SealedDeck {
|
||||||
private ArrayList<BoosterGenerator> packs = new ArrayList<BoosterGenerator>();
|
private List<Closure1<List<CardPrinted>, BoosterGenerator>> packs = new ArrayList<Closure1<List<CardPrinted>, BoosterGenerator>>();
|
||||||
public String LandSetCode[] = {""};
|
public String LandSetCode[] = {""};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,8 +50,9 @@ public class SealedDeck {
|
|||||||
|
|
||||||
if (sealedType.equals("Full")) {
|
if (sealedType.equals("Full")) {
|
||||||
BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getAllUniqueCards());
|
BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getAllUniqueCards());
|
||||||
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpFull);
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
packs.add(bpFull);
|
packs.add(picker);
|
||||||
|
|
||||||
LandSetCode[0] = CardDb.instance().getCard("Plains").getSet();
|
LandSetCode[0] = CardDb.instance().getCard("Plains").getSet();
|
||||||
} else if (sealedType.equals("Block")) {
|
} else if (sealedType.equals("Block")) {
|
||||||
@@ -78,19 +84,19 @@ public class SealedDeck {
|
|||||||
String[] pp = p.toString().split("/");
|
String[] pp = p.toString().split("/");
|
||||||
for (int i = 0; i < nPacks; i++) {
|
for (int i = 0; i < nPacks; i++) {
|
||||||
BoosterGenerator bpMulti = new BoosterGenerator(pp[i]);
|
BoosterGenerator bpMulti = new BoosterGenerator(pp[i]);
|
||||||
packs.add(bpMulti);
|
packs.add(BoosterGenerator.getSimplePicker(bpMulti));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BoosterGenerator bpOne = new BoosterGenerator(sets[0]);
|
BoosterGenerator bpOne = new BoosterGenerator(sets[0]);
|
||||||
for (int i = 0; i < nPacks; i++) { packs.add(bpOne); }
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpOne);
|
||||||
|
for (int i = 0; i < nPacks; i++) { packs.add(picker); }
|
||||||
}
|
}
|
||||||
|
|
||||||
LandSetCode[0] = block.getLandSet().getCode();
|
LandSetCode[0] = block.getLandSet().getCode();
|
||||||
|
|
||||||
} else if (sealedType.equals("Custom")) {
|
} else if (sealedType.equals("Custom")) {
|
||||||
String dList[];
|
String dList[];
|
||||||
ArrayList<CustomSealed> customs = new ArrayList<CustomSealed>();
|
ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||||
ArrayList<String> customList = new ArrayList<String>();
|
|
||||||
|
|
||||||
// get list of custom draft files
|
// get list of custom draft files
|
||||||
File dFolder = new File("res/sealed/");
|
File dFolder = new File("res/sealed/");
|
||||||
@@ -105,73 +111,41 @@ public class SealedDeck {
|
|||||||
for (int i = 0; i < dList.length; i++) {
|
for (int i = 0; i < dList.length; i++) {
|
||||||
if (dList[i].endsWith(".sealed")) {
|
if (dList[i].endsWith(".sealed")) {
|
||||||
ArrayList<String> dfData = FileUtil.readFile("res/sealed/" + dList[i]);
|
ArrayList<String> dfData = FileUtil.readFile("res/sealed/" + dList[i]);
|
||||||
|
CustomLimited cs = CustomLimited.parse(dfData);
|
||||||
CustomSealed cs = new CustomSealed();
|
|
||||||
|
|
||||||
for (int j = 0; j < dfData.size(); j++) {
|
|
||||||
|
|
||||||
String dfd = dfData.get(j);
|
|
||||||
|
|
||||||
if (dfd.startsWith("Name:"))
|
|
||||||
cs.Name = dfd.substring(5);
|
|
||||||
if (dfd.startsWith("Type:"))
|
|
||||||
cs.Type = dfd.substring(5);
|
|
||||||
if (dfd.startsWith("DeckFile:"))
|
|
||||||
cs.DeckFile = dfd.substring(9);
|
|
||||||
if (dfd.startsWith("IgnoreRarity:"))
|
|
||||||
cs.IgnoreRarity = dfd.substring(13).equals("True");
|
|
||||||
if (dfd.startsWith("LandSetCode:"))
|
|
||||||
cs.LandSetCode = dfd.substring(12);
|
|
||||||
|
|
||||||
if (dfd.startsWith("NumCards:"))
|
|
||||||
cs.NumCards = Integer.parseInt(dfd.substring(9));
|
|
||||||
if (dfd.startsWith("NumSpecials:"))
|
|
||||||
cs.NumSpecials = Integer.parseInt(dfd.substring(12));
|
|
||||||
if (dfd.startsWith("NumMythics:"))
|
|
||||||
cs.NumMythics = Integer.parseInt(dfd.substring(11));
|
|
||||||
if (dfd.startsWith("NumRares:"))
|
|
||||||
cs.NumRares = Integer.parseInt(dfd.substring(9));
|
|
||||||
if (dfd.startsWith("NumUncommons:"))
|
|
||||||
cs.NumUncommons = Integer.parseInt(dfd.substring(13));
|
|
||||||
if (dfd.startsWith("NumCommons:"))
|
|
||||||
cs.NumCommons = Integer.parseInt(dfd.substring(11));
|
|
||||||
if (dfd.startsWith("NumPacks:"))
|
|
||||||
cs.NumPacks = Integer.parseInt(dfd.substring(9));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
customs.add(cs);
|
customs.add(cs);
|
||||||
customList.add(cs.Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
CustomSealed chosenSealed = null;
|
|
||||||
|
|
||||||
// present list to user
|
// present list to user
|
||||||
if (customs.size() < 1)
|
if (customs.size() < 1)
|
||||||
JOptionPane.showMessageDialog(null, "No custom sealed files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "No custom sealed files found.", "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
Object p = GuiUtils.getChoice("Choose Custom Sealed Pool", customList.toArray());
|
final CustomLimited draft = (CustomLimited) GuiUtils.getChoice("Choose Custom Sealed Pool", customs.toArray());
|
||||||
|
|
||||||
for (int i = 0; i < customs.size(); i++) {
|
DeckManager dio = AllZone.getDeckManager();
|
||||||
CustomSealed cs = customs.get(i);
|
Deck dPool = dio.getDeck(draft.DeckFile);
|
||||||
|
if (dPool == null) {
|
||||||
if (cs.Name.equals(p.toString()))
|
throw new RuntimeException("BoosterGenerator : deck not found - " + draft.DeckFile);
|
||||||
chosenSealed = cs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chosenSealed.IgnoreRarity)
|
BoosterGenerator bpCustom = new BoosterGenerator(dPool);
|
||||||
chosenSealed.NumCommons = chosenSealed.NumCards;
|
Lambda1<List<CardPrinted>, BoosterGenerator> fnPick = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
|
||||||
|
@Override public List<CardPrinted> apply(BoosterGenerator pack) {
|
||||||
|
if ( draft.IgnoreRarity ) {
|
||||||
|
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, 0, draft.NumCards);
|
||||||
|
}
|
||||||
|
return pack.getBoosterPack(draft.NumCommons, 0, 0, draft.NumUncommons, 0, draft.NumRares, draft.NumMythics, draft.NumSpecials, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BoosterGenerator bpCustom = new BoosterGenerator(chosenSealed.DeckFile, chosenSealed.NumCommons, chosenSealed.NumUncommons, chosenSealed.NumRares, chosenSealed.NumMythics, chosenSealed.NumSpecials, chosenSealed.IgnoreRarity);
|
Closure1<List<CardPrinted>, BoosterGenerator> picker = new Closure1<List<CardPrinted>, BoosterGenerator>(fnPick, bpCustom);
|
||||||
|
|
||||||
for (int i = 0; i < chosenSealed.NumPacks; i++) {
|
for (int i = 0; i < draft.NumPacks; i++) {
|
||||||
packs.add(bpCustom);
|
packs.add(picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
LandSetCode[0] = chosenSealed.LandSetCode;
|
LandSetCode[0] = draft.LandSetCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +159,7 @@ public class SealedDeck {
|
|||||||
ItemPool<CardPrinted> pool = new ItemPool<CardPrinted>(CardPrinted.class);
|
ItemPool<CardPrinted> pool = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||||
|
|
||||||
for (int i = 0; i < packs.size(); i++)
|
for (int i = 0; i < packs.size(); i++)
|
||||||
pool.addAllCards(packs.get(i).getBoosterPack());
|
pool.addAllCards(packs.get(i).apply());
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
@@ -410,21 +384,6 @@ public class SealedDeck {
|
|||||||
return aiDeck;
|
return aiDeck;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomSealed {
|
|
||||||
public String Name;
|
|
||||||
public String Type;
|
|
||||||
public String DeckFile;
|
|
||||||
public Boolean IgnoreRarity;
|
|
||||||
public int NumCards = 15;
|
|
||||||
public int NumSpecials = 0;
|
|
||||||
public int NumMythics = 1;
|
|
||||||
public int NumRares = 1;
|
|
||||||
public int NumUncommons = 3;
|
|
||||||
public int NumCommons = 11;
|
|
||||||
public int NumPacks = 3;
|
|
||||||
public String LandSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer()).getMostRecentSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeckColors {
|
class DeckColors {
|
||||||
public String Color1 = "none";
|
public String Color1 = "none";
|
||||||
public String Color2 = "none";
|
public String Color2 = "none";
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package forge.item;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.BoosterGenerator;
|
|
||||||
import forge.SetUtils;
|
import forge.SetUtils;
|
||||||
|
import forge.card.BoosterGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import forge.CardList;
|
|||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Quest_Assignment;
|
import forge.Quest_Assignment;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
|
import forge.card.QuestBoosterPack;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import java.util.Map.Entry;
|
|||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import forge.ReadBoosterPack;
|
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
|
import forge.card.QuestBoosterPack;
|
||||||
|
import forge.card.ReadBoosterPack;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.item.Booster;
|
import forge.item.Booster;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package net.slightlymagic.braids.util.lambda;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not try to instantiate this class, because you cannot; this is simply
|
|
||||||
* a marker for the null literal.
|
|
||||||
*/
|
|
||||||
public final class Null {
|
|
||||||
private Null() {;}
|
|
||||||
}
|
|
||||||
15
src/main/java/net/slightlymagic/maxmtg/Closure1.java
Normal file
15
src/main/java/net/slightlymagic/maxmtg/Closure1.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package net.slightlymagic.maxmtg;
|
||||||
|
|
||||||
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
|
||||||
|
/** This class represents an action (lambda) and some arguments to make a call at a later time */
|
||||||
|
public class Closure1<R, A1> {
|
||||||
|
private final Lambda1<R, A1> method;
|
||||||
|
private final A1 argument;
|
||||||
|
|
||||||
|
public Closure1(Lambda1<R, A1> lambda, A1 object) {
|
||||||
|
method = lambda;
|
||||||
|
argument = object;
|
||||||
|
}
|
||||||
|
public R apply() { return method.apply(argument); }
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package forge;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.card.ReadDraftBoosterPack;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.limited.BoosterDraftAI;
|
import forge.game.limited.BoosterDraftAI;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
|
import forge.card.ReadDraftBoosterPack;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
|
|
||||||
import forge.game.limited.BoosterDraft;
|
import forge.game.limited.BoosterDraft;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package forge;
|
|||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import forge.card.ReadBoosterPack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
* User: dhudson
|
* User: dhudson
|
||||||
|
|||||||
Reference in New Issue
Block a user