minor optimizations of CardRules, fix typo in comment of MtgDataParser

This commit is contained in:
Maxmtg
2011-09-26 19:17:54 +00:00
parent 897028e94d
commit 0c5d719985
2 changed files with 7 additions and 8 deletions

View File

@@ -61,13 +61,13 @@ public final class CardRules {
}
public CardRules(final String cardName, final CardType cardType, final CardManaCost manacost,
final String ptLine, final String[] cardRules, final Map<String, CardInSet> setsData,
final String ptLine, final String[] oracleRules, final Map<String, CardInSet> setsData,
final boolean removedFromRandomDecks, final boolean removedFromAIDecks)
{
this.name = cardName;
this.type = cardType;
this.cost = manacost;
this.rules = cardRules;
this.rules = oracleRules;
this.color = new CardColor(cost);
this.isRemovedFromAIDecks = removedFromAIDecks;
this.isRemovedFromRandomDecks = removedFromRandomDecks;
@@ -75,10 +75,7 @@ public final class CardRules {
//System.out.println(cardName);
if (cardType.isCreature()) {
if (ptLine == null){
throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", cardName));
}
int slashPos = ptLine.indexOf('/');
int slashPos = ptLine == null ? -1 : ptLine.indexOf('/');
if (slashPos == -1) {
throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", cardName));
}
@@ -136,6 +133,8 @@ public final class CardRules {
public abstract static class Predicates {
public static final Predicate<CardRules> isKeptInAiDecks = new Predicate<CardRules>() {
@Override public boolean isTrue(CardRules card) { return !card.isRemovedFromAIDecks; } };
public static final Predicate<CardRules> isKeptInRandomDecks = new Predicate<CardRules>() {
@Override public boolean isTrue(CardRules card) { return !card.isRemovedFromRandomDecks; } };
// Static builder methods - they choose concrete implementation by themselves

View File

@@ -52,7 +52,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
setsToSkipPrefixes.add("BTD");
setsToSkipPrefixes.add("DKM");
//setsToSkipPrefixes.add("ATH"); // No need to skip it really.
// On gatherer's opinion this cards was releases twice in original set
// On gatherer's opinion this cards were released twice in original set
// Promo sets - all cards have been issued in other sets
setsToSkipPrefixes.add("SDC");