public IEnumerator CreatePreventStatus(DealDamageAction dda)
        {
            OnDealDamageStatusEffect preventStatus = new OnDealDamageStatusEffect(base.Card, "PreventDamage", "Prevent all damage that would be dealt to " + base.CharacterCard.Title + " this turn.", new TriggerType[] { TriggerType.CancelAction }, base.TurnTaker, base.Card);

            preventStatus.TargetCriteria.IsSpecificCard = base.CharacterCard;
            preventStatus.UntilThisTurnIsOver(base.Game);
            preventStatus.UntilCardLeavesPlay(base.CharacterCard);
            IEnumerator statusCoroutine = AddStatusEffect(preventStatus);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(statusCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(statusCoroutine);
            }
            yield break;
        }
Esempio n. 2
0
        public IEnumerator AddTackleEffect(DealDamageAction dda)
        {
            // "Until the start of your next turn, whenever that target would deal damage, reduce that damage to 1."
            Card pinned = dda.Target;
            OnDealDamageStatusEffect tackleEffect = new OnDealDamageStatusEffect(base.Card, "ReduceToOne", "Until the start of " + base.CharacterCard.Title + "'s next turn, whenever " + pinned.Title + " would deal damage, reduce that damage to 1.", new TriggerType[] { TriggerType.ReduceDamage }, base.TurnTaker, base.Card);

            tackleEffect.SourceCriteria.IsSpecificCard = pinned;
            tackleEffect.UntilStartOfNextTurn(base.TurnTaker);
            tackleEffect.DamageAmountCriteria.GreaterThan = 1;
            tackleEffect.UntilCardLeavesPlay(pinned);

            IEnumerator statusCoroutine = base.GameController.AddStatusEffect(tackleEffect, true, GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(statusCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(statusCoroutine);
            }
            yield break;
        }
Esempio n. 3
0
        public IEnumerator AddCrashEffect(DealDamageAction dda)
        {
            // "The next time that target would deal damage, prevent that damage and you may destroy an environment card."
            Card provoked = dda.Target;
            OnDealDamageStatusEffect crashEffect = new OnDealDamageStatusEffect(base.Card, "PreventAndDestroy", "The next time " + provoked.Title + " would deal damage, prevent that damage and " + base.CharacterCard.Title + " may destroy an environment card.", new TriggerType[] { TriggerType.CancelAction, TriggerType.DestroyCard }, base.TurnTaker, base.Card);

            crashEffect.SourceCriteria.IsSpecificCard    = provoked;
            crashEffect.DamageAmountCriteria.GreaterThan = 0;
            crashEffect.NumberOfUses = 1;
            crashEffect.UntilCardLeavesPlay(provoked);
            crashEffect.CanEffectStack = true;

            IEnumerator statusCoroutine = base.GameController.AddStatusEffect(crashEffect, true, GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(statusCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(statusCoroutine);
            }
            yield break;
        }
        private IEnumerator AssignBlocked(PhaseChangeAction pca)
        {
            // "At the end of the villain turn, each hero except the 2 heroes with the lowest HP become [b]BLOCKED[/b] until the start of the villain turn."
            // Find exactly 2 hero character cards with lowest HP
            List <Card> currentLowestHeroes = new List <Card>();
            IEnumerator findLowestCoroutine = GameController.FindTargetsWithLowestHitPoints(1, 2, (Card c) => c.IsHeroCharacterCard, currentLowestHeroes, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(this.GameController.StartCoroutine(findLowestCoroutine));
            }
            else
            {
                this.GameController.ExhaustCoroutine(findLowestCoroutine);
            }
            string lowestNames = "";

            if (currentLowestHeroes.Any())
            {
                lowestNames += currentLowestHeroes.First().Title;
                if (currentLowestHeroes.Count() > 1)
                {
                    lowestNames += ", " + currentLowestHeroes.ElementAt(1).Title;
                }
            }
            Log.Debug("Found 2 heroes with lowest HP: " + lowestNames);

            // All OTHER active hero characters become BLOCKED
            LinqCardCriteria criteria = new LinqCardCriteria((Card c) => c.IsHeroCharacterCard && c.IsActive && !currentLowestHeroes.Contains(c));
            List <Card>      toBlock  = base.GameController.FindCardsWhere(criteria).ToList();

            foreach (Card hero in toBlock)
            {
                //Log.Debug("Creating status effects for " + hero.Title);
                // BLOCKED comprises 2 status effects, both expiring at the start of the villain turn, when the hero leaves play, or when this card leaves play:
                // The hero cannot deal damage to non-Terrain villain targets
                OnDealDamageStatusEffect cantHitNonTerrain = new OnDealDamageStatusEffect(cardWithMethod: this.Card, methodToExecute: nameof(this.PreventDamage), description: hero.Title + " cannot deal damage to non-Terrain villain targets.", triggerTypes: new TriggerType[] { TriggerType.CancelAction }, decisionMaker: base.TurnTaker, cardSource: this.Card, powerNumerals: null);
                //Log.Debug("Initialized cantHitNonTerrain");
                cantHitNonTerrain.UntilStartOfNextTurn(this.TurnTaker);
                cantHitNonTerrain.UntilTargetLeavesPlay(hero);
                cantHitNonTerrain.UntilCardLeavesPlay(this.Card);
                cantHitNonTerrain.SourceCriteria.IsSpecificCard = hero;
                cantHitNonTerrain.TargetCriteria.IsVillain      = true;
                cantHitNonTerrain.BeforeOrAfter = BeforeOrAfter.Before;
                IEnumerator addCantHitCoroutine = AddStatusEffect(cantHitNonTerrain);
                //Log.Debug("Built cantHitNonTerrain for " + hero.Title);
                // When the hero would be dealt damage by a villain target, redirect it to a non-BLOCKED hero
                OnDealDamageStatusEffect redirectWhenHit = new OnDealDamageStatusEffect(cardWithMethod: this.Card, methodToExecute: nameof(this.RedirectDamage), description: "When " + hero.Title + " would be dealt damage by a villain target, redirect it to a non-BLOCKED hero.", triggerTypes: new TriggerType[] { TriggerType.RedirectDamage }, decisionMaker: base.TurnTaker, cardSource: this.Card, powerNumerals: null);
                redirectWhenHit.UntilStartOfNextTurn(this.TurnTaker);
                redirectWhenHit.UntilTargetLeavesPlay(hero);
                redirectWhenHit.UntilCardLeavesPlay(this.Card);
                redirectWhenHit.SourceCriteria.IsVillain      = true;
                redirectWhenHit.TargetCriteria.IsSpecificCard = hero;
                redirectWhenHit.BeforeOrAfter = BeforeOrAfter.Before;
                IEnumerator addRedirectCoroutine = AddStatusEffect(redirectWhenHit);
                //Log.Debug("Built redirectWhenHit for " + hero.Title);
                if (base.UseUnityCoroutines)
                {
                    yield return(this.GameController.StartCoroutine(addCantHitCoroutine));

                    yield return(this.GameController.StartCoroutine(addRedirectCoroutine));
                }
                else
                {
                    this.GameController.ExhaustCoroutine(addCantHitCoroutine);
                    this.GameController.ExhaustCoroutine(addRedirectCoroutine);
                }
            }

            string escapedNames = "";

            if (currentLowestHeroes.Any())
            {
                escapedNames = currentLowestHeroes.First().Title;
                if (currentLowestHeroes.Count > 1)
                {
                    escapedNames += " and " + currentLowestHeroes.ElementAt(1).Title;
                }
            }
            string blockedAnnouncement = escapedNames + " slip through Narrow Escape!";

            if (blockedHeroes.Any())
            {
                blockedAnnouncement += " All other heroes are BLOCKED!";
            }
            IEnumerator messageCoroutine = base.GameController.SendMessageAction(blockedAnnouncement, Priority.High, cardSource: GetCardSource(), showCardSource: true);

            if (base.UseUnityCoroutines)
            {
                yield return(this.GameController.StartCoroutine(messageCoroutine));
            }
            else
            {
                this.GameController.ExhaustCoroutine(messageCoroutine);
            }
            yield break;
        }