public override int Resolve()
    {
        if (target == null)
        {
            return(0);
        }
        AbstractStatusEffect existingEffect = this.target.statusEffects.FirstOrDefault(status => status.ID.Equals(this.effect.ID));

        // If the effect already exists, add stacks to it if applicable, else applying a status effect already on an argument has no effect.
        if (existingEffect != null)
        {
            if (this.stacksToApply > 0 && existingEffect.stacks > 0)
            {
                existingEffect.stacks += this.stacksToApply;
            }
            return(0);
        }

        AbstractStatusEffect newCopy = this.effect.MakeCopy();

        newCopy.host = target;

        this.target.statusEffects.Add(newCopy);
        newCopy.TriggerOnEffectApplied();
        EventSystemManager.Instance.TriggerEvent(new EventStatusEffectApplied(this.target, newCopy, this.stacksToApply));
        return(0);
    }
Esempio n. 2
0
 public static List <AbstractIntent> BuffSelf(AbstractBattleUnit self,
                                              AbstractStatusEffect statusEffect,
                                              int stacks = 1)
 {
     return(new BuffSelfIntent(self, statusEffect, stacks)
            .ToSingletonList <AbstractIntent>());
 }
        public override int OverrideStatusEffectApplicationToOwner(
            AbstractStatusEffect statusEffectApplied,
            int numStacksApplied)
        {
            if (numStacksApplied < 0)
            {
                return(numStacksApplied);
            }

            if (this.Stacks <= 0) // if we're removing stress, we're not modifying that
            {
                this.Stacks = 0;
                return(numStacksApplied);
            }

            if (statusEffectApplied.GetType() == typeof(StressStatusEffect))
            {
                var stacksToRemove = 0;
                if (numStacksApplied > this.Stacks)
                {
                    stacksToRemove = this.Stacks;
                    this.Stacks    = 0;
                    return(numStacksApplied - stacksToRemove);
                }
                if (Stacks >= numStacksApplied)
                {
                    Stacks -= numStacksApplied;
                    return(0);
                }
            }
            return(numStacksApplied);
        }
Esempio n. 4
0
 ///<summary>
 ///Trigger when an argument has stacks added to.
 ///</summary>
 public EventStatusEffectApplied(AbstractArgument argAppliedTo, AbstractStatusEffect effect, int stacks = 0)
 {
     this.type          = EventType.ARGUMENT_STATUS_EFFECT_APPLIED;
     this.argAppliedTo  = argAppliedTo;
     this.effectApplied = effect;
     this.stacksAdded   = stacks;
 }
    ///<summary>
    ///Apply a status effect to the argument.
    ///<list type="bullet">
    ///<item><term>src</term><description>The character applying the effect.</description></item>
    ///<item><term>target</term><description>The argument receiving the effect.</description></item>
    ///<item><term>effect</term><description>The effect to apply.</description></item>
    ///<item><term>stacksToApply</term><description>The number of stacks of the effect to apply. Defaults to 0, as most status effects don't use stacks.</description></item>
    ///</list>
    ///</summary>
    public ApplyStatusEffectAction(AbstractCharacter src, AbstractArgument target, AbstractStatusEffect effect, int stacksToApply = 0)
    {
        this.source = src;
        this.target = target;
        this.effect = effect;

        this.stacksToApply = stacksToApply;
    }
 public BuffSelfIntent(AbstractBattleUnit self,
                       AbstractStatusEffect statusEffect,
                       int stacks = 1) :
     base(self,
          IntentIcons.BuffIntent)
 {
     Stacks            = stacks;
     this.StatusEffect = statusEffect;
 }
Esempio n. 7
0
 public DealGreaterDamageToEnemiesWithStatusEffectPerk(
     AbstractStatusEffect abstractStatusEffectType,
     int damageChange,
     string name)
 {
     DamageChange = damageChange;
     TargetEffect = abstractStatusEffectType;
     this.MyName  = name;
 }
