Example #1
0
        public string GetStatus(int nextPlay)
        {
            int?t = null;

            if (!string.IsNullOrEmpty(_stateToken))
            {
                t = int.Parse(_stateToken);
            }

            var game = new TicTacToeGameBasic(t, nextPlay);

            return(GetStatusImpl(game));
        }
Example #2
0
        private string GetStatusImpl(TicTacToeGameBasic game)
        {
            if (game.IsWin)
            {
                var winner = "You ";

                if ((_isMachineFirst && game.AllGamePlays.Count % 2 != 0)
                    ||
                    (!_isMachineFirst && game.AllGamePlays.Count % 2 == 0)
                    )
                {
                    winner = "Machine ";
                }

                return(winner + "Win!");
            }

            if (game.IsTie)
            {
                return("Tie!");
            }

            return(String.Empty);
        }
Example #3
0
        public string GetStatus()
        {
            var game = new TicTacToeGameBasic(int.Parse(_stateToken));

            return(GetStatusImpl(game));
        }