SimulationTestCase: fix Game init with Localizer

This commit is contained in:
Hans Mackowiak
2019-04-11 11:35:22 +00:00
committed by Sol
parent 08d3015ed5
commit 4dd411d619

View File

@@ -29,22 +29,13 @@ import forge.item.IPaperCard;
import forge.model.FModel; import forge.model.FModel;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import junit.framework.TestCase; import junit.framework.TestCase;
public class SimulationTestCase extends TestCase { public class SimulationTestCase extends TestCase {
private static boolean initialized = false; private static boolean initialized = false;
protected Game initAndCreateGame() { protected Game initAndCreateGame() {
List<RegisteredPlayer> players = Lists.newArrayList();
Deck d1 = new Deck();
players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p2", null)));
Set<AIOption> 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) { if (!initialized) {
GuiBase.setInterface(new GuiDesktop()); GuiBase.setInterface(new GuiDesktop());
@@ -57,6 +48,19 @@ public class SimulationTestCase extends TestCase {
}); });
initialized = true; initialized = true;
} }
// need to be done after FModel.initialize, or the Localizer isn't loaded yet
List<RegisteredPlayer> players = Lists.newArrayList();
Deck d1 = new Deck();
players.add(new RegisteredPlayer(d1).setPlayer(new LobbyPlayerAi("p2", null)));
Set<AIOption> 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; return game;
} }