Skip to content

Commit

Permalink
Fixed valid moves UI issue
Browse files Browse the repository at this point in the history
  • Loading branch information
skotz committed Dec 16, 2016
1 parent eec592b commit 0e073fe
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Chase.GUI/GameForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<Move> 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);
}
}
}
}
Expand Down

0 comments on commit 0e073fe

Please sign in to comment.