mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
checkstyle and refactor
This commit is contained in:
@@ -132,7 +132,7 @@
|
|||||||
<!-- Checks for Size Violations. -->
|
<!-- Checks for Size Violations. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||||
<module name="LineLength">
|
<module name="LineLength">
|
||||||
<property name="max" value="120"/>
|
<property name="max" value="180"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="MethodLength"/>
|
<module name="MethodLength"/>
|
||||||
<module name="ParameterNumber"/>
|
<module name="ParameterNumber"/>
|
||||||
|
|||||||
@@ -46,18 +46,18 @@ public final class BoosterUtils {
|
|||||||
// There should be 1 Multicolor card for every 4 cards in a single color
|
// There should be 1 Multicolor card for every 4 cards in a single color
|
||||||
|
|
||||||
final List<Predicate<CardRules>> colorFilters = new ArrayList<Predicate<CardRules>>();
|
final List<Predicate<CardRules>> colorFilters = new ArrayList<Predicate<CardRules>>();
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isMulticolor);
|
colorFilters.add(CardRules.Predicates.Presets.IS_MULTICOLOR);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (i != 2) {
|
if (i != 2) {
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isColorless);
|
colorFilters.add(CardRules.Predicates.Presets.IS_COLORLESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isWhite);
|
colorFilters.add(CardRules.Predicates.Presets.IS_WHITE);
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isRed);
|
colorFilters.add(CardRules.Predicates.Presets.IS_RED);
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isBlue);
|
colorFilters.add(CardRules.Predicates.Presets.IS_BLUE);
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isBlack);
|
colorFilters.add(CardRules.Predicates.Presets.IS_BLACK);
|
||||||
colorFilters.add(CardRules.Predicates.Presets.isGreen);
|
colorFilters.add(CardRules.Predicates.Presets.IS_GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Iterable<CardPrinted> cardpool = CardDb.instance().getAllUniqueCards();
|
final Iterable<CardPrinted> cardpool = CardDb.instance().getAllUniqueCards();
|
||||||
@@ -223,19 +223,19 @@ public final class BoosterUtils {
|
|||||||
} else {
|
} else {
|
||||||
final String col = color.toLowerCase();
|
final String col = color.toLowerCase();
|
||||||
if (col.startsWith("wh")) {
|
if (col.startsWith("wh")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isWhite;
|
colorFilter = CardRules.Predicates.Presets.IS_WHITE;
|
||||||
} else if (col.startsWith("bla")) {
|
} else if (col.startsWith("bla")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isBlack;
|
colorFilter = CardRules.Predicates.Presets.IS_BLACK;
|
||||||
} else if (col.startsWith("blu")) {
|
} else if (col.startsWith("blu")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isBlue;
|
colorFilter = CardRules.Predicates.Presets.IS_BLUE;
|
||||||
} else if (col.startsWith("re")) {
|
} else if (col.startsWith("re")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isRed;
|
colorFilter = CardRules.Predicates.Presets.IS_RED;
|
||||||
} else if (col.startsWith("col")) {
|
} else if (col.startsWith("col")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isColorless;
|
colorFilter = CardRules.Predicates.Presets.IS_COLORLESS;
|
||||||
} else if (col.startsWith("gre")) {
|
} else if (col.startsWith("gre")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isGreen;
|
colorFilter = CardRules.Predicates.Presets.IS_GREEN;
|
||||||
} else if (col.startsWith("mul")) {
|
} else if (col.startsWith("mul")) {
|
||||||
colorFilter = CardRules.Predicates.Presets.isMulticolor;
|
colorFilter = CardRules.Predicates.Presets.IS_MULTICOLOR;
|
||||||
} else {
|
} else {
|
||||||
colorFilter = Predicate.getTrue(CardRules.class);
|
colorFilter = Predicate.getTrue(CardRules.class);
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ public final class BoosterUtils {
|
|||||||
* @return the card printed
|
* @return the card printed
|
||||||
*/
|
*/
|
||||||
public static CardPrinted findCardOfColor(final List<CardPrinted> in, final int color) {
|
public static CardPrinted findCardOfColor(final List<CardPrinted> in, final int color) {
|
||||||
final Predicate<CardRules> filter = CardRules.Predicates.Presets.colors.get(color);
|
final Predicate<CardRules> filter = CardRules.Predicates.Presets.COLORS.get(color);
|
||||||
if (null == filter) {
|
if (null == filter) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public final class CardManaCost implements Comparable<CardManaCost> {
|
|||||||
private Float compareWeight = null;
|
private Float compareWeight = null;
|
||||||
|
|
||||||
/** The Constant empty. */
|
/** The Constant empty. */
|
||||||
public static final CardManaCost empty = new CardManaCost();
|
public static final CardManaCost EMPTY = new CardManaCost();
|
||||||
|
|
||||||
// pass mana cost parser here
|
// pass mana cost parser here
|
||||||
private CardManaCost() {
|
private CardManaCost() {
|
||||||
@@ -89,7 +89,7 @@ public final class CardManaCost implements Comparable<CardManaCost> {
|
|||||||
public int getCMC() {
|
public int getCMC() {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (CardManaCostShard s : shards) {
|
for (CardManaCostShard s : shards) {
|
||||||
sum += s.cmc;
|
sum += s.getCmc();
|
||||||
}
|
}
|
||||||
return sum + genericCost;
|
return sum + genericCost;
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ public final class CardManaCost implements Comparable<CardManaCost> {
|
|||||||
if (compareWeight == null) {
|
if (compareWeight == null) {
|
||||||
float weight = genericCost;
|
float weight = genericCost;
|
||||||
for (CardManaCostShard s : shards) {
|
for (CardManaCostShard s : shards) {
|
||||||
weight += s.cmpc;
|
weight += s.getCmpc();
|
||||||
}
|
}
|
||||||
if (hasNoCost) {
|
if (hasNoCost) {
|
||||||
weight = -1; // for those who doesn't even have a 0 sign on card
|
weight = -1; // for those who doesn't even have a 0 sign on card
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ public class CardManaCostShard {
|
|||||||
private final int shard;
|
private final int shard;
|
||||||
|
|
||||||
/** The cmc. */
|
/** The cmc. */
|
||||||
public final int cmc;
|
private final int cmc;
|
||||||
|
|
||||||
/** The cmpc. */
|
/** The cmpc. */
|
||||||
public final float cmpc;
|
private final float cmpc;
|
||||||
private final String stringValue;
|
private final String stringValue;
|
||||||
|
|
||||||
/** The image key. */
|
/** The image key. */
|
||||||
public final String imageKey;
|
private final String imageKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new card mana cost shard.
|
* Instantiates a new card mana cost shard.
|
||||||
@@ -169,7 +169,7 @@ public class CardManaCostShard {
|
|||||||
/** The Constant G2. */
|
/** The Constant G2. */
|
||||||
public static final CardManaCostShard G2 = new CardManaCostShard(Atom.GREEN | Atom.OR_2_COLORLESS, "2/G", "2G");
|
public static final CardManaCostShard G2 = new CardManaCostShard(Atom.GREEN | Atom.OR_2_COLORLESS, "2/G", "2G");
|
||||||
|
|
||||||
private static final CardManaCostShard[] allPossible = new CardManaCostShard[] { X, WHITE, BLUE, BLACK, RED, GREEN,
|
private static final CardManaCostShard[] ALL_POSSIBLE = new CardManaCostShard[] { X, WHITE, BLUE, BLACK, RED, GREEN,
|
||||||
PW, PU, PB, PR, PG, WU, WB, WR, WG, UB, UR, UG, BR, BG, RG, W2, U2, B2, R2, G2 };
|
PW, PU, PB, PR, PG, WU, WB, WR, WG, UB, UR, UG, BR, BG, RG, W2, U2, B2, R2, G2 };
|
||||||
|
|
||||||
private int getCMC() {
|
private int getCMC() {
|
||||||
@@ -250,9 +250,9 @@ public class CardManaCostShard {
|
|||||||
* @return the card mana cost shard
|
* @return the card mana cost shard
|
||||||
*/
|
*/
|
||||||
public static CardManaCostShard valueOf(final int atoms) {
|
public static CardManaCostShard valueOf(final int atoms) {
|
||||||
for (int i = 0; i < allPossible.length; i++) {
|
for (int i = 0; i < ALL_POSSIBLE.length; i++) {
|
||||||
if (allPossible[i].shard == atoms) {
|
if (ALL_POSSIBLE[i].shard == atoms) {
|
||||||
return allPossible[i];
|
return ALL_POSSIBLE[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException(String.format("Not fount: mana shard with profile = %x", atoms));
|
throw new RuntimeException(String.format("Not fount: mana shard with profile = %x", atoms));
|
||||||
@@ -267,4 +267,25 @@ public class CardManaCostShard {
|
|||||||
public final String toString() {
|
public final String toString() {
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cmc
|
||||||
|
*/
|
||||||
|
public int getCmc() {
|
||||||
|
return cmc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cmpc
|
||||||
|
*/
|
||||||
|
public float getCmpc() {
|
||||||
|
return cmpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the imageKey
|
||||||
|
*/
|
||||||
|
public String getImageKey() {
|
||||||
|
return imageKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,19 +180,19 @@ public class CardRatings {
|
|||||||
*
|
*
|
||||||
* @param cardName
|
* @param cardName
|
||||||
* the card name
|
* the card name
|
||||||
* @param Rating
|
* @param rating
|
||||||
* the rating
|
* the rating
|
||||||
*/
|
*/
|
||||||
public final void putFullRating(final String cardName, final int Rating) {
|
public final void putFullRating(final String cardName, final int rating) {
|
||||||
if (fullRatings.containsKey(cardName)) {
|
if (fullRatings.containsKey(cardName)) {
|
||||||
int r = fullRatings.get(cardName);
|
int r = fullRatings.get(cardName);
|
||||||
int nr = (r + Rating) / 2;
|
int nr = (r + rating) / 2;
|
||||||
fullRatings.put(cardName, nr);
|
fullRatings.put(cardName, nr);
|
||||||
} else {
|
} else {
|
||||||
fullRatings.put(cardName, Rating);
|
fullRatings.put(cardName, rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempRatings.add("Full:" + cardName + ":" + Rating);
|
tempRatings.add("Full:" + cardName + ":" + rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,20 +202,20 @@ public class CardRatings {
|
|||||||
* the card name
|
* the card name
|
||||||
* @param setCode
|
* @param setCode
|
||||||
* the set code
|
* the set code
|
||||||
* @param Rating
|
* @param rating
|
||||||
* the rating
|
* the rating
|
||||||
*/
|
*/
|
||||||
public final void putBlockRating(final String cardName, final String setCode, final int Rating) {
|
public final void putBlockRating(final String cardName, final String setCode, final int rating) {
|
||||||
String cNsC = cardName + "|" + setCode;
|
String cNsC = cardName + "|" + setCode;
|
||||||
if (blockRatings.containsKey(cNsC)) {
|
if (blockRatings.containsKey(cNsC)) {
|
||||||
int r = blockRatings.get(cNsC);
|
int r = blockRatings.get(cNsC);
|
||||||
int nr = (r + Rating) / 2;
|
int nr = (r + rating) / 2;
|
||||||
blockRatings.put(cNsC, nr);
|
blockRatings.put(cNsC, nr);
|
||||||
} else {
|
} else {
|
||||||
blockRatings.put(cNsC, Rating);
|
blockRatings.put(cNsC, rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempRatings.add("Block:" + cNsC + ":" + Rating);
|
tempRatings.add("Block:" + cNsC + ":" + rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,20 +225,20 @@ public class CardRatings {
|
|||||||
* the card name
|
* the card name
|
||||||
* @param custName
|
* @param custName
|
||||||
* the cust name
|
* the cust name
|
||||||
* @param Rating
|
* @param rating
|
||||||
* the rating
|
* the rating
|
||||||
*/
|
*/
|
||||||
public final void putCustomRating(final String cardName, final String custName, final int Rating) {
|
public final void putCustomRating(final String cardName, final String custName, final int rating) {
|
||||||
String cNcN = cardName + "|" + custName;
|
String cNcN = cardName + "|" + custName;
|
||||||
if (customRatings.containsKey(cNcN)) {
|
if (customRatings.containsKey(cNcN)) {
|
||||||
int r = customRatings.get(cNcN);
|
int r = customRatings.get(cNcN);
|
||||||
int nr = (r + Rating) / 2;
|
int nr = (r + rating) / 2;
|
||||||
customRatings.put(cNcN, nr);
|
customRatings.put(cNcN, nr);
|
||||||
} else {
|
} else {
|
||||||
customRatings.put(cNcN, Rating);
|
customRatings.put(cNcN, rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempRatings.add("Custom:" + cNcN + ":" + Rating);
|
tempRatings.add("Custom:" + cNcN + ":" + rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.TreeMap;
|
|||||||
public class CardRuleCharacteristics {
|
public class CardRuleCharacteristics {
|
||||||
private String cardName = null;
|
private String cardName = null;
|
||||||
private CardType cardType = null;
|
private CardType cardType = null;
|
||||||
private CardManaCost manaCost = CardManaCost.empty;
|
private CardManaCost manaCost = CardManaCost.EMPTY;
|
||||||
private CardColor color = null;
|
private CardColor color = null;
|
||||||
private String ptLine = null;
|
private String ptLine = null;
|
||||||
private String[] cardRules = null;
|
private String[] cardRules = null;
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ public final class CardRules {
|
|||||||
public abstract static class Predicates {
|
public abstract static class Predicates {
|
||||||
|
|
||||||
/** The Constant isKeptInAiDecks. */
|
/** The Constant isKeptInAiDecks. */
|
||||||
public static final Predicate<CardRules> isKeptInAiDecks = new Predicate<CardRules>() {
|
public static final Predicate<CardRules> IS_KEPT_IN_AI_DECKS = new Predicate<CardRules>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isTrue(final CardRules card) {
|
public boolean isTrue(final CardRules card) {
|
||||||
return !card.isRemovedFromAIDecks;
|
return !card.isRemovedFromAIDecks;
|
||||||
@@ -336,7 +336,7 @@ public final class CardRules {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant isKeptInRandomDecks. */
|
/** The Constant isKeptInRandomDecks. */
|
||||||
public static final Predicate<CardRules> isKeptInRandomDecks = new Predicate<CardRules>() {
|
public static final Predicate<CardRules> IS_KEPT_IN_RANDOM_DECKS = new Predicate<CardRules>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isTrue(final CardRules card) {
|
public boolean isTrue(final CardRules card) {
|
||||||
return !card.isRemovedFromRandomDecks;
|
return !card.isRemovedFromRandomDecks;
|
||||||
@@ -738,16 +738,16 @@ public final class CardRules {
|
|||||||
public static class Presets {
|
public static class Presets {
|
||||||
|
|
||||||
/** The Constant isCreature. */
|
/** The Constant isCreature. */
|
||||||
public static final Predicate<CardRules> isCreature = coreType(true, CardCoreType.Creature);
|
public static final Predicate<CardRules> IS_CREATURE = coreType(true, CardCoreType.Creature);
|
||||||
|
|
||||||
/** The Constant isArtifact. */
|
/** The Constant isArtifact. */
|
||||||
public static final Predicate<CardRules> isArtifact = coreType(true, CardCoreType.Artifact);
|
public static final Predicate<CardRules> IS_ARTIFACT = coreType(true, CardCoreType.Artifact);
|
||||||
|
|
||||||
/** The Constant isLand. */
|
/** The Constant isLand. */
|
||||||
public static final Predicate<CardRules> isLand = coreType(true, CardCoreType.Land);
|
public static final Predicate<CardRules> IS_LAND = coreType(true, CardCoreType.Land);
|
||||||
|
|
||||||
/** The Constant isBasicLand. */
|
/** The Constant isBasicLand. */
|
||||||
public static final Predicate<CardRules> isBasicLand = new Predicate<CardRules>() {
|
public static final Predicate<CardRules> IS_BASIC_LAND = new Predicate<CardRules>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isTrue(final CardRules subject) {
|
public boolean isTrue(final CardRules subject) {
|
||||||
return subject.getType().isBasicLand();
|
return subject.getType().isBasicLand();
|
||||||
@@ -755,78 +755,78 @@ public final class CardRules {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant isPlaneswalker. */
|
/** The Constant isPlaneswalker. */
|
||||||
public static final Predicate<CardRules> isPlaneswalker = coreType(true, CardCoreType.Planeswalker);
|
public static final Predicate<CardRules> IS_PLANESWALKER = coreType(true, CardCoreType.Planeswalker);
|
||||||
|
|
||||||
/** The Constant isInstant. */
|
/** The Constant isInstant. */
|
||||||
public static final Predicate<CardRules> isInstant = coreType(true, CardCoreType.Instant);
|
public static final Predicate<CardRules> IS_INSTANT = coreType(true, CardCoreType.Instant);
|
||||||
|
|
||||||
/** The Constant isSorcery. */
|
/** The Constant isSorcery. */
|
||||||
public static final Predicate<CardRules> isSorcery = coreType(true, CardCoreType.Sorcery);
|
public static final Predicate<CardRules> IS_SORCERY = coreType(true, CardCoreType.Sorcery);
|
||||||
|
|
||||||
/** The Constant isEnchantment. */
|
/** The Constant isEnchantment. */
|
||||||
public static final Predicate<CardRules> isEnchantment = coreType(true, CardCoreType.Enchantment);
|
public static final Predicate<CardRules> IS_ENCHANTMENT = coreType(true, CardCoreType.Enchantment);
|
||||||
|
|
||||||
/** The Constant isNonLand. */
|
/** The Constant isNonLand. */
|
||||||
public static final Predicate<CardRules> isNonLand = coreType(false, CardCoreType.Land);
|
public static final Predicate<CardRules> IS_NON_LAND = coreType(false, CardCoreType.Land);
|
||||||
|
|
||||||
/** The Constant isNonCreatureSpell. */
|
/** The Constant isNonCreatureSpell. */
|
||||||
public static final Predicate<CardRules> isNonCreatureSpell = Predicate.compose(isCreature,
|
public static final Predicate<CardRules> IS_NON_CREATURE_SPELL = Predicate.compose(IS_CREATURE,
|
||||||
PredicatesOp.NOR, isLand);
|
PredicatesOp.NOR, IS_LAND);
|
||||||
|
|
||||||
/** The Constant isWhite. */
|
/** The Constant isWhite. */
|
||||||
public static final Predicate<CardRules> isWhite = isColor(CardColor.WHITE);
|
public static final Predicate<CardRules> IS_WHITE = isColor(CardColor.WHITE);
|
||||||
|
|
||||||
/** The Constant isBlue. */
|
/** The Constant isBlue. */
|
||||||
public static final Predicate<CardRules> isBlue = isColor(CardColor.BLUE);
|
public static final Predicate<CardRules> IS_BLUE = isColor(CardColor.BLUE);
|
||||||
|
|
||||||
/** The Constant isBlack. */
|
/** The Constant isBlack. */
|
||||||
public static final Predicate<CardRules> isBlack = isColor(CardColor.BLACK);
|
public static final Predicate<CardRules> IS_BLACK = isColor(CardColor.BLACK);
|
||||||
|
|
||||||
/** The Constant isRed. */
|
/** The Constant isRed. */
|
||||||
public static final Predicate<CardRules> isRed = isColor(CardColor.RED);
|
public static final Predicate<CardRules> IS_RED = isColor(CardColor.RED);
|
||||||
|
|
||||||
/** The Constant isGreen. */
|
/** The Constant isGreen. */
|
||||||
public static final Predicate<CardRules> isGreen = isColor(CardColor.GREEN);
|
public static final Predicate<CardRules> IS_GREEN = isColor(CardColor.GREEN);
|
||||||
|
|
||||||
/** The Constant isColorless. */
|
/** The Constant isColorless. */
|
||||||
public static final Predicate<CardRules> isColorless = hasCntColors((byte) 0);
|
public static final Predicate<CardRules> IS_COLORLESS = hasCntColors((byte) 0);
|
||||||
|
|
||||||
/** The Constant isMulticolor. */
|
/** The Constant isMulticolor. */
|
||||||
public static final Predicate<CardRules> isMulticolor = hasAtLeastCntColors((byte) 2);
|
public static final Predicate<CardRules> IS_MULTICOLOR = hasAtLeastCntColors((byte) 2);
|
||||||
|
|
||||||
/** The Constant colors. */
|
/** The Constant colors. */
|
||||||
public static final List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
|
public static final List<Predicate<CardRules>> COLORS = new ArrayList<Predicate<CardRules>>();
|
||||||
static {
|
static {
|
||||||
colors.add(isWhite);
|
COLORS.add(IS_WHITE);
|
||||||
colors.add(isBlue);
|
COLORS.add(IS_BLUE);
|
||||||
colors.add(isBlack);
|
COLORS.add(IS_BLACK);
|
||||||
colors.add(isRed);
|
COLORS.add(IS_RED);
|
||||||
colors.add(isGreen);
|
COLORS.add(IS_GREEN);
|
||||||
colors.add(isColorless);
|
COLORS.add(IS_COLORLESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The Constant constantTrue. */
|
/** The Constant constantTrue. */
|
||||||
public static final Predicate<CardRules> constantTrue = Predicate.getTrue(CardRules.class);
|
public static final Predicate<CardRules> CONSTANT_TRUE = Predicate.getTrue(CardRules.class);
|
||||||
|
|
||||||
// Think twice before using these, since rarity is a prop of printed
|
// Think twice before using these, since rarity is a prop of printed
|
||||||
// card.
|
// card.
|
||||||
/** The Constant isInLatestSetCommon. */
|
/** The Constant isInLatestSetCommon. */
|
||||||
public static final Predicate<CardRules> isInLatestSetCommon = rarityInCardsLatestSet(true,
|
public static final Predicate<CardRules> IS_IN_LATEST_SET_COMMON = rarityInCardsLatestSet(true,
|
||||||
CardRarity.Common);
|
CardRarity.Common);
|
||||||
|
|
||||||
/** The Constant isInLatestSetUncommon. */
|
/** The Constant isInLatestSetUncommon. */
|
||||||
public static final Predicate<CardRules> isInLatestSetUncommon = rarityInCardsLatestSet(true,
|
public static final Predicate<CardRules> IS_IN_LATEST_SET_UNCOMMON = rarityInCardsLatestSet(true,
|
||||||
CardRarity.Uncommon);
|
CardRarity.Uncommon);
|
||||||
|
|
||||||
/** The Constant isInLatestSetRare. */
|
/** The Constant isInLatestSetRare. */
|
||||||
public static final Predicate<CardRules> isInLatestSetRare = rarityInCardsLatestSet(true, CardRarity.Rare);
|
public static final Predicate<CardRules> IS_IN_LATEST_SET_RARE = rarityInCardsLatestSet(true, CardRarity.Rare);
|
||||||
|
|
||||||
/** The Constant isInLatestSetMythicRare. */
|
/** The Constant isInLatestSetMythicRare. */
|
||||||
public static final Predicate<CardRules> isInLatestSetMythicRare = rarityInCardsLatestSet(true,
|
public static final Predicate<CardRules> IS_IN_LATEST_SET_MYTHIC_RARE = rarityInCardsLatestSet(true,
|
||||||
CardRarity.MythicRare);
|
CardRarity.MythicRare);
|
||||||
|
|
||||||
/** The Constant isInLatestSetSpecial. */
|
/** The Constant isInLatestSetSpecial. */
|
||||||
public static final Predicate<CardRules> isInLatestSetSpecial = rarityInCardsLatestSet(true,
|
public static final Predicate<CardRules> IS_IN_LATEST_SET_SPECIAL = rarityInCardsLatestSet(true,
|
||||||
CardRarity.Special);
|
CardRarity.Special);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ public class CardRulesReader {
|
|||||||
* Reset.
|
* Reset.
|
||||||
*/
|
*/
|
||||||
public final void reset() {
|
public final void reset() {
|
||||||
characteristics = new CardRuleCharacteristics[] { new CardRuleCharacteristics(), null };
|
this.characteristics = new CardRuleCharacteristics[] { new CardRuleCharacteristics(), null };
|
||||||
curCharacteristics = 0;
|
this.curCharacteristics = 0;
|
||||||
removedFromAIDecks = false;
|
this.removedFromAIDecks = false;
|
||||||
removedFromRandomDecks = false;
|
this.removedFromRandomDecks = false;
|
||||||
isDoubleFacedCard = false;
|
this.isDoubleFacedCard = false;
|
||||||
isFlipCard = false;
|
this.isFlipCard = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,12 +47,12 @@ public class CardRulesReader {
|
|||||||
* @return the card
|
* @return the card
|
||||||
*/
|
*/
|
||||||
public final CardRules[] getCard() {
|
public final CardRules[] getCard() {
|
||||||
CardRules[] ret = new CardRules[] {
|
final CardRules[] ret = new CardRules[] {
|
||||||
new CardRules(characteristics[0], isDoubleFacedCard, false, removedFromRandomDecks, removedFromAIDecks),
|
new CardRules(this.characteristics[0], this.isDoubleFacedCard, false, this.removedFromRandomDecks,
|
||||||
null };
|
this.removedFromAIDecks), null };
|
||||||
if (characteristics[1] != null) {
|
if (this.characteristics[1] != null) {
|
||||||
ret[1] = new CardRules(characteristics[1], isDoubleFacedCard, true, removedFromRandomDecks,
|
ret[1] = new CardRules(this.characteristics[1], this.isDoubleFacedCard, true, this.removedFromRandomDecks,
|
||||||
removedFromAIDecks);
|
this.removedFromAIDecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -66,43 +66,48 @@ public class CardRulesReader {
|
|||||||
*/
|
*/
|
||||||
public final void parseLine(final String line) {
|
public final void parseLine(final String line) {
|
||||||
if (line.startsWith("Name:")) {
|
if (line.startsWith("Name:")) {
|
||||||
characteristics[curCharacteristics].setCardName(getValueAfterKey(line, "Name:"));
|
this.characteristics[this.curCharacteristics].setCardName(CardRulesReader.getValueAfterKey(line, "Name:"));
|
||||||
if (characteristics[curCharacteristics].getCardName() == null
|
if ((this.characteristics[this.curCharacteristics].getCardName() == null)
|
||||||
|| characteristics[curCharacteristics].getCardName().isEmpty()) {
|
|| this.characteristics[this.curCharacteristics].getCardName().isEmpty()) {
|
||||||
throw new RuntimeException("Card name is empty");
|
throw new RuntimeException("Card name is empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (line.startsWith("ManaCost:")) {
|
} else if (line.startsWith("ManaCost:")) {
|
||||||
String sCost = getValueAfterKey(line, "ManaCost:");
|
final String sCost = CardRulesReader.getValueAfterKey(line, "ManaCost:");
|
||||||
characteristics[curCharacteristics].setManaCost("no cost".equals(sCost) ? CardManaCost.empty
|
this.characteristics[this.curCharacteristics].setManaCost("no cost".equals(sCost) ? CardManaCost.EMPTY
|
||||||
: new CardManaCost(new ParserCardnameTxtManaCost(sCost)));
|
: new CardManaCost(new ParserCardnameTxtManaCost(sCost)));
|
||||||
|
|
||||||
} else if (line.startsWith("Types:")) {
|
} else if (line.startsWith("Types:")) {
|
||||||
characteristics[curCharacteristics].setCardType(CardType.parse(getValueAfterKey(line, "Types:")));
|
this.characteristics[this.curCharacteristics].setCardType(CardType.parse(CardRulesReader.getValueAfterKey(
|
||||||
|
line, "Types:")));
|
||||||
|
|
||||||
} else if (line.startsWith("Oracle:")) {
|
} else if (line.startsWith("Oracle:")) {
|
||||||
characteristics[curCharacteristics].setCardRules(getValueAfterKey(line, "Oracle:").split("\\n"));
|
this.characteristics[this.curCharacteristics].setCardRules(CardRulesReader
|
||||||
|
.getValueAfterKey(line, "Oracle:").split("\\n"));
|
||||||
|
|
||||||
} else if (line.startsWith("PT:")) {
|
} else if (line.startsWith("PT:")) {
|
||||||
characteristics[curCharacteristics].setPtLine(getValueAfterKey(line, "PT:"));
|
this.characteristics[this.curCharacteristics].setPtLine(CardRulesReader.getValueAfterKey(line, "PT:"));
|
||||||
} else if (line.startsWith("Loyalty:")) {
|
} else if (line.startsWith("Loyalty:")) {
|
||||||
characteristics[curCharacteristics].setPtLine(getValueAfterKey(line, "Loyalty:"));
|
this.characteristics[this.curCharacteristics].setPtLine(CardRulesReader.getValueAfterKey(line, "Loyalty:"));
|
||||||
|
|
||||||
} else if (line.startsWith("SVar:RemAIDeck:")) {
|
} else if (line.startsWith("SVar:RemAIDeck:")) {
|
||||||
removedFromAIDecks = "True".equalsIgnoreCase(getValueAfterKey(line, "SVar:RemAIDeck:"));
|
this.removedFromAIDecks = "True"
|
||||||
|
.equalsIgnoreCase(CardRulesReader.getValueAfterKey(line, "SVar:RemAIDeck:"));
|
||||||
|
|
||||||
} else if (line.startsWith("SVar:RemRandomDeck:")) {
|
} else if (line.startsWith("SVar:RemRandomDeck:")) {
|
||||||
removedFromRandomDecks = "True".equalsIgnoreCase(getValueAfterKey(line, "SVar:RemRandomDeck:"));
|
this.removedFromRandomDecks = "True".equalsIgnoreCase(CardRulesReader.getValueAfterKey(line,
|
||||||
|
"SVar:RemRandomDeck:"));
|
||||||
|
|
||||||
} else if (line.startsWith("SetInfo:")) {
|
} else if (line.startsWith("SetInfo:")) {
|
||||||
parseSetInfoLine(line, characteristics[curCharacteristics].getSetsData());
|
CardRulesReader.parseSetInfoLine(line, this.characteristics[this.curCharacteristics].getSetsData());
|
||||||
|
|
||||||
} else if (line.startsWith("AlternateMode:")) {
|
} else if (line.startsWith("AlternateMode:")) {
|
||||||
isDoubleFacedCard = "DoubleFaced".equalsIgnoreCase(getValueAfterKey(line, "AlternateMode:"));
|
this.isDoubleFacedCard = "DoubleFaced".equalsIgnoreCase(CardRulesReader.getValueAfterKey(line,
|
||||||
isFlipCard = "Flip".equalsIgnoreCase(getValueAfterKey(line, "AlternateMode:"));
|
"AlternateMode:"));
|
||||||
|
this.isFlipCard = "Flip".equalsIgnoreCase(CardRulesReader.getValueAfterKey(line, "AlternateMode:"));
|
||||||
} else if (line.equals("ALTERNATE")) {
|
} else if (line.equals("ALTERNATE")) {
|
||||||
characteristics[1] = new CardRuleCharacteristics();
|
this.characteristics[1] = new CardRuleCharacteristics();
|
||||||
curCharacteristics = 1;
|
this.curCharacteristics = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -143,7 +148,7 @@ public class CardRulesReader {
|
|||||||
if (pieces.length > numPicIx) {
|
if (pieces.length > numPicIx) {
|
||||||
try {
|
try {
|
||||||
numIllustrations = Integer.parseInt(pieces[numPicIx]);
|
numIllustrations = Integer.parseInt(pieces[numPicIx]);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (final NumberFormatException nfe) {
|
||||||
throw new RuntimeException("Fourth item of SetInfo is not an integer in <<" + value + ">>");
|
throw new RuntimeException("Fourth item of SetInfo is not an integer in <<" + value + ">>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +174,7 @@ public class CardRulesReader {
|
|||||||
throw new RuntimeException("Unrecognized rarity string <<" + txtRarity + ">>");
|
throw new RuntimeException("Unrecognized rarity string <<" + txtRarity + ">>");
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInSet cardInSet = new CardInSet(rarity, numIllustrations);
|
final CardInSet cardInSet = new CardInSet(rarity, numIllustrations);
|
||||||
|
|
||||||
setsData.put(setCode, cardInSet);
|
setsData.put(setCode, cardInSet);
|
||||||
}
|
}
|
||||||
@@ -206,8 +211,8 @@ public class CardRulesReader {
|
|||||||
public ParserCardnameTxtManaCost(final String cost) {
|
public ParserCardnameTxtManaCost(final String cost) {
|
||||||
this.cost = cost.split(" ");
|
this.cost = cost.split(" ");
|
||||||
// System.out.println(cost);
|
// System.out.println(cost);
|
||||||
nextToken = 0;
|
this.nextToken = 0;
|
||||||
colorlessCost = 0;
|
this.colorlessCost = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -215,11 +220,12 @@ public class CardRulesReader {
|
|||||||
*
|
*
|
||||||
* @see forge.card.CardManaCost.ManaParser#getTotalColorlessCost()
|
* @see forge.card.CardManaCost.ManaParser#getTotalColorlessCost()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getTotalColorlessCost() {
|
public final int getTotalColorlessCost() {
|
||||||
if (hasNext()) {
|
if (this.hasNext()) {
|
||||||
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
||||||
}
|
}
|
||||||
return colorlessCost;
|
return this.colorlessCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -229,7 +235,7 @@ public class CardRulesReader {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean hasNext() {
|
public final boolean hasNext() {
|
||||||
return nextToken < cost.length;
|
return this.nextToken < this.cost.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -240,10 +246,10 @@ public class CardRulesReader {
|
|||||||
@Override
|
@Override
|
||||||
public final CardManaCostShard next() {
|
public final CardManaCostShard next() {
|
||||||
|
|
||||||
String unparsed = cost[nextToken++];
|
final String unparsed = this.cost[this.nextToken++];
|
||||||
// System.out.println(unparsed);
|
// System.out.println(unparsed);
|
||||||
if (StringUtils.isNumeric(unparsed)) {
|
if (StringUtils.isNumeric(unparsed)) {
|
||||||
colorlessCost += Integer.parseInt(unparsed);
|
this.colorlessCost += Integer.parseInt(unparsed);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The Constant unknown. */
|
/** The Constant unknown. */
|
||||||
public static final CardSet unknown = new CardSet(-1, "Undefined", "???", "??");
|
public static final CardSet UNKNOWN = new CardSet(-1, "Undefined", "???", "??");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name.
|
* Gets the name.
|
||||||
@@ -116,7 +116,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The Constant fnGetName. */
|
/** The Constant fnGetName. */
|
||||||
public static final Lambda1<String, CardSet> fnGetName = new Lambda1<String, CardSet>() {
|
public static final Lambda1<String, CardSet> FN_GET_NAME = new Lambda1<String, CardSet>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(final CardSet arg1) {
|
public String apply(final CardSet arg1) {
|
||||||
return arg1.name;
|
return arg1.name;
|
||||||
@@ -124,7 +124,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fn1. */
|
/** The Constant fn1. */
|
||||||
public static final Lambda1<CardSet, CardSet> fn1 = new Lambda1<CardSet, CardSet>() {
|
public static final Lambda1<CardSet, CardSet> FN1 = new Lambda1<CardSet, CardSet>() {
|
||||||
@Override
|
@Override
|
||||||
public CardSet apply(final CardSet arg1) {
|
public CardSet apply(final CardSet arg1) {
|
||||||
return arg1;
|
return arg1;
|
||||||
@@ -319,7 +319,7 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
|||||||
public abstract static class Predicates {
|
public abstract static class Predicates {
|
||||||
|
|
||||||
/** The Constant canMakeBooster. */
|
/** The Constant canMakeBooster. */
|
||||||
public static final Predicate<CardSet> canMakeBooster = new CanMakeBooster();
|
public static final Predicate<CardSet> CAN_MAKE_BOOSTER = new CanMakeBooster();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is legal in format.
|
* Checks if is legal in format.
|
||||||
@@ -356,13 +356,13 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
|||||||
public abstract static class Presets {
|
public abstract static class Presets {
|
||||||
|
|
||||||
/** The Constant setsInT2. */
|
/** The Constant setsInT2. */
|
||||||
public static final Predicate<CardSet> setsInT2 = isLegalInFormat(SetUtils.getStandard());
|
public static final Predicate<CardSet> SETS_IN_STANDARD = isLegalInFormat(SetUtils.getStandard());
|
||||||
|
|
||||||
/** The Constant setsInExt. */
|
/** The Constant setsInExt. */
|
||||||
public static final Predicate<CardSet> setsInExt = isLegalInFormat(SetUtils.getExtended());
|
public static final Predicate<CardSet> SETS_IN_EXT = isLegalInFormat(SetUtils.getExtended());
|
||||||
|
|
||||||
/** The Constant setsInModern. */
|
/** The Constant setsInModern. */
|
||||||
public static final Predicate<CardSet> setsInModern = isLegalInFormat(SetUtils.getModern());
|
public static final Predicate<CardSet> SET_IN_MODERN = isLegalInFormat(SetUtils.getModern());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,19 @@ import forge.card.CardManaCost.ManaParser;
|
|||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
|
||||||
/** This class can read CardRules from Arch's mtg-data.txt file */
|
/** This class can read CardRules from Arch's mtg-data.txt file. */
|
||||||
public final class MtgDataParser implements Iterator<CardRules> {
|
public final class MtgDataParser implements Iterator<CardRules> {
|
||||||
|
|
||||||
private Iterator<String> it;
|
private final Iterator<String> it;
|
||||||
private final List<String> mtgDataLines;
|
private final List<String> mtgDataLines;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new mtg data parser.
|
* Instantiates a new mtg data parser.
|
||||||
*/
|
*/
|
||||||
public MtgDataParser() {
|
public MtgDataParser() {
|
||||||
mtgDataLines = FileUtil.readFile(ForgeProps.getFile(NewConstants.MTG_DATA));
|
this.mtgDataLines = FileUtil.readFile(ForgeProps.getFile(NewConstants.MTG_DATA));
|
||||||
it = mtgDataLines.iterator();
|
this.it = this.mtgDataLines.iterator();
|
||||||
skipSetList();
|
this.skipSetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> setsToSkipPrefixes = new ArrayList<String>();
|
private static List<String> setsToSkipPrefixes = new ArrayList<String>();
|
||||||
@@ -33,53 +33,53 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
// lands from
|
// lands from
|
||||||
// there
|
// there
|
||||||
static {
|
static {
|
||||||
setsToSkipPrefixes.add("VG"); // Vanguard
|
MtgDataParser.setsToSkipPrefixes.add("VG"); // Vanguard
|
||||||
setsToSkipPrefixes.add("ME"); // Mtgo master's editions
|
MtgDataParser.setsToSkipPrefixes.add("ME"); // Mtgo master's editions
|
||||||
setsToSkipPrefixes.add("FV"); // From the vaults
|
MtgDataParser.setsToSkipPrefixes.add("FV"); // From the vaults
|
||||||
|
|
||||||
// Duel decks... or... should I keep them?
|
// Duel decks... or... should I keep them?
|
||||||
setsToSkipPrefixes.add("DVD");
|
MtgDataParser.setsToSkipPrefixes.add("DVD");
|
||||||
setsToSkipPrefixes.add("EVT");
|
MtgDataParser.setsToSkipPrefixes.add("EVT");
|
||||||
setsToSkipPrefixes.add("EVG");
|
MtgDataParser.setsToSkipPrefixes.add("EVG");
|
||||||
setsToSkipPrefixes.add("GVL");
|
MtgDataParser.setsToSkipPrefixes.add("GVL");
|
||||||
setsToSkipPrefixes.add("JVC");
|
MtgDataParser.setsToSkipPrefixes.add("JVC");
|
||||||
setsToSkipPrefixes.add("DDG");
|
MtgDataParser.setsToSkipPrefixes.add("DDG");
|
||||||
setsToSkipPrefixes.add("PVC");
|
MtgDataParser.setsToSkipPrefixes.add("PVC");
|
||||||
|
|
||||||
// Archenemy - we cannot play it now anyway
|
// Archenemy - we cannot play it now anyway
|
||||||
setsToSkipPrefixes.add("ARC");
|
MtgDataParser.setsToSkipPrefixes.add("ARC");
|
||||||
|
|
||||||
// Planechase - this too
|
// Planechase - this too
|
||||||
setsToSkipPrefixes.add("HOP");
|
MtgDataParser.setsToSkipPrefixes.add("HOP");
|
||||||
|
|
||||||
// Reprints
|
// Reprints
|
||||||
setsToSkipPrefixes.add("BRB");
|
MtgDataParser.setsToSkipPrefixes.add("BRB");
|
||||||
setsToSkipPrefixes.add("BTD");
|
MtgDataParser.setsToSkipPrefixes.add("BTD");
|
||||||
setsToSkipPrefixes.add("DKM");
|
MtgDataParser.setsToSkipPrefixes.add("DKM");
|
||||||
// setsToSkipPrefixes.add("ATH"); // No need to skip it really.
|
// setsToSkipPrefixes.add("ATH"); // No need to skip it really.
|
||||||
// On gatherer's opinion this cards were released 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
|
// Promo sets - all cards have been issued in other sets
|
||||||
setsToSkipPrefixes.add("SDC");
|
MtgDataParser.setsToSkipPrefixes.add("SDC");
|
||||||
setsToSkipPrefixes.add("ASTRAL");
|
MtgDataParser.setsToSkipPrefixes.add("ASTRAL");
|
||||||
|
|
||||||
// Premium decks
|
// Premium decks
|
||||||
setsToSkipPrefixes.add("H09");
|
MtgDataParser.setsToSkipPrefixes.add("H09");
|
||||||
setsToSkipPrefixes.add("H10");
|
MtgDataParser.setsToSkipPrefixes.add("H10");
|
||||||
|
|
||||||
// Un-sets are weird, but lands from there are valuable
|
// Un-sets are weird, but lands from there are valuable
|
||||||
unSets.add("UNH");
|
MtgDataParser.unSets.add("UNH");
|
||||||
unSets.add("UGL");
|
MtgDataParser.unSets.add("UGL");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean weHaveNext;
|
private boolean weHaveNext;
|
||||||
|
|
||||||
private void skipSetList() {
|
private void skipSetList() {
|
||||||
String nextLine = it.next();
|
String nextLine = this.it.next();
|
||||||
while (nextLine.length() > 0 && it.hasNext()) {
|
while ((nextLine.length() > 0) && this.it.hasNext()) {
|
||||||
nextLine = it.next();
|
nextLine = this.it.next();
|
||||||
}
|
}
|
||||||
weHaveNext = it.hasNext();
|
this.weHaveNext = this.it.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -89,7 +89,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return weHaveNext;
|
return this.weHaveNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CardRuleCharacteristics[] chars = new CardRuleCharacteristics[2];
|
private final CardRuleCharacteristics[] chars = new CardRuleCharacteristics[2];
|
||||||
@@ -101,25 +101,26 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CardRules next() {
|
public CardRules next() {
|
||||||
if (chars[1] != null) {
|
if (this.chars[1] != null) {
|
||||||
CardRules ret = new CardRules(chars[1], false, true, false, false);
|
final CardRules ret = new CardRules(this.chars[1], false, true, false, false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
chars[0] = new CardRuleCharacteristics();
|
this.chars[0] = new CardRuleCharacteristics();
|
||||||
Map<String, CardInSet> sets = new HashMap<String, CardInSet>();
|
final Map<String, CardInSet> sets = new HashMap<String, CardInSet>();
|
||||||
|
|
||||||
String nextline = readSingleCard(chars[0]);
|
String nextline = this.readSingleCard(this.chars[0]);
|
||||||
if (nextline != null) {
|
if (nextline != null) {
|
||||||
if (nextline.equals("----")) {
|
if (nextline.equals("----")) {
|
||||||
chars[1] = new CardRuleCharacteristics();
|
this.chars[1] = new CardRuleCharacteristics();
|
||||||
nextline = readSingleCard(chars[1]);
|
nextline = this.readSingleCard(this.chars[1]);
|
||||||
}
|
}
|
||||||
if (!nextline.isEmpty()) {
|
if (!nextline.isEmpty()) {
|
||||||
String setsLine = nextline;
|
final String setsLine = nextline;
|
||||||
boolean isBasicLand = chars[0].getCardType().isLand() && chars[0].getCardType().isBasic();
|
final boolean isBasicLand = this.chars[0].getCardType().isLand()
|
||||||
chars[0].setSetsData(getValidEditions(setsLine, isBasicLand));
|
&& this.chars[0].getCardType().isBasic();
|
||||||
if (chars[1] != null) {
|
this.chars[0].setSetsData(this.getValidEditions(setsLine, isBasicLand));
|
||||||
chars[1].setSetsData(getValidEditions(setsLine, isBasicLand));
|
if (this.chars[1] != null) {
|
||||||
|
this.chars[1].setSetsData(this.getValidEditions(setsLine, isBasicLand));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,52 +129,52 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
if (sets.isEmpty()) {
|
if (sets.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
} // that was a bad card - it won't be added by invoker
|
} // that was a bad card - it won't be added by invoker
|
||||||
if (chars[0] == null) {
|
if (this.chars[0] == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CardRules(chars[0], false, false, false, false);
|
return new CardRules(this.chars[0], false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readSingleCard(final CardRuleCharacteristics ret) {
|
private String readSingleCard(final CardRuleCharacteristics ret) {
|
||||||
|
|
||||||
if (!it.hasNext()) {
|
if (!this.it.hasNext()) {
|
||||||
weHaveNext = false;
|
this.weHaveNext = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ret.setCardName(it.next());
|
ret.setCardName(this.it.next());
|
||||||
|
|
||||||
if (!it.hasNext()) {
|
if (!this.it.hasNext()) {
|
||||||
weHaveNext = false;
|
this.weHaveNext = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String manaCost = it.next();
|
String manaCost = this.it.next();
|
||||||
ret.setManaCost(CardManaCost.empty);
|
ret.setManaCost(CardManaCost.EMPTY);
|
||||||
CardType type = null;
|
CardType type = null;
|
||||||
if (manaCost.startsWith("{")) {
|
if (manaCost.startsWith("{")) {
|
||||||
ret.setManaCost(new CardManaCost(new ManaParserMtgData(manaCost)));
|
ret.setManaCost(new CardManaCost(new ManaParserMtgData(manaCost)));
|
||||||
if (!it.hasNext()) {
|
if (!this.it.hasNext()) {
|
||||||
weHaveNext = false;
|
this.weHaveNext = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
type = CardType.parse(it.next());
|
type = CardType.parse(this.it.next());
|
||||||
} else { // Land?
|
} else { // Land?
|
||||||
type = CardType.parse(manaCost);
|
type = CardType.parse(manaCost);
|
||||||
manaCost = null;
|
manaCost = null;
|
||||||
}
|
}
|
||||||
ret.setPtLine(null);
|
ret.setPtLine(null);
|
||||||
if (type.isCreature() || type.isPlaneswalker()) {
|
if (type.isCreature() || type.isPlaneswalker()) {
|
||||||
if (!it.hasNext()) {
|
if (!this.it.hasNext()) {
|
||||||
weHaveNext = false;
|
this.weHaveNext = false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ret.setPtLine(it.next());
|
ret.setPtLine(this.it.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
String nextline = it.next();
|
final String nextline = this.it.next();
|
||||||
ArrayList<String> rules = new ArrayList<String>();
|
final ArrayList<String> rules = new ArrayList<String>();
|
||||||
while (nextline != null
|
while ((nextline != null)
|
||||||
&& !nextline.isEmpty()
|
&& !nextline.isEmpty()
|
||||||
&& !nextline.equals("----")
|
&& !nextline.equals("----")
|
||||||
&& !java.util.regex.Pattern.matches(
|
&& !java.util.regex.Pattern.matches(
|
||||||
@@ -186,19 +187,19 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, CardInSet> getValidEditions(final String sets, final boolean isBasicLand) {
|
private Map<String, CardInSet> getValidEditions(final String sets, final boolean isBasicLand) {
|
||||||
String[] setsData = sets.split(", ");
|
final String[] setsData = sets.split(", ");
|
||||||
Map<String, CardInSet> result = new HashMap<String, CardInSet>();
|
final Map<String, CardInSet> result = new HashMap<String, CardInSet>();
|
||||||
for (int iSet = 0; iSet < setsData.length; iSet++) {
|
for (final String element : setsData) {
|
||||||
int spacePos = setsData[iSet].indexOf(' ');
|
final int spacePos = element.indexOf(' ');
|
||||||
String setCode = setsData[iSet].substring(0, spacePos);
|
final String setCode = element.substring(0, spacePos);
|
||||||
boolean shouldSkip = false;
|
boolean shouldSkip = false;
|
||||||
for (String s : setsToSkipPrefixes) {
|
for (final String s : MtgDataParser.setsToSkipPrefixes) {
|
||||||
if (setCode.startsWith(s)) {
|
if (setCode.startsWith(s)) {
|
||||||
shouldSkip = true;
|
shouldSkip = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String s : unSets) {
|
for (final String s : MtgDataParser.unSets) {
|
||||||
if (setCode.startsWith(s) && !isBasicLand) {
|
if (setCode.startsWith(s) && !isBasicLand) {
|
||||||
shouldSkip = true;
|
shouldSkip = true;
|
||||||
break;
|
break;
|
||||||
@@ -207,7 +208,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
if (shouldSkip) {
|
if (shouldSkip) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result.put(setCode, parseCardInSet(setsData[iSet], spacePos));
|
result.put(setCode, MtgDataParser.parseCardInSet(element, spacePos));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -222,7 +223,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
* @return the card in set
|
* @return the card in set
|
||||||
*/
|
*/
|
||||||
public static CardInSet parseCardInSet(final String unparsed, final int spaceAt) {
|
public static CardInSet parseCardInSet(final String unparsed, final int spaceAt) {
|
||||||
char rarity = unparsed.charAt(spaceAt + 1);
|
final char rarity = unparsed.charAt(spaceAt + 1);
|
||||||
CardRarity rating;
|
CardRarity rating;
|
||||||
switch (rarity) {
|
switch (rarity) {
|
||||||
case 'L':
|
case 'L':
|
||||||
@@ -249,9 +250,9 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int number = 1;
|
int number = 1;
|
||||||
int bracketAt = unparsed.indexOf('(', spaceAt);
|
final int bracketAt = unparsed.indexOf('(', spaceAt);
|
||||||
if (-1 != bracketAt) {
|
if (-1 != bracketAt) {
|
||||||
String sN = unparsed.substring(bracketAt + 2, unparsed.indexOf(')', bracketAt));
|
final String sN = unparsed.substring(bracketAt + 2, unparsed.indexOf(')', bracketAt));
|
||||||
number = Integer.parseInt(sN);
|
number = Integer.parseInt(sN);
|
||||||
}
|
}
|
||||||
return new CardInSet(rating, number);
|
return new CardInSet(rating, number);
|
||||||
@@ -284,8 +285,8 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
public ManaParserMtgData(final String cost0) {
|
public ManaParserMtgData(final String cost0) {
|
||||||
this.cost = cost0;
|
this.cost = cost0;
|
||||||
// System.out.println(cost);
|
// System.out.println(cost);
|
||||||
nextBracket = cost0.indexOf('{');
|
this.nextBracket = cost0.indexOf('{');
|
||||||
colorlessCost = 0;
|
this.colorlessCost = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -293,11 +294,12 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
*
|
*
|
||||||
* @see forge.card.CardManaCost.ManaParser#getTotalColorlessCost()
|
* @see forge.card.CardManaCost.ManaParser#getTotalColorlessCost()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getTotalColorlessCost() {
|
public int getTotalColorlessCost() {
|
||||||
if (hasNext()) {
|
if (this.hasNext()) {
|
||||||
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
||||||
}
|
}
|
||||||
return colorlessCost;
|
return this.colorlessCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -307,7 +309,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return nextBracket != -1;
|
return this.nextBracket != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -317,13 +319,13 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CardManaCostShard next() {
|
public CardManaCostShard next() {
|
||||||
int closeBracket = cost.indexOf('}', nextBracket);
|
final int closeBracket = this.cost.indexOf('}', this.nextBracket);
|
||||||
String unparsed = cost.substring(nextBracket + 1, closeBracket);
|
final String unparsed = this.cost.substring(this.nextBracket + 1, closeBracket);
|
||||||
nextBracket = cost.indexOf('{', closeBracket + 1);
|
this.nextBracket = this.cost.indexOf('{', closeBracket + 1);
|
||||||
|
|
||||||
// System.out.println(unparsed);
|
// System.out.println(unparsed);
|
||||||
if (StringUtils.isNumeric(unparsed)) {
|
if (StringUtils.isNumeric(unparsed)) {
|
||||||
colorlessCost += Integer.parseInt(unparsed);
|
this.colorlessCost += Integer.parseInt(unparsed);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,21 +97,21 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.fnNameCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.FN_NAME_COMPARE,
|
||||||
PresetColumns.fnNameGet));
|
PresetColumns.FN_NAME_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 60, PresetColumns.fnColorCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 60, PresetColumns.FN_COLOR_COMPARE,
|
||||||
PresetColumns.fnColorGet));
|
PresetColumns.FN_COLOR_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE,
|
||||||
PresetColumns.fnTypeGet));
|
PresetColumns.FN_TYPE_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 60, PresetColumns.fnStatsCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 60, PresetColumns.FN_STATS_COMPARE,
|
||||||
PresetColumns.fnStatsGet));
|
PresetColumns.FN_STATS_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 25, PresetColumns.fnRarityCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("R", 25, PresetColumns.FN_RARITY_COMPARE,
|
||||||
PresetColumns.fnRarityGet));
|
PresetColumns.FN_RARITY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
|
||||||
PresetColumns.fnAiStatusGet));
|
PresetColumns.FN_AI_STATUS_GET));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
|
|||||||
@@ -144,21 +144,21 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
// setupMenu();
|
// setupMenu();
|
||||||
|
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.FN_NAME_COMPARE,
|
||||||
PresetColumns.fnNameGet));
|
PresetColumns.FN_NAME_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.FN_COLOR_COMPARE,
|
||||||
PresetColumns.fnColorGet));
|
PresetColumns.FN_COLOR_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE,
|
||||||
PresetColumns.fnTypeGet));
|
PresetColumns.FN_TYPE_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.FN_STATS_COMPARE,
|
||||||
PresetColumns.fnStatsGet));
|
PresetColumns.FN_STATS_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.FN_RARITY_COMPARE,
|
||||||
PresetColumns.fnRarityGet));
|
PresetColumns.FN_RARITY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
|
||||||
PresetColumns.fnAiStatusGet));
|
PresetColumns.FN_AI_STATUS_GET));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
setDeck(cardpool, bottomPool, GameType.Quest);
|
setDeck(cardpool, bottomPool, GameType.Quest);
|
||||||
|
|
||||||
// this affects the card pool
|
// this affects the card pool
|
||||||
top.sort(4, true);// sort by type
|
top.sort(4, true); // sort by type
|
||||||
top.sort(3, true);// then sort by color
|
top.sort(3, true); // then sort by color
|
||||||
|
|
||||||
bottom.sort(1, true);
|
bottom.sort(1, true);
|
||||||
} // show(Command)
|
} // show(Command)
|
||||||
@@ -127,19 +127,19 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
|
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.FN_NAME_COMPARE,
|
||||||
PresetColumns.fnNameGet));
|
PresetColumns.FN_NAME_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.FN_COLOR_COMPARE,
|
||||||
PresetColumns.fnColorGet));
|
PresetColumns.FN_COLOR_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE,
|
||||||
PresetColumns.fnTypeGet));
|
PresetColumns.FN_TYPE_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.FN_STATS_COMPARE,
|
||||||
PresetColumns.fnStatsGet));
|
PresetColumns.FN_STATS_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.FN_RARITY_COMPARE,
|
||||||
PresetColumns.fnRarityGet));
|
PresetColumns.FN_RARITY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData
|
columns.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData
|
||||||
.getCards().fnNewGet));
|
.getCards().fnNewGet));
|
||||||
|
|
||||||
|
|||||||
@@ -203,22 +203,22 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
// creatures
|
// creatures
|
||||||
|
|
||||||
sb.append(String.format("%d Creatures%n-------------%n",
|
sb.append(String.format("%d Creatures%n-------------%n",
|
||||||
CardRules.Predicates.Presets.isCreature.aggregate(all, all.fnToCard, all.fnToCount)));
|
CardRules.Predicates.Presets.IS_CREATURE.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isCreature.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.IS_CREATURE.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// spells
|
// spells
|
||||||
sb.append(String.format("%d Spells%n----------%n",
|
sb.append(String.format("%d Spells%n----------%n",
|
||||||
CardRules.Predicates.Presets.isNonCreatureSpell.aggregate(all, all.fnToCard, all.fnToCount)));
|
CardRules.Predicates.Presets.IS_NON_CREATURE_SPELL.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isNonCreatureSpell.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.IS_NON_CREATURE_SPELL.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// lands
|
// lands
|
||||||
sb.append(String.format("%d Land%n--------%n",
|
sb.append(String.format("%d Land%n--------%n",
|
||||||
CardRules.Predicates.Presets.isLand.aggregate(all, all.fnToCard, all.fnToCount)));
|
CardRules.Predicates.Presets.IS_LAND.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isLand.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.IS_LAND.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import forge.quest.data.ReadPriceList;
|
|||||||
*/
|
*/
|
||||||
public final class DeckEditorShop extends DeckEditorBase {
|
public final class DeckEditorShop extends DeckEditorBase {
|
||||||
|
|
||||||
/** Constant <code>serialVersionUID=3988857075791576483L</code> */
|
/** Constant <code>serialVersionUID=3988857075791576483L</code>. */
|
||||||
private static final long serialVersionUID = 3988857075791576483L;
|
private static final long serialVersionUID = 3988857075791576483L;
|
||||||
|
|
||||||
private JButton buyButton = new JButton();
|
private JButton buyButton = new JButton();
|
||||||
@@ -139,19 +139,19 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
*/
|
*/
|
||||||
private void setup() {
|
private void setup() {
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.FN_NAME_COMPARE,
|
||||||
PresetColumns.fnNameGet));
|
PresetColumns.FN_NAME_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.FN_COLOR_COMPARE,
|
||||||
PresetColumns.fnColorGet));
|
PresetColumns.FN_COLOR_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE,
|
||||||
PresetColumns.fnTypeGet));
|
PresetColumns.FN_TYPE_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.FN_STATS_COMPARE,
|
||||||
PresetColumns.fnStatsGet));
|
PresetColumns.FN_STATS_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 30, PresetColumns.fnRarityCompare,
|
columns.add(new TableColumnInfo<InventoryItem>("R", 30, PresetColumns.FN_RARITY_COMPARE,
|
||||||
PresetColumns.fnRarityGet));
|
PresetColumns.FN_RARITY_GET));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 35, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 35, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
List<TableColumnInfo<InventoryItem>> columnsBelow = new ArrayList<TableColumnInfo<InventoryItem>>(columns);
|
List<TableColumnInfo<InventoryItem>> columnsBelow = new ArrayList<TableColumnInfo<InventoryItem>>(columns);
|
||||||
@@ -213,13 +213,13 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
sellButton.setText("Sell Card");
|
sellButton.setText("Sell Card");
|
||||||
sellButton.addActionListener(new java.awt.event.ActionListener() {
|
sellButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
sellButton_actionPerformed(e);
|
sellButtonActionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buyButton.setText("Buy Card");
|
buyButton.setText("Buy Card");
|
||||||
buyButton.addActionListener(new java.awt.event.ActionListener() {
|
buyButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
buyButton_actionPerformed(e);
|
buyButtonActionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
return 1337;
|
return 1337;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buyButton_actionPerformed(final ActionEvent e) {
|
private void buyButtonActionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = top.getSelectedCard();
|
InventoryItem item = top.getSelectedCard();
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return;
|
return;
|
||||||
@@ -325,7 +325,7 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
return Predicate.getTrue(InventoryItem.class);
|
return Predicate.getTrue(InventoryItem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sellButton_actionPerformed(final ActionEvent e) {
|
private void sellButtonActionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = bottom.getSelectedCard();
|
InventoryItem item = bottom.getSelectedCard();
|
||||||
if (item == null || !(item instanceof CardPrinted)) {
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -115,49 +115,49 @@ class FilterCheckBoxes {
|
|||||||
public final Predicate<CardPrinted> buildFilter() {
|
public final Predicate<CardPrinted> buildFilter() {
|
||||||
List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
|
List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
|
||||||
if (white.isSelected()) {
|
if (white.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isWhite);
|
colors.add(CardRules.Predicates.Presets.IS_WHITE);
|
||||||
}
|
}
|
||||||
if (blue.isSelected()) {
|
if (blue.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isBlue);
|
colors.add(CardRules.Predicates.Presets.IS_BLUE);
|
||||||
}
|
}
|
||||||
if (black.isSelected()) {
|
if (black.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isBlack);
|
colors.add(CardRules.Predicates.Presets.IS_BLACK);
|
||||||
}
|
}
|
||||||
if (red.isSelected()) {
|
if (red.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isRed);
|
colors.add(CardRules.Predicates.Presets.IS_RED);
|
||||||
}
|
}
|
||||||
if (green.isSelected()) {
|
if (green.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isGreen);
|
colors.add(CardRules.Predicates.Presets.IS_GREEN);
|
||||||
}
|
}
|
||||||
if (colorless.isSelected()) {
|
if (colorless.isSelected()) {
|
||||||
colors.add(CardRules.Predicates.Presets.isColorless);
|
colors.add(CardRules.Predicates.Presets.IS_COLORLESS);
|
||||||
}
|
}
|
||||||
Predicate<CardRules> filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.constantTrue : Predicate
|
Predicate<CardRules> filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.CONSTANT_TRUE : Predicate
|
||||||
.or(colors);
|
.or(colors);
|
||||||
|
|
||||||
List<Predicate<CardRules>> types = new ArrayList<Predicate<CardRules>>();
|
List<Predicate<CardRules>> types = new ArrayList<Predicate<CardRules>>();
|
||||||
if (land.isSelected()) {
|
if (land.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isLand);
|
types.add(CardRules.Predicates.Presets.IS_LAND);
|
||||||
}
|
}
|
||||||
if (creature.isSelected()) {
|
if (creature.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isCreature);
|
types.add(CardRules.Predicates.Presets.IS_CREATURE);
|
||||||
}
|
}
|
||||||
if (sorcery.isSelected()) {
|
if (sorcery.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isSorcery);
|
types.add(CardRules.Predicates.Presets.IS_SORCERY);
|
||||||
}
|
}
|
||||||
if (instant.isSelected()) {
|
if (instant.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isInstant);
|
types.add(CardRules.Predicates.Presets.IS_INSTANT);
|
||||||
}
|
}
|
||||||
if (planeswalker.isSelected()) {
|
if (planeswalker.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isPlaneswalker);
|
types.add(CardRules.Predicates.Presets.IS_PLANESWALKER);
|
||||||
}
|
}
|
||||||
if (artifact.isSelected()) {
|
if (artifact.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isArtifact);
|
types.add(CardRules.Predicates.Presets.IS_ARTIFACT);
|
||||||
}
|
}
|
||||||
if (enchantment.isSelected()) {
|
if (enchantment.isSelected()) {
|
||||||
types.add(CardRules.Predicates.Presets.isEnchantment);
|
types.add(CardRules.Predicates.Presets.IS_ENCHANTMENT);
|
||||||
}
|
}
|
||||||
Predicate<CardRules> filterByType = types.size() == 7 ? CardRules.Predicates.Presets.constantTrue : Predicate
|
Predicate<CardRules> filterByType = types.size() == 7 ? CardRules.Predicates.Presets.CONSTANT_TRUE : Predicate
|
||||||
.or(types);
|
.or(types);
|
||||||
|
|
||||||
return Predicate.brigde(Predicate.and(filterByColor, filterByType), CardPrinted.fnGetRules);
|
return Predicate.brigde(Predicate.and(filterByColor, filterByType), CardPrinted.fnGetRules);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class ManaCostRenderer extends DefaultTableCellRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CardManaCostShard s : shards) {
|
for (CardManaCostShard s : shards) {
|
||||||
ManaSymbols.drawSymbol(s.imageKey, g, (int) xpos, 1);
|
ManaSymbols.drawSymbol(s.getImageKey(), g, (int) xpos, 1);
|
||||||
xpos += offset;
|
xpos += offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import forge.item.InventoryItemFromSet;
|
|||||||
public abstract class PresetColumns {
|
public abstract class PresetColumns {
|
||||||
|
|
||||||
private static CardManaCost toManaCost(final InventoryItem i) {
|
private static CardManaCost toManaCost(final InventoryItem i) {
|
||||||
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : CardManaCost.empty;
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : CardManaCost.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CardColor toColor(final InventoryItem i) {
|
private static CardColor toColor(final InventoryItem i) {
|
||||||
@@ -36,7 +36,7 @@ public abstract class PresetColumns {
|
|||||||
|
|
||||||
private static CardSet toSetCmp(final InventoryItem i) {
|
private static CardSet toSetCmp(final InventoryItem i) {
|
||||||
return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet())
|
return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet())
|
||||||
: CardSet.unknown;
|
: CardSet.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toSetStr(final InventoryItem i) {
|
private static String toSetStr(final InventoryItem i) {
|
||||||
@@ -53,7 +53,7 @@ public abstract class PresetColumns {
|
|||||||
|
|
||||||
/** The Constant fnQtyCompare. */
|
/** The Constant fnQtyCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnQtyCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_QTY_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getValue();
|
return from.getValue();
|
||||||
@@ -61,7 +61,7 @@ public abstract class PresetColumns {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnQtyGet. */
|
/** The Constant fnQtyGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnQtyGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_QTY_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getValue();
|
return from.getValue();
|
||||||
@@ -70,7 +70,7 @@ public abstract class PresetColumns {
|
|||||||
|
|
||||||
/** The Constant fnNameCompare. */
|
/** The Constant fnNameCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNameCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_NAME_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getKey().getName();
|
return from.getKey().getName();
|
||||||
@@ -78,7 +78,7 @@ public abstract class PresetColumns {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnNameGet. */
|
/** The Constant fnNameGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnNameGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_NAME_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getKey().getName();
|
return from.getKey().getName();
|
||||||
@@ -87,41 +87,41 @@ public abstract class PresetColumns {
|
|||||||
|
|
||||||
/** The Constant fnCostCompare. */
|
/** The Constant fnCostCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnCostCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_COST_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toManaCost(from.getKey());
|
return PresetColumns.toManaCost(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnCostGet. */
|
/** The Constant fnCostGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnCostGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_COST_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toManaCost(from.getKey());
|
return PresetColumns.toManaCost(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnColorCompare. */
|
/** The Constant fnColorCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnColorCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_COLOR_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toColor(from.getKey());
|
return PresetColumns.toColor(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnColorGet. */
|
/** The Constant fnColorGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnColorGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_COLOR_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toColor(from.getKey());
|
return PresetColumns.toColor(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnTypeCompare. */
|
/** The Constant fnTypeCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnTypeCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_TYPE_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getKey().getType();
|
return from.getKey().getType();
|
||||||
@@ -129,7 +129,7 @@ public abstract class PresetColumns {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnTypeGet. */
|
/** The Constant fnTypeGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnTypeGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_TYPE_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return from.getKey().getType();
|
return from.getKey().getType();
|
||||||
@@ -138,69 +138,69 @@ public abstract class PresetColumns {
|
|||||||
|
|
||||||
/** The Constant fnStatsCompare. */
|
/** The Constant fnStatsCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnStatsCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_STATS_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toPTL(from.getKey());
|
return PresetColumns.toPTL(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnStatsGet. */
|
/** The Constant fnStatsGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnStatsGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_STATS_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toPTL(from.getKey());
|
return PresetColumns.toPTL(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnRarityCompare. */
|
/** The Constant fnRarityCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnRarityCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_RARITY_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toRarity(from.getKey());
|
return PresetColumns.toRarity(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnRarityGet. */
|
/** The Constant fnRarityGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnRarityGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_RARITY_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toRarity(from.getKey());
|
return PresetColumns.toRarity(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnSetCompare. */
|
/** The Constant fnSetCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnSetCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_SET_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toSetCmp(from.getKey());
|
return PresetColumns.toSetCmp(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnSetGet. */
|
/** The Constant fnSetGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnSetGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_SET_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toSetStr(from.getKey());
|
return PresetColumns.toSetStr(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnAiStatusCompare. */
|
/** The Constant fnAiStatusCompare. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnAiStatusCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> FN_AI_STATUS_COMPARE = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toAiCmp(from.getKey());
|
return PresetColumns.toAiCmp(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The Constant fnAiStatusGet. */
|
/** The Constant fnAiStatusGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnAiStatusGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> FN_AI_STATUS_GET = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return toAiStr(from.getKey());
|
return PresetColumns.toAiStr(from.getKey());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,14 +170,14 @@ public final class TableWithCards {
|
|||||||
*/
|
*/
|
||||||
public static String getStats(final ItemPoolView<InventoryItem> deck) {
|
public static String getStats(final ItemPoolView<InventoryItem> deck) {
|
||||||
int total = deck.countAll();
|
int total = deck.countAll();
|
||||||
int creature = CardRules.Predicates.Presets.isCreature.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
int creature = CardRules.Predicates.Presets.IS_CREATURE.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
||||||
int land = CardRules.Predicates.Presets.isLand.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
int land = CardRules.Predicates.Presets.IS_LAND.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
||||||
|
|
||||||
StringBuffer show = new StringBuffer();
|
StringBuffer show = new StringBuffer();
|
||||||
show.append("Total - ").append(total).append(", Creatures - ").append(creature).append(", Land - ")
|
show.append("Total - ").append(total).append(", Creatures - ").append(creature).append(", Land - ")
|
||||||
.append(land);
|
.append(land);
|
||||||
String[] color = Constant.Color.ONLY_COLORS;
|
String[] color = Constant.Color.ONLY_COLORS;
|
||||||
List<Predicate<CardRules>> predicates = CardRules.Predicates.Presets.colors;
|
List<Predicate<CardRules>> predicates = CardRules.Predicates.Presets.COLORS;
|
||||||
for (int i = 0; i < color.length; ++i) {
|
for (int i = 0; i < color.length; ++i) {
|
||||||
show.append(String.format(", %s - %d", color[i], predicates.get(i).count(deck, deck.fnToCard)));
|
show.append(String.format(", %s - %d", color[i], predicates.get(i).count(deck, deck.fnToCard)));
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ public final class TableWithCards {
|
|||||||
} else if (useFilter) {
|
} else if (useFilter) {
|
||||||
model.addCards(filter.select(pool, pool.fnToPrinted));
|
model.addCards(filter.select(pool, pool.fnToPrinted));
|
||||||
} else if (wantUnique) {
|
} else if (wantUnique) {
|
||||||
model.addCards(CardRules.Predicates.Presets.constantTrue.uniqueByLast(pool, pool.fnToCardName,
|
model.addCards(CardRules.Predicates.Presets.CONSTANT_TRUE.uniqueByLast(pool, pool.fnToCardName,
|
||||||
pool.fnToCard));
|
pool.fnToCard));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class BoosterPack implements InventoryItemFromSet {
|
|||||||
|
|
||||||
private CardPrinted getRandomBasicLand(final CardSet set) {
|
private CardPrinted getRandomBasicLand(final CardSet set) {
|
||||||
return Predicate.and(CardPrinted.Predicates.printedInSets(set.getCode()),
|
return Predicate.and(CardPrinted.Predicates.printedInSets(set.getCode()),
|
||||||
CardRules.Predicates.Presets.isBasicLand, CardPrinted.fnGetRules).random(
|
CardRules.Predicates.Presets.IS_BASIC_LAND, CardPrinted.fnGetRules).random(
|
||||||
CardDb.instance().getAllCards());
|
CardDb.instance().getAllCards());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,12 +267,12 @@ public final class QuestUtilCards {
|
|||||||
int winPacks = q.getWin() / 10;
|
int winPacks = q.getWin() / 10;
|
||||||
int totalPacks = Math.min(levelPacks + winPacks, 6);
|
int totalPacks = Math.min(levelPacks + winPacks, 6);
|
||||||
|
|
||||||
final Predicate<CardSet> filterExt = CardSet.Predicates.Presets.setsInExt;
|
final Predicate<CardSet> filterExt = CardSet.Predicates.Presets.SETS_IN_EXT;
|
||||||
final Predicate<CardSet> filterT2booster = Predicate.and(CardSet.Predicates.canMakeBooster,
|
final Predicate<CardSet> filterT2booster = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||||
CardSet.Predicates.Presets.setsInT2);
|
CardSet.Predicates.Presets.SETS_IN_STANDARD);
|
||||||
final Predicate<CardSet> filterExtButT2 = Predicate.and(CardSet.Predicates.canMakeBooster,
|
final Predicate<CardSet> filterExtButT2 = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||||
Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.setsInT2)));
|
Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.SETS_IN_STANDARD)));
|
||||||
final Predicate<CardSet> filterNotExt = Predicate.and(CardSet.Predicates.canMakeBooster,
|
final Predicate<CardSet> filterNotExt = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
|
||||||
Predicate.not(filterExt));
|
Predicate.not(filterExt));
|
||||||
|
|
||||||
q.shopList.clear();
|
q.shopList.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user