mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Checkstyle-changes for mtg-data.txt parser
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.FileUtil;
|
import forge.FileUtil;
|
||||||
@@ -13,6 +14,7 @@ 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 */
|
||||||
public final class MtgDataParser implements Iterator<CardRules> {
|
public final class MtgDataParser implements Iterator<CardRules> {
|
||||||
|
|
||||||
private Iterator<String> it;
|
private Iterator<String> it;
|
||||||
@@ -77,8 +79,6 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasNext() { return weHaveNext; }
|
public boolean hasNext() { return weHaveNext; }
|
||||||
|
|
||||||
private static final String[] emptyArray = new String[0]; // list.toArray() needs this =(
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CardRules next() {
|
public CardRules next() {
|
||||||
if (!it.hasNext()) { weHaveNext = false; return null; }
|
if (!it.hasNext()) { weHaveNext = false; return null; }
|
||||||
@@ -118,9 +118,8 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
|
|
||||||
if (sets.isEmpty()) { return null; } // that was a bad card - it won't be added by invoker
|
if (sets.isEmpty()) { return null; } // that was a bad card - it won't be added by invoker
|
||||||
|
|
||||||
return new CardRules(name, type, cost, ptOrLoyalty, strs.toArray(emptyArray), sets,
|
return new CardRules(name, type, cost, ptOrLoyalty,
|
||||||
// TODO: fix last two parameters
|
strs.toArray(ArrayUtils.EMPTY_STRING_ARRAY), sets, false, false);
|
||||||
false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, CardInSet> getValidEditions(final String sets, final boolean isBasicLand) {
|
private Map<String, CardInSet> getValidEditions(final String sets, final boolean isBasicLand) {
|
||||||
@@ -162,19 +161,18 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
|
|
||||||
@Override public void remove() { }
|
@Override public void remove() { }
|
||||||
|
|
||||||
|
/** This is a mana-parser for mana written in curly braces like {2}{R}{B} */
|
||||||
|
public static final class ManaParserMtgData implements ManaParser {
|
||||||
public static class ManaParserMtgData implements ManaParser {
|
|
||||||
private final String cost;
|
private final String cost;
|
||||||
|
|
||||||
private int nextBracket;
|
private int nextBracket;
|
||||||
private int colorlessCost;
|
private int colorlessCost;
|
||||||
|
|
||||||
|
|
||||||
public ManaParserMtgData(final String cost) {
|
public ManaParserMtgData(final String cost0) {
|
||||||
this.cost = cost;
|
this.cost = cost0;
|
||||||
// System.out.println(cost);
|
// System.out.println(cost);
|
||||||
nextBracket = cost.indexOf('{');
|
nextBracket = cost0.indexOf('{');
|
||||||
colorlessCost = 0;
|
colorlessCost = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +218,4 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
|||||||
@Override
|
@Override
|
||||||
public void remove() { } // unsuported
|
public void remove() { } // unsuported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user