move loadDynamicGameData to Main

This commit is contained in:
slapshot5
2012-01-07 06:51:47 +00:00
parent ade0f94f5d
commit f976459395
3 changed files with 127 additions and 127 deletions

View File

@@ -17,7 +17,12 @@
*/ */
package forge.view.swing; package forge.view.swing;
import java.util.ArrayList;
import forge.AllZone; import forge.AllZone;
import forge.Constant;
import forge.ConstantStringArrayList;
import forge.FileUtil;
import forge.Singletons; import forge.Singletons;
import forge.error.ErrorViewer; import forge.error.ErrorViewer;
import forge.error.ExceptionHandler; import forge.error.ExceptionHandler;
@@ -55,7 +60,7 @@ public final class Main {
AllZone.setSkin(skin); AllZone.setSkin(skin);
// Need this soon after card factory is loaded // Need this soon after card factory is loaded
OldGuiNewGame.loadDynamicGamedata(); Main.loadDynamicGamedata();
// TODO this code should go elsewhere, like wherever we start a new // TODO this code should go elsewhere, like wherever we start a new
// game. // game.
@@ -66,10 +71,125 @@ public final class Main {
view.setModel(model); view.setModel(model);
} catch (final Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: } catch (final Throwable exn) {
// must
// catch all throwables here.
ErrorViewer.showError(exn); ErrorViewer.showError(exn);
} }
} }
/**
* Load dynamic gamedata.
*/
public static void loadDynamicGamedata() {
if (!Constant.CardTypes.LOADED[0]) {
final ArrayList<String> typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt");
ArrayList<String> tList = null;
Constant.CardTypes.CARD_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.SUPER_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.BASIC_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.LAND_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.CREATURE_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.INSTANT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.SORCERY_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.ENCHANTMENT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.ARTIFACT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.WALKER_TYPES[0] = new ConstantStringArrayList();
if (typeListFile.size() > 0) {
for (int i = 0; i < typeListFile.size(); i++) {
final String s = typeListFile.get(i);
if (s.equals("[CardTypes]")) {
tList = Constant.CardTypes.CARD_TYPES[0].getList();
}
else if (s.equals("[SuperTypes]")) {
tList = Constant.CardTypes.SUPER_TYPES[0].getList();
}
else if (s.equals("[BasicTypes]")) {
tList = Constant.CardTypes.BASIC_TYPES[0].getList();
}
else if (s.equals("[LandTypes]")) {
tList = Constant.CardTypes.LAND_TYPES[0].getList();
}
else if (s.equals("[CreatureTypes]")) {
tList = Constant.CardTypes.CREATURE_TYPES[0].getList();
}
else if (s.equals("[InstantTypes]")) {
tList = Constant.CardTypes.INSTANT_TYPES[0].getList();
}
else if (s.equals("[SorceryTypes]")) {
tList = Constant.CardTypes.SORCERY_TYPES[0].getList();
}
else if (s.equals("[EnchantmentTypes]")) {
tList = Constant.CardTypes.ENCHANTMENT_TYPES[0].getList();
}
else if (s.equals("[ArtifactTypes]")) {
tList = Constant.CardTypes.ARTIFACT_TYPES[0].getList();
}
else if (s.equals("[WalkerTypes]")) {
tList = Constant.CardTypes.WALKER_TYPES[0].getList();
}
else if (s.length() > 1) {
tList.add(s);
}
}
}
Constant.CardTypes.LOADED[0] = true;
/*
* if (Constant.Runtime.DevMode[0]) {
* System.out.println(Constant.CardTypes.cardTypes[0].list);
* System.out.println(Constant.CardTypes.superTypes[0].list);
* System.out.println(Constant.CardTypes.basicTypes[0].list);
* System.out.println(Constant.CardTypes.landTypes[0].list);
* System.out.println(Constant.CardTypes.creatureTypes[0].list);
* System.out.println(Constant.CardTypes.instantTypes[0].list);
* System.out.println(Constant.CardTypes.sorceryTypes[0].list);
* System.out.println(Constant.CardTypes.enchantmentTypes[0].list);
* System.out.println(Constant.CardTypes.artifactTypes[0].list);
* System.out.println(Constant.CardTypes.walkerTypes[0].list); }
*/
}
if (!Constant.Keywords.LOADED[0]) {
final ArrayList<String> nskwListFile = FileUtil.readFile("res/gamedata/NonStackingKWList.txt");
Constant.Keywords.NON_STACKING_LIST[0] = new ConstantStringArrayList();
if (nskwListFile.size() > 1) {
for (int i = 0; i < nskwListFile.size(); i++) {
final String s = nskwListFile.get(i);
if (s.length() > 1) {
Constant.Keywords.NON_STACKING_LIST[0].getList().add(s);
}
}
}
Constant.Keywords.LOADED[0] = true;
/*
* if (Constant.Runtime.DevMode[0]) {
* System.out.println(Constant.Keywords.NonStackingList[0].list); }
*/
}
/*
* if (!Constant.Color.loaded[0]) { ArrayList<String> lcListFile =
* FileUtil.readFile("res/gamedata/LandColorList");
*
* if (lcListFile.size() > 1) { for (int i=0; i<lcListFile.size(); i++)
* { String s = lcListFile.get(i); if (s.length() > 1)
* Constant.Color.LandColor[0].map.add(s); } }
* Constant.Keywords.loaded[0] = true; if (Constant.Runtime.DevMode[0])
* { System.out.println(Constant.Keywords.NonStackingList[0].list); } }
*/
}
} }

View File