Esempio n. 8
0
 public static List <AbstractIntent> StatusEffectToRandomPc(
     AbstractBattleUnit source,
     AbstractStatusEffect effect,
     int stacks)
 {
     return(DebuffOtherIntent.StatusEffectToRandomPc(
                source,
                effect, stacks
                ).ToSingletonList <AbstractIntent>());
 }
 public static DebuffOtherIntent StatusEffectToRandomPc(
     AbstractBattleUnit source,
     AbstractStatusEffect effect,
     int stacks)
 {
     return(StatusEffect(source,
                         GameState.Instance.AllyUnitsInBattle.Where(item => !item.IsDead).PickRandom(),
                         effect,
                         stacks));
 }
 public BuffOtherIntent(AbstractBattleUnit self,
                        AbstractStatusEffect statusEffect,
                        int stacks = 1) :
     base(self,
          IntentIcons.BuffIntent)
 {
     Stacks            = stacks;
     this.StatusEffect = statusEffect;
     // Just picks another unit in the party at random
     BattleUnitDeciderFunction = () => GameState.Instance.EnemyUnitsInBattle.Where(item => item != Source).PickRandom();
 }
 public static DebuffOtherIntent StatusEffect(
     AbstractBattleUnit source,
     AbstractBattleUnit target,
     AbstractStatusEffect effect,
     int stacks)
 {
     return(new DebuffOtherIntent(source, () =>
     {
         ActionManager.Instance.ApplyStatusEffect(target, effect, stacks);
     }));
 }
Esempio n. 12
0
    public static List <AbstractIntent> DebuffRandomOther(AbstractBattleUnit self, AbstractStatusEffect debuff_requiresStacksSet)
    {
        return(new DebuffOtherIntent(self, () =>
        {
            var target = IntentTargeting.GetRandomLivingPlayerUnit();

            ActionManager.Instance.ApplyStatusEffect(target,
                                                     debuff_requiresStacksSet,
                                                     debuff_requiresStacksSet.Stacks);
        }).ToSingletonList <AbstractIntent>());
    }
 public static AbstractSoldierPerk CreateGrantsStatusEffectPerk(
     string name,
     string description,
     AbstractStatusEffect effect,
     int stacks)
 {
     return(new GrantsStatusEffectPerk(
                name,
                description,
                effect,
                stacks));
 }
 public GrantsStatusEffectPerk(
     string name,
     string description,
     AbstractStatusEffect effect,
     int stacks    = 1,
     Rarity rarity = Rarity.NOT_IN_POOL)
 {
     GivenName        = name;
     GivenDescription = description;
     Stacks           = stacks;
     Effect           = effect;
     Rarity           = rarity;
 }
Esempio n. 15
0
    public static List <AbstractIntent> BuffOther(AbstractBattleUnit self,
                                                  AbstractStatusEffect statusEffect,
                                                  int stacks = 1,
                                                  Func <AbstractBattleUnit> battleUnitDecider = null)
    {
        var intent = new BuffOtherIntent(self, statusEffect, stacks);

        if (battleUnitDecider != null)
        {
            intent.BattleUnitDeciderFunction = battleUnitDecider;
        }
        return(intent.ToSingletonList <AbstractIntent>());
    }
Esempio n. 16
0
    public static List <AbstractIntent> AttackRandomPcWithDebuff(
        AbstractStatusEffect debuff_requiresSetStacks,
        AbstractBattleUnit source,
        int percentDamage,
        int numHits = 1)
    {
        int damagePerHit = GameState.Instance.DoomCounter.GetAdjustedDamage(percentDamage);

        var attackIntent = SingleUnitAttackIntent.AttackRandomPc(source, damagePerHit, numHits);

        return(new List <AbstractIntent>
        {
            attackIntent,
            DebuffOtherIntent.StatusEffect(source, attackIntent.Target, debuff_requiresSetStacks.CloneStatusEffect(), debuff_requiresSetStacks.Stacks)
        });
    }
