Example #1
0
        private void _cantGoButton_Click(object sender, RoutedEventArgs e)
        {
            _cantGoButton.IsEnabled = false;
            Player      player     = new Player("name", _userCards);
            List <Card> cardsDrawn = _gameDeck.Deal(1);

            //Checks if card draw is equal to the card in the pile
            if (player.CardMatches(cardsDrawn[cardsDrawn.Count - 1], playPile[playPile.Count - 1]) == true)
            {
                playPile.Add(cardsDrawn[cardsDrawn.Count - 1]);
                ShowCardImage(_playPile, playPile[playPile.Count - 1]);
            }
            foreach (Button button in _userButtons)
            {
                button.IsEnabled = false;
            }
            //AI Computers turns
            AIComputer comp1 = new AIComputer(comp1Hand);

            //Adds the AI computers cards into the pile
            playPile.AddRange(comp1.Play(playPile[playPile.Count - 1]));
            //Checks if the computer wins
            _win = comp1.CheckWinOrLoss();
            //Shows the card in the center pile
            ShowCardImage(_playPile, playPile[playPile.Count - 1]);
            AIComputer comp2 = new AIComputer(comp2Hand);

            playPile.AddRange(comp2.Play(playPile[playPile.Count - 1]));
            _win = comp2.CheckWinOrLoss();
            ShowCardImage(_playPile, playPile[playPile.Count - 1]);
            AIComputer comp3 = new AIComputer(comp3Hand);

            playPile.AddRange(comp3.Play(playPile[playPile.Count - 1]));
            _win = comp3.CheckWinOrLoss();
            ShowCardImage(_playPile, playPile[playPile.Count - 1]);

            _cantGoButton.IsEnabled = true;

            //Enables all the user card buttons after the AI's have gone
            foreach (Button button in _userButtons)
            {
                button.IsEnabled = true;
            }
        }