mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
renamed CardSet to CardEdition, moved static ???Utils classes to AllZone (not a best place, but better than just static classes) divided formats from sets
This commit is contained in:
9
.gitattributes
vendored
9
.gitattributes
vendored
@@ -11017,8 +11017,6 @@ src/main/java/forge/PlayerType.java svneol=native#text/plain
|
||||
src/main/java/forge/PlayerUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/PlayerZone.java svneol=native#text/plain
|
||||
src/main/java/forge/PlayerZoneComesIntoPlay.java svneol=native#text/plain
|
||||
src/main/java/forge/SetInfo.java svneol=native#text/plain
|
||||
src/main/java/forge/SetUtils.java svneol=native#text/plain
|
||||
src/main/java/forge/SimpleCombat.java svneol=native#text/plain
|
||||
src/main/java/forge/Singletons.java svneol=native#text/plain
|
||||
src/main/java/forge/StaticEffect.java svneol=native#text/plain
|
||||
@@ -11033,6 +11031,7 @@ src/main/java/forge/card/CardBlock.java -text
|
||||
src/main/java/forge/card/CardCharacteristics.java -text
|
||||
src/main/java/forge/card/CardColor.java -text
|
||||
src/main/java/forge/card/CardCoreType.java -text
|
||||
src/main/java/forge/card/CardEdition.java -text
|
||||
src/main/java/forge/card/CardInSet.java -text
|
||||
src/main/java/forge/card/CardManaCost.java -text
|
||||
src/main/java/forge/card/CardManaCostShard.java -text
|
||||
@@ -11040,10 +11039,12 @@ src/main/java/forge/card/CardRarity.java -text
|
||||
src/main/java/forge/card/CardRuleCharacteristics.java -text
|
||||
src/main/java/forge/card/CardRules.java -text
|
||||
src/main/java/forge/card/CardRulesReader.java svneol=native#text/plain
|
||||
src/main/java/forge/card/CardSet.java -text
|
||||
src/main/java/forge/card/CardSuperType.java -text
|
||||
src/main/java/forge/card/CardType.java -text
|
||||
src/main/java/forge/card/FormatUtils.java -text
|
||||
src/main/java/forge/card/MtgDataParser.java -text
|
||||
src/main/java/forge/card/SetInfo.java svneol=native#text/plain
|
||||
src/main/java/forge/card/SetUtils.java svneol=native#text/plain
|
||||
src/main/java/forge/card/TriggerReplacementBase.java -text
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactory.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityfactory/AbilityFactoryAlterLife.java svneol=native#text/plain
|
||||
@@ -11243,7 +11244,6 @@ src/main/java/forge/deck/generate/GenerateThemeDeck.java svneol=native#text/plai
|
||||
src/main/java/forge/deck/generate/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/io/DeckFileHeader.java -text
|
||||
src/main/java/forge/deck/io/DeckGroupSerializer.java -text
|
||||
src/main/java/forge/deck/io/DeckReaderBase.java -text
|
||||
src/main/java/forge/deck/io/DeckSerializer.java -text
|
||||
src/main/java/forge/deck/io/OldDeckParser.java -text
|
||||
src/main/java/forge/deck/package-info.java svneol=native#text/plain
|
||||
@@ -11377,6 +11377,7 @@ src/main/java/forge/util/FileSection.java -text
|
||||
src/main/java/forge/util/FileUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/util/FolderMap.java svneol=native#text/plain
|
||||
src/main/java/forge/util/FolderMapView.java -text
|
||||
src/main/java/forge/util/FolderStorageReader.java -text
|
||||
src/main/java/forge/util/HttpUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/util/IFolderMap.java -text
|
||||
src/main/java/forge/util/IFolderMapView.java -text
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.List;
|
||||
|
||||
import net.slightlymagic.braids.util.UtilFunctions;
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.FormatUtils;
|
||||
import forge.card.SetUtils;
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.cardfactory.PreloadingCardFactory;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
@@ -570,4 +572,18 @@ public final class AllZone {
|
||||
return AllZone.cardRatings;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
private static SetUtils setUtils = null;
|
||||
public static SetUtils getEditions() {
|
||||
return setUtils != null ? setUtils : (setUtils = new SetUtils());
|
||||
}
|
||||
|
||||
private static FormatUtils formats = null;
|
||||
public static FormatUtils getFormats() {
|
||||
return formats != null ? formats : ( formats = new FormatUtils());
|
||||
}
|
||||
|
||||
} // AllZone
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.Constant.Zone;
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.SetInfo;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
@@ -8218,7 +8219,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* </p>
|
||||
*
|
||||
* @param sInfo
|
||||
* a {@link forge.SetInfo} object.
|
||||
* a {@link forge.card.SetInfo} object.
|
||||
*/
|
||||
public final void addSet(final SetInfo sInfo) {
|
||||
this.getCharacteristics().getSets().add(sInfo);
|
||||
|
||||
@@ -25,6 +25,8 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
|
||||
import com.google.code.jyield.Generator;
|
||||
|
||||
import forge.card.SetInfo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* CardFilter class.
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import com.google.code.jyield.Generator;
|
||||
import com.google.code.jyield.Yieldable;
|
||||
|
||||
import forge.card.SetInfo;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.google.code.jyield.YieldUtils;
|
||||
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardRulesReader;
|
||||
import forge.card.SetInfo;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.error.ErrorViewer;
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.slightlymagic.maxmtg.Predicate;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.SetInfo;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellAbilityList;
|
||||
@@ -731,7 +732,7 @@ public final class CardUtil {
|
||||
}
|
||||
|
||||
// Second, try 2 letter set code with MWS filename format
|
||||
final String mwsSet2 = String.format("%s/%s%s.full", SetUtils.getCode2ByCode(setName), mwsCardName, nn);
|
||||
final String mwsSet2 = String.format("%s/%s%s.full", AllZone.getEditions().getCode2ByCode(setName), mwsCardName, nn);
|
||||
f = new File(path, mwsSet2 + ".jpg");
|
||||
if (f.exists()) {
|
||||
return mwsSet2;
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.swing.JFrame;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.properties.ForgeProps;
|
||||
@@ -71,7 +71,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
||||
final String urlBase = ForgeProps.getProperty(NewConstants.CARDFORGE_URL) + "/fpics/";
|
||||
|
||||
final String setCode3 = c.getSet();
|
||||
final CardSet thisSet = SetUtils.getSetByCode(setCode3);
|
||||
final CardEdition thisSet = AllZone.getEditions().getEditionByCode(setCode3);
|
||||
final String setCode2 = thisSet.getCode2();
|
||||
|
||||
final String imgFN = CardUtil.buildFilename(c, cardName);
|
||||
|
||||
@@ -51,6 +51,7 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.card.SetInfo;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -497,7 +498,7 @@ public final class GuiMigrateLocalMWSSetPicturesHQ extends DefaultBoundedRangeMo
|
||||
for (int j = 0; j < cSetInfo.size(); j++) {
|
||||
c.setCurSetCode(cSetInfo.get(j).getCode());
|
||||
final String setCode3 = c.getCurSetCode();
|
||||
final String setCode2 = SetUtils.getCode2ByCode(c.getCurSetCode());
|
||||
final String setCode2 = AllZone.getEditions().getCode2ByCode(c.getCurSetCode());
|
||||
|
||||
int n = 0;
|
||||
if (cSetInfo.get(j).getPicCount() > 0) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package forge.card;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -42,6 +43,8 @@ import forge.util.MyRandom;
|
||||
*/
|
||||
public class BoosterGenerator {
|
||||
|
||||
private static final int BOOSTERS_TO_FIND_MYTHIC = 8;
|
||||
|
||||
// Function to open a booster as it is.
|
||||
/** The Constant IDENTITY_PICK. */
|
||||
public static final Lambda1<List<CardPrinted>, BoosterGenerator> IDENTITY_PICK = new Lambda1<List<CardPrinted>, BoosterGenerator>() {
|
||||
@@ -65,17 +68,11 @@ public class BoosterGenerator {
|
||||
}
|
||||
|
||||
// These lists are to hold cards grouped by rarity in advance.
|
||||
private final List<CardPrinted> basicLands = new ArrayList<CardPrinted>();
|
||||
|
||||
private final List<CardPrinted> allButLands = 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 final List<CardPrinted> doubleFacedCommons = new ArrayList<CardPrinted>();
|
||||
private final List<CardPrinted> doubleFacedUncommons = new ArrayList<CardPrinted>();
|
||||
private final List<CardPrinted> doubleFacedRares = new ArrayList<CardPrinted>();
|
||||
private final List<CardPrinted> doubleFacedMythics = new ArrayList<CardPrinted>();
|
||||
|
||||
private final Map<CardRarity, List<CardPrinted>> cardsByRarity = new EnumMap<CardRarity, List<CardPrinted>>(CardRarity.class);
|
||||
private final Map<CardRarity, List<CardPrinted>> twoFacedByRarity = new EnumMap<CardRarity, List<CardPrinted>>(CardRarity.class);
|
||||
|
||||
// private List<CardPrinted> commonCreatures;
|
||||
// private List<CardPrinted> commonNonCreatures;
|
||||
@@ -90,6 +87,16 @@ public class BoosterGenerator {
|
||||
private int numDoubleFaced = 0;
|
||||
private int numSpecials = 0;
|
||||
|
||||
private BoosterGenerator()
|
||||
{
|
||||
for( CardRarity v : CardRarity.values() )
|
||||
{
|
||||
cardsByRarity.put(v, new ArrayList<CardPrinted>());
|
||||
twoFacedByRarity.put(v, new ArrayList<CardPrinted>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for BoosterGenerator.
|
||||
@@ -99,6 +106,7 @@ public class BoosterGenerator {
|
||||
* the cards
|
||||
*/
|
||||
public BoosterGenerator(final Iterable<CardPrinted> cards) {
|
||||
this();
|
||||
for (final CardPrinted c : cards) {
|
||||
this.addToRarity(c);
|
||||
}
|
||||
@@ -111,6 +119,7 @@ public class BoosterGenerator {
|
||||
* the d pool
|
||||
*/
|
||||
public BoosterGenerator(final ItemPoolView<CardPrinted> dPool) {
|
||||
this();
|
||||
for (final Entry<CardPrinted, Integer> e : dPool) {
|
||||
this.addToRarity(e.getKey());
|
||||
}
|
||||
@@ -124,11 +133,12 @@ public class BoosterGenerator {
|
||||
* @param cardSet
|
||||
* the card set
|
||||
*/
|
||||
public BoosterGenerator(final CardSet cardSet) {
|
||||
public BoosterGenerator(final CardEdition cardSet) {
|
||||
this();
|
||||
if (!cardSet.canGenerateBooster()) {
|
||||
throw new InvalidParameterException("BoosterGenerator: Set " + cardSet + " cannot generate boosters!");
|
||||
}
|
||||
final CardSet.BoosterData bs = cardSet.getBoosterData();
|
||||
final CardEdition.BoosterData bs = cardSet.getBoosterData();
|
||||
|
||||
this.numCommons = bs.getCommon();
|
||||
this.numUncommons = bs.getUncommon();
|
||||
@@ -188,7 +198,7 @@ public class BoosterGenerator {
|
||||
int indexRares = Integer.MAX_VALUE;
|
||||
int indexMythics = Integer.MAX_VALUE;
|
||||
for (int iCard = 0; iCard < count; iCard++) {
|
||||
final int rollD8 = MyRandom.getRandom().nextInt(8);
|
||||
final int rollD8 = MyRandom.getRandom().nextInt(BOOSTERS_TO_FIND_MYTHIC);
|
||||
final boolean takeMythic = (mythicsSize > 0) && (rollD8 < 1);
|
||||
if (takeMythic) {
|
||||
if (indexMythics >= mythicsSize) {
|
||||
@@ -271,47 +281,35 @@ public class BoosterGenerator {
|
||||
|
||||
final List<CardPrinted> temp = new ArrayList<CardPrinted>();
|
||||
|
||||
temp.addAll(this.pickRandomCards(this.commons, nCom));
|
||||
/*
|
||||
* if( nComCreat > 0 || nComNonCr > 0) { if
|
||||
* (commonNonCreatures.isEmpty()) {
|
||||
* CardRules.Predicates.Presets.isCreature.split(commons,
|
||||
* CardPrinted.fnGetRules, commonCreatures, commonNonCreatures); }
|
||||
* temp.addAll(pickRandomCards(commonCreatures, nComCreat));
|
||||
* temp.addAll(pickRandomCards(commonNonCreatures, nComNonCr)); }
|
||||
*/
|
||||
|
||||
temp.addAll(this.pickRandomCards(this.uncommons, nUnc));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.Common), nCom));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.Uncommon), nUnc));
|
||||
|
||||
if (nRareSlots > 0) {
|
||||
temp.addAll(this.pickRandomRaresOrMythics(this.rares, this.mythics, nRareSlots));
|
||||
temp.addAll(this.pickRandomRaresOrMythics(cardsByRarity.get(CardRarity.Rare),
|
||||
cardsByRarity.get(CardRarity.MythicRare), nRareSlots));
|
||||
}
|
||||
if ((nRares > 0) || (nMythics > 0)) {
|
||||
temp.addAll(this.pickRandomCards(this.rares, nRares));
|
||||
temp.addAll(this.pickRandomCards(this.mythics, nMythics));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.Rare), nRares));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.MythicRare), nMythics));
|
||||
}
|
||||
if (nDoubls > 0) {
|
||||
final int dblFacedRarity = MyRandom.getRandom().nextInt(14);
|
||||
List<CardPrinted> listToUse;
|
||||
if (dblFacedRarity < 9) { // Common
|
||||
listToUse = this.doubleFacedCommons;
|
||||
} else if (dblFacedRarity < 13) { // Uncommon
|
||||
listToUse = this.doubleFacedUncommons;
|
||||
} else { // Rare or Mythic
|
||||
if (MyRandom.getRandom().nextInt(8) == 0) {
|
||||
listToUse = this.doubleFacedMythics;
|
||||
} else {
|
||||
listToUse = this.doubleFacedRares;
|
||||
}
|
||||
}
|
||||
temp.addAll(this.pickRandomCards(listToUse, nDoubls));
|
||||
final int dblFacedRarity = MyRandom.getRandom().nextInt(nCom + nUnc + nRareSlots);
|
||||
CardRarity rarityInSlot = CardRarity.MythicRare;
|
||||
if( dblFacedRarity < nCom )
|
||||
rarityInSlot = CardRarity.Common;
|
||||
else if( dblFacedRarity < nCom + nUnc )
|
||||
rarityInSlot = CardRarity.Uncommon;
|
||||
else if( MyRandom.getRandom().nextInt(BOOSTERS_TO_FIND_MYTHIC) != 0 )
|
||||
rarityInSlot = CardRarity.Rare;
|
||||
|
||||
temp.addAll(this.pickRandomCards(twoFacedByRarity.get(rarityInSlot), nDoubls));
|
||||
}
|
||||
|
||||
temp.addAll(this.pickRandomCards(this.specials, nSpecs));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.Special), nSpecs));
|
||||
|
||||
temp.addAll(this.pickRandomCards(this.allButLands, nAnyCard));
|
||||
|
||||
temp.addAll(this.pickRandomCards(this.basicLands, nLands));
|
||||
temp.addAll(this.pickRandomCards(cardsByRarity.get(CardRarity.BasicLand), nLands));
|
||||
|
||||
return temp;
|
||||
}
|
||||
@@ -320,48 +318,15 @@ public class BoosterGenerator {
|
||||
if (c.getCard().isAltState()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CardRarity rarity = c.getRarity();
|
||||
if (c.getCard().isDoubleFaced() && (this.numDoubleFaced > 0)) {
|
||||
switch (c.getRarity()) {
|
||||
case Common:
|
||||
this.doubleFacedCommons.add(c);
|
||||
break;
|
||||
case Uncommon:
|
||||
this.doubleFacedUncommons.add(c);
|
||||
break;
|
||||
case Rare:
|
||||
this.doubleFacedRares.add(c);
|
||||
break;
|
||||
case MythicRare:
|
||||
this.doubleFacedMythics.add(c);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
twoFacedByRarity.get(rarity).add(c);
|
||||
} else {
|
||||
switch (c.getRarity()) {
|
||||
case Common:
|
||||
this.commons.add(c);
|
||||
break;
|
||||
case Uncommon:
|
||||
this.uncommons.add(c);
|
||||
break;
|
||||
case Rare:
|
||||
this.rares.add(c);
|
||||
break;
|
||||
case MythicRare:
|
||||
this.mythics.add(c);
|
||||
break;
|
||||
case Special:
|
||||
this.specials.add(c);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cardsByRarity.get(rarity).add(c);
|
||||
}
|
||||
|
||||
if (c.getCard().getType().isBasicLand()) {
|
||||
this.basicLands.add(c);
|
||||
} else {
|
||||
if (!c.getCard().getType().isBasicLand()) {
|
||||
this.allButLands.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import forge.item.CardPrinted;
|
||||
* This is a CardBlock class.
|
||||
*/
|
||||
public final class CardBlock implements Comparable<CardBlock> {
|
||||
private static final CardSet[] EMPTY_SET_ARRAY = new CardSet[] {};
|
||||
private static final CardEdition[] EMPTY_SET_ARRAY = new CardEdition[] {};
|
||||
|
||||
private final int orderNum;
|
||||
private final String name;
|
||||
private final CardSet[] sets;
|
||||
private final CardSet landSet;
|
||||
private final CardEdition[] sets;
|
||||
private final CardEdition landSet;
|
||||
private final int cntBoostersDraft;
|
||||
private final int cntBoostersSealed;
|
||||
private Predicate<CardPrinted> filter = null;
|
||||
@@ -53,7 +53,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
||||
* @param cntBoostersSealed
|
||||
* the cnt boosters sealed
|
||||
*/
|
||||
public CardBlock(final int index, final String name, final List<CardSet> sets, final CardSet landSet,
|
||||
public CardBlock(final int index, final String name, final List<CardEdition> sets, final CardEdition landSet,
|
||||
final int cntBoostersDraft, final int cntBoostersSealed) {
|
||||
this.orderNum = index;
|
||||
this.name = name;
|
||||
@@ -77,7 +77,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
||||
*
|
||||
* @return the sets
|
||||
*/
|
||||
public CardSet[] getSets() {
|
||||
public CardEdition[] getSets() {
|
||||
return this.sets;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
||||
*
|
||||
* @return the land set
|
||||
*/
|
||||
public CardSet getLandSet() {
|
||||
public CardEdition getLandSet() {
|
||||
return this.landSet;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
||||
|
||||
private Predicate<CardPrinted> buildFilter() {
|
||||
final List<String> setCodes = new ArrayList<String>();
|
||||
for (final CardSet set : this.sets) {
|
||||
for (final CardEdition set : this.sets) {
|
||||
setCodes.add(set.getCode());
|
||||
}
|
||||
return CardPrinted.Predicates.printedInSets(setCodes, true);
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.card;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.CardColor;
|
||||
import forge.SetInfo;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.AbilityMana;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
|
||||
@@ -19,8 +19,6 @@ package forge.card;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
import forge.SetUtils;
|
||||
import forge.game.GameFormat;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -30,7 +28,7 @@ import forge.game.GameFormat;
|
||||
* @author Forge
|
||||
* @version $Id: CardSet.java 9708 2011-08-09 19:34:12Z jendave $
|
||||
*/
|
||||
public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
private final int index;
|
||||
private final String code;
|
||||
private final String code2;
|
||||
@@ -49,7 +47,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
* @param code2
|
||||
* the code2
|
||||
*/
|
||||
public CardSet(final int index, final String name, final String code, final String code2) {
|
||||
public CardEdition(final int index, final String name, final String code, final String code2) {
|
||||
this(index, name, code, code2, null);
|
||||
}
|
||||
|
||||
@@ -67,7 +65,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
* @param booster
|
||||
* the booster
|
||||
*/
|
||||
public CardSet(final int index, final String name, final String code, final String code2, final BoosterData booster) {
|
||||
public CardEdition(final int index, final String name, final String code, final String code2, final BoosterData booster) {
|
||||
this.code = code;
|
||||
this.code2 = code2;
|
||||
this.index = index;
|
||||
@@ -76,7 +74,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
}
|
||||
|
||||
/** The Constant unknown. */
|
||||
public static final CardSet UNKNOWN = new CardSet(-1, "Undefined", "???", "??");
|
||||
public static final CardEdition UNKNOWN = new CardEdition(-1, "Undefined", "???", "??");
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
@@ -133,17 +131,17 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
}
|
||||
|
||||
/** The Constant fnGetName. */
|
||||
public static final Lambda1<String, CardSet> FN_GET_NAME = new Lambda1<String, CardSet>() {
|
||||
public static final Lambda1<String, CardEdition> FN_GET_NAME = new Lambda1<String, CardEdition>() {
|
||||
@Override
|
||||
public String apply(final CardSet arg1) {
|
||||
public String apply(final CardEdition arg1) {
|
||||
return arg1.name;
|
||||
}
|
||||
};
|
||||
|
||||
/** The Constant fn1. */
|
||||
public static final Lambda1<CardSet, CardSet> FN1 = new Lambda1<CardSet, CardSet>() {
|
||||
public static final Lambda1<CardEdition, CardEdition> FN1 = new Lambda1<CardEdition, CardEdition>() {
|
||||
@Override
|
||||
public CardSet apply(final CardSet arg1) {
|
||||
public CardEdition apply(final CardEdition arg1) {
|
||||
return arg1;
|
||||
}
|
||||
};
|
||||
@@ -154,7 +152,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(final CardSet o) {
|
||||
public int compareTo(final CardEdition o) {
|
||||
if (o == null) {
|
||||
return 1;
|
||||
}
|
||||
@@ -188,7 +186,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
return false;
|
||||
}
|
||||
|
||||
final CardSet other = (CardSet) obj;
|
||||
final CardEdition other = (CardEdition) obj;
|
||||
return other.name.equals(this.name) && this.code.equals(other.code);
|
||||
}
|
||||
|
||||
@@ -345,53 +343,15 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
public abstract static class Predicates {
|
||||
|
||||
/** The Constant canMakeBooster. */
|
||||
public static final Predicate<CardSet> CAN_MAKE_BOOSTER = new CanMakeBooster();
|
||||
public static final Predicate<CardEdition> CAN_MAKE_BOOSTER = new CanMakeBooster();
|
||||
|
||||
/**
|
||||
* Checks if is legal in format.
|
||||
*
|
||||
* @param format
|
||||
* the format
|
||||
* @return the predicate
|
||||
*/
|
||||
public static final Predicate<CardSet> isLegalInFormat(final GameFormat format) {
|
||||
return new LegalInFormat(format);
|
||||
}
|
||||
|
||||
private static class CanMakeBooster extends Predicate<CardSet> {
|
||||
private static class CanMakeBooster extends Predicate<CardEdition> {
|
||||
@Override
|
||||
public boolean isTrue(final CardSet subject) {
|
||||
public boolean isTrue(final CardEdition subject) {
|
||||
return subject.canGenerateBooster();
|
||||
}
|
||||
}
|
||||
|
||||
private static class LegalInFormat extends Predicate<CardSet> {
|
||||
private final GameFormat format;
|
||||
|
||||
public LegalInFormat(final GameFormat fmt) {
|
||||
this.format = fmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(final CardSet subject) {
|
||||
return this.format.isSetLegal(subject.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class Presets.
|
||||
*/
|
||||
public abstract static class Presets {
|
||||
|
||||
/** The Constant setsInT2. */
|
||||
public static final Predicate<CardSet> SETS_IN_STANDARD = Predicates
|
||||
.isLegalInFormat(SetUtils.getStandard());
|
||||
|
||||
/** The Constant setsInExt. */
|
||||
public static final Predicate<CardSet> SETS_IN_EXT = Predicates.isLegalInFormat(SetUtils.getExtended());
|
||||
|
||||
/** The Constant setsInModern. */
|
||||
public static final Predicate<CardSet> SET_IN_MODERN = Predicates.isLegalInFormat(SetUtils.getModern());
|
||||
}
|
||||
}
|
||||
}
|
||||
131
src/main/java/forge/card/FormatUtils.java
Normal file
131
src/main/java/forge/card/FormatUtils.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.game.GameFormat;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
public final class FormatUtils {
|
||||
|
||||
private final Map<String, GameFormat> formats = new TreeMap<String, GameFormat>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
/**
|
||||
* Gets the standard.
|
||||
*
|
||||
* @return the standard
|
||||
*/
|
||||
public GameFormat getStandard() {
|
||||
return formats.get("Standard");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extended.
|
||||
*
|
||||
* @return the extended
|
||||
*/
|
||||
public GameFormat getExtended() {
|
||||
return formats.get("Extended");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the modern.
|
||||
*
|
||||
* @return the modern
|
||||
*/
|
||||
public GameFormat getModern() {
|
||||
return formats.get("Modern");
|
||||
}
|
||||
|
||||
// list are immutable, no worries
|
||||
/**
|
||||
* Gets the formats.
|
||||
*
|
||||
* @return the formats
|
||||
*/
|
||||
public Collection<GameFormat> getFormats() {
|
||||
return formats.values();
|
||||
}
|
||||
|
||||
public FormatUtils() {
|
||||
final List<String> fData = FileUtil.readFile("res/blockdata/formats.txt");
|
||||
|
||||
for (final String s : fData) {
|
||||
if (StringUtils.isBlank(s)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = null;
|
||||
final List<String> sets = new ArrayList<String>(); // default: all
|
||||
// sets
|
||||
// allowed
|
||||
final List<String> bannedCards = new ArrayList<String>(); // default:
|
||||
// nothing
|
||||
// banned
|
||||
|
||||
final String[] sParts = s.trim().split("\\|");
|
||||
for (final String sPart : sParts) {
|
||||
final String[] kv = sPart.split(":", 2);
|
||||
final String key = kv[0].toLowerCase();
|
||||
if ("name".equals(key)) {
|
||||
name = kv[1];
|
||||
} else if ("sets".equals(key)) {
|
||||
sets.addAll(Arrays.asList(kv[1].split(", ")));
|
||||
} else if ("banned".equals(key)) {
|
||||
bannedCards.addAll(Arrays.asList(kv[1].split("; ")));
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
throw new RuntimeException("Format must have a name! Check formats.txt file");
|
||||
}
|
||||
final GameFormat thisFormat = new GameFormat(name, sets, bannedCards);
|
||||
|
||||
formats.put(name, thisFormat);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Predicates {
|
||||
|
||||
public static final Predicate<CardEdition> isLegalInFormat(final GameFormat format) {
|
||||
return new LegalInFormat(format);
|
||||
}
|
||||
|
||||
private static class LegalInFormat extends Predicate<CardEdition> {
|
||||
private final GameFormat format;
|
||||
|
||||
public LegalInFormat(final GameFormat fmt) {
|
||||
this.format = fmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(final CardEdition subject) {
|
||||
return this.format.isSetLegal(subject.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/** The Constant setsInT2. */
|
||||
public static final Predicate<CardEdition> SETS_IN_STANDARD = Predicates
|
||||
.isLegalInFormat(AllZone.getFormats().getStandard());
|
||||
|
||||
/** The Constant setsInExt. */
|
||||
public static final Predicate<CardEdition> SETS_IN_EXT = Predicates.isLegalInFormat(AllZone.getFormats().getExtended());
|
||||
|
||||
/** The Constant setsInModern. */
|
||||
public static final Predicate<CardEdition> SET_IN_MODERN = Predicates.isLegalInFormat(AllZone.getFormats().getModern());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
@@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge;
|
||||
package forge.card;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -15,20 +15,17 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge;
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardSet;
|
||||
import forge.game.GameFormat;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
/**
|
||||
@@ -41,80 +38,28 @@ import forge.util.FileUtil;
|
||||
*/
|
||||
public final class SetUtils {
|
||||
|
||||
private SetUtils() {
|
||||
throw new AssertionError();
|
||||
private final List<CardEdition> allSets;
|
||||
|
||||
public final List<CardEdition> getAllSets() {
|
||||
return allSets;
|
||||
}
|
||||
|
||||
public SetUtils() {
|
||||
allSets = loadSetData(loadBoosterData());
|
||||
allBlocks = loadBlockData();
|
||||
}
|
||||
|
||||
/** Constant <code>setData</code>. */
|
||||
private static Map<String, CardSet> setsByCode = new HashMap<String, CardSet>();
|
||||
private static List<CardSet> allSets = new ArrayList<CardSet>();
|
||||
private static List<CardBlock> allBlocks = new ArrayList<CardBlock>();
|
||||
|
||||
private static List<GameFormat> formats = new ArrayList<GameFormat>();
|
||||
private static GameFormat fmtStandard = null;
|
||||
private static GameFormat fmtExtended = null;
|
||||
private static GameFormat fmtModern = null;
|
||||
|
||||
/**
|
||||
* Gets the standard.
|
||||
*
|
||||
* @return the standard
|
||||
*/
|
||||
public static GameFormat getStandard() {
|
||||
return SetUtils.fmtStandard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extended.
|
||||
*
|
||||
* @return the extended
|
||||
*/
|
||||
public static GameFormat getExtended() {
|
||||
return SetUtils.fmtExtended;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the modern.
|
||||
*
|
||||
* @return the modern
|
||||
*/
|
||||
public static GameFormat getModern() {
|
||||
return SetUtils.fmtModern;
|
||||
}
|
||||
|
||||
// list are immutable, no worries
|
||||
/**
|
||||
* Gets the formats.
|
||||
*
|
||||
* @return the formats
|
||||
*/
|
||||
public static List<GameFormat> getFormats() {
|
||||
return SetUtils.formats;
|
||||
}
|
||||
private final Map<String, CardEdition> setsByCode = new TreeMap<String, CardEdition>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final List<CardBlock> allBlocks;
|
||||
|
||||
/**
|
||||
* Gets the blocks.
|
||||
*
|
||||
* @return the blocks
|
||||
*/
|
||||
public static List<CardBlock> getBlocks() {
|
||||
return SetUtils.allBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all sets.
|
||||
*
|
||||
* @return the all sets
|
||||
*/
|
||||
public static List<CardSet> getAllSets() {
|
||||
return SetUtils.allSets;
|
||||
}
|
||||
|
||||
// Perform that first of all
|
||||
static {
|
||||
SetUtils.loadSetData(SetUtils.loadBoosterData());
|
||||
SetUtils.loadBlockData();
|
||||
SetUtils.loadFormatData();
|
||||
public List<CardBlock> getBlocks() {
|
||||
return allBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,8 +69,8 @@ public final class SetUtils {
|
||||
* the code
|
||||
* @return the sets the by code
|
||||
*/
|
||||
public static CardSet getSetByCode(final String code) {
|
||||
return SetUtils.setsByCode.get(code);
|
||||
public CardEdition getEditionByCode(final String code) {
|
||||
return setsByCode.get(code);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,10 +80,10 @@ public final class SetUtils {
|
||||
* the code
|
||||
* @return the sets the by code or throw
|
||||
*/
|
||||
public static CardSet getSetByCodeOrThrow(final String code) {
|
||||
final CardSet set = SetUtils.setsByCode.get(code);
|
||||
public CardEdition getEditionByCodeOrThrow(final String code) {
|
||||
final CardEdition set = setsByCode.get(code);
|
||||
if (null == set) {
|
||||
throw new RuntimeException(String.format("Set with code '%s' not found", code));
|
||||
throw new RuntimeException(String.format("Edition with code '%s' not found", code));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
@@ -151,14 +96,14 @@ public final class SetUtils {
|
||||
* the code
|
||||
* @return the code2 by code
|
||||
*/
|
||||
public static String getCode2ByCode(final String code) {
|
||||
final CardSet set = SetUtils.setsByCode.get(code);
|
||||
public String getCode2ByCode(final String code) {
|
||||
final CardEdition set = setsByCode.get(code);
|
||||
return set == null ? "" : set.getCode2();
|
||||
}
|
||||
|
||||
private static Map<String, CardSet.BoosterData> loadBoosterData() {
|
||||
private Map<String, CardEdition.BoosterData> loadBoosterData() {
|
||||
final ArrayList<String> fData = FileUtil.readFile("res/blockdata/boosters.txt");
|
||||
final Map<String, CardSet.BoosterData> result = new HashMap<String, CardSet.BoosterData>();
|
||||
final Map<String, CardEdition.BoosterData> result = new HashMap<String, CardEdition.BoosterData>();
|
||||
|
||||
for (final String s : fData) {
|
||||
if (StringUtils.isBlank(s)) {
|
||||
@@ -191,15 +136,16 @@ public final class SetUtils {
|
||||
nDF = Integer.parseInt(kv[1]);
|
||||
}
|
||||
}
|
||||
result.put(code, new CardSet.BoosterData(nC, nU, nR, nS, nDF));
|
||||
result.put(code, new CardEdition.BoosterData(nC, nU, nR, nS, nDF));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// parser code - quite boring.
|
||||
private static void loadSetData(final Map<String, CardSet.BoosterData> boosters) {
|
||||
private List<CardEdition> loadSetData(final Map<String, CardEdition.BoosterData> boosters) {
|
||||
final ArrayList<String> fData = FileUtil.readFile("res/blockdata/setdata.txt");
|
||||
|
||||
final List<CardEdition> allSets = new ArrayList<CardEdition>();
|
||||
for (final String s : fData) {
|
||||
if (StringUtils.isBlank(s)) {
|
||||
continue;
|
||||
@@ -225,21 +171,21 @@ public final class SetUtils {
|
||||
alias = kv[1];
|
||||
}
|
||||
}
|
||||
final CardSet set = new CardSet(index, name, code, code2, boosters.get(code));
|
||||
final CardEdition set = new CardEdition(index, name, code, code2, boosters.get(code));
|
||||
boosters.remove(code);
|
||||
SetUtils.setsByCode.put(code, set);
|
||||
setsByCode.put(code, set);
|
||||
if (alias != null) {
|
||||
SetUtils.setsByCode.put(alias, set);
|
||||
setsByCode.put(alias, set);
|
||||
}
|
||||
SetUtils.allSets.add(set);
|
||||
allSets.add(set);
|
||||
}
|
||||
assert boosters.isEmpty();
|
||||
Collections.sort(SetUtils.allSets);
|
||||
SetUtils.allSets = Collections.unmodifiableList(SetUtils.allSets);
|
||||
return allSets;
|
||||
}
|
||||
|
||||
private static void loadBlockData() {
|
||||
private List<CardBlock> loadBlockData() {
|
||||
final ArrayList<String> fData = FileUtil.readFile("res/blockdata/blocks.txt");
|
||||
final List<CardBlock> theBlocks = new ArrayList<CardBlock>();
|
||||
|
||||
for (final String s : fData) {
|
||||
if (StringUtils.isBlank(s)) {
|
||||
@@ -250,8 +196,8 @@ public final class SetUtils {
|
||||
|
||||
String name = null;
|
||||
int index = -1;
|
||||
final List<CardSet> sets = new ArrayList<CardSet>(4);
|
||||
CardSet landSet = null;
|
||||
final List<CardEdition> sets = new ArrayList<CardEdition>(4);
|
||||
CardEdition landSet = null;
|
||||
int draftBoosters = 3;
|
||||
int sealedBoosters = 6;
|
||||
|
||||
@@ -263,9 +209,9 @@ public final class SetUtils {
|
||||
} else if ("index".equals(key)) {
|
||||
index = Integer.parseInt(kv[1]);
|
||||
} else if ("set0".equals(key) || "set1".equals(key) || "set2".equals(key)) {
|
||||
sets.add(SetUtils.getSetByCodeOrThrow(kv[1]));
|
||||
sets.add(getEditionByCodeOrThrow(kv[1]));
|
||||
} else if ("landsetcode".equals(key)) {
|
||||
landSet = SetUtils.getSetByCodeOrThrow(kv[1]);
|
||||
landSet = getEditionByCodeOrThrow(kv[1]);
|
||||
} else if ("draftpacks".equals(key)) {
|
||||
draftBoosters = Integer.parseInt(kv[1]);
|
||||
} else if ("sealedpacks".equals(key)) {
|
||||
@@ -273,56 +219,10 @@ public final class SetUtils {
|
||||
}
|
||||
|
||||
}
|
||||
SetUtils.allBlocks.add(new CardBlock(index, name, sets, landSet, draftBoosters, sealedBoosters));
|
||||
theBlocks.add(new CardBlock(index, name, sets, landSet, draftBoosters, sealedBoosters));
|
||||
}
|
||||
Collections.reverse(SetUtils.allBlocks);
|
||||
SetUtils.allBlocks = Collections.unmodifiableList(SetUtils.allBlocks);
|
||||
}
|
||||
|
||||
private static void loadFormatData() {
|
||||
final ArrayList<String> fData = FileUtil.readFile("res/blockdata/formats.txt");
|
||||
|
||||
for (final String s : fData) {
|
||||
if (StringUtils.isBlank(s)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = null;
|
||||
final List<String> sets = new ArrayList<String>(); // default: all
|
||||
// sets
|
||||
// allowed
|
||||
final List<String> bannedCards = new ArrayList<String>(); // default:
|
||||
// nothing
|
||||
// banned
|
||||
|
||||
final String[] sParts = s.trim().split("\\|");
|
||||
for (final String sPart : sParts) {
|
||||
final String[] kv = sPart.split(":", 2);
|
||||
final String key = kv[0].toLowerCase();
|
||||
if ("name".equals(key)) {
|
||||
name = kv[1];
|
||||
} else if ("sets".equals(key)) {
|
||||
sets.addAll(Arrays.asList(kv[1].split(", ")));
|
||||
} else if ("banned".equals(key)) {
|
||||
bannedCards.addAll(Arrays.asList(kv[1].split("; ")));
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
throw new RuntimeException("Format must have a name! Check formats.txt file");
|
||||
}
|
||||
final GameFormat thisFormat = new GameFormat(name, sets, bannedCards);
|
||||
if (name.equalsIgnoreCase("Standard")) {
|
||||
SetUtils.fmtStandard = thisFormat;
|
||||
}
|
||||
if (name.equalsIgnoreCase("Modern")) {
|
||||
SetUtils.fmtModern = thisFormat;
|
||||
}
|
||||
if (name.equalsIgnoreCase("Extended")) {
|
||||
SetUtils.fmtExtended = thisFormat;
|
||||
}
|
||||
SetUtils.formats.add(thisFormat);
|
||||
}
|
||||
SetUtils.formats = Collections.unmodifiableList(SetUtils.formats);
|
||||
Collections.reverse(theBlocks);
|
||||
return Collections.unmodifiableList(theBlocks);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,4 +68,16 @@ public abstract class DeckBase implements IHasName, Serializable, Comparable<Dec
|
||||
cloneFieldsTo(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public final String getBestFileName() {
|
||||
final char[] c = getName().toCharArray();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; (i < c.length) && (i < 20); i++) {
|
||||
if (Character.isLetterOrDigit(c[i]) || (c[i] == '-')) {
|
||||
sb.append(c[i]);
|
||||
}
|
||||
}
|
||||
return sb.toString().replaceAll("[^-_$#@.{[()]} a-zA-Z0-9]", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@ import java.util.List;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.FolderStorageReader;
|
||||
import forge.util.IItemSerializer;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class DeckGroupSerializer extends DeckReaderBase<DeckGroup> implements IItemSerializer<DeckGroup> {
|
||||
public class DeckGroupSerializer extends FolderStorageReader<DeckGroup> implements IItemSerializer<DeckGroup> {
|
||||
/**
|
||||
* TODO: Write javadoc for Constructor.
|
||||
* @param deckDir0
|
||||
@@ -93,7 +94,7 @@ public class DeckGroupSerializer extends DeckReaderBase<DeckGroup> implements II
|
||||
}
|
||||
|
||||
public File makeFileFor(final DeckGroup decks) {
|
||||
return new File(getDirectory(), deriveFileName(cleanDeckName(decks.getName())));
|
||||
return new File(getDirectory(), decks.getBestFileName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.deck.Deck;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.FolderStorageReader;
|
||||
import forge.util.IItemSerializer;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.DefaultObjectWrapper;
|
||||
@@ -46,7 +47,7 @@ import freemarker.template.TemplateException;
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class DeckSerializer extends DeckReaderBase<Deck> implements IItemSerializer<Deck> {
|
||||
public class DeckSerializer extends FolderStorageReader<Deck> implements IItemSerializer<Deck> {
|
||||
|
||||
public DeckSerializer(File deckDir0) {
|
||||
super(deckDir0);
|
||||
@@ -226,7 +227,7 @@ public class DeckSerializer extends DeckReaderBase<Deck> implements IItemSeriali
|
||||
* @return a File
|
||||
*/
|
||||
public File makeFileFor(final Deck deck) {
|
||||
return new File(getDirectory(), deriveFileName(cleanDeckName(deck.getName())) + ".dck");
|
||||
return new File(getDirectory(), deck.getBestFileName() + ".dck");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -35,10 +35,9 @@ import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.SetUtils;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.item.CardDb;
|
||||
@@ -94,12 +93,12 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
break;
|
||||
|
||||
case Block: // Draft from cards by block or set
|
||||
final List<CardBlock> blocks = SetUtils.getBlocks();
|
||||
final List<CardBlock> blocks = AllZone.getEditions().getBlocks();
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose Block", blocks.toArray());
|
||||
final CardBlock block = (CardBlock) o;
|
||||
|
||||
final CardSet[] cardSets = block.getSets();
|
||||
final CardEdition[] cardSets = block.getSets();
|
||||
final String[] sets = new String[cardSets.length];
|
||||
for (int k = cardSets.length - 1; k >= 0; --k) {
|
||||
sets[k] = cardSets[k].getCode();
|
||||
@@ -125,12 +124,12 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
final Object p = GuiUtils.getChoice("Choose Set Combination", setCombos.toArray());
|
||||
final String[] pp = p.toString().split("/");
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
final BoosterGenerator bpMulti = new BoosterGenerator(SetUtils.getSetByCode(pp[i]));
|
||||
final BoosterGenerator bpMulti = new BoosterGenerator(AllZone.getEditions().getEditionByCode(pp[i]));
|
||||
this.packs.add(BoosterGenerator.getSimplePicker(bpMulti));
|
||||
}
|
||||
|
||||
} else {
|
||||
final BoosterGenerator bpOne = new BoosterGenerator(SetUtils.getSetByCode(sets[0]));
|
||||
final BoosterGenerator bpOne = new BoosterGenerator(AllZone.getEditions().getEditionByCode(sets[0]));
|
||||
final Closure1<List<CardPrinted>, BoosterGenerator> pick1 = BoosterGenerator.getSimplePicker(bpOne);
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.packs.add(pick1);
|
||||
|
||||
@@ -31,10 +31,9 @@ import forge.CardList;
|
||||
import forge.CardListFilter;
|
||||
import forge.CardListUtil;
|
||||
import forge.Constant;
|
||||
import forge.SetUtils;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.spellability.AbilityMana;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
@@ -79,10 +78,10 @@ public class SealedDeck {
|
||||
this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getSet();
|
||||
} else if (sealedType.equals("Block")) {
|
||||
|
||||
final Object o = GuiUtils.getChoice("Choose Block", SetUtils.getBlocks().toArray());
|
||||
final Object o = GuiUtils.getChoice("Choose Block", AllZone.getEditions().getBlocks().toArray());
|
||||
final CardBlock block = (CardBlock) o;
|
||||
|
||||
final CardSet[] cardSets = block.getSets();
|
||||
final CardEdition[] cardSets = block.getSets();
|
||||
final String[] sets = new String[cardSets.length];
|
||||
for (int k = cardSets.length - 1; k >= 0; --k) {
|
||||
sets[k] = cardSets[k].getCode();
|
||||
@@ -106,11 +105,11 @@ public class SealedDeck {
|
||||
|
||||
final String[] pp = p.toString().split("/");
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
final BoosterGenerator bpMulti = new BoosterGenerator(SetUtils.getSetByCode(pp[i]));
|
||||
final BoosterGenerator bpMulti = new BoosterGenerator(AllZone.getEditions().getEditionByCode(pp[i]));
|
||||
this.packs.add(BoosterGenerator.getSimplePicker(bpMulti));
|
||||
}
|
||||
} else {
|
||||
final BoosterGenerator bpOne = new BoosterGenerator(SetUtils.getSetByCode(sets[0]));
|
||||
final BoosterGenerator bpOne = new BoosterGenerator(AllZone.getEditions().getEditionByCode(sets[0]));
|
||||
final Closure1<List<CardPrinted>, BoosterGenerator> picker = BoosterGenerator.getSimplePicker(bpOne);
|
||||
for (int i = 0; i < nPacks; i++) {
|
||||
this.packs.add(picker);
|
||||
|
||||
@@ -20,11 +20,11 @@ package forge.gui.deckeditor;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.card.CardColor;
|
||||
import forge.card.CardManaCost;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
@@ -51,9 +51,9 @@ public abstract class PresetColumns {
|
||||
return i instanceof CardPrinted ? ((CardPrinted) i).getRarity() : CardRarity.Unknown;
|
||||
}
|
||||
|
||||
private static CardSet toSetCmp(final InventoryItem i) {
|
||||
return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet())
|
||||
: CardSet.UNKNOWN;
|
||||
private static CardEdition toSetCmp(final InventoryItem i) {
|
||||
return i instanceof InventoryItemFromSet ? AllZone.getEditions().getEditionByCode(((InventoryItemFromSet) i).getSet())
|
||||
: CardEdition.UNKNOWN;
|
||||
}
|
||||
|
||||
private static String toSetStr(final InventoryItem i) {
|
||||
|
||||
@@ -29,9 +29,9 @@ import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.SetUtils;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.gui.game.CardDetailPanel;
|
||||
import forge.gui.game.CardPicturePanel;
|
||||
import forge.item.BoosterPack;
|
||||
@@ -116,7 +116,7 @@ public class CardPanelLite extends CardPanelBase {
|
||||
} else {
|
||||
if (card instanceof BoosterPack) {
|
||||
final BoosterPack booster = (BoosterPack) card;
|
||||
final CardSet set = SetUtils.getSetByCodeOrThrow(booster.getSet());
|
||||
final CardEdition set = AllZone.getEditions().getEditionByCodeOrThrow(booster.getSet());
|
||||
final String tpl = "%s booster pack.%n%nContains %d cards.%n%nBuy it to reveal the cards and add them to your inventory.";
|
||||
this.description.setText(String.format(tpl, set.getName(), set.getBoosterData().getTotal()));
|
||||
} else if (card instanceof PreconDeck) {
|
||||
|
||||
@@ -33,9 +33,9 @@ import net.slightlymagic.maxmtg.PredicateString.StringOp;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.game.GameFormat;
|
||||
import forge.item.CardPrinted;
|
||||
|
||||
@@ -91,10 +91,10 @@ public class FilterNameTypeSetPanel extends JComponent {
|
||||
|
||||
this.searchSetCombo.removeAllItems();
|
||||
this.searchSetCombo.addItem("(all sets and formats)");
|
||||
for (final GameFormat s : SetUtils.getFormats()) {
|
||||
for (final GameFormat s : AllZone.getFormats().getFormats()) {
|
||||
this.searchSetCombo.addItem(s);
|
||||
}
|
||||
for (final CardSet s : SetUtils.getAllSets()) {
|
||||
for (final CardEdition s : AllZone.getEditions().getAllSets()) {
|
||||
this.searchSetCombo.addItem(s);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ public class FilterNameTypeSetPanel extends JComponent {
|
||||
|
||||
if (this.searchSetCombo.getSelectedIndex() != 0) {
|
||||
final Object selected = this.searchSetCombo.getSelectedItem();
|
||||
if (selected instanceof CardSet) {
|
||||
rules.add(CardPrinted.Predicates.printedInSets(((CardSet) selected).getCode()));
|
||||
if (selected instanceof CardEdition) {
|
||||
rules.add(CardPrinted.Predicates.printedInSets(((CardEdition) selected).getCode()));
|
||||
} else if (selected instanceof GameFormat) {
|
||||
rules.add(((GameFormat) selected).getFilterRules());
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.util.List;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
|
||||
/**
|
||||
* TODO Write javadoc for this type.
|
||||
@@ -33,14 +33,14 @@ import forge.card.CardSet;
|
||||
public class BoosterPack implements InventoryItemFromSet {
|
||||
|
||||
/** The Constant fnFromSet. */
|
||||
public static final Lambda1<BoosterPack, CardSet> FN_FROM_SET = new Lambda1<BoosterPack, CardSet>() {
|
||||
public static final Lambda1<BoosterPack, CardEdition> FN_FROM_SET = new Lambda1<BoosterPack, CardEdition>() {
|
||||
@Override
|
||||
public BoosterPack apply(final CardSet arg1) {
|
||||
public BoosterPack apply(final CardEdition arg1) {
|
||||
return new BoosterPack(arg1);
|
||||
}
|
||||
};
|
||||
|
||||
private final CardSet cardSet;
|
||||
private final CardEdition cardSet;
|
||||
private final String name;
|
||||
|
||||
private List<CardPrinted> cards = null;
|
||||
@@ -52,7 +52,7 @@ public class BoosterPack implements InventoryItemFromSet {
|
||||
* the set
|
||||
*/
|
||||
public BoosterPack(final String set) {
|
||||
this(SetUtils.getSetByCodeOrThrow(set));
|
||||
this(AllZone.getEditions().getEditionByCodeOrThrow(set));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class BoosterPack implements InventoryItemFromSet {
|
||||
* @param set
|
||||
* the set
|
||||
*/
|
||||
public BoosterPack(final CardSet set) {
|
||||
public BoosterPack(final CardEdition set) {
|
||||
this.cardSet = set;
|
||||
this.name = this.cardSet.getName() + " Booster Pack";
|
||||
}
|
||||
@@ -111,14 +111,14 @@ public class BoosterPack implements InventoryItemFromSet {
|
||||
return "booster/" + this.cardSet.getCode() + ".png";
|
||||
}
|
||||
|
||||
private CardPrinted getRandomBasicLand(final CardSet set) {
|
||||
private CardPrinted getRandomBasicLand(final CardEdition set) {
|
||||
return Predicate.and(CardPrinted.Predicates.printedInSets(set.getCode()),
|
||||
CardRules.Predicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES).random(
|
||||
CardDb.instance().getAllCards());
|
||||
}
|
||||
|
||||
private CardPrinted getLandFromNearestSet() {
|
||||
final List<CardSet> sets = SetUtils.getAllSets();
|
||||
final List<CardEdition> sets = AllZone.getEditions().getAllSets();
|
||||
final int iThisSet = sets.indexOf(this.cardSet);
|
||||
for (int iSet = iThisSet; iSet < sets.size(); iSet++) {
|
||||
final CardPrinted land = this.getRandomBasicLand(sets.get(iSet));
|
||||
@@ -127,7 +127,7 @@ public class BoosterPack implements InventoryItemFromSet {
|
||||
}
|
||||
}
|
||||
// if not found (though that's impossible)
|
||||
return this.getRandomBasicLand(SetUtils.getSetByCode("M12"));
|
||||
return this.getRandomBasicLand(AllZone.getEditions().getEditionByCode("M12"));
|
||||
}
|
||||
|
||||
private void generate() {
|
||||
|
||||
@@ -31,8 +31,8 @@ import net.slightlymagic.maxmtg.Predicate;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.SetUtils;
|
||||
import forge.card.CardInSet;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.MtgDataParser;
|
||||
@@ -392,10 +392,10 @@ public final class CardDb {
|
||||
|
||||
// Find card with maximal set index
|
||||
result = namedCards.get(0);
|
||||
int resIndex = SetUtils.getSetByCode((result).getSet()).getIndex();
|
||||
int resIndex = AllZone.getEditions().getEditionByCode((result).getSet()).getIndex();
|
||||
for (final CardPrinted card : namedCards) {
|
||||
|
||||
final int thisIndex = SetUtils.getSetByCode((card).getSet()).getIndex();
|
||||
final int thisIndex = AllZone.getEditions().getEditionByCode((card).getSet()).getIndex();
|
||||
if (thisIndex > resIndex) {
|
||||
result = card;
|
||||
resIndex = thisIndex;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.deck.Deck;
|
||||
import forge.quest.SellRules;
|
||||
import forge.util.FileSection;
|
||||
@@ -88,7 +88,7 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
|
||||
imageFilename = kv.get("Image");
|
||||
description = kv.get("Description");
|
||||
if( SetUtils.getSetByCode(kv.get("set").toUpperCase()) != null )
|
||||
if( AllZone.getEditions().getEditionByCode(kv.get("set").toUpperCase()) != null )
|
||||
{ setProxy = kv.get("set"); }
|
||||
|
||||
this.set = setProxy;
|
||||
|
||||
@@ -3,14 +3,14 @@ package forge.quest.data;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckReaderBase;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.util.FolderStorageReader;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class PreconReader extends DeckReaderBase<PreconDeck> {
|
||||
public class PreconReader extends FolderStorageReader<PreconDeck> {
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for Constructor.
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.item.CardPrinted;
|
||||
@@ -235,7 +235,7 @@ public final class QuestData {
|
||||
public void newGame(final int diff, final String m0de, final boolean standardStart) {
|
||||
this.setDifficulty(diff);
|
||||
|
||||
final Predicate<CardPrinted> filter = standardStart ? SetUtils.getStandard().getFilterPrinted()
|
||||
final Predicate<CardPrinted> filter = standardStart ? AllZone.getFormats().getStandard().getFilterPrinted()
|
||||
: CardPrinted.Predicates.Presets.IS_TRUE;
|
||||
|
||||
this.myCards.setupNewGameCardPool(filter, diff);
|
||||
|
||||
@@ -23,12 +23,13 @@ import java.util.Map.Entry;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
import forge.SetUtils;
|
||||
import forge.AllZone;
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.BoosterUtils;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardSet;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.FormatUtils;
|
||||
import forge.deck.Deck;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.CardDb;
|
||||
@@ -317,18 +318,18 @@ public final class QuestUtilCards {
|
||||
/**
|
||||
* Generate cards in shop.
|
||||
*/
|
||||
private final Predicate<CardSet> filterExt = CardSet.Predicates.Presets.SETS_IN_EXT;
|
||||
private final Predicate<CardEdition> filterExt = FormatUtils.Predicates.SETS_IN_EXT;
|
||||
|
||||
/** The filter t2booster. */
|
||||
private final Predicate<CardSet> filterT2booster = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||
CardSet.Predicates.Presets.SETS_IN_STANDARD);
|
||||
private final Predicate<CardEdition> filterT2booster = Predicate.and(CardEdition.Predicates.CAN_MAKE_BOOSTER,
|
||||
FormatUtils.Predicates.SETS_IN_STANDARD);
|
||||
|
||||
/** The filter ext but t2. */
|
||||
private final Predicate<CardSet> filterExtButT2 = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||
Predicate.and(this.filterExt, Predicate.not(CardSet.Predicates.Presets.SETS_IN_STANDARD)));
|
||||
private final Predicate<CardEdition> filterExtButT2 = Predicate.and(CardEdition.Predicates.CAN_MAKE_BOOSTER,
|
||||
Predicate.and(this.filterExt, Predicate.not(FormatUtils.Predicates.SETS_IN_STANDARD)));
|
||||
|
||||
/** The filter not ext. */
|
||||
private final Predicate<CardSet> filterNotExt = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||
private final Predicate<CardEdition> filterNotExt = Predicate.and(CardEdition.Predicates.CAN_MAKE_BOOSTER,
|
||||
Predicate.not(this.filterExt));
|
||||
|
||||
/**
|
||||
@@ -340,9 +341,9 @@ public final class QuestUtilCards {
|
||||
public void generateBoostersInShop(final int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final int rollD100 = MyRandom.getRandom().nextInt(100);
|
||||
final Predicate<CardSet> filter = rollD100 < 40 ? this.filterT2booster
|
||||
final Predicate<CardEdition> filter = rollD100 < 40 ? this.filterT2booster
|
||||
: (rollD100 < 75 ? this.filterExtButT2 : this.filterNotExt);
|
||||
this.q.getShopList().addAllFlat(filter.random(SetUtils.getAllSets(), 1, BoosterPack.FN_FROM_SET));
|
||||
this.q.getShopList().addAllFlat(filter.random(AllZone.getEditions().getAllSets(), 1, BoosterPack.FN_FROM_SET));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.deck.io;
|
||||
package forge.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
@@ -31,14 +31,12 @@ import javax.swing.JOptionPane;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.util.IHasName;
|
||||
import forge.util.IItemReader;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public abstract class DeckReaderBase<T extends IHasName> implements IItemReader<T> {
|
||||
public abstract class FolderStorageReader<T extends IHasName> implements IItemReader<T> {
|
||||
|
||||
private final File directory;
|
||||
|
||||
@@ -47,7 +45,7 @@ public abstract class DeckReaderBase<T extends IHasName> implements IItemReader<
|
||||
}
|
||||
|
||||
|
||||
public DeckReaderBase(File deckDir0) {
|
||||
public FolderStorageReader(File deckDir0) {
|
||||
|
||||
directory = deckDir0;
|
||||
|
||||
@@ -69,11 +67,6 @@ public abstract class DeckReaderBase<T extends IHasName> implements IItemReader<
|
||||
}
|
||||
}
|
||||
|
||||
public String deriveFileName(final String deckName) {
|
||||
// skips all but the listed characters
|
||||
return deckName.replaceAll("[^-_$#@.{[()]} a-zA-Z0-9]", "");
|
||||
}
|
||||
|
||||
// only accepts numbers, letters or dashes up to 20 characters in length
|
||||
/**
|
||||
*
|
||||
@@ -83,16 +76,6 @@ public abstract class DeckReaderBase<T extends IHasName> implements IItemReader<
|
||||
* a String
|
||||
* @return a String
|
||||
*/
|
||||
protected String cleanDeckName(final String in) {
|
||||
final char[] c = in.toCharArray();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; (i < c.length) && (i < 20); i++) {
|
||||
if (Character.isLetterOrDigit(c[i]) || (c[i] == '-')) {
|
||||
sb.append(c[i]);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -106,7 +89,7 @@ public abstract class DeckReaderBase<T extends IHasName> implements IItemReader<
|
||||
final T newDeck = read(file);
|
||||
if (null == newDeck) {
|
||||
|
||||
String msg = "A deck or similiar object at " + file.getPath() + " failed to load.\nPlease submit this as a bug with the mentioned file/directory attached.";
|
||||
String msg = "An object stored in " + file.getPath() + " failed to load.\nPlease submit this as a bug with the mentioned file/directory attached.";
|
||||
// JOptionPane.showMessageDialog(null, msg); -- This becomes bugged if uncommented, but i need these messages to debug other peoples decks // Max Mtg
|
||||
continue;
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Zone;
|
||||
import forge.Player;
|
||||
import forge.SetUtils;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.control.match.ControlWinLose;
|
||||
@@ -519,13 +518,14 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
||||
*
|
||||
*/
|
||||
private void awardBooster() {
|
||||
final List<GameFormat> formats = SetUtils.getFormats();
|
||||
final ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1,
|
||||
formats);
|
||||
final GameFormat[] emptyFormatArray = {};
|
||||
final GameFormat[] formats = AllZone.getFormats().getFormats().toArray(emptyFormatArray) ;
|
||||
final ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1, formats);
|
||||
|
||||
String prefferedFormat = Singletons.getModel().getQuestPreferences().getPreference(QPref.BOOSTER_FORMAT);
|
||||
int index = 0;
|
||||
for (int i = 0; i < formats.size(); i++) {
|
||||
if (formats.get(i).toString().equals(Singletons.getModel().getQuestPreferences().getPreference(QPref.BOOSTER_FORMAT))) {
|
||||
for (int i = 0; i < formats.length; i++) {
|
||||
if (formats[i].toString().equals(prefferedFormat)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
@Override
|
||||
public ItemPoolView<CardPrinted> nextChoice() {
|
||||
this.n--;
|
||||
final BoosterGenerator pack = new BoosterGenerator(SetUtils.getSetByCode("M11"));
|
||||
final BoosterGenerator pack = new BoosterGenerator(AllZone.getEditions().getEditionByCode("M11"));
|
||||
return ItemPool.createFrom(pack.getBoosterPack(), CardPrinted.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user