Exemplo n.º 1
0
        /// <summary>
        /// Initiates the gameplay by establishing the first drawn card as the designated trump suit,
        /// dealing 6 cards to each player, and declaring the first player to attack
        /// based on which player possesses the lowest ranking trump card
        /// </summary>
        /// ***TODO: Determine first attacker based on lowest trump card in initial hand
        /// (rather than assume the player is always the attacked off the bat)***
        private void StartGame()
        {
            cbxDeck.FaceUp = false;
            // shuffle
            mainDeck.Shuffle();

            // seeing the order of the deck in debug console for debugging
            //mainDeck.ShowDeck(); // This shows all cards, turn this off when done development
            System.Diagnostics.Debug.WriteLine(mainDeck.ToString());
            try
            {
                // The 14th card will be the trump
                cbxTrumpCard.Card = mainDeck.GetCard(13);
                System.Diagnostics.Debug.WriteLine(cbxTrumpCard.Card.ToString());
                PlayingCard.trumpSuit = cbxTrumpCard.Card.Suit;

                InitialDeal();

                PlayingCard firstCard = mainDeck.DrawCard();

                cbxTrumpCard.Card = firstCard; // Moving the trump card to bottom

                // add the trump card back but at the last place in the deck
                mainDeck.AddCardAtBottom(firstCard);
            }
            catch (IndexOutOfRangeException)
            {
                System.Diagnostics.Debug.WriteLine("Exception caught when trying to draw card out of index.");
            }
        }
Exemplo n.º 2
0
Arquivo: Durak.cs Projeto: alto4/Durak
        /// <summary>
        /// When the main form loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmGame_Load(object sender, EventArgs e)
        {
            // TEST SHUFFLE
            mainDeck.Shuffle();

            // seeing the order of the deck in debug console for debugging
            mainDeck.ShowDeck();
            System.Diagnostics.Debug.WriteLine(mainDeck.ToString());

            //initialDeal();
            InitialDeal();
            PlayingCard firstCard = mainDeck.DrawCard();

            this.cbxDeck.Card = firstCard;

            txtPlayHistory.Text += firstCard.Suit + " is the initial trump suit.";
            //txtPlayHistory.Text += "\nThere are now " + mainDeck.Count() + " cards left in the deck";

            //Wire out the out of cards event handler
            //mainDeck.OutOfCards MAKE A METHOD TO TRIGGER AN OUT OF CARDS EVENT
            //Show the number of cards left in the deck
        }