예제 #1
0
        private void SpinWheelAndGuessLetter()
        {
            int wheelResult = wheel.Spin();

            if (wheelResult == 0)
            {
                Console.WriteLine("Uh, you lose a turn");
                loseTurn = true;
            }
            else if (wheelResult < 0)
            {
                Console.WriteLine("Sorry, bankrupt...");
                player.CurrentMoney = 0;
                bankrupt            = true;
            }
            else
            {
                Console.WriteLine("You will get ${0} for each correct letter! Guess a letter please", wheelResult);
                char guessedLetter = Console.ReadKey().KeyChar;
                int  count         = challenge.CheckLetter(guessedLetter);
                if (count == 0)
                {
                    Console.WriteLine("The answer doesn't include this letter");
                    loseTurn = true;
                }
                else
                {
                    player.CurrentMoney += wheelResult * count;
                    Console.WriteLine();
                    Console.WriteLine("Great job! You won ${0} for {1} correct letters!", wheelResult * count, count);
                }
            }
        }
예제 #2
0
        }   // end btnSolve_Click method

        /* ---------- btnSpin_Click Method ---------- */

        /*   Divide the game into two parts:
         *   Part 1: Player spins the wheel.
         *   Part 2: Player guesses a letter. */
        private void btnSpin_Click(object sender, EventArgs e)
        {
            /* ----- Game part 1: Spin the wheel ----- */
            // Create an instance of Wheel class
            Wheel spinWheel = new Wheel();

            spinWheel.Spin();
            dollarSpinned = spinWheel.GetValue;
            MessageBox.Show(player.Name + " landed on $" + dollarSpinned);

            if (dollarSpinned != -1000 && dollarSpinned != 0)
            {
                /* ----- Game part 2: Guess a letter ----- */
                GuessALetter();
            }
            else
            {
                // the value of wheel lands on -1000 or 0
                MessageBox.Show(player.Name + " lost this turn.");
                DisplayReward();
                PassGameToNext();
            }
        }   // end btnSpin_Click method