mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Boosters collection now uses data from cardeditions/setname.txt
BoosterTemplate.java class turned unneeded
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -13919,7 +13919,6 @@ src/main/java/forge/StaticEffect.java svneol=native#text/plain
|
||||
src/main/java/forge/StaticEffects.java svneol=native#text/plain
|
||||
src/main/java/forge/card/AggregationMethod.java -text
|
||||
src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
||||
src/main/java/forge/card/BoosterTemplate.java -text
|
||||
src/main/java/forge/card/CardAiHints.java -text
|
||||
src/main/java/forge/card/CardBlock.java -text
|
||||
src/main/java/forge/card/CardCharacteristics.java -text
|
||||
|
||||
@@ -222,7 +222,8 @@ public class ImageCache {
|
||||
return ImageCache.TOURNAMENTPACK_PREFIX + ((TournamentPack)ii).getEdition();
|
||||
if ( ii instanceof BoosterPack ) {
|
||||
BoosterPack bp = (BoosterPack)ii;
|
||||
String suffix = (1 >= bp.getBoosterData().getArtIndices()) ? "" : ("_" + bp.getArtIndex());
|
||||
int cntPics = Singletons.getModel().getEditions().get(bp.getEdition()).getCntBoosterPictures();
|
||||
String suffix = (1 >= cntPics) ? "" : ("_" + bp.getArtIndex());
|
||||
return ImageCache.BOOSTER_PREFIX + bp.getEdition() + suffix;
|
||||
}
|
||||
if ( ii instanceof FatPack )
|
||||
@@ -248,7 +249,7 @@ public class ImageCache {
|
||||
final int cntPictures;
|
||||
final boolean hasManyPictures;
|
||||
if (includeSet) {
|
||||
cntPictures = card.isTraditional() ? CardDb.instance().getPrintCount(card.getName(), edition) : CardDb.variants().getPrintCount(card.getName(), edition);
|
||||
cntPictures = !card.isVariant() ? CardDb.instance().getPrintCount(card.getName(), edition) : CardDb.variants().getPrintCount(card.getName(), edition);
|
||||
hasManyPictures = cntPictures > 1;
|
||||
} else {
|
||||
// without set number of pictures equals number of urls provided in Svar:Picture
|
||||
@@ -256,7 +257,7 @@ public class ImageCache {
|
||||
cntPictures = StringUtils.countMatches(urls, "\\") + 1;
|
||||
|
||||
// raise the art index limit to the maximum of the sets this card was printed in
|
||||
int maxCntPictures = card.isTraditional() ? CardDb.instance().getMaxPrintCount(card.getName()) : CardDb.variants().getMaxPrintCount(card.getName());
|
||||
int maxCntPictures = !card.isVariant() ? CardDb.instance().getMaxPrintCount(card.getName()) : CardDb.variants().getMaxPrintCount(card.getName());
|
||||
hasManyPictures = maxCntPictures > 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.util.TextUtil;
|
||||
import forge.util.storage.StorageReaderFile;
|
||||
|
||||
public class BoosterTemplate extends SealedProductTemplate {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final static BoosterTemplate genericBooster = new BoosterTemplate(null, 1, Lists.newArrayList(
|
||||
Pair.of(BoosterGenerator.COMMON, 10), Pair.of(BoosterGenerator.UNCOMMON, 3),
|
||||
Pair.of(BoosterGenerator.RARE_MYTHIC, 1), Pair.of(BoosterGenerator.BASIC_LAND, 1)
|
||||
));
|
||||
|
||||
private final int foilRate = 68;
|
||||
private final int artIndices;
|
||||
|
||||
private BoosterTemplate(String edition, int artIndices0, Iterable<Pair<String, Integer>> itrSlots) {
|
||||
super(edition, itrSlots);
|
||||
artIndices = artIndices0;
|
||||
}
|
||||
|
||||
public final int getFoilChance() {
|
||||
return this.foilRate;
|
||||
}
|
||||
|
||||
public int getArtIndices() {
|
||||
return artIndices;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
|
||||
s.append("consisting of ");
|
||||
for(Pair<String, Integer> p : slots) {
|
||||
s.append(p.getRight()).append(" ").append(p.getLeft()).append(", ");
|
||||
}
|
||||
|
||||
// trim the last comma and space
|
||||
s.replace(s.length() - 2, s.length(), "");
|
||||
|
||||
// put an 'and' before the previous comma
|
||||
int lastCommaIdx = s.lastIndexOf(",");
|
||||
if (0 < lastCommaIdx) {
|
||||
s.replace(lastCommaIdx+1, lastCommaIdx+1, " and");
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public static final class Reader extends StorageReaderFile<BoosterTemplate> {
|
||||
public Reader(String pathname) {
|
||||
super(pathname, BoosterTemplate.FN_GET_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BoosterTemplate read(String line, int i) {
|
||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||
final String edition = headAndData[0];
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nCovers = 1;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("cover"))
|
||||
nCovers = Integer.parseInt(kv[0]);
|
||||
else
|
||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||
}
|
||||
|
||||
return new BoosterTemplate(edition, nCovers, slots);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import forge.util.MyRandom;
|
||||
import forge.util.maps.CollectionSuppliers;
|
||||
import forge.util.maps.MapOfLists;
|
||||
import forge.util.maps.TreeMapOfLists;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
public final class CardDb implements ICardDatabase {
|
||||
private static volatile CardDb commonCards = null; // 'volatile' keyword makes this working
|
||||
@@ -233,8 +232,8 @@ public final class CardDb implements ICardDatabase {
|
||||
candidates[cnt++] = pc;
|
||||
}
|
||||
|
||||
if (candidates.length == 0 ) return null;
|
||||
if (candidates.length == 1 ) return candidates[0];
|
||||
if (cnt == 0 ) return null;
|
||||
if (cnt == 1 ) return candidates[0];
|
||||
return candidates[MyRandom.getRandom().nextInt(cnt)];
|
||||
} else
|
||||
for( PaperCard pc : cards ) {
|
||||
@@ -315,23 +314,16 @@ public final class CardDb implements ICardDatabase {
|
||||
public final Map<String, CardRules> regularCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER);
|
||||
public final Map<String, CardRules> variantsCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
private void addNewCard(final CardRules card) {
|
||||
if (null == card) {
|
||||
return;
|
||||
} // consider that a success
|
||||
// System.out.println(card.getName());
|
||||
final String cardName = card.getName();
|
||||
|
||||
|
||||
if ( card.isTraditional() )
|
||||
regularCards.put(cardName, card);
|
||||
else
|
||||
variantsCards.put(cardName, card);
|
||||
}
|
||||
|
||||
CardSorter(final Iterable<CardRules> parser) {
|
||||
for (CardRules cr : parser) {
|
||||
this.addNewCard(cr);
|
||||
for (CardRules card : parser) {
|
||||
if (null == card) continue;
|
||||
|
||||
final String cardName = card.getName();
|
||||
if ( card.isVariant() )
|
||||
variantsCards.put(cardName, card);
|
||||
else
|
||||
regularCards.put(cardName, card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,17 +79,25 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
/** The Constant unknown. */
|
||||
private final static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
public static final CardEdition UNKNOWN = new CardEdition("1990-01-01", "??", "???", Type.UNKNOWN, "Undefined", null, false, new CardInSet[]{});
|
||||
public static final CardEdition UNKNOWN = new CardEdition("1990-01-01", "??", "???", Type.UNKNOWN, "Undefined", new CardInSet[]{});
|
||||
|
||||
private Date date;
|
||||
private final String code2;
|
||||
private final String code;
|
||||
private final Type type;
|
||||
private final String name;
|
||||
private final String alias;
|
||||
private final boolean whiteBorder;
|
||||
private String code2;
|
||||
private String code;
|
||||
private Type type;
|
||||
private String name;
|
||||
private String alias = null;
|
||||
private boolean whiteBorder = false;
|
||||
private final CardInSet[] cards;
|
||||
|
||||
|
||||
private int boosterArts = 1;
|
||||
private SealedProductTemplate boosterTpl = null;
|
||||
|
||||
private CardEdition(CardInSet[] cards) {
|
||||
this.cards = cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new card set.
|
||||
*
|
||||
@@ -103,20 +111,23 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
* @param name the name of the set
|
||||
* @param an optional secondary code alias for the set
|
||||
*/
|
||||
private CardEdition(String date, String code2, String code, Type type, String name, String alias, boolean whiteBorder, CardInSet[] cards) {
|
||||
private CardEdition(String date, String code2, String code, Type type, String name, CardInSet[] cards) {
|
||||
this(cards);
|
||||
this.code2 = code2;
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.alias = alias;
|
||||
this.whiteBorder = whiteBorder;
|
||||
this.cards = cards;
|
||||
this.date = parseDate(date);
|
||||
|
||||
}
|
||||
|
||||
private static Date parseDate(String date) {
|
||||
if( date.length() <= 7 )
|
||||
date = date + "-01";
|
||||
try {
|
||||
this.date = formatter.parse(date);
|
||||
return formatter.parse(date);
|
||||
} catch (ParseException e) {
|
||||
this.date = new Date();
|
||||
return new Date();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +201,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
private static class CanMakeBooster implements Predicate<CardEdition> {
|
||||
@Override
|
||||
public boolean apply(final CardEdition subject) {
|
||||
return Singletons.getModel().getBoosters().contains(subject.getCode());
|
||||
return subject.boosterTpl != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +247,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
public static final Predicate<CardEdition> hasBasicLands = new Predicate<CardEdition>() {
|
||||
@Override
|
||||
public boolean apply(CardEdition ed) {
|
||||
return null != CardDb.instance().tryGetCard("Plains", ed.getCode());
|
||||
return null != CardDb.instance().tryGetCard("Plains", ed.getCode(), 0);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -253,28 +264,6 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
protected CardEdition read(File file) {
|
||||
final Map<String, List<String>> contents = FileSection.parseSections(FileUtil.readFile(file));
|
||||
|
||||
FileSection section = FileSection.parse(contents.get("metadata"), "=");
|
||||
String name = section.get("name");
|
||||
String date = section.get("date");
|
||||
String code = section.get("code");
|
||||
String code2 = section.get("code2");
|
||||
if( code2 == null )
|
||||
code2 = code;
|
||||
|
||||
String type = section.get("type");
|
||||
String alias = section.get("alias");
|
||||
boolean borderWhite = "white".equalsIgnoreCase(section.get("border"));
|
||||
|
||||
Type enumType = Type.UNKNOWN;
|
||||
if (null != type && !type.isEmpty()) {
|
||||
try {
|
||||
enumType = Type.valueOf(type.toUpperCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore; type will get UNKNOWN
|
||||
System.err.println(String.format("Ignoring unknown type in set definitions: name: %s; type: %s", name, type));
|
||||
}
|
||||
}
|
||||
|
||||
List<CardEdition.CardInSet> processedCards = new ArrayList<CardEdition.CardInSet>();
|
||||
for(String line : contents.get("cards")) {
|
||||
if (StringUtils.isBlank(line))
|
||||
@@ -288,7 +277,35 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
processedCards.add(cis);
|
||||
}
|
||||
|
||||
return new CardEdition(date, code2, code, enumType, name, alias, borderWhite, processedCards.toArray(arrCards));
|
||||
CardEdition res = new CardEdition(processedCards.toArray(arrCards));
|
||||
|
||||
|
||||
FileSection section = FileSection.parse(contents.get("metadata"), "=");
|
||||
res.name = section.get("name");
|
||||
res.date = parseDate(section.get("date"));
|
||||
res.code = section.get("code");
|
||||
res.code2 = section.get("code2");
|
||||
if( res.code2 == null )
|
||||
res.code2 = res.code;
|
||||
|
||||
res.boosterArts = section.getInt("BoosterCovers", 1);
|
||||
String boosterDesc = section.get("Booster");
|
||||
res.boosterTpl = boosterDesc == null ? null : new SealedProductTemplate(res.code, SealedProductTemplate.Reader.parseSlots(boosterDesc));
|
||||
|
||||
res.alias = section.get("alias");
|
||||
res.whiteBorder = "white".equalsIgnoreCase(section.get("border"));
|
||||
String type = section.get("type");
|
||||
Type enumType = Type.UNKNOWN;
|
||||
if (null != type && !type.isEmpty()) {
|
||||
try {
|
||||
enumType = Type.valueOf(type.toUpperCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore; type will get UNKNOWN
|
||||
System.err.println(String.format("Ignoring unknown type in set definitions: name: %s; type: %s", res.name, type));
|
||||
}
|
||||
}
|
||||
res.type = enumType;
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -304,4 +321,20 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public int getCntBoosterPictures() {
|
||||
return boosterArts;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public SealedProductTemplate getBoosterTemplate() {
|
||||
return boosterTpl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import forge.card.mana.ManaCost;
|
||||
|
||||
/**
|
||||
@@ -96,8 +95,9 @@ public final class CardRules implements ICardCharacteristics {
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean isTraditional() {
|
||||
return !(getType().isVanguard() || getType().isScheme() || getType().isPlane() || getType().isPhenomenon());
|
||||
public boolean isVariant() {
|
||||
CardType t = getType();
|
||||
return t.isVanguard() || t.isScheme() || t.isPlane() || t.isPhenomenon();
|
||||
}
|
||||
|
||||
public CardSplitType getSplitType() {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.TreeMap;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.util.IItemReader;
|
||||
import forge.util.storage.StorageView;
|
||||
|
||||
public final class EditionCollection extends StorageView<CardEdition> {
|
||||
@@ -88,5 +89,29 @@ public final class EditionCollection extends StorageView<CardEdition> {
|
||||
return EditionCollection.this.get(code);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public IItemReader<SealedProductTemplate> getBoosterGenerator() {
|
||||
// TODO Auto-generated method stub
|
||||
return new IItemReader<SealedProductTemplate>() {
|
||||
|
||||
@Override
|
||||
public Map<String, SealedProductTemplate> readAll() {
|
||||
Map<String, SealedProductTemplate> map = new TreeMap<String, SealedProductTemplate>(String.CASE_INSENSITIVE_ORDER);
|
||||
for(CardEdition ce : EditionCollection.this) {
|
||||
map.put(ce.getCode(), ce.getBoosterTemplate());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemKey(SealedProductTemplate item) {
|
||||
return item.getEdition();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ public class MetaSet {
|
||||
|
||||
switch(type) {
|
||||
case Full:
|
||||
return new UnOpenedProduct(BoosterTemplate.genericBooster);
|
||||
return new UnOpenedProduct(SealedProductTemplate.genericBooster);
|
||||
|
||||
case Booster:
|
||||
return new UnOpenedProduct(Singletons.getModel().getBoosters().get(data));
|
||||
@@ -174,7 +174,7 @@ public class MetaSet {
|
||||
|
||||
case JoinedSet:
|
||||
Predicate<PaperCard> predicate = IPaperCard.Predicates.printedInSets(data.split(" "));
|
||||
return new UnOpenedProduct(BoosterTemplate.genericBooster, predicate);
|
||||
return new UnOpenedProduct(SealedProductTemplate.genericBooster, predicate);
|
||||
|
||||
case Choose: return UnOpenedMeta.choose(data);
|
||||
case Random: return UnOpenedMeta.random(data);
|
||||
|
||||
@@ -32,6 +32,13 @@ import forge.util.storage.StorageReaderFile;
|
||||
|
||||
public class SealedProductTemplate {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final static SealedProductTemplate genericBooster = new SealedProductTemplate(null, Lists.newArrayList(
|
||||
Pair.of(BoosterGenerator.COMMON, 10), Pair.of(BoosterGenerator.UNCOMMON, 3),
|
||||
Pair.of(BoosterGenerator.RARE_MYTHIC, 1), Pair.of(BoosterGenerator.BASIC_LAND, 1)
|
||||
));
|
||||
|
||||
|
||||
protected final List<Pair<String, Integer>> slots;
|
||||
protected final String name;
|
||||
|
||||
@@ -69,24 +76,47 @@ public class SealedProductTemplate {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
|
||||
s.append("consisting of ");
|
||||
for(Pair<String, Integer> p : slots) {
|
||||
s.append(p.getRight()).append(" ").append(p.getLeft()).append(", ");
|
||||
}
|
||||
|
||||
// trim the last comma and space
|
||||
s.replace(s.length() - 2, s.length(), "");
|
||||
|
||||
// put an 'and' before the previous comma
|
||||
int lastCommaIdx = s.lastIndexOf(",");
|
||||
if (0 < lastCommaIdx) {
|
||||
s.replace(lastCommaIdx+1, lastCommaIdx+1, " and");
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public static final class Reader extends StorageReaderFile<SealedProductTemplate> {
|
||||
public Reader(String pathname) {
|
||||
super(pathname, SealedProductTemplate.FN_GET_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SealedProductTemplate read(String line, int i) {
|
||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||
final String edition = headAndData[0];
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
|
||||
public static List<Pair<String, Integer>> parseSlots(String data) {
|
||||
final String[] dataz = TextUtil.splitWithParenthesis(data, ',');
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
for(String slotDesc : data) {
|
||||
for(String slotDesc : dataz) {
|
||||
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
|
||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
return new SealedProductTemplate(edition, slots);
|
||||
@Override
|
||||
protected SealedProductTemplate read(String line, int i) {
|
||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||
return new SealedProductTemplate(headAndData[0], parseSlots(headAndData[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.IPaperCard;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.google.common.base.Supplier;
|
||||
import forge.Card;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
@@ -88,7 +87,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
||||
|
||||
switch (draftType) {
|
||||
case Full: // Draft from all cards in Forge
|
||||
Supplier<List<PaperCard>> s = new UnOpenedProduct(BoosterTemplate.genericBooster);
|
||||
Supplier<List<PaperCard>> s = new UnOpenedProduct(SealedProductTemplate.genericBooster);
|
||||
|
||||
for (int i = 0; i < 3; i++) this.product.add(s);
|
||||
IBoosterDraft.LAND_SET_CODE[0] = CardDb.instance().getCard("Plains").getEdition();
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.deck.Deck;
|
||||
@@ -101,7 +100,7 @@ public class CustomLimited extends DeckBase {
|
||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||
}
|
||||
} else
|
||||
slots = BoosterTemplate.genericBooster.getSlots();
|
||||
slots = SealedProductTemplate.genericBooster.getSlots();
|
||||
|
||||
final CustomLimited cd = new CustomLimited(data.get("Name"), slots);
|
||||
cd.landSetCode = data.get("LandSetCode");
|
||||
|
||||
@@ -27,11 +27,11 @@ import javax.swing.JOptionPane;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.card.UnOpenedMeta;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.deck.CardPool;
|
||||
@@ -71,7 +71,7 @@ public class SealedCardPoolGenerator {
|
||||
case Full:
|
||||
// Choose number of boosters
|
||||
|
||||
chooseNumberOfBoosters(new UnOpenedProduct(BoosterTemplate.genericBooster));
|
||||
chooseNumberOfBoosters(new UnOpenedProduct(SealedProductTemplate.genericBooster));
|
||||
landSetCode = CardDb.instance().getCard("Plains").getEdition();
|
||||
break;
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.control.FControl;
|
||||
import forge.game.GameEndReason;
|
||||
@@ -562,7 +562,7 @@ public class QuestWinLose extends ControlWinLose {
|
||||
} else {
|
||||
final List<String> sets = new ArrayList<String>();
|
||||
|
||||
for (BoosterTemplate bd : Singletons.getModel().getBoosters()) {
|
||||
for (SealedProductTemplate bd : Singletons.getModel().getBoosters()) {
|
||||
if (qData.getFormat().isSetLegal(bd.getEdition())) {
|
||||
sets.add(bd.getEdition());
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package forge.item;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class BoosterPack extends OpenablePack {
|
||||
@@ -32,14 +32,15 @@ public class BoosterPack extends OpenablePack {
|
||||
public static final Function<CardEdition, BoosterPack> FN_FROM_SET = new Function<CardEdition, BoosterPack>() {
|
||||
@Override
|
||||
public BoosterPack apply(final CardEdition arg1) {
|
||||
BoosterTemplate d = Singletons.getModel().getBoosters().get(arg1.getCode());
|
||||
SealedProductTemplate d = Singletons.getModel().getBoosters().get(arg1.getCode());
|
||||
return new BoosterPack(arg1.getName(), d);
|
||||
}
|
||||
};
|
||||
|
||||
public BoosterPack(final String name0, final BoosterTemplate boosterData) {
|
||||
public BoosterPack(final String name0, final SealedProductTemplate boosterData) {
|
||||
super(name0, boosterData);
|
||||
artIndex = MyRandom.getRandom().nextInt(boosterData.getArtIndices()) + 1;
|
||||
int maxIdx = Singletons.getModel().getEditions().get(boosterData.getEdition()).getCntBoosterPictures();
|
||||
artIndex = MyRandom.getRandom().nextInt(maxIdx) + 1;
|
||||
hash = super.hashCode() ^ artIndex;
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ public class BoosterPack extends OpenablePack {
|
||||
return new BoosterPack(name, contents);
|
||||
}
|
||||
|
||||
public BoosterTemplate getBoosterData() {
|
||||
public SealedProductTemplate getBoosterData() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
protected final BoosterTemplate contents;
|
||||
protected final SealedProductTemplate contents;
|
||||
protected final String name;
|
||||
private final int hash;
|
||||
private List<PaperCard> cards = null;
|
||||
|
||||
public OpenablePack(String name0, BoosterTemplate boosterData) {
|
||||
public OpenablePack(String name0, SealedProductTemplate boosterData) {
|
||||
if (null == name0) { throw new NullArgumentException("name0"); }
|
||||
if (null == boosterData) { throw new NullArgumentException("boosterData"); }
|
||||
contents = boosterData;
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Map;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
|
||||
@@ -22,9 +22,9 @@ import java.util.List;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.SealedProductTemplate;
|
||||
|
||||
public class TournamentPack extends OpenablePack {
|
||||
|
||||
@@ -32,12 +32,12 @@ public class TournamentPack extends OpenablePack {
|
||||
public static final Function<CardEdition, TournamentPack> FN_FROM_SET = new Function<CardEdition, TournamentPack>() {
|
||||
@Override
|
||||
public TournamentPack apply(final CardEdition arg1) {
|
||||
BoosterTemplate d = Singletons.getModel().getTournamentPacks().get(arg1.getCode());
|
||||
SealedProductTemplate d = Singletons.getModel().getTournamentPacks().get(arg1.getCode());
|
||||
return new TournamentPack(arg1.getName(), d);
|
||||
}
|
||||
};
|
||||
|
||||
public TournamentPack(final String name0, final BoosterTemplate boosterData) {
|
||||
public TournamentPack(final String name0, final SealedProductTemplate boosterData) {
|
||||
super(name0, boosterData);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.FThreads;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.EditionCollection;
|
||||
@@ -37,7 +36,6 @@ import forge.card.FormatCollection;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.card.cardfactory.CardStorageReader;
|
||||
import forge.deck.CardCollections;
|
||||
import forge.error.BugReporter;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.game.limited.GauntletMini;
|
||||
import forge.gauntlet.GauntletData;
|
||||
@@ -81,9 +79,9 @@ public enum FModel {
|
||||
|
||||
private final EditionCollection editions;
|
||||
private final FormatCollection formats;
|
||||
private final IStorageView<BoosterTemplate> boosters;
|
||||
private final IStorageView<SealedProductTemplate> boosters;
|
||||
private final IStorageView<SealedProductTemplate> specialBoosters;
|
||||
private final IStorageView<BoosterTemplate> tournaments;
|
||||
private final IStorageView<SealedProductTemplate> tournaments;
|
||||
private final IStorageView<FatPackTemplate> fatPacks;
|
||||
private final IStorageView<CardBlock> blocks;
|
||||
private final IStorageView<CardBlock> fantasyBlocks;
|
||||
@@ -152,9 +150,9 @@ public enum FModel {
|
||||
|
||||
|
||||
this.formats = new FormatCollection("res/blockdata/formats.txt");
|
||||
this.boosters = new StorageView<BoosterTemplate>(new BoosterTemplate.Reader("res/blockdata/boosters.txt"));
|
||||
this.boosters = new StorageView<SealedProductTemplate>(editions.getBoosterGenerator());
|
||||
this.specialBoosters = new StorageView<SealedProductTemplate>(new SealedProductTemplate.Reader("res/blockdata/boosters-special.txt"));
|
||||
this.tournaments = new StorageView<BoosterTemplate>(new BoosterTemplate.Reader("res/blockdata/starters.txt"));
|
||||
this.tournaments = new StorageView<SealedProductTemplate>(new SealedProductTemplate.Reader("res/blockdata/starters.txt"));
|
||||
this.fatPacks = new StorageView<FatPackTemplate>(new FatPackTemplate.Reader("res/blockdata/fatpacks.txt"));
|
||||
this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions));
|
||||
this.fantasyBlocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/fantasyblocks.txt", editions));
|
||||
@@ -363,12 +361,12 @@ public enum FModel {
|
||||
}
|
||||
|
||||
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
|
||||
public final IStorageView<BoosterTemplate> getTournamentPacks() {
|
||||
public final IStorageView<SealedProductTemplate> getTournamentPacks() {
|
||||
return tournaments;
|
||||
}
|
||||
|
||||
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
|
||||
public final IStorageView<BoosterTemplate> getBoosters() {
|
||||
public final IStorageView<SealedProductTemplate> getBoosters() {
|
||||
return boosters;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.card.UnOpenedProduct;
|
||||
import forge.gui.CardListViewer;
|
||||
import forge.gui.GuiChoose;
|
||||
@@ -184,8 +184,8 @@ public class QuestUtilUnlockSets {
|
||||
*/
|
||||
public static void doUnlock(QuestController qData, final CardEdition unlockedSet) {
|
||||
|
||||
IStorageView<BoosterTemplate> starters = Singletons.getModel().getTournamentPacks();
|
||||
IStorageView<BoosterTemplate> boosters = Singletons.getModel().getBoosters();
|
||||
IStorageView<SealedProductTemplate> starters = Singletons.getModel().getTournamentPacks();
|
||||
IStorageView<SealedProductTemplate> boosters = Singletons.getModel().getBoosters();
|
||||
qData.getFormat().unlockSet(unlockedSet.getCode());
|
||||
|
||||
List<PaperCard> cardsWon = new ArrayList<PaperCard>();
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.util.List;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.BoosterTemplate;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.card.SealedProductTemplate;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.limited.IBoosterDraft;
|
||||
import forge.item.PaperCard;
|
||||
@@ -49,7 +49,7 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
@Override
|
||||
public ItemPoolView<PaperCard> nextChoice() {
|
||||
this.n--;
|
||||
BoosterTemplate booster = Singletons.getModel().getBoosters().get("M11");
|
||||
SealedProductTemplate booster = Singletons.getModel().getBoosters().get("M11");
|
||||
return ItemPool.createFrom(BoosterGenerator.getBoosterPack(booster), PaperCard.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user