Exemple #1
0
        public CardState DiscardMatching(Func <CardState, bool> predicate)
        {
            var card = Random.ChoiceOrDefault(Hand.Where(predicate));

            if (card != null)
            {
                Discard(card);
            }
            return(card);
        }
Exemple #2
0
        public static Deck MakeRandomDeck(ICardCollection cardCollection, GameRules gameRules, int deckSize, Random random)
        {
            var cards = cardCollection.GetCards().ToList();

            if (deckSize < gameRules.MinDeckSize || deckSize > gameRules.MaxDeckSize)
            {
                throw new ArgumentException("Deck size is incorrect");
            }
            var deck = new Deck(gameRules);

            while (deck.Count < deckSize)
            {
                var card = random.ChoiceOrDefault(cards.Where(x => deck.CanAddCard(x)));
                if (card == null)
                {
                    throw new ArgumentException("Collection is not large enough");
                }
                deck.Add(card);
            }
            return(deck);
        }
Exemple #3
0
 public void AskForChoice()
 {
     MakeChoice(this, random.ChoiceOrDefault(player.Hand));
 }