Beispiel #1
0
 public Player Constructor(uint playerNumber)
 {
     Player target = new Player(playerNumber);
     return target;
     // TODO: add assertions to method PlayerTest.Constructor(UInt32)
 }
Beispiel #2
0
        /// <summary>
        /// Player gains a card from the supply.
        /// </summary>
        /// <param name="player">
        /// The player gaining the card.
        /// </param>
        /// <param name="card">
        /// The card the player gains from the supply.
        /// </param>
        public void PlayerGainsCard(Player player, CardName card)
        {
            Contract.Requires(Players.Contains(player));
            Contract.Requires(Supply[card] != 0);

            Contract.Ensures(player.TopOfDiscard.Name == card);

            player.AddCardToZone(CardFactory.CreateCard(card), Zone.Discard);
            Supply[card]--;

            if (Supply[card] == 0)
            {
                if (card == CardName.Province)
                {
                    GameOver = true;
                }
                else
                {
                    numberOfEmptyPiles++;
                }
            }

            if (numberOfEmptyPiles == 3)
            {
                GameOver = true;
            }
        }