public Card PlayerGainCardFromSupply(Card cardType, PlayerState playerState, DeckPlacement defaultLocation = DeckPlacement.Discard, GainReason gainReason = GainReason.Gain)
{
bool canGainCardFromSupply = CanGainCardFromSupply(cardType);
PileOfCards pile = this.GetPile(cardType);
if (pile == null)
{
System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
return null;
}
if (GetPile(this.supplyPiles, cardType) != null)
this.hasPileEverBeenGained[pile] = true;
if (!IsCardEqualOrOfType(pile.TopCard(), cardType))
{
System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
return null;
}
Card card = pile.DrawCardFromTop();
if (card == null)
{
System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
return null;
}
System.Diagnostics.Debug.Assert(canGainCardFromSupply);
playerState.GainCard(this, card, DeckPlacement.Supply, defaultLocation, gainReason);
return card;
}