/**************************************************************************************** * 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}"; }
/**************************************************************************************** * 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]); }
/**************************************************************************************** * 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); }
public void ChooseCard(ListBox LB, int index) { if (Sim.CurrentPlayer != index) { lblInstruction.Text = "Not your cards! use other box!"; return; } Card ChosenCard; try { ChosenCard = (Card)LB.SelectedItem; } catch { return; } if (ChosenCard == null) { return; } if (Sim.Board.Players[Sim.CurrentPlayer].Hand.Count(o => o.Type == CardType.PlaceMeeple) > 0) { if (ChosenCard.Type != CardType.PlaceMeeple) { lblInstruction.Text = "You Must choose PlaceMeeple at the start!"; return; } } SelectedCard = ChosenCard; StealthX = -1; StealthY = -1; if (ChosenCard.Type == CardType.PlaceMeeple) { lblInstruction.Text = "Card selected: " + ChosenCard.ToString() + ", now pick a destination!"; SelectedMeeple = Sim.Board.Meeples.First(o => o.X < 0 && o.Player.ID == Sim.CurrentPlayer); } else { lblInstruction.Text = "Card selected: " + ChosenCard.ToString() + ", now pick a meeple!"; } }