Beispiel #1
0
        /// <summary>
        /// Plays the first phase of play for the game.
        /// </summary>
        /// <param name="info"> The current game info. </param>
        protected void PlayPhaseOne(GermanWhistInfo info)
        {
            // Plays 13 rounds
            for (int i = 0; i < 13; i++, info.RoundNumber++)
            {
                // Reset the suit order
                SuitOrder.Reset();
                SuitOrder.SetTrumps(info.Trumps);

                // Sets the card being played for to the top card in the deck
                info.ToPlayFor = this.Deck[0];

                // Make each player play a card
                foreach (GermanWhistPlayer play in this.Players)
                {
                    Console.Clear();
                    Console.WriteLine("Player {0}'s turn", play.ID);
                    Console.ReadKey(true);
                    Console.Clear();

                    this.MakePlayerMove(info, play);
                }

                Console.Clear();

                // Decide who won the card and give players their new cards
                int winnerIndex = this.DecideCardWinner(info);

                Console.ReadKey(true);

                // Reset variables that need to be reset
                info.CardsInPlay.Clear();
                info.FirstSuitLaid = Suit.Null;

                // Swap the players if the second player won
                if (winnerIndex == 1)
                {
                    this.OrderPlayer();
                }
            }

            info.ToPlayFor = new Card(Value.Null, Suit.Null);
        }
Beispiel #2
0
        /// <summary>
        /// Plays the second phase of play for the game.
        /// </summary>
        /// <param name="info"> The current game info. </param>
        protected void PlayPhaseTwo(GermanWhistInfo info)
        {
            // Play 13 rounds
            for (int i = 0; i < 13; i++, info.RoundNumber++)
            {
                // Reset the suit order
                SuitOrder.Reset();
                SuitOrder.SetTrumps(info.Trumps);

                // Make each player play a card
                foreach (GermanWhistPlayer play in this.Players)
                {
                    Console.Clear();
                    Console.WriteLine("Player {0}'s turn", play.ID);
                    Console.ReadKey(true);
                    Console.Clear();

                    this.MakePlayerMove(info, play);
                }

                Console.Clear();

                // Decide who won the trick
                int winnerIndex = this.DecideTrickWinner(info);

                Console.ReadKey(true);

                // Reset info
                info.CardsInPlay.Clear();
                info.FirstSuitLaid = Suit.Null;

                // Swap the players if the second player won
                if (winnerIndex == 1)
                {
                    this.OrderPlayer();
                }
            }

            Console.WriteLine("\n\n");
        }
Beispiel #3
0
        public void WorstCardTest()
        {
            // arrange
            List <Card> cardsList = new List <Card>();

            cardsList.Add(new Card(Value.Ace, Suit.Spades));
            cardsList.Add(new Card(Value.Ace, Suit.Diamonds));
            cardsList.Add(new Card(Value.King, Suit.Diamonds));
            cardsList.Add(new Card(Value.Seven, Suit.Clubs));
            Card[] cards = cardsList.ToArray();

            // arrange 1
            SuitOrder.Reset();
            Settings.AceHigh = false;

            // act
            Card actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[1], actual);

            // arrange 2
            SuitOrder.Reset();
            Settings.AceHigh = true;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[3], actual);

            // arrange 3
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Spades);
            Settings.AceHigh = false;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[1], actual);

            // arrange 4
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Spades);
            Settings.AceHigh = true;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[3], actual);

            // arrange 5
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Diamonds);
            Settings.AceHigh = false;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[0], actual);

            // arrange 6
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Diamonds);
            Settings.AceHigh = true;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[3], actual);

            // arrange 7
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Clubs);
            Settings.AceHigh = false;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[1], actual);

            // arrange 8
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Clubs);
            Settings.AceHigh = true;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[2], actual);

            // arrange 9
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Hearts);
            SuitOrder.SetPlayed(Suit.Diamonds);
            Settings.AceHigh = false;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[0], actual);

            // arrange 10
            SuitOrder.Reset();
            SuitOrder.SetTrumps(Suit.Hearts);
            SuitOrder.SetPlayed(Suit.Diamonds);
            Settings.AceHigh = true;

            // act
            actual = Card.LowestCardFromArray(cards);

            // assert
            Assert.AreEqual(cardsList[3], actual);
        }