public static char GetPlayerChar(TicTacToePlayer player) { return(player == TicTacToePlayer.None ? ' ' : player == TicTacToePlayer.Tic ? 'X' : player == TicTacToePlayer.Tac ? 'O' : '?' ); }
public TicTacToeAction(int position, TicTacToePlayer player) { if (position < 0 || position > 8) { throw new ArgumentException("position must be between 0 and 8, inclusive", nameof(position)); } Position = position; Player = player; }
protected TicTacToePlayer CheckChainForWinner(List <TicTacToePlayer> chain) { // We only verify that all the players in the list are the same, the length needs to be the length to win if (chain.Count != ChainForWin) { return(TicTacToePlayer.None); } TicTacToePlayer leader = chain[0]; foreach (var p in chain) { if (p != leader) { return(TicTacToePlayer.None); } } return(leader); }
public TicTacToeGame() { NewGame(); CurrentPlayer = TicTacToePlayer.Tic; }
public void NextPlayer() { CurrentPlayer = CurrentPlayer == TicTacToePlayer.Tic ? TicTacToePlayer.Tac : TicTacToePlayer.Tic; }