CardPrinted - getCard() field that returns CardRules instance is now known as getRules()

getRules() method from CardRules was renamed to getOracleText()
This commit is contained in:
Maxmtg
2013-02-18 08:28:35 +00:00
parent add7ab382a
commit 36f37b103c
32 changed files with 103 additions and 104 deletions

View File

@@ -2063,9 +2063,9 @@ public class Card extends GameEntity implements Comparable<Card> {
if (this.isType("Vanguard")) { if (this.isType("Vanguard")) {
final CardPrinted avatar = CardDb.getCard(this); final CardPrinted avatar = CardDb.getCard(this);
sb.append("Hand Modifier: "); sb.append("Hand Modifier: ");
sb.append(avatar.getCard().getHand()); sb.append(avatar.getRules().getHand());
sb.append("\r\nLife Modifier: "); sb.append("\r\nLife Modifier: ");
sb.append(avatar.getCard().getLife()); sb.append(avatar.getRules().getLife());
sb.append("\r\n\r\n"); sb.append("\r\n\r\n");
} }
sb.append(this.getAbilityText()); sb.append(this.getAbilityText());

View File

@@ -183,7 +183,7 @@ public final class CardUtil {
* @return the string * @return the string
*/ */
public static String buildFilename(final CardPrinted card) { public static String buildFilename(final CardPrinted card) {
final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount(); final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount();
return CardUtil.buildFilename(card.getName(), card.getEdition(), card.getArtIndex(), maxIndex, false); return CardUtil.buildFilename(card.getName(), card.getEdition(), card.getArtIndex(), maxIndex, false);
} }
@@ -197,7 +197,7 @@ public final class CardUtil {
* @return the string * @return the string
*/ */
public static String buildFilename(final CardPrinted card, final String nameToUse) { public static String buildFilename(final CardPrinted card, final String nameToUse) {
final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount(); final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount();
return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false); return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false);
} }

View File

@@ -301,14 +301,14 @@ public class BoosterGenerator {
} }
private void addToRarity(final CardPrinted c) { private void addToRarity(final CardPrinted c) {
if (c.getCard().isAltState()) { if (c.getRules().isAltState()) {
return; return;
} }
Map<CardRarity, List<CardPrinted>> targetList = c.getCard().isDoubleFaced() ? twoFacedByRarity : singleFacedByRarity; Map<CardRarity, List<CardPrinted>> targetList = c.getRules().isDoubleFaced() ? twoFacedByRarity : singleFacedByRarity;
targetList.get(c.getRarity()).add(c); targetList.get(c.getRarity()).add(c);
if (!c.getCard().getType().isBasicLand()) { if (!c.getRules().getType().isBasicLand()) {
this.allButLands.add(c); this.allButLands.add(c);
} }
} }

View File

@@ -32,7 +32,7 @@ public class CardRuleCharacteristics {
private SpellManaCost manaCost = SpellManaCost.NO_COST; private SpellManaCost manaCost = SpellManaCost.NO_COST;
private ColorSet color = null; private ColorSet color = null;
private String ptLine = null; private String ptLine = null;
private String[] cardRules = null; private String oracleText = null;
private Map<String, CardInSet> setsData = new TreeMap<String, CardInSet>(); private Map<String, CardInSet> setsData = new TreeMap<String, CardInSet>();
private String dlUrl; private String dlUrl;
private DeckHints deckHints; private DeckHints deckHints;
@@ -140,8 +140,8 @@ public class CardRuleCharacteristics {
* *
* @return the cardRules * @return the cardRules
*/ */
public final String[] getCardRules() { public final String getOracleText() {
return this.cardRules; return this.oracleText;
} }
/** /**
@@ -150,8 +150,8 @@ public class CardRuleCharacteristics {
* @param cardRules0 * @param cardRules0
* the cardRules to set * the cardRules to set
*/ */
public final void setCardRules(final String[] cardRules0) { public final void setCardRules(final String cardRules0) {
this.cardRules = cardRules0; this.oracleText = cardRules0;
} }
/** /**

View File

@@ -104,8 +104,8 @@ public final class CardRules {
* *
* @return the rules * @return the rules
*/ */
public String[] getRules() { public String getOracleText() {
return this.characteristics.getCardRules(); return this.characteristics.getOracleText();
} }
/** /**
@@ -285,13 +285,12 @@ public final class CardRules {
* @return true, if successful * @return true, if successful
*/ */
public boolean rulesContain(final String text) { public boolean rulesContain(final String text) {
if (this.characteristics.getCardRules() == null) { if (this.characteristics.getOracleText() == null) {
return false; return false;
} }
for (final String r : this.characteristics.getCardRules()) {
if (StringUtils.containsIgnoreCase(r, text)) { if (StringUtils.containsIgnoreCase(this.characteristics.getOracleText(), text)) {
return true; return true;
}
} }
return false; return false;
} }

View File

@@ -152,7 +152,7 @@ public class CardRulesReader {
case 'O': case 'O':
if (line.startsWith("Oracle:")) { if (line.startsWith("Oracle:")) {
this.characteristics[this.curCharacteristics].setCardRules(CardRulesReader this.characteristics[this.curCharacteristics].setCardRules(CardRulesReader
.getValueAfterKey(line, "Oracle:").split("\\n")); .getValueAfterKey(line, "Oracle:"));
} }
break; break;

View File

@@ -199,7 +199,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
"([A-Z0-9][A-Z0-9][A-Z0-9] [CURM], )*[A-Z0-9][A-Z0-9][A-Z0-9] [CURM]", nextline)) { "([A-Z0-9][A-Z0-9][A-Z0-9] [CURM], )*[A-Z0-9][A-Z0-9][A-Z0-9] [CURM]", nextline)) {
rules.add(nextline); rules.add(nextline);
} }
ret.setCardRules(rules.toArray(new String[rules.size()])); ret.setCardRules(StringUtils.join(rules, '\n'));
return nextline; return nextline;
} }

