コード例 #1
0
        // Main game loop
        void Play()
        {
            Boolean draw;
            int     drawCounter;
            int     pointCounter;

            // each round
            do
            {
                Rounds++;
                pointCounter = 0;
                deck.GetPlayerCards(ref P1, ref P2);
                pointCounter++;

                Console.WriteLine($"P1 Score: {P1.Points}\tP2 Score: {P2.Points}\nRound: {Rounds}");

                Console.WriteLine($"Player 1 plays: {P1.Card}\tPlayer 2 plays: {P2.Card}");
                // each draw
                do
                {
                    draw = CheckRoundOutcome(P1, P2, pointCounter);
                    if (draw)
                    {
                        Console.WriteLine($"                   {new string('>', 9)}WAR{new string('<', 9)}");
                        drawCounter = 0;
                        while (drawCounter < 4 && !deck.Empty(P1, P2))
                        {
                            drawCounter++;
                            deck.GetPlayerCards(ref P1, ref P2);
                            pointCounter++;
                            Console.WriteLine($"                {P1.Card}\t                {P2.Card}");
                        }
                        draw = CheckRoundOutcome(P1, P2, pointCounter);
                    }
                } while (draw);
                Console.WriteLine("Press <enter> to continue...");
                Console.ReadLine();
            } while (!deck.Empty(P1, P2) && Rounds < 26);

            CheckGameOutcome(P1, P2);
        }