private void GuessCard()
        {
            Casino casino = new Casino();
            Card pickedCard = new Card();
            string hintMessage;
            int guesses = int.Parse(lblGuesses.Text);

            foreach (Card card in _deck)
                _mysteryCard = new GuessCard(card);

                foreach (Card guessCard in _deckToPick)
                {
                    if (cbPickDeck.SelectedItem.ToString() == guessCard.ToString())
                    {
                        hintMessage = _mysteryCard.CardHints(guessCard);
                        lblHints.Text = hintMessage;
                        pickedCard = guessCard;
                    }
                }
                if (_mysteryCard.IsWinner(pickedCard))
                {
                    lblCard.Visible = true;
                    lblCardName.Visible = false;
                    DialogResult result = MessageBox.Show("You are a winner! \nWould you like to play again?",
                                                           "Guess The Card Result",
                                                          MessageBoxButtons.YesNo);
                    switch (result)
                    {
                        case DialogResult.Yes: StartGame();
                            break;
                        case DialogResult.No: casino.Show();
                            break;
                    }
                }
                else if (guesses == 4)
                {
                    lblGuesses.Text = "5";
                    DialogResult result = MessageBox.Show("You are a loser! \nWould you like to play again?",
                                                           "Guess The Card Result",
                                                          MessageBoxButtons.YesNo);
                    switch (result)
                    {
                        case DialogResult.Yes: StartGame();
                            break;
                        case DialogResult.No: casino.Show();
                            break;
                    }

                }
                else
                {
                    _deckToPick.Discard(pickedCard);
                    LoadDeck();

                    guesses++;
                    lblGuesses.Text = guesses.ToString();
                }
        }
Example #2
0
        private void GuessCard()
        {
            Casino casino     = new Casino();
            Card   pickedCard = new Card();
            string hintMessage;
            int    guesses = int.Parse(lblGuesses.Text);

            foreach (Card card in _deck)
            {
                _mysteryCard = new GuessCard(card);
            }

            foreach (Card guessCard in _deckToPick)
            {
                if (cbPickDeck.SelectedItem.ToString() == guessCard.ToString())
                {
                    hintMessage   = _mysteryCard.CardHints(guessCard);
                    lblHints.Text = hintMessage;
                    pickedCard    = guessCard;
                }
            }
            if (_mysteryCard.IsWinner(pickedCard))
            {
                lblCard.Visible     = true;
                lblCardName.Visible = false;
                DialogResult result = MessageBox.Show("You are a winner! \nWould you like to play again?",
                                                      "Guess The Card Result",
                                                      MessageBoxButtons.YesNo);
                switch (result)
                {
                case DialogResult.Yes: StartGame();
                    break;

                case DialogResult.No: casino.Show();
                    break;
                }
            }
            else if (guesses == 4)
            {
                lblGuesses.Text = "5";
                DialogResult result = MessageBox.Show("You are a loser! \nWould you like to play again?",
                                                      "Guess The Card Result",
                                                      MessageBoxButtons.YesNo);
                switch (result)
                {
                case DialogResult.Yes: StartGame();
                    break;

                case DialogResult.No: casino.Show();
                    break;
                }
            }
            else
            {
                _deckToPick.Discard(pickedCard);
                LoadDeck();

                guesses++;
                lblGuesses.Text = guesses.ToString();
            }
        }