mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
moved cardFace and rules reader to core
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -29,6 +29,7 @@ forge-core/src/main/java/forge/card/CardCharacteristicName.java -text
|
||||
forge-core/src/main/java/forge/card/CardCoreType.java -text
|
||||
forge-core/src/main/java/forge/card/CardDb.java -text
|
||||
forge-core/src/main/java/forge/card/CardEdition.java -text
|
||||
forge-core/src/main/java/forge/card/CardFace.java -text
|
||||
forge-core/src/main/java/forge/card/CardRarity.java -text
|
||||
forge-core/src/main/java/forge/card/CardRules.java -text
|
||||
forge-core/src/main/java/forge/card/CardRulesPredicates.java -text
|
||||
@@ -14683,8 +14684,6 @@ forge-gui/src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plai
|
||||
forge-gui/src/main/java/forge/card/CardBlock.java -text
|
||||
forge-gui/src/main/java/forge/card/CardCharacteristics.java -text
|
||||
forge-gui/src/main/java/forge/card/CardEditionPredicates.java -text
|
||||
forge-gui/src/main/java/forge/card/CardFace.java -text
|
||||
forge-gui/src/main/java/forge/card/CardRulesReader.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/card/MetaSet.java -text
|
||||
forge-gui/src/main/java/forge/card/TriggerReplacementBase.java -text
|
||||
forge-gui/src/main/java/forge/card/UnOpenedMeta.java -text
|
||||
|
||||
@@ -18,7 +18,13 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.mana.IParserManaCost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
|
||||
/**
|
||||
* A collection of methods containing full
|
||||
@@ -37,7 +43,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
|
||||
private ColorSet colorIdentity = null;
|
||||
|
||||
public CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah) {
|
||||
private CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah) {
|
||||
splitType = altMode;
|
||||
mainPart = faces[0];
|
||||
otherPart = faces[1];
|
||||
@@ -219,4 +225,265 @@ public final class CardRules implements ICardCharacteristics {
|
||||
return colorIdentity;
|
||||
|
||||
}
|
||||
|
||||
/** Instantiates class, reads a card. For batch operations better create you own reader instance. */
|
||||
public static CardRules fromScript(Iterable<String> script) {
|
||||
Reader crr = new Reader();
|
||||
for(String line : script) {
|
||||
crr.parseLine(line);
|
||||
}
|
||||
return crr.getCard();
|
||||
}
|
||||
|
||||
// Reads cardname.txt
|
||||
public static class Reader {
|
||||
// fields to build
|
||||
private CardFace[] faces = new CardFace[] { null, null };
|
||||
private String[] pictureUrl = new String[] { null, null };
|
||||
private int curFace = 0;
|
||||
private CardSplitType altMode = CardSplitType.None;
|
||||
private String handLife = null;
|
||||
|
||||
// fields to build CardAiHints
|
||||
private boolean removedFromAIDecks = false;
|
||||
private boolean removedFromRandomDecks = false;
|
||||
private DeckHints hints = null;
|
||||
private DeckHints needs = null;
|
||||
|
||||
|
||||
/**
|
||||
* Reset all fields to parse next card (to avoid allocating new CardRulesReader N times)
|
||||
*/
|
||||
public final void reset() {
|
||||
this.curFace = 0;
|
||||
this.faces[0] = null;
|
||||
this.faces[1] = null;
|
||||
this.pictureUrl[0] = null;
|
||||
this.pictureUrl[1] = null;
|
||||
|
||||
this.handLife = null;
|
||||
this.altMode = CardSplitType.None;
|
||||
|
||||
this.removedFromAIDecks = false;
|
||||
this.removedFromRandomDecks = false;
|
||||
this.needs = null;
|
||||
this.hints = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card.
|
||||
*
|
||||
* @return the card
|
||||
*/
|
||||
public final CardRules getCard() {
|
||||
CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, hints, needs );
|
||||
faces[0].assignMissingFields();
|
||||
if (null != faces[1]) faces[1].assignMissingFields();
|
||||
final CardRules result = new CardRules(faces, altMode, cah);
|
||||
result.setDlUrls(pictureUrl);
|
||||
if (StringUtils.isNotBlank(handLife))
|
||||
result.setVanguardProperties(handLife);
|
||||
return result;
|
||||
}
|
||||
|
||||
public final CardRules readCard(final Iterable<String> script) {
|
||||
this.reset();
|
||||
for (String line : script) {
|
||||
if (line.isEmpty() || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
this.parseLine(line);
|
||||
}
|
||||
return this.getCard();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param line
|
||||
* the line
|
||||
*/
|
||||
public final void parseLine(final String line) {
|
||||
int colonPos = line.indexOf(':');
|
||||
String key = colonPos > 0 ? line.substring(0, colonPos) : line;
|
||||
String value = colonPos > 0 ? line.substring(1+colonPos).trim() : null;
|
||||
|
||||
switch(key.charAt(0)) {
|
||||
case 'A':
|
||||
if ("A".equals(key))
|
||||
this.faces[curFace].addAbility(value);
|
||||
else if ("AlternateMode".equals(key)) {
|
||||
//System.out.println(faces[curFace].getName());
|
||||
this.altMode = CardSplitType.smartValueOf(value);
|
||||
} else if ("ALTERNATE".equals(key)) {
|
||||
this.curFace = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if ("Colors".equals(key)) {
|
||||
// This is forge.card.CardColor not forge.CardColor.
|
||||
// Why do we have two classes with the same name?
|
||||
ColorSet newCol = ColorSet.fromNames(value.split(","));
|
||||
this.faces[this.curFace].setColor(newCol);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if ("DeckHints".equals(key)) {
|
||||
hints = new DeckHints(value);
|
||||
} else if ("DeckNeeds".equals(key)) {
|
||||
needs = new DeckHints(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
if ("HandLifeModifier".equals(key)) {
|
||||
handLife = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
if ("K".equals(key)) {
|
||||
this.faces[this.curFace].addKeyword(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if ("Loyalty".equals(key)) {
|
||||
this.faces[this.curFace].setInitialLoyalty(Integer.valueOf(value));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if ("ManaCost".equals(key)) {
|
||||
this.faces[this.curFace].setManaCost("no cost".equals(value) ? ManaCost.NO_COST
|
||||
: new ManaCost(new ManaCostParser(value)));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
if ("Name".equals(key)) {
|
||||
this.faces[this.curFace] = new CardFace(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
if ("Oracle".equals(key)) {
|
||||
this.faces[this.curFace].setOracleText(value);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
if ("PT".equals(key)) {
|
||||
this.faces[this.curFace].setPtText(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
if ("R".equals(key)) {
|
||||
this.faces[this.curFace].addReplacementEffect(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
if ("S".equals(key)) {
|
||||
this.faces[this.curFace].addStaticAbility(value);
|
||||
} else if ( "SVar".equals(key) ) {
|
||||
if ( null == value ) throw new IllegalArgumentException("SVar has no variable name");
|
||||
|
||||
colonPos = value.indexOf(':');
|
||||
String variable = colonPos > 0 ? value.substring(0, colonPos) : value;
|
||||
value = colonPos > 0 ? value.substring(1+colonPos) : null;
|
||||
|
||||
if ( "RemAIDeck".equals(variable) ) {
|
||||
this.removedFromAIDecks = "True".equalsIgnoreCase(value);
|
||||
} else if ( "RemRandomDeck".equals(variable) ) {
|
||||
this.removedFromRandomDecks = "True".equalsIgnoreCase(value);
|
||||
} else if ( "Picture".equals(variable) ) {
|
||||
this.pictureUrl[this.curFace] = value;
|
||||
} else if ( "Rarity".equals(variable) ) {
|
||||
// discard that, they should supply it in SetInfo
|
||||
} else
|
||||
this.faces[curFace].addSVar(variable, value);
|
||||
} else if ("SetInfo".equals(key)) {
|
||||
// deprecated
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if ("T".equals(key)) {
|
||||
this.faces[this.curFace].addTrigger(value);
|
||||
} else if ("Types".equals(key)) {
|
||||
this.faces[this.curFace].setType(CardType.parse(value));
|
||||
} else if ("Text".equals(key) && !"no text".equals(value) && StringUtils.isNotBlank(value)) {
|
||||
this.faces[this.curFace].setNonAbilityText(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ParserCardnameTxtManaCost.
|
||||
*/
|
||||
private static class ManaCostParser implements IParserManaCost {
|
||||
private final StringTokenizer st;
|
||||
private int colorlessCost;
|
||||
|
||||
public ManaCostParser(final String cost) {
|
||||
st = new StringTokenizer(cost, " ");
|
||||
this.colorlessCost = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getTotalColorlessCost() {
|
||||
if (this.hasNext()) {
|
||||
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
||||
}
|
||||
return this.colorlessCost;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasNext() {
|
||||
return st.hasMoreTokens();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
@Override
|
||||
public final ManaCostShard next() {
|
||||
|
||||
final String unparsed = st.nextToken();
|
||||
// System.out.println(unparsed);
|
||||
try {
|
||||
int iVal = Integer.parseInt(unparsed);
|
||||
this.colorlessCost += iVal;
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException nex) { }
|
||||
|
||||
return ManaCostShard.parseNonGeneric(unparsed);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
} // unsuported
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import forge.card.CardRules;
|
||||
*/
|
||||
public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFromSet, IPaperCard {
|
||||
// Reference to rules
|
||||
private final transient CardRules card;
|
||||
private final transient CardRules rules;
|
||||
|
||||
// These fields are kinda PK for PrintedCard
|
||||
public final String name;
|
||||
@@ -72,7 +72,7 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
||||
|
||||
@Override
|
||||
public CardRules getRules() {
|
||||
return this.card;
|
||||
return this.rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +100,7 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
||||
public static final Function<PaperCard, CardRules> FN_GET_RULES = new Function<PaperCard, CardRules>() {
|
||||
@Override
|
||||
public CardRules apply(final PaperCard from) {
|
||||
return from.card;
|
||||
return from.rules;
|
||||
}
|
||||
};
|
||||
public static final Function<PaperCard, String> FN_GET_NAME = new Function<PaperCard, String>() {
|
||||
@@ -117,7 +117,7 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
||||
public PaperCard(final CardRules c, final String edition0, final CardRarity rare, final int index, final boolean foil) {
|
||||
if ( edition0 == null || c == null || rare == null )
|
||||
throw new IllegalArgumentException("Cannot create card without rules, edition or rarity");
|
||||
this.card = c;
|
||||
this.rules = c;
|
||||
this.name = c.getName();
|
||||
this.edition = edition0;
|
||||
this.artIndex = index;
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.card;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.mana.IParserManaCost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* CardReader class.
|
||||
* </p>
|
||||
*
|
||||
* Forked from forge.CardReader at rev 10010.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CardRulesReader {
|
||||
// fields to build
|
||||
private CardFace[] faces = new CardFace[] { null, null };
|
||||
private String[] pictureUrl = new String[] { null, null };
|
||||
private int curFace = 0;
|
||||
private CardSplitType altMode = CardSplitType.None;
|
||||
private String handLife = null;
|
||||
|
||||
// fields to build CardAiHints
|
||||
private boolean removedFromAIDecks = false;
|
||||
private boolean removedFromRandomDecks = false;
|
||||
private DeckHints hints = null;
|
||||
private DeckHints needs = null;
|
||||
|
||||
|
||||
|
||||
// Reset all fields to parse next card (to avoid allocating new
|
||||
// CardRulesReader N times)
|
||||
/**
|
||||
* Reset.
|
||||
*/
|
||||
public final void reset() {
|
||||
this.curFace = 0;
|
||||
this.faces[0] = null;
|
||||
this.faces[1] = null;
|
||||
this.pictureUrl[0] = null;
|
||||
this.pictureUrl[1] = null;
|
||||
|
||||
this.handLife = null;
|
||||
this.altMode = CardSplitType.None;
|
||||
|
||||
this.removedFromAIDecks = false;
|
||||
this.removedFromRandomDecks = false;
|
||||
this.needs = null;
|
||||
this.hints = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the card.
|
||||
*
|
||||
* @return the card
|
||||
*/
|
||||
public final CardRules getCard() {
|
||||
CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, hints, needs );
|
||||
faces[0].assignMissingFields();
|
||||
if (null != faces[1]) faces[1].assignMissingFields();
|
||||
final CardRules result = new CardRules(faces, altMode, cah);
|
||||
result.setDlUrls(pictureUrl);
|
||||
if (StringUtils.isNotBlank(handLife))
|
||||
result.setVanguardProperties(handLife);
|
||||
return result;
|
||||
}
|
||||
|
||||
public final CardRules readCard(final Iterable<String> script) {
|
||||
this.reset();
|
||||
for (String line : script) {
|
||||
if (line.isEmpty() || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
this.parseLine(line);
|
||||
}
|
||||
return this.getCard();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param line
|
||||
* the line
|
||||
*/
|
||||
public final void parseLine(final String line) {
|
||||
int colonPos = line.indexOf(':');
|
||||
String key = colonPos > 0 ? line.substring(0, colonPos) : line;
|
||||
String value = colonPos > 0 ? line.substring(1+colonPos).trim() : null;
|
||||
|
||||
switch(key.charAt(0)) {
|
||||
case 'A':
|
||||
if ("A".equals(key))
|
||||
this.faces[curFace].addAbility(value);
|
||||
else if ("AlternateMode".equals(key)) {
|
||||
//System.out.println(faces[curFace].getName());
|
||||
this.altMode = CardSplitType.smartValueOf(value);
|
||||
} else if ("ALTERNATE".equals(key)) {
|
||||
this.curFace = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if ("Colors".equals(key)) {
|
||||
// This is forge.card.CardColor not forge.CardColor.
|
||||
// Why do we have two classes with the same name?
|
||||
ColorSet newCol = ColorSet.fromNames(value.split(","));
|
||||
this.faces[this.curFace].setColor(newCol);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if ("DeckHints".equals(key)) {
|
||||
hints = new DeckHints(value);
|
||||
} else if ("DeckNeeds".equals(key)) {
|
||||
needs = new DeckHints(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
if ("HandLifeModifier".equals(key)) {
|
||||
handLife = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
if ("K".equals(key)) {
|
||||
this.faces[this.curFace].addKeyword(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if ("Loyalty".equals(key)) {
|
||||
this.faces[this.curFace].setInitialLoyalty(Integer.valueOf(value));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if ("ManaCost".equals(key)) {
|
||||
this.faces[this.curFace].setManaCost("no cost".equals(value) ? ManaCost.NO_COST
|
||||
: new ManaCost(new ParserCardnameTxtManaCost(value)));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
if ("Name".equals(key)) {
|
||||
this.faces[this.curFace] = new CardFace(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
if ("Oracle".equals(key)) {
|
||||
this.faces[this.curFace].setOracleText(value);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
if ("PT".equals(key)) {
|
||||
this.faces[this.curFace].setPtText(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
if ("R".equals(key)) {
|
||||
this.faces[this.curFace].addReplacementEffect(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
if ("S".equals(key)) {
|
||||
this.faces[this.curFace].addStaticAbility(value);
|
||||
} else if ( "SVar".equals(key) ) {
|
||||
if ( null == value ) throw new IllegalArgumentException("SVar has no variable name");
|
||||
|
||||
colonPos = value.indexOf(':');
|
||||
String variable = colonPos > 0 ? value.substring(0, colonPos) : value;
|
||||
value = colonPos > 0 ? value.substring(1+colonPos) : null;
|
||||
|
||||
if ( "RemAIDeck".equals(variable) ) {
|
||||
this.removedFromAIDecks = "True".equalsIgnoreCase(value);
|
||||
} else if ( "RemRandomDeck".equals(variable) ) {
|
||||
this.removedFromRandomDecks = "True".equalsIgnoreCase(value);
|
||||
} else if ( "Picture".equals(variable) ) {
|
||||
this.pictureUrl[this.curFace] = value;
|
||||
} else if ( "Rarity".equals(variable) ) {
|
||||
// discard that, they should supply it in SetInfo
|
||||
} else
|
||||
this.faces[curFace].addSVar(variable, value);
|
||||
} else if ("SetInfo".equals(key)) {
|
||||
// deprecated
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if ("T".equals(key)) {
|
||||
this.faces[this.curFace].addTrigger(value);
|
||||
} else if ("Types".equals(key)) {
|
||||
this.faces[this.curFace].setType(CardType.parse(value));
|
||||
} else if ("Text".equals(key) && !"no text".equals(value) && StringUtils.isNotBlank(value)) {
|
||||
this.faces[this.curFace].setNonAbilityText(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates class, reads a card. Do not use for batch operations.
|
||||
* @param script
|
||||
* @return
|
||||
*/
|
||||
public static CardRules parseSingleCard(Iterable<String> script) {
|
||||
CardRulesReader crr = new CardRulesReader();
|
||||
for(String line : script) {
|
||||
crr.parseLine(line);
|
||||
}
|
||||
return crr.getCard();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ParserCardnameTxtManaCost.
|
||||
*/
|
||||
public static class ParserCardnameTxtManaCost implements IParserManaCost {
|
||||
private final StringTokenizer st;
|
||||
private int colorlessCost;
|
||||
|
||||
public ParserCardnameTxtManaCost(final String cost) {
|
||||
st = new StringTokenizer(cost, " ");
|
||||
this.colorlessCost = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getTotalColorlessCost() {
|
||||
if (this.hasNext()) {
|
||||
throw new RuntimeException("Colorless cost should be obtained after iteration is complete");
|
||||
}
|
||||
return this.colorlessCost;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasNext() {
|
||||
return st.hasMoreTokens();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
@Override
|
||||
public final ManaCostShard next() {
|
||||
|
||||
final String unparsed = st.nextToken();
|
||||
// System.out.println(unparsed);
|
||||
try {
|
||||
int iVal = Integer.parseInt(unparsed);
|
||||
this.colorlessCost += iVal;
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException nex) { }
|
||||
|
||||
return ManaCostShard.parseNonGeneric(unparsed);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
} // unsuported
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,7 +45,6 @@ import org.apache.commons.lang.time.StopWatch;
|
||||
import forge.FThreads;
|
||||
import forge.ICardStorageReader;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardRulesReader;
|
||||
import forge.error.BugReporter;
|
||||
import forge.gui.toolbox.FProgressBar;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -127,7 +126,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
|
||||
private final List<CardRules> loadCardsInRange(final List<File> files, int from, int to) {
|
||||
|
||||
CardRulesReader rulesReader = new CardRulesReader();
|
||||
CardRules.Reader rulesReader = new CardRules.Reader();
|
||||
|
||||
List<CardRules> result = new ArrayList<CardRules>();
|
||||
for(int i = from; i < to; i++) {
|
||||
@@ -139,7 +138,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
|
||||
private final List<CardRules> loadCardsInRangeFromZip(final List<ZipEntry> files, int from, int to) {
|
||||
|
||||
CardRulesReader rulesReader = new CardRulesReader();
|
||||
CardRules.Reader rulesReader = new CardRules.Reader();
|
||||
|
||||
List<CardRules> result = new ArrayList<CardRules>();
|
||||
for(int i = from; i < to; i++) {
|
||||
@@ -314,7 +313,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
*
|
||||
* @return the card loaded from the stream
|
||||
*/
|
||||
protected final CardRules loadCard(CardRulesReader reader, final InputStream inputStream) {
|
||||
protected final CardRules loadCard(CardRules.Reader reader, final InputStream inputStream) {
|
||||
reader.reset();
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(inputStream, this.charset);
|
||||
@@ -331,7 +330,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
*
|
||||
* @return a new Card instance
|
||||
*/
|
||||
protected final CardRules loadCard(final CardRulesReader reader, final File file) {
|
||||
protected final CardRules loadCard(final CardRules.Reader reader, final File file) {
|
||||
FileInputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
@@ -360,7 +359,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
*
|
||||
* @return a new Card instance
|
||||
*/
|
||||
protected final CardRules loadCard(final CardRulesReader rulesReader, final ZipEntry entry) {
|
||||
protected final CardRules loadCard(final CardRules.Reader rulesReader, final ZipEntry entry) {
|
||||
InputStream zipInputStream = null;
|
||||
try {
|
||||
zipInputStream = this.zip.getInputStream(entry);
|
||||
@@ -390,7 +389,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
output.add(new ArrayList<String>());
|
||||
}
|
||||
final List<File> allFiles = new ArrayList<File>();
|
||||
final CardRulesReader rulesReader = new CardRulesReader();
|
||||
final CardRules.Reader rulesReader = new CardRules.Reader();
|
||||
final CardStorageReader reader = new CardStorageReader(NewConstants.CARD_DATA_DIR, false, null);
|
||||
reader.fillFilesArray(allFiles, reader.cardsfolder);
|
||||
for (File file : allFiles) {
|
||||
@@ -469,7 +468,7 @@ public class CardStorageReader implements ICardStorageReader {
|
||||
|
||||
//check for oracle text appearing in ability descriptions missing "{G}" formatting
|
||||
if (updated) { //if lines updated above, ensure updated oracle text used
|
||||
rules = new CardRulesReader().readCard(lines);
|
||||
rules = CardRules.fromScript(lines);
|
||||
}
|
||||
String oracleText = rules.getOracleText();
|
||||
String[] sentences = oracleText.replace(rules.getName(), "CARDNAME").split("\\.|\\\\n|\\\"|\\(|\\)");
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRulesReader;
|
||||
import forge.card.CardRules;
|
||||
import forge.item.PaperToken;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.quest.bazaar.QuestPetController;
|
||||
@@ -143,7 +143,7 @@ public class QuestUtil {
|
||||
script.add("Types:" + properties[5].replace(';', ' '));
|
||||
script.add("Oracle:"); // tokens don't have texts yet
|
||||
String fileName = PaperToken.makeTokenFileName(properties[1], properties[2], properties[3], properties[4]);
|
||||
final PaperToken c = new PaperToken(CardRulesReader.parseSingleCard(script), CardEdition.UNKNOWN, fileName);
|
||||
final PaperToken c = new PaperToken(CardRules.fromScript(script), CardEdition.UNKNOWN, fileName);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardRulesReader;
|
||||
import forge.item.PaperToken;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.util.FileUtil;
|
||||
@@ -59,7 +58,7 @@ public class QuestPetStats {
|
||||
public final PaperToken getCard() {
|
||||
if (null == petCard) {
|
||||
List<String> cardLines = FileUtil.readFile(new File(NewConstants.CARD_DATA_PETS_DIR, cardFile));
|
||||
CardRules rules = CardRulesReader.parseSingleCard(cardLines);
|
||||
CardRules rules = CardRules.fromScript(cardLines);
|
||||
petCard = new PaperToken(rules, CardEdition.UNKNOWN, picture);
|
||||
}
|
||||
return petCard;
|
||||
|
||||
@@ -9,7 +9,7 @@ import junit.framework.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRulesReader;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.DeckHints;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.util.FileUtil;
|
||||
@@ -133,7 +133,7 @@ public class DeckHintsTest {
|
||||
File dir = new File(NewConstants.CARD_DATA_DIR, firstLetter);
|
||||
File txtFile = new File(dir, filename);
|
||||
|
||||
CardRulesReader crr = new CardRulesReader();
|
||||
CardRules.Reader crr = new CardRules.Reader();
|
||||
for (String line : FileUtil.readFile(txtFile)) {
|
||||
crr.parseLine(line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user