private void UpdateControls()
{
labelLeftPips.Text = "Pips: " + currentGameState.Board.PipCount(0);
labelRightPips.Text = "Pips: " + currentGameState.Board.PipCount(1);
SetTurn(currentGameState.PlayerOnTurn);
if (currentGameState.Board.FinishedCount(0) == 15 || currentGameState.Board.FinishedCount(1) == 15 || status == GameStatus.GameOver)
{
Render();
this.Refresh();
MessageBox.Show("Gameover");
return;
}
if (madeMoves.Count > 0)
{
buttonUndo.Enabled = true;
buttonUndo.Visible = true;
}
if (currentGameState.PlayerOnTurn == 0 && currentGameState.PlayerOnRoll == 0 && currentGameState.CanDouble())
{
buttonDouble.Enabled = true;
buttonDouble.Visible = true;
}
else
{
buttonDouble.Enabled = false;
buttonDouble.Visible = false;
buttonDouble.Refresh();
}
if (currentGameState.PlayerOnTurn == 0 && currentGameState.PlayerOnRoll == 0 && currentGameState.DiceRolled && legalPlays.Count > 0 && legalPlays[0].Count > 0)
{
if (madeMoves.Count == legalPlays[0].Count)
{
buttonDone.Enabled = true;
buttonDone.Visible = true;
}
else
{
buttonDone.Enabled = false;
buttonDone.Visible = false;
}
}
if (currentGameState.PlayerOnTurn == 0 && !currentGameState.DiceRolled)
{
watch = Stopwatch.StartNew();
textBoxLog.Text += "Watch reset for move " + Environment.NewLine;
textBoxLog.SelectionStart = textBoxLog.Text.Length;
textBoxLog.ScrollToCaret();
buttonRoll.Enabled = true;
buttonRoll.Visible = true;
}
if (currentGameState.PlayerOnRoll == 0 && currentGameState.PlayerOnTurn == 0 && currentGameState.DiceRolled)
{
watch = Stopwatch.StartNew();
textBoxLog.Text += "Watch reset for move " + Environment.NewLine;
textBoxLog.SelectionStart = textBoxLog.Text.Length;
textBoxLog.ScrollToCaret();
}
if (currentGameState.PlayerOnTurn == 1)
HandleAI();
Render();
this.Refresh();
//this.Invalidate();
}