Exemplo n.º 1
0
        public async Task <Game> SetupGameAsync()
        {
            var boardState = _board.ResetGameBoardState();

            //Create a new game with 3 players, 1 himan 1 unskilled AI and 1 skilled AI.
            _players = new List <IPlayer>
            {
                new HumanPlayer(_board),
                new SkilledPlayer(_board),
                new UnSkilledPlayer(_board)
            };

            _state = new GameState(_players);

            _deck.Shuffle();
            _deck.Deal(ref _players);

            //Find out which player goes first and set as current player
            CurrentPlayer = _players.Where(x => x.HasSevenDiamonds()).First();
            _humanPlayer  = _players.First(x => x.IsHuman()) as IHumanPlayer;

            var response = new Game
            {
                BoardState = boardState,
                History    = await _state.GetHistory(),
                GameOver   = await _state.IsGameOver(),
                PlayerHand = _humanPlayer.ShowHand(),
                NextPlayer = CurrentPlayer
            };


            return(response);
        }
Exemplo n.º 2
0
        public async Task <Game> StartGame()
        {
            var boardState = _board.GetGameBoardState();

            CurrentPlayer.FirstTurn(_state);

            var response = new Game
            {
                BoardState = boardState,
                History    = await _state.GetHistory(),
                GameOver   = await _state.IsGameOver(),
                PlayerHand = _humanPlayer.ShowHand(),
                NextPlayer = await GetNextPlayerAsync()
            };

            CurrentPlayer = response.NextPlayer;

            return(response);
        }