private string ApplyTurn(int i, int j) { if (i < 0 || i >= 3) { return("Invalid row."); } if (j < 0 || j >= 3) { return("Invalid column."); } if (Table[i, j] != ' ') { return("Field is not empty."); } Table[i, j] = OnTurn; DisplayTable[i, j].Text = OnTurn.ToString(); if (CheckIsEnd()) { return("#END"); } SwitchTurn(); if (IsAIOnTurn) { AIDelay.Start(); } return(null); }
private void NewGame() { (PlayerType, PlayerType)? players = null; do { players = ChoosePlayers.Choose(); } while (players == null); Player1Type = players.Value.Item1; Player2Type = players.Value.Item2; ResetTable(); SyncDisplayTable(); OnTurn = 'X'; if (IsAIOnTurn) { AIDelay.Start(); } }