mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
New format for SetInfo lines, to convert card scripts either run 'assignSetInfo.py' or wait for upcoming cardfolder commits
This commit is contained in:
@@ -19,6 +19,7 @@ package forge.card;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ import forge.card.mana.ManaCost;
|
|||||||
* @version $Id: CardRules.java 9708 2011-08-09 19:34:12Z jendave $
|
* @version $Id: CardRules.java 9708 2011-08-09 19:34:12Z jendave $
|
||||||
*/
|
*/
|
||||||
public final class CardRules implements ICardCharacteristics {
|
public final class CardRules implements ICardCharacteristics {
|
||||||
|
private final static EditionCollection editions = new EditionCollection(); // create a copy here, Singletons.model... is not initialized yet.
|
||||||
|
|
||||||
private final CardSplitType splitType;
|
private final CardSplitType splitType;
|
||||||
private final ICardFace mainPart;
|
private final ICardFace mainPart;
|
||||||
@@ -48,7 +50,13 @@ public final class CardRules implements ICardCharacteristics {
|
|||||||
mainPart = faces[0];
|
mainPart = faces[0];
|
||||||
otherPart = faces[1];
|
otherPart = faces[1];
|
||||||
aiHints = cah;
|
aiHints = cah;
|
||||||
setsPrinted.putAll(sets);
|
|
||||||
|
//System.out.print(faces[0].getName());
|
||||||
|
|
||||||
|
for (Entry<String, CardInSet> cs : sets.entrySet()) {
|
||||||
|
if( editions.get(cs.getKey()) != null )
|
||||||
|
setsPrinted.put(cs.getKey(), cs.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
if ( setsPrinted.isEmpty() ) {
|
if ( setsPrinted.isEmpty() ) {
|
||||||
System.err.println(getName() + " was not assigned any set.");
|
System.err.println(getName() + " was not assigned any set.");
|
||||||
|
|||||||
@@ -221,8 +221,7 @@ public class CardRulesReader {
|
|||||||
} else
|
} else
|
||||||
this.faces[curFace].addSVar(variable, value);
|
this.faces[curFace].addSVar(variable, value);
|
||||||
} else if ("SetInfo".equals(key)) {
|
} else if ("SetInfo".equals(key)) {
|
||||||
if ( curFace == 0 )
|
parseSetInfoLine(value);
|
||||||
CardRulesReader.parseSetInfoLine(value, sets);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -247,41 +246,33 @@ public class CardRulesReader {
|
|||||||
* @param setsData
|
* @param setsData
|
||||||
* the current mapping of set names to CardInSet instances
|
* the current mapping of set names to CardInSet instances
|
||||||
*/
|
*/
|
||||||
private static void parseSetInfoLine(final String value, final Map<String, CardInSet> setsData) {
|
private void parseSetInfoLine(final String value) {
|
||||||
final int setCodeIx = 0;
|
|
||||||
final int rarityIx = 1;
|
|
||||||
final int numPicIx = 3;
|
|
||||||
|
|
||||||
// Sample SetInfo line:
|
// Sample SetInfo line:
|
||||||
// SetInfo:POR|Land|http://magiccards.info/scans/en/po/203.jpg|4
|
// SetInfo:POR Land x4
|
||||||
|
|
||||||
final String[] pieces = value.split("\\|");
|
int i = 0;
|
||||||
|
String setCode = null;
|
||||||
|
String txtRarity = "Common";
|
||||||
|
String txtCount = "x1";
|
||||||
|
|
||||||
if (pieces.length <= rarityIx) {
|
StringTokenizer stt = new StringTokenizer(value, " ");
|
||||||
throw new RuntimeException("SetInfo line <<" + value + ">> has insufficient pieces");
|
while(stt.hasMoreTokens()) {
|
||||||
|
if( i == 0 ) setCode = stt.nextToken();
|
||||||
|
if( i == 1 ) txtRarity = stt.nextToken();
|
||||||
|
if( i == 2 ) txtCount = stt.nextToken();
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String setCode = pieces[setCodeIx];
|
|
||||||
final String txtRarity = pieces[rarityIx];
|
|
||||||
// pieces[2] is the magiccards.info URL for illustration #1, which we do
|
|
||||||
// not need.
|
|
||||||
int numIllustrations = 1;
|
|
||||||
|
|
||||||
if (setsData.containsKey(setCode)) {
|
int numIllustrations = 1;
|
||||||
|
if ( i > 2 )
|
||||||
|
numIllustrations = Integer.parseInt(txtCount.substring(1));
|
||||||
|
|
||||||
|
if (sets.containsKey(setCode)) {
|
||||||
|
System.err.print(faces[0].getName());
|
||||||
throw new RuntimeException("Found multiple SetInfo lines for set code <<" + setCode + ">>");
|
throw new RuntimeException("Found multiple SetInfo lines for set code <<" + setCode + ">>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pieces.length > numPicIx) {
|
|
||||||
try {
|
|
||||||
numIllustrations = Integer.parseInt(pieces[numPicIx]);
|
|
||||||
} catch (final NumberFormatException nfe) {
|
|
||||||
throw new RuntimeException("Fourth item of SetInfo is not an integer in <<" + value + ">>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numIllustrations < 1) {
|
|
||||||
throw new RuntimeException("Fourth item of SetInfo is not a positive integer, but" + numIllustrations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CardRarity rarity = null;
|
CardRarity rarity = null;
|
||||||
if ("Land".equals(txtRarity)) {
|
if ("Land".equals(txtRarity)) {
|
||||||
@@ -302,7 +293,7 @@ public class CardRulesReader {
|
|||||||
|
|
||||||
final CardInSet cardInSet = new CardInSet(rarity, numIllustrations);
|
final CardInSet cardInSet = new CardInSet(rarity, numIllustrations);
|
||||||
|
|
||||||
setsData.put(setCode, cardInSet);
|
sets.put(setCode, cardInSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user