mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18: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;
|
package forge.card;
|
||||||
|
|
||||||
|
import forge.Constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>CardColor class.</p>
|
* <p>CardColor class.</p>
|
||||||
*
|
*
|
||||||
@@ -28,7 +30,7 @@ public final class CardColor implements Comparable<CardColor> {
|
|||||||
|
|
||||||
public int countColors() { byte v = myColor; int c = 0; for (; v != 0; c++) { v &= v - 1; } return c; } // bit count
|
public int countColors() { byte v = myColor; int c = 0; for (; v != 0; c++) { v &= v - 1; } return c; } // bit count
|
||||||
// order has to be: W U B R G multi colorless - same as cards numbering through a set
|
// order has to be: W U B R G multi colorless - same as cards numbering through a set
|
||||||
public int getOrderWeight() { return myColor == 0 ? 0x400 : (countColors() == 1 ? myColor : 0x200); }
|
public int getOrderWeight() { return myColor == 0 ? 0x400 : (countColors() == 1 ? myColor : 0x200); }
|
||||||
|
|
||||||
public boolean isColorless() { return myColor == 0; }
|
public boolean isColorless() { return myColor == 0; }
|
||||||
public boolean isMulticolor() { return countColors() > 1; }
|
public boolean isMulticolor() { return countColors() > 1; }
|
||||||
@@ -36,9 +38,7 @@ public final class CardColor implements Comparable<CardColor> {
|
|||||||
public boolean isEqual(final byte color) { return color == myColor; }
|
public boolean isEqual(final byte color) { return color == myColor; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(final CardColor other) {
|
public int compareTo(final CardColor other) { return orderWeight - other.orderWeight; }
|
||||||
return orderWeight - other.orderWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Presets
|
// Presets
|
||||||
public boolean hasWhite() { return hasAnyColor(WHITE); }
|
public boolean hasWhite() { return hasAnyColor(WHITE); }
|
||||||
@@ -56,12 +56,12 @@ public final class CardColor implements Comparable<CardColor> {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
switch (myColor) {
|
switch (myColor) {
|
||||||
case 0: return "colorless";
|
case 0: return Constant.Color.Colorless;
|
||||||
case WHITE: return "white"; // Constant.Color.White;
|
case WHITE: return Constant.Color.White;
|
||||||
case BLUE: return "blue"; // Constant.Color.Blue;
|
case BLUE: return Constant.Color.Blue;
|
||||||
case BLACK: return "black"; // Constant.Color.Black;
|
case BLACK: return Constant.Color.Black;
|
||||||
case RED: return "red"; // Constant.Color.Red;
|
case RED: return Constant.Color.Red;
|
||||||
case GREEN: return "green"; // Constant.Color.Green;
|
case GREEN: return Constant.Color.Green;
|
||||||
default: return "multi";
|
default: return "multi";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,9 +125,9 @@ public class QuestDataIO {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
// card names are stored as plain text - need to read them from there
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mark the QD as the latest version
|
//mark the QD as the latest version
|
||||||
@@ -223,10 +223,16 @@ public class QuestDataIO {
|
|||||||
CardPool result = new CardPool();
|
CardPool result = new CardPool();
|
||||||
while (reader.hasMoreChildren()) {
|
while (reader.hasMoreChildren()) {
|
||||||
reader.moveDown();
|
reader.moveDown();
|
||||||
CardPrinted cp = readCardPrinted(reader);
|
String nodename = reader.getNodeName();
|
||||||
String sCnt = reader.getAttribute("n");
|
if("string".equals(nodename)) {
|
||||||
int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
|
CardPrinted cp = CardDb.instance().getCard(reader.getValue());
|
||||||
result.add(cp, cnt);
|
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();
|
reader.moveUp();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
|||||||
public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||||
int level;
|
int level;
|
||||||
private int maxLevel;
|
private int maxLevel;
|
||||||
private String name;
|
// transient here ?
|
||||||
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user