Beispiel #1
0
        private void PlayComputer(Player player)
        {
            // Draw card.
            player.DrawCard();

            // Move between 0 and 3 times.
            var numberOfMoves = new Random().Next(4);

            for (int i = 0; i < numberOfMoves; i++)
            {
                var randomDestinationId = _gameEngine.RoomsAvailable[player.Position]
                                          [new Random().Next(_gameEngine.RoomsAvailable[player.Position].Count)];
                GoToARoom(_gameEngine.PlayersList.IndexOf(player), randomDestinationId);
            }

            var position = player.Position;

            // Play a random card.
            var randomCardIndex = new Random().Next(player.Hand.Count);
            var cardPlayed      = player.Hand.ElementAt(randomCardIndex);
            var success         = player.PlayCard(randomCardIndex);

            // Remove the card from the hand.
            player.Hand.Remove(cardPlayed);

            UpdateCurrentPlayPanel(_gameEngine.PlayersList.IndexOf(player), cardPlayed, success);

            var newPosition = player.Position;

            if (newPosition != position)
            {
                GoToARoom(_gameEngine.PlayersList.IndexOf(player), newPosition);
            }

            while (player.Hand.Count > 7)
            {
                player.LoseCard(null);
            }

            if (_gameEngine.CurrentYear == 1)
            {
                _gameEngine.PassToSophomoreYearIfNeeded();
            }
            _gameEngine.ApplyQpStep(player);
            if (_gameEngine.IsGameOver())
            {
                EndGame();
            }
        }