public CardState DiscardMatching(Func <CardState, bool> predicate) { var card = Random.ChoiceOrDefault(Hand.Where(predicate)); if (card != null) { Discard(card); } return(card); }
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); }
public void AskForChoice() { MakeChoice(this, random.ChoiceOrDefault(player.Hand)); }