From bc248c60090f04a2ba22bbca90e083d8e474580e Mon Sep 17 00:00:00 2001 From: melvinzhang Date: Sat, 4 Apr 2015 21:20:08 +0800 Subject: [PATCH] replace call to setDifficulty and setAIs with MagicPlayerDefinition constructor that takes a player profile --- .../ui/duel/viewer/DeckStrengthViewer.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/magic/ui/duel/viewer/DeckStrengthViewer.java b/src/magic/ui/duel/viewer/DeckStrengthViewer.java index 7f19d23018..c8f34ffc6b 100644 --- a/src/magic/ui/duel/viewer/DeckStrengthViewer.java +++ b/src/magic/ui/duel/viewer/DeckStrengthViewer.java @@ -8,6 +8,8 @@ import magic.ui.IconImages; import magic.model.MagicDuel; import magic.model.MagicGame; import magic.model.IGameController; +import magic.model.player.AiPlayer; +import magic.model.MagicPlayerDefinition; import magic.headless.HeadlessGameController; import magic.ui.theme.ThemeFactory; import magic.ui.widget.FontsAndBorders; @@ -49,8 +51,6 @@ public class DeckStrengthViewer extends JPanel implements ActionListener { private static final Color MEDIUM_COLOR=new Color(0xFF,0x7F,0x00); private static final Color LOW_COLOR=new Color(0xEE,0x2C,0x2C); - private static final MagicAI[] DEFAULT_AIS = {MagicAIImpl.MMABFast.getAI(),MagicAIImpl.MMABFast.getAI()}; - private final MagicDuel duel; private final JProgressBar progressBar; private final JLabel gameLabel; @@ -205,8 +205,18 @@ public class DeckStrengthViewer extends JPanel implements ActionListener { final DuelConfig config=new DuelConfig(DuelConfig.getInstance()); config.setNrOfGames(generalConfig.getStrengthGames()); final MagicDuel testDuel=new MagicDuel(config,duel); - testDuel.setDifficulty(generalConfig.getStrengthDifficulty()); - testDuel.setAIs(DEFAULT_AIS); + + final MagicPlayerDefinition[] players = new MagicPlayerDefinition[2]; + for (int i = 0; i < 2; i++) { + final AiPlayer pp = new AiPlayer(); + pp.setPlayerName(MagicAIImpl.DECKSTR_AIS[i].toString()); + pp.setAiType(MagicAIImpl.DECKSTR_AIS[i]); + pp.setAiLevel(generalConfig.getStrengthDifficulty()); + + players[i] = new MagicPlayerDefinition(pp, config.getPlayerDeckProfile(i)); + } + testDuel.setPlayers(players); + progressBar.setMaximum(testDuel.getGamesTotal()); progressBar.setValue(0); setStrength(0);