private bool IsAffordable(ICostlyCard costlyCard)
        {
            var characters = player.CardsInPlay.OfType<ICharacterInPlay>().Where(x => x.CanPayFor(costlyCard)).ToList();
            var sum = characters.Sum(x => x.Resources);

            return (characters.Count > 0 && (costlyCard.IsVariableCost || sum >= costlyCard.PrintedCost));
        }
        public virtual bool CanPayFor(ICostlyCard costlyCard)
        {
            if (costlyCard == null)
            {
                throw new ArgumentNullException("costlyCard");
            }

            //var cost = costlyCard.GetResourceCost(Game);
            //if (cost == null && Card.PrintedCardType == CardType.Hero)
            //    return true;

            if (Card.HasEffect <IDuringCheckForResourceMatch>())
            {
                var check = new CheckForResourceMatch(Game, costlyCard);

                foreach (var checkEffect in Card.Text.Effects.OfType <IDuringCheckForResourceMatch>())
                {
                    checkEffect.DuringCheckForResourceMatch(check);
                }

                return(check.IsResourceMatch);
            }

            return(false);
        }
        private bool IsAffordable(ICostlyCard costlyCard)
        {
            var characters = player.CardsInPlay.OfType <ICharacterInPlay>().Where(x => x.CanPayFor(costlyCard)).ToList();
            var sum        = characters.Sum(x => x.Resources);

            return(characters.Count > 0 && (costlyCard.IsVariableCost || sum >= costlyCard.PrintedCost));
        }
        private PayResourcesEffectBase(ISource source, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard, ICardEffect cardEffect)
            : base("Pay Resources", GetText(player, resourceSphere, numberOfResources, isVariableCost), source)
        {
            if (player == null)
                throw new ArgumentNullException("player");

            this.resourceSphere = resourceSphere;
            this.numberOfResources = numberOfResources;
            this.isVariableCost = isVariableCost;
            this.player = player;
            this.costlyCard = costlyCard;
            this.cardEffect = cardEffect;
        }
        public PlayAttachableEffect(IGame game, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard)
            : base(game, resourceSphere, numberOfResources, isVariableCost, player, costlyCard)
        {
            var attachableCard = costlyCard as IAttachableCard;

            if (attachableCard == null)
                throw new ArgumentException("costlyCard does not implement IAttachable - it cannot be played as an attachment");

            if (!(attachableCard is IAttachmentCard) && !(attachableCard is ITreasureCard))
                throw new ArgumentException("costlyCard does not implment IAttachmentCard or ITreasureCard - it is not a valid attachable player card");

            this.attachableCard = attachableCard;
            this.attachmentCard = costlyCard as IAttachmentCard;
            this.treasureCard = costlyCard as ITreasureCard;
        }
Example #6
0
        public override bool CanPayFor(ICostlyCard costlyCard)
        {
            if (costlyCard == null)
            {
                throw new ArgumentNullException("costlyCard");
            }

            if (base.CanPayFor(costlyCard))
            {
                return(true);
            }

            if (costlyCard.PrintedSphere == Sphere.Neutral)
            {
                return(true);
            }

            return(HasResourceIcon(costlyCard.PrintedSphere));
        }
        private PayResourcesEffectBase(ISource source, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard, ICardEffect cardEffect)
            : base("Pay Resources", GetText(player, resourceSphere, numberOfResources, isVariableCost), source)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            this.resourceSphere    = resourceSphere;
            this.numberOfResources = numberOfResources;
            this.isVariableCost    = isVariableCost;
            this.player            = player;
            this.costlyCard        = costlyCard;
            this.cardEffect        = cardEffect;
        }
 protected PayResourcesEffectBase(ISource source, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard)
     : this(source, resourceSphere, numberOfResources, isVariableCost, player, costlyCard, null)
 {
     if (costlyCard == null)
     {
         throw new ArgumentNullException("costlyCard");
     }
 }
 public CheckForResourceMatch(IGame game, ICostlyCard costlyCard)
     : base(game)
 {
     this.costlyCard = costlyCard;
     this.cardEffect = null;
 }
Example #10
0
        public PlayAttachableEffect(IGame game, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard)
            : base(game, resourceSphere, numberOfResources, isVariableCost, player, costlyCard)
        {
            var attachableCard = costlyCard as IAttachableCard;

            if (attachableCard == null)
            {
                throw new ArgumentException("costlyCard does not implement IAttachable - it cannot be played as an attachment");
            }

            if (!(attachableCard is IAttachmentCard) && !(attachableCard is ITreasureCard))
            {
                throw new ArgumentException("costlyCard does not implment IAttachmentCard or ITreasureCard - it is not a valid attachable player card");
            }

            this.attachableCard = attachableCard;
            this.attachmentCard = costlyCard as IAttachmentCard;
            this.treasureCard   = costlyCard as ITreasureCard;
        }
 protected PayResourcesEffectBase(ISource source, Sphere resourceSphere, byte numberOfResources, bool isVariableCost, IPlayer player, ICostlyCard costlyCard)
     : this(source, resourceSphere, numberOfResources, isVariableCost, player, costlyCard, null)
 {
     if (costlyCard == null)
         throw new ArgumentNullException("costlyCard");
 }
 public ResourcePayment(ICostlyCard costlyCard)
     : this()
 {
     this.costlyCard = costlyCard;
     this.cardEffect = null;
 }
 public ResourcePayment(ICostlyCard costlyCard)
     : this()
 {
     this.costlyCard = costlyCard;
     this.cardEffect = null;
 }
 public CheckForResourceMatch(IGame game, ICostlyCard costlyCard)
     : base(game)
 {
     this.costlyCard = costlyCard;
     this.cardEffect = null;
 }