Prerelease standardization

This commit is contained in:
Sol
2020-01-07 05:59:26 +00:00
committed by Michael Kamensky
parent 3aca94dc9b
commit 2cc39c2580
7 changed files with 100 additions and 2 deletions

View File

@@ -553,6 +553,23 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
return Lists.newArrayList(Iterables.filter(this.roAllCards, predicate));
}
// Do I want a foiled version of these cards?
@Override
public List<PaperCard> getAllCardsFromEdition(CardEdition edition) {
List<PaperCard> cards = Lists.newArrayList();
for(CardInSet cis : edition.getCards()) {
PaperCard card = this.getCard(cis.name, edition.getCode());
if (card == null) {
// Just in case the card is listed in the edition file but Forge doesn't support it
continue;
}
cards.add(card);
}
return cards;
}
@Override
public boolean contains(String name) {
return allCardsByName.containsKey(getName(name));

View File

@@ -110,6 +110,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
private Type type;
private String name;
private String alias = null;
private String prerelease = null;
private boolean whiteBorder = false;
private FoilType foilType = FoilType.NOT_SUPPORTED;
private double foilChanceInBooster = 0;
@@ -178,6 +179,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
public Type getType() { return type; }
public String getName() { return name; }
public String getAlias() { return alias; }
public String getPrerelease() { return prerelease; }
public FoilType getFoilType() { return foilType; }
public double getFoilChanceInBooster() { return foilChanceInBooster; }
public boolean getFoilAlwaysInCommonSlot() { return foilAlwaysInCommonSlot; }
@@ -333,6 +335,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
}
}
res.type = enumType;
res.prerelease = section.get("Prerelease", null);
switch(section.get("foil", "newstyle").toLowerCase()) {
case "notsupported":
@@ -413,6 +416,16 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
return res;
}
public Iterable<CardEdition> getPrereleaseEditions() {
List<CardEdition> res = Lists.newArrayList(this);
return Iterables.filter(res, new Predicate<CardEdition>() {
@Override
public boolean apply(final CardEdition edition) {
return edition.getPrerelease() != null;
}
});
}
public CardEdition getEditionByCodeOrThrow(final String code) {
final CardEdition set = this.get(code);
if (null == set) {

View File

@@ -28,6 +28,8 @@ public interface ICardDatabase extends Iterable<PaperCard> {
List<PaperCard> getAllCards(String cardName);
List<PaperCard> getAllCards(Predicate<PaperCard> predicate);
List<PaperCard> getAllCardsFromEdition(CardEdition edition);
Predicate<? super PaperCard> wasPrintedInSets(List<String> allowedSetCodes);
}