Ejemplo n.º 1
0
        static void CheckFiveCard()
        {
            //Deckをつくってまぜる
            var myDeck = new Deck();

            myDeck.Shuffle();
            var player = new Player();

            const int DRAWNUM = 5;

            for (int i = 0; i < DRAWNUM; i++)
            {
                player.Cards.Add(myDeck.Draw());
                DrawMessageLight(player.Cards.Last(), player.Cards.Count);
            }
            DrawLine();

            //Pair判定と出力
            HasPairMessage(player.IsHasOnePair());

            //twoPair判定と出力
            HasTwoPairMessage(player.IsHasDoublePair());

            //threeOfAKind判定と出力
            HasThreeCardMessage(player.IsHasTrio());
        }
Ejemplo n.º 2
0
        static void AllDraw()
        {
            //Deckをつくってまぜる
            var myDeck = new Deck();

            myDeck.Shuffle();

            //引いたカードを保管する
            var Draws = new List <Card>();

            //while版
            while (myDeck.Count() > 0)
            {
                Draws.Add(myDeck.Draw());
                DrawMessage(Draws.Last(), Draws.Count);
            }
        }
        static void Main(string[] args)
        {
            Deck newDeck = new Deck();

            newDeck.Shuffle();
            Console.WriteLine("Creating a new deck...");
            Console.WriteLine("\n");
            newDeck.ListCards();
            Console.WriteLine("\n");
            Console.WriteLine("Drawn cards...");
            Console.WriteLine("\n");
            Card[] tempCards = newDeck.Draw(5);
            foreach (Card cards in tempCards)
            {
                Console.WriteLine(cards.ToString());
            }
            Console.WriteLine("\n");
            Console.WriteLine("New shuffled deck...");
            Console.WriteLine("\n");
            newDeck.ListCards();
            Console.WriteLine("\n");
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public void Play()
        {
            //set up objects
            Setup();
            //Shuffle the deck
            mainDeck.Shuffle();
            //Deal 9 cards to each player
            Deal();

            //get the right player
            int count        = 0;
            int playerChoice = 0;

            //Add a card to the discard pile to initialize it.
            //Set its faceup value to true.  NOTE: All cards in discard pile
            //are face up.
            discardPile.Add(mainDeck.Draw());

            //Set up logic to turn 3 random cards face up per player
            int randomPosition;

            for (int i = 0; i < 3; i++)
            {
                randomPosition = rnd.Next(0, 9);

                //Loops keep checking the player hand until it finds a facedown.
                //Prevents from trying to change cards that are already face up.
                while (true)
                {
                    if (pHands[0].Peek(randomPosition).FaceUp == false)
                    {
                        pHands[0].Peek(randomPosition).FaceUp = true;
                        break;
                    }
                    randomPosition = rnd.Next(0, 9);
                }

                while (true)
                {
                    if (pHands[1].Peek(randomPosition).FaceUp == false)
                    {
                        pHands[1].Peek(randomPosition).FaceUp = true;
                        break;
                    }
                }
            }

            while (Turn(players[playerChoice], pHands[playerChoice]))
            {
                Console.WriteLine("\n");


                for (int i = 0; i < 9; i++)
                {
                    if (i == 3 || i == 6)
                    {
                        Console.Write("\n");
                    }
                    Console.Write("{0}{1}{2}  ", pHands[playerChoice].Peek(i).Suit, pHands[playerChoice].Peek(i).Value, pHands[playerChoice].Peek(i).FaceUp);
                }

                count++;
                playerChoice = count % 2;
            }

            //Get the score for each hand
            Console.WriteLine("\n");
            Console.WriteLine("Player 1 score: {0}", pHands[0].Score());
            Console.WriteLine("Player 2 score: {0}", pHands[1].Score());
        }