From 0e073fe1d42bc0af9fee774727c66a160c2867e1 Mon Sep 17 00:00:00 2001 From: Scott Clayton Date: Fri, 16 Dec 2016 11:10:29 -0600 Subject: [PATCH] Fixed valid moves UI issue --- Chase.GUI/GameForm.cs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Chase.GUI/GameForm.cs b/Chase.GUI/GameForm.cs index dcb60f3..29c1933 100644 --- a/Chase.GUI/GameForm.cs +++ b/Chase.GUI/GameForm.cs @@ -161,7 +161,14 @@ private void RefreshBoard(Move lastmove) } // Status information - infoLabel.Text = game.PlayerToMove.ToString() + "'s Turn"; + if (type == GameType.NotStarted) + { + infoLabel.Text = "Ready"; + } + else + { + infoLabel.Text = game.PlayerToMove.ToString() + "'s Turn"; + } } private void ClickTile(int index) @@ -215,18 +222,21 @@ private void ClickTile(int index) } else { - // Select a source tile - selectedFromTile = index; - - // If the move we need to make is filling in points after a capture List moves = game.GetAllMoves(); - if (moves.Count > 0 && moves[0].Increment > 0) + if (moves.Count > 0 && moves.Any(x => x.FromIndex == index)) { - Move move = moves.FirstOrDefault(x => x.ToIndex == selectedFromTile); + // Select a source tile + selectedFromTile = index; - if (move != null) + // If the move we need to make is filling in points after a capture + if (moves[0].Increment > 0) { - MakeMove(move); + Move move = moves.FirstOrDefault(x => x.ToIndex == selectedFromTile); + + if (move != null) + { + MakeMove(move); + } } } }