Example #1
0
        public PlayResponse Play(PlayRequest playRequest)
        {
            PlayResponse playResponse = new PlayResponse();

            if (playRequest.TicTacToeBoard[playRequest.PositionX][playRequest.PositionY] == ControlEnums.Player.None)
            {
                playRequest.TicTacToeBoard[playRequest.PositionX][playRequest.PositionY] = Player;

                playResponse.TicTacToeBoard = playRequest.TicTacToeBoard;
            }

            playResponse.PlayerWon = _victoryValidator.CheckForVictory(playRequest.TicTacToeBoard, Player);

            return(playResponse);
        }
Example #2
0
        public PlayResponse Play(PlayRequest playRequest)
        {
            PlayResponse PlayResponse = new PlayResponse();

            for (int i = 0; i < playRequest.TicTacToeBoard.Count; i++)
            {
                for (int j = 0; j < playRequest.TicTacToeBoard.Count; j++)
                {
                    if (playRequest.TicTacToeBoard[i][j].Equals(ControlEnums.Player.None))
                    {
                        playRequest.TicTacToeBoard[i][j] = Player;

                        PlayResponse.TicTacToeBoard = playRequest.TicTacToeBoard;
                        PlayResponse.PlayerWon      = _victoryValidator.CheckForVictory(playRequest.TicTacToeBoard, Player);

                        return(PlayResponse);
                    }
                }
            }

            PlayResponse.TicTacToeBoard = playRequest.TicTacToeBoard;
            return(PlayResponse);
        }