From 4dd411d619eb52df966b26bf414f47869cd559aa Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Thu, 11 Apr 2019 11:35:22 +0000 Subject: [PATCH] SimulationTestCase: fix Game init with Localizer --- .../ai/simulation/SimulationTestCase.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/forge-gui-desktop/src/test/java/forge/ai/simulation/SimulationTestCase.java b/forge-gui-desktop/src/test/java/forge/ai/simulation/SimulationTestCase.java index 7b7a8bfe108..4cac504d5f9 100644 --- a/forge-gui-desktop/src/test/java/forge/ai/simulation/SimulationTestCase.java +++ b/forge-gui-desktop/src/test/java/forge/ai/simulation/SimulationTestCase.java @@ -29,22 +29,13 @@ import forge.item.IPaperCard; import forge.model.FModel; import forge.properties.ForgePreferences; import forge.properties.ForgePreferences.FPref; + import junit.framework.TestCase; public class SimulationTestCase extends TestCase { private static boolean initialized = false; protected Game initAndCreateGame() { - List players = Lists.newArrayList(); - Deck d1 = new Deck(); - players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p2", null))); - Set options = new HashSet<>(); - options.add(AIOption.USE_SIMULATION); - players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p1", options))); - GameRules rules = new GameRules(GameType.Constructed); - Match match = new Match(rules, players, "Test"); - Game game = new Game(players, rules, match); - game.setAge(GameStage.Play); if (!initialized) { GuiBase.setInterface(new GuiDesktop()); @@ -57,6 +48,19 @@ public class SimulationTestCase extends TestCase { }); initialized = true; } + + // need to be done after FModel.initialize, or the Localizer isn't loaded yet + List players = Lists.newArrayList(); + Deck d1 = new Deck(); + players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p2", null))); + Set options = new HashSet<>(); + options.add(AIOption.USE_SIMULATION); + players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p1", options))); + GameRules rules = new GameRules(GameType.Constructed); + Match match = new Match(rules, players, "Test"); + Game game = new Game(players, rules, match); + game.setAge(GameStage.Play); + return game; }