Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created July 27, 2019 11:15
Show Gist options
  • Save BMU-Verlag/07232c56ba0564e8786eb85cda033804 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/07232c56ba0564e8786eb85cda033804 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 (gameActive && fields[column][row] == Player.None)
{
var currentSymbol = "";
if (currentPlayer == Player.Player1)
{
currentSymbol = "X";
}
else
{
currentSymbol = "O";
}
button.Content = currentSymbol;
fields[column][row] = currentPlayer;
if (currentPlayer == Player.Player1)
{
currentPlayer = Player.Player2;
GameInformation.Content = "O ist am Zug";
}
else
{
currentPlayer = Player.Player1;
GameInformation.Content = "X ist am Zug";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment