Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created July 30, 2019 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/7549ab5c4b85dee63c22381dbe64ef98 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/7549ab5c4b85dee63c22381dbe64ef98 to your computer and use it in GitHub Desktop.
private void Button_Click(object sender, EventArgs e)
{
var button = (Button)sender;
int column = Grid.GetColumn(button);
int row = Grid.GetRow(button);
if (FieldIsLegal(column, row))
{
MarkField(button, column, row);
var playerWon = CheckForWinner();
if (playerWon)
{
GameInformation.Content = $"{GetCurrentSymbol()} hat gewonnen!";
gameActive = false;
}
else if (fieldsMarked >= FIELD_SIZE * FIELD_SIZE)
{
GameInformation.Content = "Unentschieden!";
gameActive = false;
}
else
{
SwitchPlayer();
GameInformation.Content = $"{GetCurrentSymbol()} ist am Zug";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment