Beispiel #1
0
        public bool IsTheControllerOf(ICardInPlay card)
        {
            if (card.BaseCard is ITreacheryCard)
            {
                return(false);
            }

            foreach (var cardInPlay in cardsInPlay)
            {
                if (cardInPlay.BaseCard.Id == card.BaseCard.Id)
                {
                    return(true);
                }

                if (cardInPlay is IAttachmentHostInPlay)
                {
                    var host = cardInPlay as IAttachmentHostInPlay;
                    if (host.Attachments.Any(x => x.BaseCard.Id == card.BaseCard.Id))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public void RemoveCardInPlay(ICardInPlay card)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }

            if (!cardsInPlay.Contains(card))
            {
                return;
            }

            cardsInPlay.Remove(card);

            var leavesPlayEffect = new CardLeavesPlayEffect(Game, card);
            var leavesPlayHandle = leavesPlayEffect.GetHandle(Game);

            Game.AddEffect(leavesPlayEffect);
            Game.TriggerEffect(leavesPlayHandle);

            foreach (var callback in cardRemovedFromPlayCallbacks)
            {
                callback(card);
            }
        }
Beispiel #3
0
        public void AddCardInPlay(ICardInPlay card)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }

            if (cardsInPlay.Contains(card))
            {
                return;
            }

            cardsInPlay.Add(card);

            var entersPlayEffect = new CardEntersPlayEffect(Game, card);
            var entersPlayHandle = entersPlayEffect.GetHandle(Game);

            Game.AddEffect(entersPlayEffect);
            Game.TriggerEffect(entersPlayHandle);

            foreach (var callback in cardAddedToPlayCallbacks)
            {
                callback(card);
            }
        }
        private void CardAddedToPlay(ICardInPlay cardInPlay)
        {
            var heroInPlay = cardInPlay as IHeroInPlay;
            if (heroInPlay != null)
            {
                var heroViewModel = new PlayerCardInPlayViewModel<IHeroCard>(dispatcher, heroInPlay);
                Dispatch(() => heroes.Add(heroViewModel));
                return;
            }

            PlayerCardInPlayViewModel viewModel = null;

            var allyInPlay = cardInPlay as IAllyInPlay;
            if (allyInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel<IAllyCard>(dispatcher, allyInPlay);
            }

            var attachmentInPlay = cardInPlay as IAttachmentInPlay;
            if (attachmentInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel<IAttachmentCard>(dispatcher, attachmentInPlay);
            }

            var treasureInPlay = cardInPlay as ITreasureInPlay;
            if (treasureInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel<ITreasureCard>(dispatcher, treasureInPlay);
            }

            if (viewModel == null)
                return;

            Dispatch(() => cardsInPlay.Add(viewModel));
        }
Beispiel #5
0
 public DamageDealt(IGame game, ICard source, ICardInPlay target, byte damage)
     : base(game)
 {
     this.Source = source;
     this.Target = target;
     this.damage = damage;
 }
 public DamageDealt(IGame game, ICard source, ICardInPlay target, byte damage)
     : base(game)
 {
     this.Source = source;
     this.Target = target;
     this.damage = damage;
 }
 protected ModifierBase(string type, PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Modifier", GetText(target, type, value), source)
 {
     this.StartPhase = startPhase;
     this.Target     = target;
     this.Duration   = duration;
     this.Value      = value;
 }
        public CardEntersPlayEffect(IGame game, ICardInPlay cardInPlay)
            : base("Card Enters Play", "When a card enters play", game)
        {
            if (cardInPlay == null)
                throw new ArgumentNullException("cardInPlay");

            this.cardInPlay = cardInPlay;
        }
 protected ModifierBase(string type, PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Modifier", GetText(target, type, value), source)
 {
     this.StartPhase = startPhase;
     this.Target = target;
     this.Duration = duration;
     this.Value = value;
 }
        public DetermineHitPoints(IGame game, ICardInPlay damageable)
            : base(game)
        {
            this.Damageable = damageable;

            var damageableCard = damageable.BaseCard as IDamageableCard;

            hitPoints = damageableCard != null ? damageableCard.PrintedHitPoints : (byte)0;
        }
Beispiel #11
0
        public DetermineHitPoints(IGame game, ICardInPlay damageable)
            : base(game)
        {
            this.Damageable = damageable;

            var damageableCard = damageable.BaseCard as IDamageableCard;

            hitPoints = damageableCard != null ? damageableCard.PrintedHitPoints : (byte)0;
        }
        public CardLeavesPlayEffect(IGame game, ICardInPlay cardInPlay)
            : base("Card Leaves Play", "When a card leaves play", game)
        {
            if (cardInPlay == null)
            {
                throw new ArgumentNullException("cardInPlay");
            }

            this.cardInPlay = cardInPlay;
        }
        private void CardRemovedFromPlay(ICardInPlay cardInPlay)
        {
            var viewModel = cardsInPlay.Where(x => x.CardId == cardInPlay.BaseCard.Id).FirstOrDefault();

            if (viewModel == null)
            {
                return;
            }

            Dispatch(() => cardsInPlay.Remove(viewModel));
        }
        private void CardAddedToPlay(ICardInPlay cardInPlay)
        {
            var heroInPlay = cardInPlay as IHeroInPlay;

            if (heroInPlay != null)
            {
                var heroViewModel = new PlayerCardInPlayViewModel <IHeroCard>(dispatcher, heroInPlay);
                Dispatch(() => heroes.Add(heroViewModel));
                return;
            }

            PlayerCardInPlayViewModel viewModel = null;

            var allyInPlay = cardInPlay as IAllyInPlay;

            if (allyInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel <IAllyCard>(dispatcher, allyInPlay);
            }

            var attachmentInPlay = cardInPlay as IAttachmentInPlay;

            if (attachmentInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel <IAttachmentCard>(dispatcher, attachmentInPlay);
            }

            var treasureInPlay = cardInPlay as ITreasureInPlay;

            if (treasureInPlay != null)
            {
                viewModel = new PlayerCardInPlayViewModel <ITreasureCard>(dispatcher, treasureInPlay);
            }

            if (viewModel == null)
            {
                return;
            }

            Dispatch(() => cardsInPlay.Add(viewModel));
        }
 public CardEntersPlay(IGame game, ICardInPlay enteringPlay)
     : base(game)
 {
     this.EnteringPlay = enteringPlay;
 }
 private static string GetText(ICardInPlay target, string type, int value)
 {
     return value > -1 ?
         string.Format("{0}: +{1} to {2}", target.Title, value, type)
         : string.Format("{0}: -{1} to {2}", target.Title, Math.Abs(value), type);
 }
        private void CardRemovedFromPlay(ICardInPlay cardInPlay)
        {
            var viewModel = cardsInPlay.Where(x => x.CardId == cardInPlay.BaseCard.Id).FirstOrDefault();
            if (viewModel == null)
                return;

            Dispatch(() => cardsInPlay.Remove(viewModel));
        }
 public CheckForTrait(IGame game, ICardInPlay target, Trait trait)
     : base(game)
 {
     this.Target = target;
     this.Trait = trait;
 }
 public CardEntersPlay(IGame game, ICardInPlay enteringPlay)
     : base(game)
 {
     this.EnteringPlay = enteringPlay;
 }
Beispiel #20
0
 public DamageHealed(IGame game, ICardInPlay target, byte damage)
     : base(game)
 {
     this.Target = target;
     this.damage = damage;
 }
 public WillpowerModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Willpower", startPhase, source, target, duration, value)
 {
 }
 public DamageHealed(IGame game, ICardInPlay target, byte damage)
     : base(game)
 {
     this.Target = target;
     this.damage = damage;
 }
 private static string GetDescription(byte damage, ICardInPlay cardInPlay)
 {
     return(string.Format("Deal {0} damage to {1}", damage, cardInPlay.Title));
 }
 private static string GetDescription(byte damage, ICardInPlay cardInPlay)
 {
     return string.Format("Deal {0} damage to {1}", damage, cardInPlay.Title);
 }
 public AttackModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Attack", startPhase, source, target, duration, value)
 {
 }
 public AttackModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Attack", startPhase, source, target, duration, value)
 {
 }
Beispiel #27
0
 public CardLeavesPlay(IGame game, ICardInPlay leavingPlay)
     : base(game)
 {
     this.LeavingPlay = leavingPlay;
 }
 public CheckForTrait(IGame game, ICardInPlay target, Trait trait)
     : base(game)
 {
     this.Target = target;
     this.Trait  = trait;
 }
 public DealDamageEffect(IGame game, ICardInPlay cardInPlay, byte damage)
     : base("Deal Damage", GetDescription(damage, cardInPlay), game)
 {
     this.cardInPlay = cardInPlay;
     this.damage = damage;
 }
 private static string GetText(ICardInPlay target, string type, int value)
 {
     return(value > -1 ?
            string.Format("{0}: +{1} to {2}", target.Title, value, type)
         : string.Format("{0}: -{1} to {2}", target.Title, Math.Abs(value), type));
 }
 public DealDamageEffect(IGame game, ICardInPlay cardInPlay, byte damage)
     : base("Deal Damage", GetDescription(damage, cardInPlay), game)
 {
     this.cardInPlay = cardInPlay;
     this.damage     = damage;
 }
Beispiel #32
0
        public void RemoveCardInPlay(ICardInPlay card)
        {
            if (card == null)
                throw new ArgumentNullException("card");

            if (!cardsInPlay.Contains(card))
                return;

            cardsInPlay.Remove(card);

            var leavesPlayEffect = new CardLeavesPlayEffect(Game, card);
            var leavesPlayHandle = leavesPlayEffect.GetHandle(Game);
            Game.AddEffect(leavesPlayEffect);
            Game.TriggerEffect(leavesPlayHandle);

            foreach (var callback in cardRemovedFromPlayCallbacks)
                callback(card);
        }
Beispiel #33
0
        public bool IsTheControllerOf(ICardInPlay card)
        {
            if (card.BaseCard is ITreacheryCard)
                return false;

            foreach (var cardInPlay in cardsInPlay)
            {
                if (cardInPlay.BaseCard.Id == card.BaseCard.Id)
                    return true;

                if (cardInPlay is IAttachmentHostInPlay)
                {
                    var host = cardInPlay as IAttachmentHostInPlay;
                    if (host.Attachments.Any(x => x.BaseCard.Id == card.BaseCard.Id))
                        return true;
                }
            }

            return false;
        }
 public CardLeavesPlay(IGame game, ICardInPlay leavingPlay)
     : base(game)
 {
     this.LeavingPlay = leavingPlay;
 }
 public WillpowerModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value)
     : base("Willpower", startPhase, source, target, duration, value)
 {
 }
Beispiel #36
0
        public void AddCardInPlay(ICardInPlay card)
        {
            if (card == null)
                throw new ArgumentNullException("card");

            if (cardsInPlay.Contains(card))
                return;

            cardsInPlay.Add(card);

            var entersPlayEffect = new CardEntersPlayEffect(Game, card);
            var entersPlayHandle = entersPlayEffect.GetHandle(Game);
            Game.AddEffect(entersPlayEffect);
            Game.TriggerEffect(entersPlayHandle);

            foreach (var callback in cardAddedToPlayCallbacks)
                callback(card);
        }