using System.Collections.Generic; using System.Linq; namespace BlackjackClasses { public class Hand { public readonly List Cards; public Hand(List cards) { Cards = cards; } public Hand() { Cards = new List(); } public void Add(Card paramCard) { Cards.Add(paramCard); } public void Add(List cardList) { Cards.AddRange(cardList); } public int getScore() { int score = 0; bool areAces = Cards.Exists(x => x.FaceValue.Equals(Card.CardValues.Ace)); if (areAces) { int aceCount = Cards.Count(y => y.FaceValue.Equals(Card.CardValues.Ace)); List handWithoutAces = Cards.FindAll(notAce => (!notAce.FaceValue.Equals(Card.CardValues.Ace))); foreach (Card card in handWithoutAces) { score += card.RealValue; } for (int i = 0; i < aceCount; i++) { if ((score + 11) > 21) score++; else score += 11; } } else { foreach (var list in Cards) { score += list.RealValue; } } return score; } } }