Esempio n. 1
0
        }                                              // Asocjacja z atrybutem

        public void AddList(CardInList cardInList)
        {
            if (!Lists.Contains(cardInList))
            {
                Lists.Add(cardInList);
            }
        }
Esempio n. 2
0
 public void AddCard(CardInList cardInList)
 {
     if (!Cards.Contains(cardInList))
     {
         Cards.Add(cardInList);
     }
 }
Esempio n. 3
0
        void CheckCardTotal(BlackJackPlayer player)
        {
            player.SetPoints(0);

            SendAcesToBack(player);
            foreach (Card CardInList in player.GetCardsInHand())
            {
                if (CardInList.GetNumber() == 11 || //Jack
                    CardInList.GetNumber() == 12 || //Queen
                    CardInList.GetNumber() == 13)   //King
                {
                    player.SetPoints(player.GetPoints() + 10);
                }
                else if (CardInList.GetNumber() == 1)
                {
                    if (PlayerList[(int)CurrentPlayer].GetPoints() > 10)
                    {
                        player.SetPoints(player.GetPoints() + 1);
                    }
                    else
                    {
                        player.SetPoints(player.GetPoints() + 11);
                    }
                }
                else
                {
                    player.SetPoints(player.GetPoints() + CardInList.GetNumber());
                }
            }
            CheckIfOver21(player);
        }
Esempio n. 4
0
        public void AddToList(CardInList cardInList)
        {
            if (Lists.Any(l => l.Card == cardInList.Card))
            {
                return;
            }

            Lists.Add(cardInList);
            cardInList.CardList.AddCard(this);
        }
Esempio n. 5
0
        public virtual void AddCard(int index, Card card, int quantity)
        {
            var cardInList = Cards.FirstOrDefault(c => c.Index == index);

            if (cardInList != null && cardInList.Card == card)
            {
                cardInList.Quantity += quantity;
            }
            else if (Cards.Any(c => c.Card == card))
            {
                throw new Exception("The indexes of given card don't match");
            }
            else
            {
                cardInList = new CardInList(card, this, index, quantity);
                Cards.Add(cardInList);
                card.AddToList(cardInList);
            }
        }