Fix showing all hands for hotseat and AI vs AI.

This commit is contained in:
elcnesh
2014-09-16 11:59:03 +00:00
parent 1907b47a54
commit 6a9ef3d94e
3 changed files with 15 additions and 14 deletions

View File

@@ -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<PlayerView> 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) {

View File

@@ -92,6 +92,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
private IGameView game;
private List<PlayerView> sortedPlayers;
private VMatchUI view;
private boolean allHands;
private EventBus uiEvents;
private IVDoc<? extends ICDoc> 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<PlayerView> players, LobbyPlayer localPlayer) {
public void initMatch(final IGameView game, final List<PlayerView> 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<VHand> hands = new ArrayList<VHand>();
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);