<commit_before>﻿using Scripts.Game.Defined.Serialized.Spells;
using Scripts.Game.Defined.Spells;
using Scripts.Game.Defined.Unserialized.Buffs;
using Scripts.Game.Defined.Unserialized.Spells;
using Scripts.Model.Buffs;
using Scripts.Model.Characters;
using Scripts.Model.Spells;
using Scripts.Model.Stats;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Scripts.Game.Defined.Serialized.Buffs {

    public class FlamingArmor : PermanentBuff {
        public const int IGNITION_CHANCE = 25;

        public FlamingArmor()
            : base(
                  Util.GetSprite("fire"),
                  "Flaming armor",
                  String.Format("Attacks on this unit have a {0}% chance of igniting the attacker", IGNITION_CHANCE)
                  ) {
        }

        public override bool IsReact(SingleSpell incomingSpell, Stats ownerOfThisBuff) {
            return incomingSpell.Target.Stats == ownerOfThisBuff
                && incomingSpell.SpellBook is Attack
                && incomingSpell.Result.IsDealDamage
                && Util.IsChance(IGNITION_CHANCE/100.0f);
        }

        protected override void ReactHelper(SingleSpell spellCast, Stats ownerOfThisBuff) {
            spellCast.Result.AddEffect(
                new AddBuff(new BuffParams(ownerOfThisBuff, spellCast.Target.Id), spellCast.Caster.Buffs, new SuperIgnited()));
        }
    }

    public class AntiHeal : Buff {

        public AntiHeal() : base(8, Util.GetSprite("skull-crossed-bones"), "Antiheal", "Healing on this unit is nullified.", false) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return (GetHealingElement(spellToReactTo) != null) && spellToReactTo.Target.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthIncrease = GetHealingElement(spellToReactTo);
            if (healthIncrease != null) {
                healthIncrease.Value = 0;
            }
        }

        private SpellEffect GetHealingElement(SingleSpell spellToReactTo) {
            SpellEffect healthIncrease = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthIncrease == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value > 0) {
                    healthIncrease = addToModStat;
                }
            }
            return healthIncrease;
        }
    }

    public class HealBoost : Buff {
        private int HEAL_MULTIPLIER = 2;

        public HealBoost() : base(3, Util.GetSprite("health-normal"), "Heal Buff", "Healing targeting this unit is doubled.", false) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return (GetHealingElement(spellToReactTo) != null) && spellToReactTo.Target.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthIncrease = GetHealingElement(spellToReactTo);
            if (healthIncrease != null) {
                healthIncrease.Value = (int)(healthIncrease.Value * HEAL_MULTIPLIER);
            }
        }

        private SpellEffect GetHealingElement(SingleSpell spellToReactTo) {
            SpellEffect healthIncrease = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthIncrease == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value > 0) {
                    healthIncrease = addToModStat;
                }
            }
            return healthIncrease;
        }
    }

    public class FishShook : PermanentBuff {
        private const float FISHY_TARGET_MULTIPLIER = 2;
        private const float OTHER_TARGET_MULTIPLIER = 0.25f;

        public FishShook()
            : base(Util.GetSprite("fish"),
                  "Fish-Shook",
                  string.Format(
                      "Basic attacks do {0}x damage on fishy targets and {1} damage on non-fish.", FISHY_TARGET_MULTIPLIER, OTHER_TARGET_MULTIPLIER)) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return spellToReactTo.SpellBook is Attack && spellToReactTo.Result.IsDealDamage && spellToReactTo.Caster.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            float localDmgMult = 0;

            // is a fish
            if (spellToReactTo.Target.Look.Breed == Characters.Breed.FISH) {
                localDmgMult = FISHY_TARGET_MULTIPLIER;
            } else { // not a fish
                localDmgMult = OTHER_TARGET_MULTIPLIER;
            }

            SpellEffect healthDamage = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) {
                    healthDamage = addToModStat;
                }
            }
            if (healthDamage != null) {
                healthDamage.Value = (int)Math.Floor(healthDamage.Value * localDmgMult);
            }
        }
    }

    public class DamageResist : PermanentBuff {
        private const float DAMAGE_MULTIPLIER = 0.7f;

        public DamageResist()
            : base(Util.GetSprite("round-shield"),
                  "Damage Resist",
                  String.Format("Reduces incident damage from basic attacks by {0}%.",
                      (1 - DAMAGE_MULTIPLIER) * 100)) { }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthDamage = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) {
                    healthDamage = addToModStat;
                }
            }
            if (healthDamage != null) {
                int tempValue = healthDamage.Value;
                healthDamage.Value = (int)Math.Floor(healthDamage.Value * DAMAGE_MULTIPLIER);
            }
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return spellToReactTo.SpellBook is Attack && spellToReactTo.Target.Stats == owner;
        }
    }

    public class SuperIgnited : AbstractIgnited {
        private const int DURATION = 3;

        public SuperIgnited() : base(DURATION, 5, 40) {
        }
    }

    public class TempIgnited : AbstractIgnited {
        private const int DURATION = 2;

        public TempIgnited() : base(DURATION) {
        }
    }

    public class PermanantIgnited : AbstractIgnited {

        public PermanantIgnited() : base() {
        }
    }

    public class Poison : PermanentBuff {

        public Poison() : base(Util.GetSprite("fox-head"), "Poisoned", "Loses health at the end of each turn.") {
        }

        protected override IList<SpellEffect> OnEndOfTurnHelper(Model.Characters.Stats owner) {
            return new SpellEffect[] {
                    new AddToModStat(owner, StatType.HEALTH, -1)
                };
        }
    }

    public class StrengthScalingPoison : Buff {

        public StrengthScalingPoison() : base(2, Util.GetSprite("fox-head"), "StrengthScalingPoison", "Loses health at the end of each turn.", true) {
        }
<commit_msg>tempIgnited lasts longer.<commit_after>﻿using Scripts.Game.Defined.Serialized.Spells;
using Scripts.Game.Defined.Spells;
using Scripts.Game.Defined.Unserialized.Buffs;
using Scripts.Game.Defined.Unserialized.Spells;
using Scripts.Model.Buffs;
using Scripts.Model.Characters;
using Scripts.Model.Spells;
using Scripts.Model.Stats;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Scripts.Game.Defined.Serialized.Buffs {

    public class FlamingArmor : PermanentBuff {
        public const int IGNITION_CHANCE = 25;

        public FlamingArmor()
            : base(
                  Util.GetSprite("fire"),
                  "Flaming armor",
                  String.Format("Attacks on this unit have a {0}% chance of igniting the attacker", IGNITION_CHANCE)
                  ) {
        }

        public override bool IsReact(SingleSpell incomingSpell, Stats ownerOfThisBuff) {
            return incomingSpell.Target.Stats == ownerOfThisBuff
                && incomingSpell.SpellBook is Attack
                && incomingSpell.Result.IsDealDamage
                && Util.IsChance(IGNITION_CHANCE / 100.0f);
        }

        protected override void ReactHelper(SingleSpell spellCast, Stats ownerOfThisBuff) {
            spellCast.Result.AddEffect(
                new AddBuff(new BuffParams(ownerOfThisBuff, spellCast.Target.Id), spellCast.Caster.Buffs, new SuperIgnited()));
        }
    }

    public class AntiHeal : Buff {

        public AntiHeal() : base(8, Util.GetSprite("skull-crossed-bones"), "Antiheal", "Healing on this unit is nullified.", false) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return (GetHealingElement(spellToReactTo) != null) && spellToReactTo.Target.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthIncrease = GetHealingElement(spellToReactTo);
            if (healthIncrease != null) {
                healthIncrease.Value = 0;
            }
        }

        private SpellEffect GetHealingElement(SingleSpell spellToReactTo) {
            SpellEffect healthIncrease = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthIncrease == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value > 0) {
                    healthIncrease = addToModStat;
                }
            }
            return healthIncrease;
        }
    }

    public class HealBoost : Buff {
        private int HEAL_MULTIPLIER = 2;

        public HealBoost() : base(3, Util.GetSprite("health-normal"), "Heal Buff", "Healing targeting this unit is doubled.", false) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return (GetHealingElement(spellToReactTo) != null) && spellToReactTo.Target.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthIncrease = GetHealingElement(spellToReactTo);
            if (healthIncrease != null) {
                healthIncrease.Value = (int)(healthIncrease.Value * HEAL_MULTIPLIER);
            }
        }

        private SpellEffect GetHealingElement(SingleSpell spellToReactTo) {
            SpellEffect healthIncrease = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthIncrease == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value > 0) {
                    healthIncrease = addToModStat;
                }
            }
            return healthIncrease;
        }
    }

    public class FishShook : PermanentBuff {
        private const float FISHY_TARGET_MULTIPLIER = 2;
        private const float OTHER_TARGET_MULTIPLIER = 0.25f;

        public FishShook()
            : base(Util.GetSprite("fish"),
                  "Fish-Shook",
                  string.Format(
                      "Basic attacks do {0}x damage on fishy targets and {1} damage on non-fish.", FISHY_TARGET_MULTIPLIER, OTHER_TARGET_MULTIPLIER)) {
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return spellToReactTo.SpellBook is Attack && spellToReactTo.Result.IsDealDamage && spellToReactTo.Caster.Stats == owner;
        }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            float localDmgMult = 0;

            // is a fish
            if (spellToReactTo.Target.Look.Breed == Characters.Breed.FISH) {
                localDmgMult = FISHY_TARGET_MULTIPLIER;
            } else { // not a fish
                localDmgMult = OTHER_TARGET_MULTIPLIER;
            }

            SpellEffect healthDamage = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) {
                    healthDamage = addToModStat;
                }
            }
            if (healthDamage != null) {
                healthDamage.Value = (int)Math.Floor(healthDamage.Value * localDmgMult);
            }
        }
    }

    public class DamageResist : PermanentBuff {
        private const float DAMAGE_MULTIPLIER = 0.7f;

        public DamageResist()
            : base(Util.GetSprite("round-shield"),
                  "Damage Resist",
                  String.Format("Reduces incident damage from basic attacks by {0}%.",
                      (1 - DAMAGE_MULTIPLIER) * 100)) { }

        protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) {
            SpellEffect healthDamage = null;
            for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) {
                SpellEffect se = spellToReactTo.Result.Effects[i];
                AddToModStat addToModStat = se as AddToModStat;
                if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) {
                    healthDamage = addToModStat;
                }
            }
            if (healthDamage != null) {
                int tempValue = healthDamage.Value;
                healthDamage.Value = (int)Math.Floor(healthDamage.Value * DAMAGE_MULTIPLIER);
            }
        }

        public override bool IsReact(SingleSpell spellToReactTo, Stats owner) {
            return spellToReactTo.SpellBook is Attack && spellToReactTo.Target.Stats == owner;
        }
    }

    public class SuperIgnited : AbstractIgnited {
        private const int DURATION = 3;

        public SuperIgnited() : base(DURATION, 5, 40) {
        }
    }

    public class TempIgnited : AbstractIgnited {
        private const int DURATION = 5;

        public TempIgnited() : base(DURATION) {
        }
    }

    public class PermanantIgnited : AbstractIgnited {

        public PermanantIgnited() : base() {
        }
    }

    public class Poison : PermanentBuff {

        public Poison() : base(Util.GetSprite("fox-head"), "Poisoned", "Loses health at the end of each turn.") {
        }

        protected override IList<SpellEffect> OnEndOfTurnHelper(Model.Characters.Stats owner) {
            return new SpellEffect[] {
                    new AddToModStat(owner, StatType.HEALTH, -1)
                };
        }
    }

    public class StrengthScalingPoison : Buff {

        public StrengthScalingPoison() : base(2, Util.GetSprite("fox-head"), "StrengthScalingPoison", "Loses health at the end of each turn.", true) {
        }

{'fraction_non_alphanumeric': 0.09035551728379874, 'fraction_numerical': 0.004920654447041457, 'mean_word_length': 2.1291377983063895, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3948580', 'n_tokens_mistral': 4795, 'n_tokens_neox': 4582, 'n_words': 1029}