using DominionBase.Enums; using DominionBase.Piles; using DominionBase.Players; using DominionBase.Properties; using System.Diagnostics.Contracts; using System.Linq; namespace DominionBase.Cards.Nocturne { public class Exorcist : Card { public Exorcist() : base(Categories.Night, Source.Nocturne, Location.Kingdom, Traits.ConditionalBenefit | Traits.Gainer | Traits.IncludesExtraPiles | Traits.RemoveCurses | Traits.RemoveFromHand | Traits.Trasher | Traits.TrashForBenefit) { BaseCost = new Cost(4); } public override void SetupSupply(IGame game, ISupply supply) { Contract.Requires(game != null, "game cannot be null"); base.SetupSupply(game, supply); WillOWisp.SetupSupply(game); Imp.SetupSupply(game); Ghost.SetupSupply(game); } public override void FollowInstructions(IPlayer player) { Contract.Requires(player != null, "player cannot be null"); base.FollowInstructions(player); var choiceTrash = new Choice(Resource.ChooseACardToTrash, this, player.Hand, ChoiceOutcome.Trash, player); var resultTrash = player.MakeChoice(choiceTrash); player.Trash(this, player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); if (resultTrash.Cards.Any()) { var trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]); var gainableSupplies = new CardCollection( player._Game.Table.SpecialPiles.Values.OfType() .Where(supply => supply.CanGain() && supply.Category.HasFlag(Categories.Spirit) && trashedCardCost > supply.CurrentCost) .Select(supply => (Card)supply.TopCard) ); var choice = new Choice("Gain a Spirit", this, gainableSupplies, ChoiceOutcome.Gain, player, false); var result = player.MakeChoice(choice); if (result.Cards.Any()) player.Gain((ISupply)player._Game.Table.SpecialPiles[result.Cards[0]], this); } } } }