View File

@@ -227,7 +227,7 @@ public class CardFactory {
public final Card getCard(final CardPrinted cp, final Player owner) { public final Card getCard(final CardPrinted cp, final Player owner) {
//System.out.println(cardName); //System.out.println(cardName);
Card c = this.getCard2(cp.getCard().getCardScript(), owner); Card c = this.getCard2(cp.getRules().getCardScript(), owner);
if (c != null) { if (c != null) {
c.setCurSetCode(cp.getEdition()); c.setCurSetCode(cp.getEdition());

View File

@@ -203,9 +203,9 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
// I used to store planes and schemes under sideboard header, so this will assign them to a correct section // I used to store planes and schemes under sideboard header, so this will assign them to a correct section
CardPrinted sample = pool.get(0); CardPrinted sample = pool.get(0);
if ( sample != null && ( sample.getCard().getType().isPlane() || sample.getCard().getType().isPhenomenon() ) ) if ( sample != null && ( sample.getRules().getType().isPlane() || sample.getRules().getType().isPhenomenon() ) )
sec = DeckSection.Planes; sec = DeckSection.Planes;
if ( sample != null && sample.getCard().getType().isScheme() ) if ( sample != null && sample.getRules().getType().isScheme() )
sec = DeckSection.Schemes; sec = DeckSection.Schemes;
d.parts.put(sec, pool); d.parts.put(sec, pool);
@@ -300,7 +300,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
public boolean apply(Deck d) { public boolean apply(Deck d) {
for(Entry<DeckSection, CardPool> cp: d) { for(Entry<DeckSection, CardPool> cp: d) {
for(Entry<CardPrinted, Integer> e : cp.getValue()) { for(Entry<CardPrinted, Integer> e : cp.getValue()) {
if ( e.getKey().getCard().getRemAIDecks() ) if ( e.getKey().getRules().getRemAIDecks() )
return false; return false;
} }
} }

View File

@@ -136,7 +136,7 @@ public enum DeckFormat {
if (null == cmd || cmd.isEmpty()) { if (null == cmd || cmd.isEmpty()) {
return "is missing a commander"; return "is missing a commander";
} }
if (!cmd.get(0).getCard().getType().isLegendary()) { if (!cmd.get(0).getRules().getType().isLegendary()) {
return "has a commander that is not a legendary creature"; return "has a commander that is not a legendary creature";
} }
@@ -152,7 +152,7 @@ public enum DeckFormat {
int phenoms = 0; int phenoms = 0;
for (Entry<CardPrinted, Integer> cp : planes) { for (Entry<CardPrinted, Integer> cp : planes) {
if (cp.getKey().getCard().getType().typeContains(CardCoreType.Phenomenon)) { if (cp.getKey().getRules().getType().typeContains(CardCoreType.Phenomenon)) {
phenoms++; phenoms++;
} }
if (cp.getValue() > 1) { if (cp.getValue() > 1) {
@@ -197,7 +197,7 @@ public enum DeckFormat {
for (Entry<String, Integer> cp : Aggregates.groupSumBy(tmp, CardPrinted.FN_GET_NAME)) { for (Entry<String, Integer> cp : Aggregates.groupSumBy(tmp, CardPrinted.FN_GET_NAME)) {
CardPrinted simpleCard = CardDb.instance().getCard(cp.getKey()); CardPrinted simpleCard = CardDb.instance().getCard(cp.getKey());
boolean canHaveMultiple = simpleCard.getCard().getType().isBasicLand() || limitExceptions.contains(cp.getKey()); boolean canHaveMultiple = simpleCard.getRules().getType().isBasicLand() || limitExceptions.contains(cp.getKey());
if (!canHaveMultiple && cp.getValue() > maxCopies) { if (!canHaveMultiple && cp.getValue() > maxCopies) {
return String.format("must not contain more than %d of '%s' card", maxCopies, cp.getKey()); return String.format("must not contain more than %d of '%s' card", maxCopies, cp.getKey());

View File

@@ -315,7 +315,7 @@ public class DeckgenUtil {
CardPool schemes = new CardPool(); CardPool schemes = new CardPool();
List<CardPrinted> allSchemes = new ArrayList<CardPrinted>(); List<CardPrinted> allSchemes = new ArrayList<CardPrinted>();
for (CardPrinted c : CardDb.variants().getAllCards()) { for (CardPrinted c : CardDb.variants().getAllCards()) {
if (c.getCard().getType().isScheme()) { if (c.getRules().getType().isScheme()) {
allSchemes.add(c); allSchemes.add(c);
} }
} }
@@ -340,7 +340,7 @@ public class DeckgenUtil {
CardPool res = new CardPool(); CardPool res = new CardPool();
List<CardPrinted> allPlanars = new ArrayList<CardPrinted>(); List<CardPrinted> allPlanars = new ArrayList<CardPrinted>();
for (CardPrinted c : CardDb.variants().getAllCards()) { for (CardPrinted c : CardDb.variants().getAllCards()) {
if (c.getCard().getType().isPlane() || c.getCard().getType().isPhenomenon()) { if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
allPlanars.add(c); allPlanars.add(c);
} }
} }
@@ -352,12 +352,12 @@ public class DeckgenUtil {
CardPrinted rndPlane = Aggregates.random(allPlanars); CardPrinted rndPlane = Aggregates.random(allPlanars);
allPlanars.remove(rndPlane); allPlanars.remove(rndPlane);
if(rndPlane.getCard().getType().isPhenomenon() && phenoms < 2) if(rndPlane.getRules().getType().isPhenomenon() && phenoms < 2)
{ {
res.add(rndPlane); res.add(rndPlane);
phenoms++; phenoms++;
} }
else if (rndPlane.getCard().getType().isPlane()) else if (rndPlane.getRules().getType().isPlane())
{ {
res.add(rndPlane); res.add(rndPlane);
} }

View File

@@ -114,10 +114,10 @@ public abstract class GenerateColoredDeckBase {
throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Cr12"); throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Cr12");
} }
tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getCard().getSetsPrinted()).getKey())); tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getRules().getSetsPrinted()).getKey()));
final int n = this.cardCounts.get(cp.getName()); final int n = this.cardCounts.get(cp.getName());
this.cardCounts.put(cp.getName(), n + 1); this.cardCounts.put(cp.getName(), n + 1);
tmpDeck.append(cp.getName() + " " + cp.getCard().getManaCost() + "\n"); tmpDeck.append(cp.getName() + " " + cp.getRules().getManaCost() + "\n");
} }
} }
@@ -133,7 +133,7 @@ public abstract class GenerateColoredDeckBase {
// not an error if looped too much - could play singleton mode, with 6 slots for 3 non-basic lands. // not an error if looped too much - could play singleton mode, with 6 slots for 3 non-basic lands.
CardPrinted cp = CardDb.instance().getCard(s); CardPrinted cp = CardDb.instance().getCard(s);
tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getCard().getSetsPrinted()).getKey())); tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getRules().getSetsPrinted()).getKey()));
final int n = this.cardCounts.get(s); final int n = this.cardCounts.get(s);
this.cardCounts.put(s, n + 1); this.cardCounts.put(s, n + 1);
@@ -169,7 +169,7 @@ public abstract class GenerateColoredDeckBase {
this.cardCounts.put(color, nLand); this.cardCounts.put(color, nLand);
CardPrinted cp = CardDb.instance().getCard(color); CardPrinted cp = CardDb.instance().getCard(color);
String basicLandSet = Aggregates.random(cp.getCard().getSetsPrinted()).getKey(); String basicLandSet = Aggregates.random(cp.getRules().getSetsPrinted()).getKey();
for (int j = 0; j <= nLand; j++) { for (int j = 0; j <= nLand; j++) {
tDeck.add(CardDb.instance().getCard(cp.getName(), basicLandSet)); tDeck.add(CardDb.instance().getCard(cp.getName(), basicLandSet));
} }
@@ -236,7 +236,7 @@ public abstract class GenerateColoredDeckBase {
// TODO: count hybrid mana differently? // TODO: count hybrid mana differently?
for (Entry<CardPrinted, Integer> cpe : outList) { for (Entry<CardPrinted, Integer> cpe : outList) {
int profile = cpe.getKey().getCard().getManaCost().getColorProfile(); int profile = cpe.getKey().getRules().getManaCost().getColorProfile();
if ((profile & MagicColor.WHITE) != 0) { if ((profile & MagicColor.WHITE) != 0) {
increment(res, Constant.Color.BASIC_LANDS.get(0), cpe.getValue()); increment(res, Constant.Color.BASIC_LANDS.get(0), cpe.getValue());

View File

@@ -149,7 +149,7 @@ public class DeckSerializer extends StorageReaderFolder<Deck> implements IItemSe
for (final Entry<CardPrinted, Integer> card : d.getMain()) { for (final Entry<CardPrinted, Integer> card : d.getMain()) {
// System.out.println(card.getSets().get(card.getSets().size() - 1).URL); // System.out.println(card.getSets().get(card.getSets().size() - 1).URL);
for( int i = card.getValue().intValue(); i > 0; --i ) { for( int i = card.getValue().intValue(); i > 0; --i ) {
list.add(card.getKey().getCard().getEditionInfo(card.getKey().getEdition()).getUrl()); list.add(card.getKey().getRules().getEditionInfo(card.getKey().getEdition()).getUrl());
} }
} }
/* /*

View File

@@ -60,7 +60,7 @@ public class GameNew {
// apply random pictures for cards // apply random pictures for cards
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_CARD_ART)) { if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_CARD_ART)) {
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount(); final int cntVariants = cardPrinted.getRules().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
if (cntVariants > 1) { if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1); card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
card.setImageFilename(CardUtil.buildFilename(card)); card.setImageFilename(CardUtil.buildFilename(card));
@@ -195,7 +195,7 @@ public class GameNew {
for ( Entry<DeckSection, CardPool> ds : toUse ) { for ( Entry<DeckSection, CardPool> ds : toUse ) {
for (Entry<CardPrinted, Integer> cp : ds.getValue()) { for (Entry<CardPrinted, Integer> cp : ds.getValue()) {
if ( cp.getKey().getCard().getRemAIDecks() ) if ( cp.getKey().getRules().getRemAIDecks() )
result.add(cp.getKey()); result.add(cp.getKey());
} }
} }
@@ -207,7 +207,7 @@ public class GameNew {
Set<CardPrinted> myRemovedAnteCards = new HashSet<CardPrinted>(); Set<CardPrinted> myRemovedAnteCards = new HashSet<CardPrinted>();
for ( Entry<DeckSection, CardPool> ds : toUse ) { for ( Entry<DeckSection, CardPool> ds : toUse ) {
for (Entry<CardPrinted, Integer> cp : ds.getValue()) { for (Entry<CardPrinted, Integer> cp : ds.getValue()) {
if ( cp.getKey().getCard().rulesContain(keywordToRemove) ) if ( cp.getKey().getRules().rulesContain(keywordToRemove) )
myRemovedAnteCards.add(cp.getKey()); myRemovedAnteCards.add(cp.getKey());
} }
} }

View File

@@ -28,8 +28,8 @@ public class MatchStartHelper {
PlayerStartConditions start = new PlayerStartConditions(deck); PlayerStartConditions start = new PlayerStartConditions(deck);
start.setStartingLife(start.getStartingLife() + avatar.getCard().getLife()); start.setStartingLife(start.getStartingLife() + avatar.getRules().getLife());
start.setStartingHand(start.getStartingHand() + avatar.getCard().getHand()); start.setStartingHand(start.getStartingHand() + avatar.getRules().getHand());
start.setCardsInCommand(Arrays.asList(avatar)); start.setCardsInCommand(Arrays.asList(avatar));
players.put(player, start); players.put(player, start);

View File

@@ -79,11 +79,11 @@ public class BoosterDraftAI {
for(Pair<CardPrinted, Double> p : rankedCards) { for(Pair<CardPrinted, Double> p : rankedCards) {
// If a card is not ai playable, somewhat decrease its rating // If a card is not ai playable, somewhat decrease its rating
if( p.getKey().getCard().getRemAIDecks() ) if( p.getKey().getRules().getRemAIDecks() )
p.setValue(p.getValue() + TAKE_BEST_THRESHOLD); p.setValue(p.getValue() + TAKE_BEST_THRESHOLD);
// if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating. // if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating.
if( !canAddMoreColors && !p.getKey().getCard().getManaCost().canBePaidWithAvaliable(currentChoice)) if( !canAddMoreColors && !p.getKey().getRules().getManaCost().canBePaidWithAvaliable(currentChoice))
p.setValue(p.getValue() + 10); p.setValue(p.getValue() + 10);
} }

View File

@@ -45,7 +45,7 @@ class DeckColors {
*/ */
public void addColorsOf(CardPrinted pickedCard) { public void addColorsOf(CardPrinted pickedCard) {
SpellManaCost colorsInCard = pickedCard.getCard().getManaCost(); SpellManaCost colorsInCard = pickedCard.getRules().getManaCost();
int colorsCanAdd = MagicColor.ALL_COLORS & ~getChosenColors().getColor(); int colorsCanAdd = MagicColor.ALL_COLORS & ~getChosenColors().getColor();
int colorsWantAdd = colorsInCard.getColorProfile() & colorsCanAdd; int colorsWantAdd = colorsInCard.getColorProfile() & colorsCanAdd;

View File

@@ -201,19 +201,19 @@ public class LimitedDeck {
System.out.println("DECK"); System.out.println("DECK");
for (CardPrinted c : deckList) { for (CardPrinted c : deckList) {
i++; i++;
System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString());
} }
i = 0; i = 0;
System.out.println("NOT PLAYABLE"); System.out.println("NOT PLAYABLE");
for (CardPrinted c : availableList) { for (CardPrinted c : availableList) {
i++; i++;
System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString());
} }
i = 0; i = 0;
System.out.println("NOT PICKED"); System.out.println("NOT PICKED");
for (CardPrinted c : getAiPlayables()) { for (CardPrinted c : getAiPlayables()) {
i++; i++;
System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString());
} }
} }
@@ -363,7 +363,7 @@ public class LimitedDeck {
// count each card color using mana costs // count each card color using mana costs
for (int i = 0; i < deckList.size(); i++) { for (int i = 0; i < deckList.size(); i++) {
final SpellManaCost mc = deckList.get(i).getCard().getManaCost(); final SpellManaCost mc = deckList.get(i).getRules().getManaCost();
// count each mana symbol in the mana cost // count each mana symbol in the mana cost
for (ManaCostShard shard : mc.getShards()) { for (ManaCostShard shard : mc.getShards()) {
@@ -428,7 +428,7 @@ public class LimitedDeck {
List<Pair<Double, CardPrinted>> ranked = rankCards(others); List<Pair<Double, CardPrinted>> ranked = rankCards(others);
for (Pair<Double, CardPrinted> bean : ranked) { for (Pair<Double, CardPrinted> bean : ranked) {
// Want a card that has just one "off" color. // Want a card that has just one "off" color.
ColorSet off = colors.getOffColors(bean.getValue().getCard().getColor()); ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor());
if (off.isWhite() || off.isBlue() || off.isBlack() || off.isRed() || off.isGreen()) { if (off.isWhite() || off.isBlue() || off.isBlack() || off.isRed() || off.isGreen()) {
colors = ColorSet.fromMask(colors.getColor() | off.getColor()); colors = ColorSet.fromMask(colors.getColor() | off.getColor());
break; break;
@@ -447,7 +447,7 @@ public class LimitedDeck {
nCards--; nCards--;
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println("Third Color[" + nCards + "]:" + bean.getValue().getName() + "(" System.out.println("Third Color[" + nCards + "]:" + bean.getValue().getName() + "("
+ bean.getValue().getCard().getManaCost() + ")"); + bean.getValue().getRules().getManaCost() + ")");
} }
} else { } else {
break; break;
@@ -472,7 +472,7 @@ public class LimitedDeck {
nCards--; nCards--;
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println("Random[" + nCards + "]:" + bean.getValue().getName() + "(" System.out.println("Random[" + nCards + "]:" + bean.getValue().getName() + "("
+ bean.getValue().getCard().getManaCost() + ")"); + bean.getValue().getRules().getManaCost() + ")");
} }
} else { } else {
break; break;
@@ -496,7 +496,7 @@ public class LimitedDeck {
getAiPlayables().remove(cardToAdd); getAiPlayables().remove(cardToAdd);
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println("Others[" + num + "]:" + cardToAdd.getName() + " (" System.out.println("Others[" + num + "]:" + cardToAdd.getName() + " ("
+ cardToAdd.getCard().getManaCost() + ")"); + cardToAdd.getRules().getManaCost() + ")");
} }
num = addDeckHintsCards(cardToAdd, num); num = addDeckHintsCards(cardToAdd, num);
} else { } else {
@@ -516,9 +516,9 @@ public class LimitedDeck {
*/ */
private int addDeckHintsCards(CardPrinted cardToAdd, int num) { private int addDeckHintsCards(CardPrinted cardToAdd, int num) {
// cards with DeckHints will try to grab additional cards from the pool // cards with DeckHints will try to grab additional cards from the pool
if (cardToAdd.getCard().getDeckHints() != null if (cardToAdd.getRules().getDeckHints() != null
&& cardToAdd.getCard().getDeckHints().getType() != DeckHints.Type.NONE) { && cardToAdd.getRules().getDeckHints().getType() != DeckHints.Type.NONE) {
DeckHints hints = cardToAdd.getCard().getDeckHints(); DeckHints hints = cardToAdd.getRules().getDeckHints();
Iterable<CardPrinted> onColor = Iterables.filter(aiPlayables, Iterable<CardPrinted> onColor = Iterables.filter(aiPlayables,
Predicates.compose(hasColor, CardPrinted.FN_GET_RULES)); Predicates.compose(hasColor, CardPrinted.FN_GET_RULES));
List<CardPrinted> comboCards = hints.filter(onColor); List<CardPrinted> comboCards = hints.filter(onColor);
@@ -557,16 +557,16 @@ public class LimitedDeck {
int numOthers = 0; int numOthers = 0;
for (ListIterator<CardPrinted> it = deckList.listIterator(); it.hasNext();) { for (ListIterator<CardPrinted> it = deckList.listIterator(); it.hasNext();) {
CardPrinted card = it.next(); CardPrinted card = it.next();
if (card.getCard().getRemRandomDecks()) { if (card.getRules().getRemRandomDecks()) {
List<CardPrinted> comboCards = new ArrayList<CardPrinted>(); List<CardPrinted> comboCards = new ArrayList<CardPrinted>();
if (card.getCard().getDeckNeeds() != null if (card.getRules().getDeckNeeds() != null
&& card.getCard().getDeckNeeds().getType() != DeckHints.Type.NONE) { && card.getRules().getDeckNeeds().getType() != DeckHints.Type.NONE) {
DeckHints needs = card.getCard().getDeckNeeds(); DeckHints needs = card.getRules().getDeckNeeds();
comboCards.addAll(needs.filter(deckList)); comboCards.addAll(needs.filter(deckList));
} }
if (card.getCard().getDeckHints() != null if (card.getRules().getDeckHints() != null
&& card.getCard().getDeckHints().getType() != DeckHints.Type.NONE) { && card.getRules().getDeckHints().getType() != DeckHints.Type.NONE) {
DeckHints hints = card.getCard().getDeckHints(); DeckHints hints = card.getRules().getDeckHints();
comboCards.addAll(hints.filter(deckList)); comboCards.addAll(hints.filter(deckList));
} }
if (comboCards.isEmpty()) { if (comboCards.isEmpty()) {
@@ -575,7 +575,7 @@ public class LimitedDeck {
} }
it.remove(); it.remove();
availableList.add(card); availableList.add(card);
if (card.getCard().getType().isCreature()) { if (card.getRules().getType().isCreature()) {
numCreatures++; numCreatures++;
} else { } else {
numOthers++; numOthers++;
@@ -616,7 +616,7 @@ public class LimitedDeck {
num--; num--;
getAiPlayables().remove(c); getAiPlayables().remove(c);
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")"); System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getRules().getManaCost() + ")");
} }
num = addDeckHintsCards(c, num); num = addDeckHintsCards(c, num);
} else { } else {
@@ -642,7 +642,7 @@ public class LimitedDeck {
Predicate<CardPrinted> filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, Predicate<CardPrinted> filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE,
CardPrinted.FN_GET_RULES); CardPrinted.FN_GET_RULES);
for (CardPrinted creature : Iterables.filter(deckList, filter)) { for (CardPrinted creature : Iterables.filter(deckList, filter)) {
int cmc = creature.getCard().getManaCost().getCMC(); int cmc = creature.getRules().getManaCost().getCMC();
if (cmc < 1) { if (cmc < 1) {
cmc = 1; cmc = 1;
} else if (cmc > 6) { } else if (cmc > 6) {
@@ -653,7 +653,7 @@ public class LimitedDeck {
for (Pair<Double, CardPrinted> bean : creatures) { for (Pair<Double, CardPrinted> bean : creatures) {
CardPrinted c = bean.getValue(); CardPrinted c = bean.getValue();
int cmc = c.getCard().getManaCost().getCMC(); int cmc = c.getRules().getManaCost().getCMC();
if (cmc < 1) { if (cmc < 1) {
cmc = 1; cmc = 1;
} else if (cmc > 6) { } else if (cmc > 6) {
@@ -681,12 +681,12 @@ public class LimitedDeck {
getAiPlayables().remove(c); getAiPlayables().remove(c);
creatureCosts.put(cmc, creatureCosts.get(cmc) + 1); creatureCosts.put(cmc, creatureCosts.get(cmc) + 1);
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")"); System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getRules().getManaCost() + ")");
} }
num = addDeckHintsCards(c, num); num = addDeckHintsCards(c, num);
} else { } else {
if (Preferences.DEV_MODE) { if (Preferences.DEV_MODE) {
System.out.println(c.getName() + " not added because CMC " + c.getCard().getManaCost().getCMC() System.out.println(c.getName() + " not added because CMC " + c.getRules().getManaCost().getCMC()
+ " has " + currentAtCmc + " already."); + " has " + currentAtCmc + " already.");
} }
} }
@@ -727,7 +727,7 @@ public class LimitedDeck {
private double getAverageCMC(List<CardPrinted> cards) { private double getAverageCMC(List<CardPrinted> cards) {
double sum = 0.0; double sum = 0.0;
for (CardPrinted cardPrinted : cards) { for (CardPrinted cardPrinted : cards) {
sum += cardPrinted.getCard().getManaCost().getCMC(); sum += cardPrinted.getRules().getManaCost().getCMC();
} }
return sum / cards.size(); return sum / cards.size();
} }

View File

@@ -48,7 +48,7 @@ public class SealedDeck extends LimitedDeck {
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
CardPrinted cp = rankedCards.get(i).getValue(); CardPrinted cp = rankedCards.get(i).getValue();
colorChooserList.add(cp); colorChooserList.add(cp);
System.out.println(cp.getName() + " " + cp.getCard().getManaCost().toString()); System.out.println(cp.getName() + " " + cp.getRules().getManaCost().toString());
} }
Iterable<CardRules> rules = Iterables.transform(colorChooserList, CardPrinted.FN_GET_RULES); Iterable<CardRules> rules = Iterables.transform(colorChooserList, CardPrinted.FN_GET_RULES);

View File

@@ -501,7 +501,7 @@ public final class GuiMigrateLocalMWSSetPicturesHQ extends DefaultBoundedRangeMo
if (imgFN.equals("none") || (!imgFN.contains(edCode) && !imgFN.contains(setCode2))) { if (imgFN.equals("none") || (!imgFN.contains(edCode) && !imgFN.contains(setCode2))) {
imgFN = GuiDisplayUtil.cleanStringMWS(cp.getName()); imgFN = GuiDisplayUtil.cleanStringMWS(cp.getName());
final int maxIndex = cp.getCard().getEditionInfo(cp.getEdition()).getCopiesCount(); final int maxIndex = cp.getRules().getEditionInfo(cp.getEdition()).getCopiesCount();
String k = maxIndex > 1 ? Integer.valueOf(cp.getArtIndex() + 1).toString() : ""; String k = maxIndex > 1 ? Integer.valueOf(cp.getArtIndex() + 1).toString() : "";
final String fn = GuiDisplayUtil.cleanStringMWS(cp.getName()) + k + ".full.jpg"; final String fn = GuiDisplayUtil.cleanStringMWS(cp.getName()) + k + ".full.jpg";
final String destFn = imgBase + File.pathSeparator + edCode + File.pathSeparator + imgFN + k + ".jpg"; final String destFn = imgBase + File.pathSeparator + edCode + File.pathSeparator + imgFN + k + ".jpg";

View File

@@ -460,7 +460,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
List<Map.Entry<InventoryItem, Integer>> cardsToRemove = new LinkedList<Map.Entry<InventoryItem,Integer>>(); List<Map.Entry<InventoryItem, Integer>> cardsToRemove = new LinkedList<Map.Entry<InventoryItem,Integer>>();
for (Map.Entry<InventoryItem, Integer> item : getTableDeck().getCards()) { for (Map.Entry<InventoryItem, Integer> item : getTableDeck().getCards()) {
CardPrinted card = (CardPrinted)item.getKey(); CardPrinted card = (CardPrinted)item.getKey();
int numToKeep = card.getCard().getType().isBasic() ? 50 : 4; int numToKeep = card.getRules().getType().isBasic() ? 50 : 4;
if ("Relentless Rats".equals(card.getName())) { if ("Relentless Rats".equals(card.getName())) {
numToKeep = Integer.MAX_VALUE; numToKeep = Integer.MAX_VALUE;
} }

View File

@@ -101,7 +101,7 @@ public enum CStatistics implements ICDoc {
int tmc = 0; int tmc = 0;
for (final Entry<CardPrinted, Integer> e : deck) { for (final Entry<CardPrinted, Integer> e : deck) {
final CardRules cardRules = e.getKey().getCard(); final CardRules cardRules = e.getKey().getRules();
final int count = e.getValue(); final int count = e.getValue();
final int cmc = cardRules.getManaCost().getCMC(); final int cmc = cardRules.getManaCost().getCMC();

View File

@@ -307,19 +307,19 @@ public final class SColumnUtil {
private static final Pattern AE_FINDER = Pattern.compile("AE", Pattern.LITERAL); private static final Pattern AE_FINDER = Pattern.compile("AE", Pattern.LITERAL);
private static SpellManaCost toManaCost(final InventoryItem i) { private static SpellManaCost toManaCost(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : SpellManaCost.NO_COST; return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getManaCost() : SpellManaCost.NO_COST;
} }
private static ColorSet toColor(final InventoryItem i) { private static ColorSet toColor(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getColor() : ColorSet.getNullColor(); return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getColor() : ColorSet.getNullColor();
} }
private static Integer toPower(final InventoryItem i) { private static Integer toPower(final InventoryItem i) {
Integer result = -1; Integer result = -1;
if (i instanceof CardPrinted) { if (i instanceof CardPrinted) {
result = ((CardPrinted) i).getCard().getIntPower(); result = ((CardPrinted) i).getRules().getIntPower();
if (result == null) { if (result == null) {
result = Integer.valueOf(((CardPrinted) i).getCard().getLoyalty()); result = Integer.valueOf(((CardPrinted) i).getRules().getLoyalty());
if (result == null) { result = -1; } if (result == null) { result = -1; }
} }
} }
@@ -327,11 +327,11 @@ public final class SColumnUtil {
} }
private static Integer toToughness(final InventoryItem i) { private static Integer toToughness(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getIntToughness() : -1; return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getIntToughness() : -1;
} }
private static Integer toCMC(final InventoryItem i) { private static Integer toCMC(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost().getCMC() : -1; return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getManaCost().getCMC() : -1;
} }
private static CardRarity toRarity(final InventoryItem i) { private static CardRarity toRarity(final InventoryItem i) {
@@ -348,11 +348,11 @@ public final class SColumnUtil {
} }
private static Integer toAiCmp(final InventoryItem i) { private static Integer toAiCmp(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatusComparable() : Integer.valueOf(-1); return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getAiStatusComparable() : Integer.valueOf(-1);
} }
private static String toAiStr(final InventoryItem i) { private static String toAiStr(final InventoryItem i) {
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatus() : "n/a"; return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getAiStatus() : "n/a";
} }
//========== //==========
@@ -427,7 +427,7 @@ public final class SColumnUtil {
@Override @Override
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) { public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
InventoryItem i = from.getKey(); InventoryItem i = from.getKey();
return i instanceof CardPrinted ? ((CardPrinted)i).getCard().getType().toString() : i.getItemType(); return i instanceof CardPrinted ? ((CardPrinted)i).getRules().getType().toString() : i.getItemType();
} }
}; };
@@ -436,7 +436,7 @@ public final class SColumnUtil {
@Override @Override
public Object apply(final Entry<InventoryItem, Integer> from) { public Object apply(final Entry<InventoryItem, Integer> from) {
InventoryItem i = from.getKey(); InventoryItem i = from.getKey();
return i instanceof CardPrinted ? ((CardPrinted)i).getCard().getType().toString() : i.getItemType(); return i instanceof CardPrinted ? ((CardPrinted)i).getRules().getType().toString() : i.getItemType();
} }
}; };

View File

@@ -64,7 +64,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloader {
for (final CardPrinted c : CardDb.instance().getUniqueCards()) { for (final CardPrinted c : CardDb.instance().getUniqueCards()) {
//System.out.println(c.getName()); //System.out.println(c.getName());
CardRules firstSide = c.getCard(); CardRules firstSide = c.getRules();
this.createDLObjects(firstSide); this.createDLObjects(firstSide);
CardRules secondSide = firstSide.getSlavePart(); CardRules secondSide = firstSide.getSlavePart();

View File

@@ -68,7 +68,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
final boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2); final boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2);
if (!foundSetImage) { if (!foundSetImage) {
final int artsCnt = c.getCard().getEditionInfo(setCode3).getCopiesCount(); final int artsCnt = c.getRules().getEditionInfo(setCode3).getCopiesCount();
final String filename = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt); final String filename = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
String url = urlBase + setCode2 + "/" + Base64Coder.encodeString(filename, true); String url = urlBase + setCode2 + "/" + Base64Coder.encodeString(filename, true);
cList.add(new DownloadObject(url, new File(this.picturesPath + File.separator + setCode3, filename))); cList.add(new DownloadObject(url, new File(this.picturesPath + File.separator + setCode3, filename)));
@@ -100,9 +100,9 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
continue; // we don't want cards from unknown sets continue; // we don't want cards from unknown sets
} }
this.addCardToList(cList, c, c.getCard().getName()); this.addCardToList(cList, c, c.getRules().getName());
if (c.getCard().isDoubleFaced()) { if (c.getRules().isDoubleFaced()) {
this.addCardToList(cList, c, c.getCard().getSlavePart().getName()); this.addCardToList(cList, c, c.getRules().getSlavePart().getName());
} }
} }

View File

@@ -69,7 +69,7 @@ public enum CSubmenuArchenemy implements ICDoc {
@Override @Override
public boolean apply(CardPrinted arg0) { public boolean apply(CardPrinted arg0) {
if(arg0.getCard().getType().isScheme()) if(arg0.getRules().getType().isScheme())
{ {
return true; return true;
} }

View File

@@ -68,7 +68,7 @@ public enum CSubmenuPlanechase implements ICDoc {
@Override @Override
public boolean apply(CardPrinted arg0) { public boolean apply(CardPrinted arg0) {
if(arg0.getCard().getType().isPlane() || arg0.getCard().getType().isPhenomenon()) if(arg0.getRules().getType().isPlane() || arg0.getRules().getType().isPhenomenon())
{ {
return true; return true;
} }

View File

@@ -95,13 +95,13 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
aiListData.add("Random"); aiListData.add("Random");
for (CardPrinted cp : getAllAvatars()) { for (CardPrinted cp : getAllAvatars()) {
humanListData.add(cp); humanListData.add(cp);
if (!cp.getCard().getRemRandomDecks()) { if (!cp.getRules().getRemRandomDecks()) {
nonRandomHumanAvatars.add(cp); nonRandomHumanAvatars.add(cp);
} }
if (!cp.getCard().getRemAIDecks()) { if (!cp.getRules().getRemAIDecks()) {
aiListData.add(cp); aiListData.add(cp);
allAiAvatars.add(cp); allAiAvatars.add(cp);
if (!cp.getCard().getRemRandomDecks()) { if (!cp.getRules().getRemRandomDecks()) {
nonRandomAiAvatars.add(cp); nonRandomAiAvatars.add(cp);
} }
} }
@@ -359,7 +359,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
public Iterable<CardPrinted> getAllAvatars() { public Iterable<CardPrinted> getAllAvatars() {
if ( allAvatars.isEmpty() ) { if ( allAvatars.isEmpty() ) {
for(CardPrinted c : CardDb.variants().getAllCards()) { for(CardPrinted c : CardDb.variants().getAllCards()) {
if( c.getCard().getType().isVanguard()) if( c.getRules().getType().isVanguard())
allAvatars.add(c); allAvatars.add(c);
} }
} }

View File

@@ -416,7 +416,7 @@ public final class CardDb {
for (final Entry<String, CardInSet> s : card.getSetsPrinted()) { for (final Entry<String, CardInSet> s : card.getSetsPrinted()) {
lastAdded = this.addToLists(card, cardName, s); lastAdded = this.addToLists(card, cardName, s);
} }
if ( lastAdded.getCard().isTraditional() ) if ( lastAdded.getRules().isTraditional() )
uniqueCommonCards.put(cardName, lastAdded); uniqueCommonCards.put(cardName, lastAdded);
else else
uniqueSpecialCards.put(cardName, lastAdded); uniqueSpecialCards.put(cardName, lastAdded);

View File

@@ -120,7 +120,7 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
* *
* @return the card * @return the card
*/ */
public CardRules getCard() { public CardRules getRules() {
return this.card; return this.card;
} }

View File

@@ -47,7 +47,7 @@ public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T,
@Override @Override
public CardRules apply(final Entry<T, Integer> from) { public CardRules apply(final Entry<T, Integer> from) {
final T item = from.getKey(); final T item = from.getKey();
return item instanceof CardPrinted ? ((CardPrinted) item).getCard() : null; return item instanceof CardPrinted ? ((CardPrinted) item).getRules() : null;
} }
}; };

View File

@@ -29,7 +29,7 @@ public class DeckHintsTest {
void test() { void test() {
CardPrinted cp = readCard("griffin_rider.txt"); CardPrinted cp = readCard("griffin_rider.txt");
Assert.assertEquals("Griffin Rider", cp.getName()); Assert.assertEquals("Griffin Rider", cp.getName());
DeckHints hints = cp.getCard().getDeckHints(); DeckHints hints = cp.getRules().getDeckHints();
Assert.assertNotNull(hints); Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.TYPE, hints.getType()); Assert.assertEquals(DeckHints.Type.TYPE, hints.getType());
@@ -50,7 +50,7 @@ public class DeckHintsTest {
void testCards() { void testCards() {
CardPrinted cp = readCard("throne_of_empires.txt"); CardPrinted cp = readCard("throne_of_empires.txt");
Assert.assertEquals("Throne of Empires", cp.getName()); Assert.assertEquals("Throne of Empires", cp.getName());
DeckHints hints = cp.getCard().getDeckHints(); DeckHints hints = cp.getRules().getDeckHints();
Assert.assertNotNull(hints); Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.NAME, hints.getType()); Assert.assertEquals(DeckHints.Type.NAME, hints.getType());
@@ -71,7 +71,7 @@ public class DeckHintsTest {
@Test(timeOut = 1000, enabled = true) @Test(timeOut = 1000, enabled = true)
void testKeywords() { void testKeywords() {
CardPrinted cp = readCard("mwonvuli_beast_tracker.txt"); CardPrinted cp = readCard("mwonvuli_beast_tracker.txt");
DeckHints hints = cp.getCard().getDeckHints(); DeckHints hints = cp.getRules().getDeckHints();
Assert.assertNotNull(hints); Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.KEYWORD, hints.getType()); Assert.assertEquals(DeckHints.Type.KEYWORD, hints.getType());
@@ -90,7 +90,7 @@ public class DeckHintsTest {
@Test(timeOut = 1000, enabled = true) @Test(timeOut = 1000, enabled = true)
void testColor() { void testColor() {
CardPrinted cp = readCard("wurms_tooth.txt"); CardPrinted cp = readCard("wurms_tooth.txt");
DeckHints hints = cp.getCard().getDeckNeeds(); DeckHints hints = cp.getRules().getDeckNeeds();
Assert.assertNotNull(hints); Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.COLOR, hints.getType()); Assert.assertEquals(DeckHints.Type.COLOR, hints.getType());
@@ -110,7 +110,7 @@ public class DeckHintsTest {
@Test(timeOut = 1000, enabled = false) @Test(timeOut = 1000, enabled = false)
void testNoFilter() { void testNoFilter() {
CardPrinted cp = readCard("assault_griffin.txt"); CardPrinted cp = readCard("assault_griffin.txt");
DeckHints hints = cp.getCard().getDeckHints(); DeckHints hints = cp.getRules().getDeckHints();
Assert.assertEquals("Assault Griffin", cp.getName()); Assert.assertEquals("Assault Griffin", cp.getName());
Assert.assertNotNull(hints); Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.NONE, hints.getType()); Assert.assertEquals(DeckHints.Type.NONE, hints.getType());