コード例 #1
0
        public void PlayGame()
        {
            this.outputText = "";

            //Shuffle the cards
            GameCardsDeck.ShuffleCards();
            GameCardsDeck.ShuffleCards();

            //Deal the cards to the players
            DealCards();

            //Perform 20 rounds of the game loop
            for (int i = 0; i < 20; i++)
            {
                PlayRound();
            }

            //Determine who won
            DetermineWinner();
        }
コード例 #2
0
        private void DealCards()
        {
            bool playerToggle = true;

            while (GameCardsDeck.CountCardsInDeck() > 0)
            {
                if (playerToggle)
                {
                    //Deal card to player 1
                    PlayerOne.ReceiveCard(GameCardsDeck.DealCard());
                    playerToggle = !playerToggle;
                }
                else
                {
                    //Deal card to player 2
                    PlayerTwo.ReceiveCard(GameCardsDeck.DealCard());
                    playerToggle = !playerToggle;
                }
            }
        }