Exemplo n.º 1
0
        /// <summary>
        /// Start a new round
        /// </summary>
        public void ContinueGame()
        {
            CurrentPlayer = players.IndexOf(GetCroupier()) + 1;
            foreach (Player player in Players)
            {
                if (player.IsCroupier)
                {
                    continue;
                }
                foreach (Card card in player.Hand)
                {
                    Discarded.Push(card);
                    card.Deck = Discarded;
                }
                player.Clear();
                GiveCard(Players.IndexOf(player), 2);
            }
            Player croupier = GetCroupier();

            foreach (Card card in croupier.Hand)
            {
                Discarded.Push(card);
                card.Deck = Discarded;
            }
            croupier.Clear();
            GiveCard(players.IndexOf(GetCroupier()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Give a number of cards to a player
        /// </summary>
        /// <param name="playerId">Player that receives cards</param>
        /// <param name="count">Number of cards the player receives</param>
        private void GiveCard(int playerId, int count = 1)
        {
            if (MyDeck.Count < count)
            {
                throw new NotEnoughCardsException();
            }
            Player player = Players[playerId];

            for (int i = 0; i < count; i++)
            {
                if (player.Hand.Any(card => card.ToStringShort == MyDeck.Peek().ToStringShort) == false)
                {
                    Card card = myDeck.Pop();
                    player.AddCard(card);
                }
                else
                {
                    Card card = myDeck.Pop();
                    Discarded.Push(card);
                    card.Deck = Discarded;
                    GiveCard(playerId);
                }
            }
        }