mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- CheckStyle.
This commit is contained in:
@@ -121,7 +121,7 @@ public class QuestDataIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
zin.close();
|
zin.close();
|
||||||
|
|
||||||
data = (QuestData) getSerializer(true).fromXML(xml.toString());
|
data = (QuestData) getSerializer(true).fromXML(xml.toString());
|
||||||
|
|
||||||
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
||||||
@@ -140,7 +140,7 @@ public class QuestDataIO {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(instance, newValue); // no difference here (used only to set initial lives)
|
field.set(instance, newValue); // no difference here (used only to set initial lives)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* updateSaveFile.
|
* updateSaveFile.
|
||||||
@@ -158,16 +158,16 @@ public class QuestDataIO {
|
|||||||
is.setCharacterStream(new StringReader(input));
|
is.setCharacterStream(new StringReader(input));
|
||||||
final Document document = builder.parse(is);
|
final Document document = builder.parse(is);
|
||||||
|
|
||||||
final int saveVersion = newData.getVersionNumber();
|
final int saveVersion = newData.getVersionNumber();
|
||||||
|
|
||||||
if( saveVersion < 3 ) {
|
if (saveVersion < 3) {
|
||||||
// no difference here (used only to set initial lives)
|
// no difference here (used only to set initial lives)
|
||||||
setFinalField(QuestData.class, "assets", newData, new QuestAssets(QuestMode.Classic));
|
setFinalField(QuestData.class, "assets", newData, new QuestAssets(QuestMode.Classic));
|
||||||
|
|
||||||
int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent());
|
int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent());
|
||||||
setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (saveVersion) {
|
switch (saveVersion) {
|
||||||
// There should be a fall-through b/w the cases so that each
|
// There should be a fall-through b/w the cases so that each
|
||||||
// version's changes get applied progressively
|
// version's changes get applied progressively
|
||||||
@@ -194,13 +194,13 @@ public class QuestDataIO {
|
|||||||
case 1:
|
case 1:
|
||||||
// nothing to do here, everything is managed by CardPoolToXml
|
// nothing to do here, everything is managed by CardPoolToXml
|
||||||
// deserializer
|
// deserializer
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (StringUtils.isBlank(newData.getName())) {
|
if (StringUtils.isBlank(newData.getName())) {
|
||||||
setFinalField(QuestData.class, "name", newData, "questData");
|
setFinalField(QuestData.class, "name", newData, "questData");
|
||||||
}
|
}
|
||||||
|
|
||||||
QuestAchievements qA = newData.getAchievements();
|
QuestAchievements qA = newData.getAchievements();
|
||||||
setFinalField(QuestAchievements.class, "win", qA, Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent()));
|
setFinalField(QuestAchievements.class, "win", qA, Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent()));
|
||||||
setFinalField(QuestAchievements.class, "lost", qA, Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent()));
|
setFinalField(QuestAchievements.class, "lost", qA, Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent()));
|
||||||
setFinalField(QuestAchievements.class, "winstreakBest", qA, Integer.parseInt(document.getElementsByTagName("winstreakBest").item(0).getTextContent()));
|
setFinalField(QuestAchievements.class, "winstreakBest", qA, Integer.parseInt(document.getElementsByTagName("winstreakBest").item(0).getTextContent()));
|
||||||
@@ -209,15 +209,17 @@ public class QuestDataIO {
|
|||||||
|
|
||||||
ArrayList<Integer> completedChallenges = new ArrayList<Integer>();
|
ArrayList<Integer> completedChallenges = new ArrayList<Integer>();
|
||||||
setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges);
|
setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges);
|
||||||
NodeList ccs = document.getElementsByTagName("completedChallenges").item(0).getChildNodes();
|
NodeList ccs = document.getElementsByTagName("completedChallenges").item(0).getChildNodes();
|
||||||
for(int iN = 0; iN < ccs.getLength(); iN++) {
|
for (int iN = 0; iN < ccs.getLength(); iN++) {
|
||||||
Node n = ccs.item(iN);
|
Node n = ccs.item(iN);
|
||||||
if ( n.getNodeType() != Node.ELEMENT_NODE ) continue;
|
if (n.getNodeType() != Node.ELEMENT_NODE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
completedChallenges.add(Integer.parseInt(n.getTextContent()));
|
completedChallenges.add(Integer.parseInt(n.getTextContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QuestAssets qS = newData.getAssets();
|
QuestAssets qS = newData.getAssets();
|
||||||
|
|
||||||
XStream xs = getSerializer(true);
|
XStream xs = getSerializer(true);
|
||||||
|
|
||||||
setFinalField(QuestAssets.class, "credits", qS, Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent()));
|
setFinalField(QuestAssets.class, "credits", qS, Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent()));
|
||||||
@@ -246,14 +248,13 @@ public class QuestDataIO {
|
|||||||
Node n = nn.item(0);
|
Node n = nn.item(0);
|
||||||
|
|
||||||
Attr att = doc.createAttribute("resolves-to");
|
Attr att = doc.createAttribute("resolves-to");
|
||||||
att.setValue(clasz.getCanonicalName());
|
att.setValue(clasz.getCanonicalName());
|
||||||
n.getAttributes().setNamedItem(att);
|
n.getAttributes().setNamedItem(att);
|
||||||
|
|
||||||
String xmlData = XmlUtil.nodeToString(n);
|
String xmlData = XmlUtil.nodeToString(n);
|
||||||
return (T) xs.fromXML(xmlData);
|
return (T) xs.fromXML(xmlData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* saveData.
|
* saveData.
|
||||||
@@ -266,7 +267,7 @@ public class QuestDataIO {
|
|||||||
try {
|
try {
|
||||||
final XStream xStream = getSerializer(false);
|
final XStream xStream = getSerializer(false);
|
||||||
|
|
||||||
final File f = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR), qd.getName() );
|
final File f = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR), qd.getName());
|
||||||
savePacked(f + ".dat", xStream, qd);
|
savePacked(f + ".dat", xStream, qd);
|
||||||
saveUnpacked(f + ".xml", xStream, qd);
|
saveUnpacked(f + ".xml", xStream, qd);
|
||||||
|
|
||||||
@@ -281,15 +282,14 @@ public class QuestDataIO {
|
|||||||
final GZIPOutputStream zout = new GZIPOutputStream(bout);
|
final GZIPOutputStream zout = new GZIPOutputStream(bout);
|
||||||
xStream.toXML(qd, zout);
|
xStream.toXML(qd, zout);
|
||||||
zout.flush();
|
zout.flush();
|
||||||
zout.close();
|
zout.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void saveUnpacked(String f, XStream xStream, QuestData qd) throws IOException {
|
private static void saveUnpacked(String f, XStream xStream, QuestData qd) throws IOException {
|
||||||
BufferedOutputStream boutUnp = new BufferedOutputStream(new FileOutputStream(f));
|
BufferedOutputStream boutUnp = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
xStream.toXML(qd, boutUnp);
|
xStream.toXML(qd, boutUnp);
|
||||||
boutUnp.flush();
|
boutUnp.flush();
|
||||||
boutUnp.close();
|
boutUnp.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
private final QuestStallManager bazaar;
|
private final QuestStallManager bazaar;
|
||||||
|
|
||||||
/** Lays out containers and borders for resizeable layout and
|
/** Lays out containers and borders for resizeable layout and
|
||||||
* instantiates top-level controller for bazaar UI.
|
* instantiates top-level controller for bazaar UI.
|
||||||
* @param bazaar0 */
|
* @param bazaar0 */
|
||||||
public ViewBazaarUI(QuestStallManager bazaar0) {
|
public ViewBazaarUI(QuestStallManager bazaar0) {
|
||||||
super();
|
super();
|
||||||
@@ -33,7 +33,7 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
// Final inits
|
// Final inits
|
||||||
this.pnlAllStalls = new JPanel();
|
this.pnlAllStalls = new JPanel();
|
||||||
this.pnlSingleStall = new ViewStall(this);
|
this.pnlSingleStall = new ViewStall(this);
|
||||||
this.bazaar = bazaar0;
|
this.bazaar = bazaar0;
|
||||||
|
|
||||||
// Component styling
|
// Component styling
|
||||||
this.setCornerDiameter(0);
|
this.setCornerDiameter(0);
|
||||||
@@ -56,7 +56,7 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
/** */
|
/** */
|
||||||
public void populateStalls() {
|
public void populateStalls() {
|
||||||
for (final String s : bazaar.getStallNames()) {
|
for (final String s : bazaar.getStallNames()) {
|
||||||
|
|
||||||
final FLabel lbl = new FLabel.Builder().text(s + " ")
|
final FLabel lbl = new FLabel.Builder().text(s + " ")
|
||||||
.fontAlign(SwingConstants.RIGHT).iconInBackground(true)
|
.fontAlign(SwingConstants.RIGHT).iconInBackground(true)
|
||||||
.fontScaleFactor(0.3).opaque(true).hoverable(true)
|
.fontScaleFactor(0.3).opaque(true).hoverable(true)
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class ViewStall extends JPanel {
|
|||||||
if (AllZone.getQuest().getAssets() == null) { return; }
|
if (AllZone.getQuest().getAssets() == null) { return; }
|
||||||
|
|
||||||
QuestAssets qS = AllZone.getQuest().getAssets();
|
QuestAssets qS = AllZone.getQuest().getAssets();
|
||||||
this.lblStats.setText( "Credits: " + qS.getCredits() + " Life: " + qS.getLife());
|
this.lblStats.setText("Credits: " + qS.getCredits() + " Life: " + qS.getLife());
|
||||||
|
|
||||||
final List<IQuestStallPurchasable> items =
|
final List<IQuestStallPurchasable> items =
|
||||||
AllZone.getQuest().getBazaar().getItems(stall.getName());
|
AllZone.getQuest().getBazaar().getItems(stall.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user