public PlayerGainCardFromSupply ( Dominion.Card cardType, |
||
cardType | Dominion.Card | |
playerState | ||
defaultLocation | DeckPlacement | |
gainReason | GainReason | |
return | Dominion.Card |
internal void GainCardsFromSupply(GameState gameState, Card cardType, int count, DeckPlacement defaultLocation = DeckPlacement.Discard) { for (int i = 0; i < count; ++i) gameState.PlayerGainCardFromSupply(cardType, this, defaultLocation); }
internal Card GainCardFromSupply(GameState gameState, Card cardType, DeckPlacement defaultLocation = DeckPlacement.Discard) { return gameState.PlayerGainCardFromSupply(cardType, this, defaultLocation); }
internal bool GainCardFromSupply(Card card, GameState gameState, DeckPlacement defaultLocation = DeckPlacement.Discard) { return gameState.PlayerGainCardFromSupply(card, this, defaultLocation:defaultLocation) != null; }
internal Card RequestPlayerGainCardFromSupply(GameState gameState, PlayerState playerGainingCard, CardPredicate acceptableCard, string description, bool isOptional = false, DeckPlacement defaultLocation = DeckPlacement.Discard) { PileOfCards exampleCard = gameState.supplyPiles.Where(cardPile => !cardPile.IsEmpty && acceptableCard(cardPile.TopCard())).FirstOrDefault(); bool hasCardOfCost = exampleCard != null; if (!hasCardOfCost) { return null; } CardPredicate cardPredicate = card => gameState.GetSupplyPile(card) != null && acceptableCard(card); // how do you know which player you are gaining for? Card cardType = this.actions.GetCardFromSupplyToGain(gameState, cardPredicate, isOptional); if (cardType == null) { if (isOptional) { return null; } throw new Exception("Must gain a card where " + description); } Card gainedCard = gameState.PlayerGainCardFromSupply(cardType, playerGainingCard, defaultLocation); if (gainedCard == null) { throw new Exception("Card specified can not be gained"); } if (!acceptableCard(gainedCard)) { throw new Exception("Card does not meet constraint: " + description); } return gainedCard; }