mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
added support for older format of quest saves (a method for deserialization of CardPool)
since color names are lowercases, I used constants from forge for their names.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.Constant;
|
||||
|
||||
/**
|
||||
* <p>CardColor class.</p>
|
||||
*
|
||||
@@ -36,9 +38,7 @@ public final class CardColor implements Comparable<CardColor> {
|
||||
public boolean isEqual(final byte color) { return color == myColor; }
|
||||
|
||||
@Override
|
||||
public int compareTo(final CardColor other) {
|
||||
return orderWeight - other.orderWeight;
|
||||
}
|
||||
public int compareTo(final CardColor other) { return orderWeight - other.orderWeight; }
|
||||
|
||||
// Presets
|
||||
public boolean hasWhite() { return hasAnyColor(WHITE); }
|
||||
@@ -56,12 +56,12 @@ public final class CardColor implements Comparable<CardColor> {
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (myColor) {
|
||||
case 0: return "colorless";
|
||||
case WHITE: return "white"; // Constant.Color.White;
|
||||
case BLUE: return "blue"; // Constant.Color.Blue;
|
||||
case BLACK: return "black"; // Constant.Color.Black;
|
||||
case RED: return "red"; // Constant.Color.Red;
|
||||
case GREEN: return "green"; // Constant.Color.Green;
|
||||
case 0: return Constant.Color.Colorless;
|
||||
case WHITE: return Constant.Color.White;
|
||||
case BLUE: return Constant.Color.Blue;
|
||||
case BLACK: return Constant.Color.Black;
|
||||
case RED: return Constant.Color.Red;
|
||||
case GREEN: return Constant.Color.Green;
|
||||
default: return "multi";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ public class QuestDataIO {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// card names are stored as plain text - need to read them from there
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//mark the QD as the latest version
|
||||
@@ -223,10 +223,16 @@ public class QuestDataIO {
|
||||
CardPool result = new CardPool();
|
||||
while (reader.hasMoreChildren()) {
|
||||
reader.moveDown();
|
||||
CardPrinted cp = readCardPrinted(reader);
|
||||
String sCnt = reader.getAttribute("n");
|
||||
int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
|
||||
result.add(cp, cnt);
|
||||
String nodename = reader.getNodeName();
|
||||
if("string".equals(nodename)) {
|
||||
CardPrinted cp = CardDb.instance().getCard(reader.getValue());
|
||||
result.add(cp);
|
||||
} else { // new format
|
||||
CardPrinted cp = readCardPrinted(reader);
|
||||
String sCnt = reader.getAttribute("n");
|
||||
int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
|
||||
result.add(cp, cnt);
|
||||
}
|
||||
reader.moveUp();
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -14,6 +14,7 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
||||
public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
int level;
|
||||
private int maxLevel;
|
||||
// transient here ?
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user