More preliminary work for the quest worlds.

This commit is contained in:
RumbleBBU
2012-11-09 10:51:32 +00:00
parent 09360ce105
commit c021be76f9
4 changed files with 89 additions and 3 deletions

1
.gitattributes vendored
View File

@@ -12363,6 +12363,7 @@ res/quest/themes/Vigilance[!!-~]Meekstone[!!-~]W.thm -text
res/quest/themes/White.thm -text res/quest/themes/White.thm -text
res/quest/themes/Wolves[!!-~]WG.thm -text res/quest/themes/Wolves[!!-~]WG.thm -text
res/quest/themes/Zombies[!!-~]B.thm -text res/quest/themes/Zombies[!!-~]B.thm -text
res/quest/world/worlds.txt -text
res/reprintSetInfo.py svneol=native#text/x-python res/reprintSetInfo.py svneol=native#text/x-python
res/sealed/ArabianExtended.sealed -text res/sealed/ArabianExtended.sealed -text
res/sealed/RtRGuildAzorius.sealed -text res/sealed/RtRGuildAzorius.sealed -text

View File

@@ -0,0 +1 @@
Index:1|Name:Shandalar|Dir:shandalar|Sets:2ED, ARN, ATQ, 3ED, LEG, DRK, FEM, 4ED, ICE, CHR, HML, ALL|Banned:Chaos Orb; Falling Star

View File

@@ -47,6 +47,7 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.QuestController; import forge.quest.QuestController;
import forge.quest.data.QuestPreferences; import forge.quest.data.QuestPreferences;
import forge.quest.data.QuestWorld;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.HttpUtil; import forge.util.HttpUtil;
import forge.util.IStorageView; import forge.util.IStorageView;
@@ -95,9 +96,7 @@ public enum FModel {
private final IStorageView<FatPackData> fatPacks; private final IStorageView<FatPackData> fatPacks;
private final IStorageView<CardBlock> blocks; private final IStorageView<CardBlock> blocks;
private final IStorageView<CardBlock> fantasyBlocks; private final IStorageView<CardBlock> fantasyBlocks;
private final IStorageView<QuestWorld> worlds;
/** /**
* Constructor. * Constructor.
@@ -144,6 +143,7 @@ public enum FModel {
this.fatPacks = new StorageView<FatPackData>(new FatPackData.Reader("res/blockdata/fatpacks.txt")); this.fatPacks = new StorageView<FatPackData>(new FatPackData.Reader("res/blockdata/fatpacks.txt"));
this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions)); this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions));
this.fantasyBlocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/fantasyblocks.txt", editions)); this.fantasyBlocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/fantasyblocks.txt", editions));
this.worlds = new StorageView<QuestWorld>(new QuestWorld.Reader("res/quest/world/worlds.txt"));
this.match = new MatchController(); this.match = new MatchController();
// TODO - there's got to be a better place for this...oblivion? // TODO - there's got to be a better place for this...oblivion?

View File

@@ -17,6 +17,14 @@
*/ */
package forge.quest.data; package forge.quest.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.google.common.base.Function;
import forge.util.StorageReaderFile;
/** /**
* This function holds the "world info" for the current quest. * This function holds the "world info" for the current quest.
* *
@@ -80,4 +88,80 @@ public class QuestWorld {
public GameFormatQuest getFormat() { public GameFormatQuest getFormat() {
return format; return format;
} }
/**
* FN_GET_NAME for reader.
*/
public static final Function<QuestWorld, String> FN_GET_NAME = new Function<QuestWorld, String>() {
public String apply(QuestWorld arg1) {
return arg1.getName();
}
};
/**
* Class for reading world definitions.
*/
public static class Reader extends StorageReaderFile<QuestWorld> {
/**
* TODO: Write javadoc for Constructor.
* @param file0
* @param keySelector0
*/
public Reader(String file0) {
super(file0, QuestWorld.FN_GET_NAME);
}
/* (non-Javadoc)
* @see forge.util.StorageReaderFile#read(java.lang.String)
*/
@Override
protected QuestWorld read(String line) {
System.out.println("Reading quest worlds 3...");
String useName = null;
String useDir = null;
int useIdx = 0;
GameFormatQuest useFormat = null;
final List<String> sets = new ArrayList<String>();
final List<String> bannedCards = new ArrayList<String>(); // if both empty, no format
final String[] sParts = line.trim().split("\\|");
for (final String sPart : sParts) {
final String[] kv = sPart.split(":", 2);
final String key = kv[0].toLowerCase();
if ("index".equals(key)) {
useIdx = new Integer(kv[1]);
} else if ("name".equals(key)) {
useName = kv[1];
} else if ("dir".equals(key)) {
useDir = kv[1];
} else if ("sets".equals(key)) {
sets.addAll(Arrays.asList(kv[1].split(", ")));
} else if ("banned".equals(key)) {
bannedCards.addAll(Arrays.asList(kv[1].split("; ")));
}
}
if (useIdx < 1) {
throw new RuntimeException("Illegal index " + useIdx + "! Check worlds.txt file");
}
else if (useName == null) {
throw new RuntimeException("World " + useIdx + " must have a name! Check worlds.txt file");
}
else if (useDir == null) {
throw new RuntimeException("World '" + useName + "' must have a directory! Check worlds.txt file");
}
if (!sets.isEmpty() || bannedCards.isEmpty()) {
useFormat = new GameFormatQuest(useName, sets, bannedCards);
}
// System.out.println("Creating quest world " + useName + " (index " + useIdx + ", dir: " + useDir);
// if (useFormat != null) { System.out.println("SETS: " + sets + "\nBANNED: " + bannedCards); }
return new QuestWorld(useIdx, useName, useDir, useFormat);
}
}
} }