From 6a9ef3d94e1e8221fcbd4450114ee586763990b0 Mon Sep 17 00:00:00 2001 From: elcnesh Date: Tue, 16 Sep 2014 11:59:03 +0000 Subject: [PATCH] Fix showing all hands for hotseat and AI vs AI. --- .../src/main/java/forge/control/FControl.java | 8 +++++--- .../java/forge/screens/match/CMatchUI.java | 19 ++++++++++--------- .../limited/LimitedWinLoseController.java | 2 -- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/forge-gui-desktop/src/main/java/forge/control/FControl.java b/forge-gui-desktop/src/main/java/forge/control/FControl.java index 78e14393261..f6d7cd953d4 100644 --- a/forge-gui-desktop/src/main/java/forge/control/FControl.java +++ b/forge-gui-desktop/src/main/java/forge/control/FControl.java @@ -474,8 +474,10 @@ public enum FControl implements KeyEventDispatcher { } } + boolean openAllHands = !anyPlayerIsAi; if (this.gameView == null) { // Watch game but do not participate + openAllHands = true; final LocalGameView gameView = new WatchLocalGame(game, inputQueue); this.gameView = gameView; this.fcVisitor = new FControlGameEventHandler(GuiBase.getInterface(), gameView); @@ -484,7 +486,7 @@ public enum FControl implements KeyEventDispatcher { this.game.subscribeToEvents(playbackControl); } - attachToGame(this.gameView); + attachToGame(this.gameView, openAllHands); // It's important to run match in a different thread to allow GUI inputs to be invoked from inside game. // Game is set on pause while gui player takes decisions @@ -507,7 +509,7 @@ public enum FControl implements KeyEventDispatcher { private FControlGameEventHandler fcVisitor; private FControlGamePlayback playbackControl; - private void attachToGame(final IGameView game0) { + private void attachToGame(final IGameView game0, final boolean openAllHands) { if (game0.getGameType().equals(GameType.Quest)) { QuestController qc = FModel.getQuest(); // Reset new list when the Match round starts, not when each game starts @@ -525,7 +527,7 @@ public enum FControl implements KeyEventDispatcher { final LobbyPlayer humanLobbyPlayer = getGuiPlayer(); // The UI controls should use these game data as models final List players = game0.getPlayers(); - CMatchUI.SINGLETON_INSTANCE.initMatch(game0, players, humanLobbyPlayer); + CMatchUI.SINGLETON_INSTANCE.initMatch(game0, players, humanLobbyPlayer, openAllHands); localPlayer = null; for (final PlayerView p : players) { diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java index 23c2469ffaf..fdfdefce6ae 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java @@ -92,6 +92,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider { private IGameView game; private List sortedPlayers; private VMatchUI view; + private boolean allHands; private EventBus uiEvents; private IVDoc selectedDocBeforeCombat; @@ -119,14 +120,11 @@ public enum CMatchUI implements ICDoc, IMenuProvider { } /** - * Instantiates at a match with a specified number of players - * and hands. - * - * @param numFieldPanels int - * @param numHandPanels int + * Instantiates at a match. */ - public void initMatch(final IGameView game, final List players, LobbyPlayer localPlayer) { + public void initMatch(final IGameView game, final List players, final LobbyPlayer localPlayer, final boolean allHands) { this.game = game; + this.allHands = allHands; view = VMatchUI.SINGLETON_INSTANCE; // TODO fix for use with multiplayer @@ -160,15 +158,18 @@ public enum CMatchUI implements ICDoc, IMenuProvider { VPlayers.SINGLETON_INSTANCE.init(players); - initHandViews(localPlayer); + initHandViews(localPlayer, allHands); } - public void initHandViews(LobbyPlayer localPlayer) { + public void initHandViews(final LobbyPlayer localPlayer) { + this.initHandViews(localPlayer, this.allHands); + } + public void initHandViews(final LobbyPlayer localPlayer, final boolean allHands) { final List hands = new ArrayList(); int i = 0; for (final PlayerView p : sortedPlayers) { - if (p.getLobbyPlayer().equals(localPlayer) || !p.getHandCards().isEmpty()) { + if (allHands || p.getLobbyPlayer().equals(localPlayer) || !p.getHandCards().isEmpty()) { VHand newHand = new VHand(EDocID.Hands[i], p); newHand.getLayoutControl().initialize(); hands.add(newHand); diff --git a/forge-gui/src/main/java/forge/limited/LimitedWinLoseController.java b/forge-gui/src/main/java/forge/limited/LimitedWinLoseController.java index 981a7b909c7..4d696948ec0 100644 --- a/forge-gui/src/main/java/forge/limited/LimitedWinLoseController.java +++ b/forge-gui/src/main/java/forge/limited/LimitedWinLoseController.java @@ -10,7 +10,6 @@ import forge.view.IGameView; public abstract class LimitedWinLoseController { private final IWinLoseView view; private final IGameView lastGame; - private final IGuiBase gui; private final boolean wonMatch; private GauntletMini gauntlet; private boolean nextRound = false; @@ -18,7 +17,6 @@ public abstract class LimitedWinLoseController { public LimitedWinLoseController(IWinLoseView view0, final IGameView game0, final IGuiBase gui) { view = view0; lastGame = game0; - this.gui = gui; gauntlet = FModel.getGauntletMini(gui); wonMatch = lastGame.isMatchWonBy(GamePlayerUtil.getGuiPlayer()); }