Esempio n. 1
0
        /****************************************************************************************
         * Method: SetupGame()
         * Programmer(s): Jayce Merinchuk, Upma Sharma
         * Date: August 09, 2018
         * Description: This method  enables/disables starting buttons, sets up the backs of the
         * cards, and tells the user to press the start button.
         * Input(s)/Output(s): No inputs, outputs a card picture and a message to the screen.
         * *************************************************************************************/
        private void SetupGame()
        {
            // Ensure only the start game button is waiting to be pressed
            StartGameButton.IsEnabled = true;
            PickCard1.IsEnabled       = false;
            PickCard2.IsEnabled       = false;
            PickCard3.IsEnabled       = false;
            ShuffleButton.IsEnabled   = false;

            // Start the game seeing the backs of the cards
            Card1.DisplayCard(14);
            Card2.DisplayCard(14);
            Card3.DisplayCard(14);
            ChosenCard.DisplayCard(14);
            OpponentCard.DisplayCard(14);

            // Notify User to press Start Game Button
            WinText.Text           = "Click The Start Game Button!";
            PlayerScoreText.Text   = $"Player Score: {PlayerScore}";
            OpponentScoreText.Text = $"Opponent Score: {OpponentScore}";
        }
Esempio n. 2
0
        /****************************************************************************************
         * Method: Start_Click()
         * Programmer(s): Jayce Merinchuk, Upma Sharma
         * Date: August 09, 2018
         * Description: Display the back of cards, enable buttons, for loop to pick new cards,
         * while loop to ensure no two cards picked were the same, output cards to the screen.
         * Input(s)/Output(s): No inputs, removes text message, enables buttons, outputs new
         * cards to the screen.
         * *************************************************************************************/
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            // Set the text of the start Game Button back to "Start Game" and clear the Card Value text Box
            StartGameButton.Content = "Start Game";
            CardValueText.Text      = "Card Value = ";

            // Start the game seeing the backs of the cards
            ChosenCard.DisplayCard(14);
            OpponentCard.DisplayCard(14);

            // Advise the user to choose a card
            WinText.Text = "Choose a card";

            // Enable the game buttons
            PickCard1.IsEnabled     = true;
            PickCard2.IsEnabled     = true;
            PickCard3.IsEnabled     = true;
            ShuffleButton.IsEnabled = true;

            // For loop to choose the cards
            for (int i = 0; i < Cards.Length; i++)
            {
                int CardValue = RandomGenerator.Next(1, 14);
                Cards[i] = CardValue;
            }
            // While loop to ensure no duplicate cards are chosen
            while (Cards[0] == Cards[1] || Cards[0] == Cards[2] || Cards[1] == Cards[2])
            {
                // For loop to choose the cards
                for (int i = 0; i < Cards.Length; i++)
                {
                    int CardValue = RandomGenerator.Next(1, 14);
                    Cards[i] = CardValue;
                }
            }
            // Display Cards
            Card1.DisplayCard(Cards[0]);
            Card2.DisplayCard(Cards[1]);
            Card3.DisplayCard(Cards[2]);
        }
Esempio n. 3
0
        /****************************************************************************************
         * Method: PickCard3Button_Click()
         * Programmer(s): Jayce Merinchuk, Upma Sharma
         * Date: August 09, 2018
         * Description: Disables buttons, puts chosen card in box, changes 3 cards to display
         * the back of the card, runs the ApplyGameRules() method.
         * Input(s)/Output(s): Input - button is clicked, Output: Back of cards displayed, chosen
         * card is placed in ChosenCard Box.
         * *************************************************************************************/
        private void PickCard3Button_Click(object sender, RoutedEventArgs e)
        {
            // Disable other buttons once a card has been chosen
            PickCard1.IsEnabled     = false;
            PickCard2.IsEnabled     = false;
            PickCard3.IsEnabled     = false;
            ShuffleButton.IsEnabled = false;

            // Put chosen card in the Chosen Card box
            ChosenCard.DisplayCard(Cards[2]);

            // Show the back of cards in the 3 upper boxes
            Card1.DisplayCard(14);
            Card2.DisplayCard(14);
            Card3.DisplayCard(14);

            // Player Index Chosen
            int PlayerIndex = Cards[2];

            // Run the rules of the game
            ApplyGameRules(PlayerIndex);
        }