@@ -18,15 +18,12 @@
package forge.view.swing; package forge.view.swing;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem; import javax.swing.JCheckBoxMenuItem;
import forge.Constant; import forge.Constant;
import forge.ConstantStringArrayList;
import forge.FileUtil;
import forge.Singletons; import forge.Singletons;
import forge.error.ErrorViewer; import forge.error.ErrorViewer;
import forge.gui.ListChooser; import forge.gui.ListChooser;
@@ -43,7 +40,7 @@ import forge.properties.NewConstants;
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class OldGuiNewGame { public final class OldGuiNewGame {
// @SuppressWarnings("unused") // @SuppressWarnings("unused")
// titledBorder2 // titledBorder2
@@ -308,123 +305,6 @@ public class OldGuiNewGame {
} }
} }
/**
* Load dynamic gamedata.
*/
public static void loadDynamicGamedata() {
if (!Constant.CardTypes.LOADED[0]) {
final ArrayList<String> typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt");
ArrayList<String> tList = null;
Constant.CardTypes.CARD_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.SUPER_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.BASIC_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.LAND_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.CREATURE_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.INSTANT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.SORCERY_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.ENCHANTMENT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.ARTIFACT_TYPES[0] = new ConstantStringArrayList();
Constant.CardTypes.WALKER_TYPES[0] = new ConstantStringArrayList();
if (typeListFile.size() > 0) {
for (int i = 0; i < typeListFile.size(); i++) {
final String s = typeListFile.get(i);
if (s.equals("[CardTypes]")) {
tList = Constant.CardTypes.CARD_TYPES[0].getList();
}
else if (s.equals("[SuperTypes]")) {
tList = Constant.CardTypes.SUPER_TYPES[0].getList();
}
else if (s.equals("[BasicTypes]")) {
tList = Constant.CardTypes.BASIC_TYPES[0].getList();
}
else if (s.equals("[LandTypes]")) {
tList = Constant.CardTypes.LAND_TYPES[0].getList();
}
else if (s.equals("[CreatureTypes]")) {
tList = Constant.CardTypes.CREATURE_TYPES[0].getList();
}
else if (s.equals("[InstantTypes]")) {
tList = Constant.CardTypes.INSTANT_TYPES[0].getList();
}
else if (s.equals("[SorceryTypes]")) {
tList = Constant.CardTypes.SORCERY_TYPES[0].getList();
}
else if (s.equals("[EnchantmentTypes]")) {
tList = Constant.CardTypes.ENCHANTMENT_TYPES[0].getList();
}
else if (s.equals("[ArtifactTypes]")) {
tList = Constant.CardTypes.ARTIFACT_TYPES[0].getList();
}
else if (s.equals("[WalkerTypes]")) {
tList = Constant.CardTypes.WALKER_TYPES[0].getList();
}
else if (s.length() > 1) {
tList.add(s);
}
}
}
Constant.CardTypes.LOADED[0] = true;
/*
* if (Constant.Runtime.DevMode[0]) {
* System.out.println(Constant.CardTypes.cardTypes[0].list);
* System.out.println(Constant.CardTypes.superTypes[0].list);
* System.out.println(Constant.CardTypes.basicTypes[0].list);
* System.out.println(Constant.CardTypes.landTypes[0].list);
* System.out.println(Constant.CardTypes.creatureTypes[0].list);
* System.out.println(Constant.CardTypes.instantTypes[0].list);
* System.out.println(Constant.CardTypes.sorceryTypes[0].list);
* System.out.println(Constant.CardTypes.enchantmentTypes[0].list);
* System.out.println(Constant.CardTypes.artifactTypes[0].list);
* System.out.println(Constant.CardTypes.walkerTypes[0].list); }
*/
}
if (!Constant.Keywords.LOADED[0]) {
final ArrayList<String> nskwListFile = FileUtil.readFile("res/gamedata/NonStackingKWList.txt");
Constant.Keywords.NON_STACKING_LIST[0] = new ConstantStringArrayList();
if (nskwListFile.size() > 1) {
for (int i = 0; i < nskwListFile.size(); i++) {
final String s = nskwListFile.get(i);
if (s.length() > 1) {
Constant.Keywords.NON_STACKING_LIST[0].getList().add(s);
}
}
}
Constant.Keywords.LOADED[0] = true;
/*
* if (Constant.Runtime.DevMode[0]) {
* System.out.println(Constant.Keywords.NonStackingList[0].list); }
*/
}
/*
* if (!Constant.Color.loaded[0]) { ArrayList<String> lcListFile =
* FileUtil.readFile("res/gamedata/LandColorList");
*
* if (lcListFile.size() > 1) { for (int i=0; i<lcListFile.size(); i++)
* { String s = lcListFile.get(i); if (s.length() > 1)
* Constant.Color.LandColor[0].map.add(s); } }
* Constant.Keywords.loaded[0] = true; if (Constant.Runtime.DevMode[0])
* { System.out.println(Constant.Keywords.NonStackingList[0].list); } }
*/
}
/** /**
* Gets the card overlay. * Gets the card overlay.
* *

View File

@@ -17,7 +17,7 @@ import forge.card.cardfactory.LazyCardFactory;
import forge.card.cardfactory.PreloadingCardFactory; import forge.card.cardfactory.PreloadingCardFactory;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.view.swing.OldGuiNewGame; import forge.view.swing.Main;
//import net.slightlymagic.braids.testng.BraidsAssertFunctions; //import net.slightlymagic.braids.testng.BraidsAssertFunctions;
@@ -44,7 +44,7 @@ public class CardFactoryTest {
*/ */
@BeforeMethod @BeforeMethod
public final void setUp() { public final void setUp() {
OldGuiNewGame.loadDynamicGamedata(); Main.loadDynamicGamedata();
this.factory = new LazyCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER)); this.factory = new LazyCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER));
} }