Esempio n. 17
0
    public override void NotifyOfEvent(AbstractEvent eventData)
    {
        EventStatusEffectApplied data = (EventStatusEffectApplied)eventData;

        if (data.effectApplied.ID.Equals("RESONANCE") || !data.argAppliedTo.Equals(this.host))      // Don't bother running through rest of event if we apply Resonance (since Resonance can't proc Resonance), or if the effect was applied to a non-resonance arg
        {
            return;
        }
        List <AbstractArgument> spreadEffectToTheseArguments = new List <AbstractArgument>();

        foreach (AbstractArgument arg in this.host.OWNER.GetSupportArguments())
        {
            if (CheckForResonance(arg) != null)
            {
                spreadEffectToTheseArguments.Add(arg);
            }
        }
        foreach (AbstractArgument arg in TurnManager.Instance.GetOtherCharacter(this.host.OWNER).GetSupportArguments())
        {
            if (CheckForResonance(arg) != null)
            {
                spreadEffectToTheseArguments.Add(arg);
            }
        }
        if (CheckForResonance(this.host.OWNER.GetCoreArgument()) != null)
        {
            spreadEffectToTheseArguments.Add(this.host.OWNER.GetCoreArgument());
        }

        if (CheckForResonance(TurnManager.Instance.GetOtherCharacter(this.host.OWNER).GetCoreArgument()) != null)
        {
            spreadEffectToTheseArguments.Add(TurnManager.Instance.GetOtherCharacter(this.host.OWNER).GetCoreArgument());
        }

        foreach (AbstractArgument arg in spreadEffectToTheseArguments)
        {
            AbstractStatusEffect instance = arg.statusEffects.Find(effect => effect.ID.Equals("RESONANCE"));
            instance.ExpireEffect(); // expire resonance BEFORE actually spreading the effect to prevent the other args w/ resonance from also triggering a resonance proc
            NegotiationManager.Instance.AddAction(new ApplyStatusEffectAction(this.host.OWNER, arg, data.effectApplied, data.effectApplied.stacks));
        }
    }
Esempio n. 18
0
    public void ApplyStatusEffect(AbstractBattleUnit unit, AbstractStatusEffect attribute, int stacks = 1)
    {
        if (unit == null)
        {
            throw new Exception("No unit specified");
        }

        if (attribute == null)
        {
            throw new Exception("No attribute specified");
        }

        if (stacks == 0)
        {
            return;
        }

        QueuedActions.ImmediateAction("ApplyStatusEffect", () =>
        {
            unit.ApplyStatusEffect(attribute, stacks);
        });
    }
    public static void ShowStatusEffectHelp(AbstractStatusEffect effect)
    {
        var description = effect.Description;

        TooltipToDisplay = description + "\n" + DebuggingInfo;
    }
Esempio n. 20
0
 public BasicApplyStatusEffectToSelfSticker(AbstractStatusEffect effect, int stacks)
 {
     Effect = effect;
     Stacks = stacks;
 }
    public static void ProcessHooksWhenStatusEffectAppliedToUnit(AbstractBattleUnit unitAffected, AbstractStatusEffect effectApplied, int stacksAppliedOrDecremented)
    {
        foreach (var status in unitAffected.StatusEffects)
        {
            var incOrDec = StatusEffectChange.DECREASE;

            if (stacksAppliedOrDecremented > 0)
            {
                incOrDec = StatusEffectChange.INCREASE;
            }

            if (status.GetType() == effectApplied.GetType())
            {
                if (incOrDec == StatusEffectChange.INCREASE)
                {
                    status.OnApplicationOrIncrease();
                }
            }
            else
            {
                stacksAppliedOrDecremented = status.OverrideStatusEffectApplicationToOwner(effectApplied, stacksAppliedOrDecremented);
            }
        }
    }
 public void Initialize(AbstractStatusEffect attr, BattleUnitAttributesHolder holder)
 {
     this.CorrespondingAttribute = attr;
     image.SetProtoSprite(CorrespondingAttribute.ProtoSprite);
     attr.CorrespondingPrefab = this;
 }
Esempio n. 23
0
 public AbstractDamageModifierToEnemiesWithStatusEffect(AbstractStatusEffect targetStatusEffect)
 {
     Name = "Damage Mod: " + targetStatusEffect.Name;
     TargetStatusEffect = targetStatusEffect;
 }
 public void ShowTooltipForStatusEffect(AbstractStatusEffect effect)
 {
     RefreshTooltip(cardReferenced: effect.ReferencedCard,
                    title: "Reference",
                    description: $"<color=green>{effect.Name}</color>:{effect.Description}");
 }
 // Returns the number of stacks that are to be applied, after processing.
 public virtual int OverrideStatusEffectApplicationToOwner(AbstractStatusEffect statusEffectApplied, int stacksAppliedOrDecremented)
 {
     return(stacksAppliedOrDecremented);
 }
 public static List <MagicWord> GetMagicWordsApplicableToStatusEffect(AbstractStatusEffect effect)
 {
     return(GetApplicableMagicWordsForString(effect.Description));
 }