mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Add commander row
This commit is contained in:
@@ -25,6 +25,7 @@ import forge.properties.ForgeConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,7 +45,7 @@ public final class ConquestData {
|
||||
private int difficulty;
|
||||
private ConquestPlane startingPlane, currentPlane;
|
||||
private int currentRegionIndex;
|
||||
private List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||
private EnumMap<ConquestPlane, ConquestPlaneData> planeDataMap = new EnumMap<ConquestPlane, ConquestPlaneData>(ConquestPlane.class);
|
||||
|
||||
private final CardPool collection = new CardPool();
|
||||
private final HashMap<String, Deck> decks = new HashMap<String, Deck>();
|
||||
@@ -62,7 +63,7 @@ public final class ConquestData {
|
||||
|
||||
private void addCommander(PaperCard card) {
|
||||
ConquestCommander commander = new ConquestCommander(card, currentPlane.getCardPool());
|
||||
commanders.add(commander);
|
||||
getCurrentPlaneData().getCommanders().add(commander);
|
||||
decks.put(commander.getDeck().getName(), commander.getDeck());
|
||||
collection.addAll(commander.getDeck().getMain());
|
||||
collection.add(card);
|
||||
@@ -84,6 +85,15 @@ public final class ConquestData {
|
||||
return currentPlane;
|
||||
}
|
||||
|
||||
public ConquestPlaneData getCurrentPlaneData() {
|
||||
ConquestPlaneData planeData = planeDataMap.get(currentPlane);
|
||||
if (planeData == null) {
|
||||
planeData = new ConquestPlaneData();
|
||||
planeDataMap.put(currentPlane, planeData);
|
||||
}
|
||||
return planeData;
|
||||
}
|
||||
|
||||
public Region getCurrentRegion() {
|
||||
return currentPlane.getRegions().get(currentRegionIndex);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,11 @@ import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.io.QuestDataIO.DeckToXml;
|
||||
import forge.quest.io.QuestDataIO.ItemPoolToXml;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.IgnoringXStream;
|
||||
import forge.util.ItemPool;
|
||||
@@ -47,6 +50,8 @@ public class ConquestDataIO {
|
||||
|
||||
protected static XStream getSerializer(final boolean isIgnoring) {
|
||||
final XStream xStream = isIgnoring ? new IgnoringXStream() : new XStream();
|
||||
xStream.registerConverter(new ItemPoolToXml());
|
||||
xStream.registerConverter(new DeckToXml());
|
||||
xStream.autodetectAnnotations(true);
|
||||
xStream.alias("CardPool", ItemPool.class);
|
||||
xStream.alias("DeckSection", CardPool.class);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConquestPlaneData {
|
||||
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||
|
||||
public List<ConquestCommander> getCommanders() {
|
||||
return commanders;
|
||||
}
|
||||
}
|
||||
@@ -675,12 +675,10 @@ public class QuestDataIO {
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class DeckToXml extends ItemPoolToXml {
|
||||
public static class DeckToXml extends ItemPoolToXml {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java.lang.Class)
|
||||
@@ -748,7 +746,7 @@ public class QuestDataIO {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemPoolToXml implements Converter {
|
||||
public static class ItemPoolToXml implements Converter {
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean canConvert(final Class clasz) {
|
||||
|
||||
Reference in New Issue
Block a user