Ejemplo n.º 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            g_spriteBatch.Begin();

            if (!g_Deck.EmptyDeck())
            {
                g_Deck.DrawCard(g_spriteBatch, new Card(13, 0), new Vector2(10, 10));
            }

            gB_High.Draw(g_spriteBatch);
            gB_Low.Draw(g_spriteBatch);
            gB_RQ.Draw(g_spriteBatch);

            g_Deck.DrawDrawnCards(g_spriteBatch);

            g_Scoreboard.Draw(g_spriteBatch, font_Arial);

            g_spriteBatch.DrawString(font_Arial, "High:", new Vector2(screenWidth - 160, 40), Color.BlanchedAlmond);
            g_spriteBatch.DrawString(font_Arial, "Low:", new Vector2(screenWidth - 160, 110), Color.BlanchedAlmond);
            g_spriteBatch.DrawString(font_Arial, "RQ:", new Vector2(screenWidth - 160, 180), Color.BlanchedAlmond);

            g_Deck.DrawCard(g_spriteBatch, g_cCard, g_cCardPos);

            g_spriteBatch.End();

            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
        public void PlayGame()
        {
            theDeck.Shuffle();

            for (int i = 0; i < CardsPerPlayer; i++)
            {
                for (int j = 0; j < NumberOfPlayers; j++)
                {
                    Card lCard = theDeck.DrawCard();
                    Players[j].addCard(lCard);
                    lCard.Drawn = true;
                }
            }

            int lHighScore = CalculateHighScore();

            Winners = new List <Player>();
            for (int i = 0; i < Scores.Count; i++)
            {
                if (Scores[i] == lHighScore)
                {
                    Winners.Add(Players[i]);
                }
            }
        }
Ejemplo n.º 3
0
        private bool PlayGame(Board board, Deck deck)
        {
            board.ClearBoard();
            deck.Shuffle();

            int fails = 0;

            while (fails < 5)
            {
                if (board.IsBoardFull())
                {
                    break;
                }

                Card card = deck.DrawCard();
                if (!board.CanAddCard(card))
                {
                    fails++;
                }
                else
                {
                    board.AddCard(card);
                }
            }

            return(board.IsBoardFull());
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var deck = new Deck();

            Console.WriteLine("Q – quit the application");
            Console.WriteLine("N – get a new deck");
            Console.WriteLine("S – shuffle the current deck");
            Console.WriteLine("D – draw next card from current deck");
            Console.WriteLine("R – display on the console all of the cards remaining in the deck");

            string line;

            while (true)
            {
                line = Console.ReadLine();

                switch (line)
                {
                case "Q":
                    ;
                    return;

                case "N":
                    deck = new Deck();
                    break;

                case "S":
                    deck.ShuffleDeck();
                    break;

                case "D":
                    deck.DrawCard();
                    break;

                case "R":
                    deck.DisplayRemainingCards();
                    break;

                default:
                    Console.WriteLine("Please use one of the following when pressing Enter: ");
                    Console.WriteLine("Q – quit the application");
                    Console.WriteLine("N – get a new deck");
                    Console.WriteLine("S – shuffle the current deck");
                    Console.WriteLine("D – draw next card from current deck");
                    Console.WriteLine("R – display on the console all of the cards remaining in the deck");
                    break;
                }
            }
        }