diff --git a/src/main/java/forge/view/swing/Main.java b/src/main/java/forge/view/swing/Main.java index 429a44984d8..7c13ec36636 100644 --- a/src/main/java/forge/view/swing/Main.java +++ b/src/main/java/forge/view/swing/Main.java @@ -17,7 +17,12 @@ */ package forge.view.swing; +import java.util.ArrayList; + import forge.AllZone; +import forge.Constant; +import forge.ConstantStringArrayList; +import forge.FileUtil; import forge.Singletons; import forge.error.ErrorViewer; import forge.error.ExceptionHandler; @@ -55,7 +60,7 @@ public final class Main { AllZone.setSkin(skin); // Need this soon after card factory is loaded - OldGuiNewGame.loadDynamicGamedata(); + Main.loadDynamicGamedata(); // TODO this code should go elsewhere, like wherever we start a new // game. @@ -66,10 +71,125 @@ public final class Main { view.setModel(model); - } catch (final Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: - // must - // catch all throwables here. + } catch (final Throwable exn) { ErrorViewer.showError(exn); } } + + /** + * Load dynamic gamedata. + */ + public static void loadDynamicGamedata() { + if (!Constant.CardTypes.LOADED[0]) { + final ArrayList typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt"); + + ArrayList 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 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 lcListFile = + * FileUtil.readFile("res/gamedata/LandColorList"); + * + * if (lcListFile.size() > 1) { for (int i=0; i 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); } } + */ + } } diff --git a/src/main/java/forge/view/swing/OldGuiNewGame.java b/src/main/java/forge/view/swing/OldGuiNewGame.java index fcfadc0e70d..23bc3f2c21c 100644 --- a/src/main/java/forge/view/swing/OldGuiNewGame.java +++ b/src/main/java/forge/view/swing/OldGuiNewGame.java @@ -18,15 +18,12 @@ package forge.view.swing; import java.awt.event.ActionEvent; -import java.util.ArrayList; import javax.swing.AbstractAction; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; import forge.Constant; -import forge.ConstantStringArrayList; -import forge.FileUtil; import forge.Singletons; import forge.error.ErrorViewer; import forge.gui.ListChooser; @@ -43,7 +40,7 @@ import forge.properties.NewConstants; * @author Forge * @version $Id$ */ -public class OldGuiNewGame { +public final class OldGuiNewGame { // @SuppressWarnings("unused") // titledBorder2 @@ -308,123 +305,6 @@ public class OldGuiNewGame { } } - /** - * Load dynamic gamedata. - */ - public static void loadDynamicGamedata() { - if (!Constant.CardTypes.LOADED[0]) { - final ArrayList typeListFile = FileUtil.readFile("res/gamedata/TypeLists.txt"); - - ArrayList 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 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 lcListFile = - * FileUtil.readFile("res/gamedata/LandColorList"); - * - * if (lcListFile.size() > 1) { for (int i=0; i 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. * diff --git a/src/test/java/forge/card/cardFactory/CardFactoryTest.java b/src/test/java/forge/card/cardFactory/CardFactoryTest.java index 358fd7302b3..6b76ce42819 100644 --- a/src/test/java/forge/card/cardFactory/CardFactoryTest.java +++ b/src/test/java/forge/card/cardFactory/CardFactoryTest.java @@ -17,7 +17,7 @@ import forge.card.cardfactory.LazyCardFactory; import forge.card.cardfactory.PreloadingCardFactory; import forge.properties.ForgeProps; import forge.properties.NewConstants; -import forge.view.swing.OldGuiNewGame; +import forge.view.swing.Main; //import net.slightlymagic.braids.testng.BraidsAssertFunctions; @@ -44,7 +44,7 @@ public class CardFactoryTest { */ @BeforeMethod public final void setUp() { - OldGuiNewGame.loadDynamicGamedata(); + Main.loadDynamicGamedata(); this.factory = new LazyCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER)); }