Esempio n. 1
0
        private int CalcDamage(DealDamage damage)
        {
            // First check for immunities, then resistance, then vulnerability (p. 197 Player's Handbook)
            if (Immunities.Contains(damage.DamageType))
            {
                return(0);
            }

            int actualHpDamage = damage.Hp;

            // Resistances and vulnerabilities do not stack, so one does as much as multiple.
            if (Resistances.Contains(damage.DamageType))
            {
                actualHpDamage /= 2; // integer division correctly rounds down
            }

            // It is technically possible to have a resistance and a vulnerability for the same damage type.
            // https://rpg.stackexchange.com/a/167448
            if (Vulnerabilities.Contains(damage.DamageType))
            {
                actualHpDamage *= 2;
            }

            return(actualHpDamage);
            // Possible future refactor: It's a little bit inefficient to check all of the
            // lists every time, especially since this function is called from in a loop.
        }
Esempio n. 2
0
        public bool Matches(string text, bool nameOnly)
        {
            CultureInfo Culture = CultureInfo.InvariantCulture;

            if (nameOnly)
            {
                return(Culture.CompareInfo.IndexOf(Name ?? "", text, CompareOptions.IgnoreCase) >= 0);
            }
            return(Culture.CompareInfo.IndexOf(Name ?? "", text, CompareOptions.IgnoreCase) >= 0 ||
                   Culture.CompareInfo.IndexOf(Source ?? "", text, CompareOptions.IgnoreCase) >= 0 ||
                   Culture.CompareInfo.IndexOf(Description ?? "", text, CompareOptions.IgnoreCase) >= 0 ||
                   Culture.CompareInfo.IndexOf(Alignment ?? "", text, CompareOptions.IgnoreCase) >= 0 ||
                   Speeds.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Senses.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Resistances.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Vulnerablities.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Immunities.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Languages.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   ConditionImmunities.Exists(s => Culture.CompareInfo.IndexOf(s ?? "", text, CompareOptions.IgnoreCase) >= 0) ||
                   Descriptions.Exists(s => s.Matches(text, nameOnly)) ||
                   Traits.Exists(s => s.Matches(text, nameOnly)) ||
                   LegendaryActions.Exists(s => s.Matches(text, nameOnly)) ||
                   Actions.Exists(s => s.Matches(text, nameOnly)) ||
                   Keywords.Exists(s => Culture.CompareInfo.IndexOf(s.Name ?? "", text, CompareOptions.IgnoreCase) >= 0));
        }
Esempio n. 3
0
 public ResistanceSet()
 {
     foreach (var damageType in (DamageType[])Enum.GetValues(typeof(DamageType)))
     {
         Resistances.Add(damageType, new ResistanceSetSettings(1f, 0));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Display input in text boxes and lists
        /// </summary>
        /// <param name="monsterToDisplay"></param>
        private void DisplayMonsterStats(Monster monsterToDisplay)
        {
            txtAC.Text    = monsterToDisplay.ArmorClass.ToString();
            txtDEX.Text   = monsterToDisplay.DexterityModifier.ToString();
            txtHP.Text    = monsterToDisplay.TotalHealth.ToString();
            txtName.Text  = monsterToDisplay.Name;
            txtPP.Text    = monsterToDisplay.PassivePerception.ToString();
            txtSpeed.Text = monsterToDisplay.PassivePerception.ToString();
            cmbMonsterTypes.SelectedValue = monsterToDisplay.Type;
            chkMultiattack.IsChecked      = monsterToDisplay.Multiattack;

            foreach (DamageType resistance in monsterToDisplay.Resistances)
            {
                lstResistances.Items.Add(resistance);
                Resistances.Add(resistance);
            }

            foreach (DamageType immunity in monsterToDisplay.Immunities)
            {
                lstImmunities.Items.Add(immunity);
                Immunities.Add(immunity);
            }

            foreach (Attack attack in monsterToDisplay.Attacks)
            {
                lstAttacks.Items.Add(attack);
                Attacks.Add(attack);
            }

            foreach (MonsterSpecial monsterSpecial in monsterToDisplay.MonsterSpecials)
            {
                lstMonsterSpecials.Items.Add(monsterSpecial);
                MonsterSpecials.Add(monsterSpecial);
            }
        }
Esempio n. 5
0
        public void TestResistancesForActor()
        {
            var you = YouInARoom(out _);

            var res = new Resistances();

            res.Immune.Add("Invincible");

            res.Resist.Add("Tough");
            res.Vulnerable.Add("Frail");

            var item = new Item("Apron");

            you.Items.Add(item);

            //this apron does not help at all.  The effect multiplier is 1 i.e. no change
            Assert.AreEqual(1, res.Calculate(you, true));
            Assert.AreEqual(1, res.Calculate(you, false));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Invincible"
            });
            Assert.AreEqual(0, res.Calculate(you, true), "You should no longer be affected being invincible");
            Assert.AreEqual(1, res.Calculate(you, false), "If not including items it should be normal i.e. 1");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(you, true));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Tough"
            });
            Assert.AreEqual(0.5, res.Calculate(you, true), "Tough should decrease susceptibility");
            Assert.AreEqual(1, res.Calculate(you, false), "If not including items it should be normal i.e. 1");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(you, true));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Frail"
            });
            Assert.AreEqual(2, res.Calculate(you, true), "Frail should increase susceptibility");
            Assert.AreEqual(1, res.Calculate(you, false), "If not including items it should be normal i.e. 1");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(you, true));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Frail"
            });
            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Tough"
            });
            Assert.AreEqual(1, res.Calculate(you, true), "Frail and Tough should cancel out");
            Assert.AreEqual(1, res.Calculate(you, false), "If not including items it should be normal i.e. 1");
        }
Esempio n. 6
0
    public void Deal(Health health, Resistances resistances)
    {
        DamageSources filteredDamageTypes = resistances.FilterDamage(sources);
        float         totalDamage         = filteredDamageTypes.CalculateTotalDamage();

        health.Subtract(totalDamage);
    }
 public void AddResistances(Resistances newResistances)
 {
     if (!resistances.Contains(newResistances))
     {
         resistances.Add(newResistances);
         totalResistances += newResistances;
     }
 }
 public void SubtractResistances(Resistances subtraction)
 {
     if (resistances.Contains(subtraction))
     {
         resistances.Remove(subtraction);
         totalResistances -= subtraction;
     }
 }
 public AuraEffect(ushort _id, int _customFlags1, int _add,
                   int _levelMin, int _levelMax, int _bonus1, int _bonus2, int _s1, int _s2, int _s3,
                   int _t1, int _t2, Resistances _res, DispelType _dis,
                   int _manacost, int _castingtime, byte _range, int _duration, int _cooldown,
                   int _aura, int _h, int _classe) : base(_id, _customFlags1, _add,
                                                          _levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _t1, _t2, _res, _dis,
                                                          _manacost, _castingtime, _range, _duration, _cooldown, _h, 0, 0, 0, _classe)
 {
     aura = _aura;
 }
 public ComboSpellTemplate(ushort _id, int _customFlags1,
                           int _levelMin, int _levelMax, int _bonus1, int _bonus2,
                           int _s1, int _s2, int _s3,
                           Resistances _res, DispelType _dis,
                           int _manacost, int _castingtime, byte _range, float _comboModifier, int _duration, int _cooldown,
                           int _h, int _classe) : base(_id, _customFlags1,
                                                       _levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _res, _dis,
                                                       _manacost, _castingtime, _range, _duration, _cooldown, _h, 0, 0, 0, _classe)
 {
     comboModifier = _comboModifier;
 }
Esempio n. 11
0
        public AuraEffect( ushort _id,int _customFlags1,  int _add,
            int _levelMin, int _levelMax, int _bonus1, int _bonus2, int _s1, int _s2, int _s3,
            int _t1, int _t2, Resistances _res, DispelType _dis,
            int _manacost, int _castingtime, byte _range, int _duration, int _cooldown,
            int _aura, int _h, int _classe)
            : base(_id,_customFlags1,  _add,
			_levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _t1, _t2, _res,_dis,
			_manacost, _castingtime, _range, _duration, _cooldown, _h, 0, 0, 0, _classe)
        {
            aura = _aura;
        }
Esempio n. 12
0
        public ComboSpellTemplate( ushort _id, int _customFlags1,   
            int _levelMin, int _levelMax, int _bonus1, int _bonus2,
            int _s1, int _s2, int _s3,
            Resistances _res, DispelType _dis,
            int _manacost, int _castingtime, byte _range, float _comboModifier, int _duration, int _cooldown,
            int _h, int _classe)
            : base(_id, _customFlags1, 
			_levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _res, _dis,
			_manacost, _castingtime, _range, _duration, _cooldown, _h, 0, 0, 0,_classe)
        {
            comboModifier = _comboModifier;
        }
Esempio n. 13
0
 public MountAuraEffect(ushort _id, int _customFlags1, int _mountid,
                        int _levelMin, int _levelMax, int _bonus1, int _bonus2, int _s1, int _s2, int _s3,
                        int _t1, int _t2, Resistances _res, DispelType _dis,
                        int _manacost, int _castingtime, int _duration, int _cooldown,
                        int _aura, int _h, int _classe) : base(_id, _customFlags1,
                                                               _levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _t1, _t2, _res, _dis,
                                                               _manacost, _castingtime, 0, _duration, _cooldown, _aura, _h, _classe)
 {
     mountId                   = _mountid;
     speedModifier             = ((float)_s2) / 100f;
     World.MountsList[mountId] = this;
 }
Esempio n. 14
0
        public MountAuraEffect( ushort _id,int _customFlags1,   int _mountid,
            int _levelMin, int _levelMax, int _bonus1, int _bonus2, int _s1, int _s2, int _s3,
            int _t1, int _t2, Resistances _res, DispelType _dis,
            int _manacost, int _castingtime, int _duration, int _cooldown,
            int _aura, int _h, int _classe)
            : base(_id, _customFlags1, 
			_levelMin, _levelMax, _bonus1, _bonus2, _s1, _s2, _s3, _t1, _t2, _res,_dis,
			_manacost, _castingtime, 0, _duration, _cooldown, _aura, _h, _classe)
        {
            mountId = _mountid;
            speedModifier = ( (float)_s2 ) / 100f;
            World.MountsList[ mountId ] = this;
        }
Esempio n. 15
0
        private void OnEnable()
        {
            integrity = GetComponent <Integrity>();

            if (initialSet || integrity == null)
            {
                return;
            }

            initialSet         = true;
            initialArmor       = integrity.Armor;
            initialResistances = integrity.Resistances;
        }
Esempio n. 16
0
        public void TestResistancesByName()
        {
            var res = new Resistances();

            res.Immune.Add("Invincible");

            res.Resist.Add("Tough");
            res.Vulnerable.Add("Frail");

            var item = new Item("Apron");

            //this apron does not help at all.  The effect multiplier is 1 i.e. no change
            Assert.AreEqual(1, res.Calculate(item));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Invincible"
            });
            Assert.AreEqual(0, res.Calculate(item), "You should no longer be affected being invincible");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(item));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Tough"
            });
            Assert.AreEqual(0.5, res.Calculate(item), "Tough should decrease susceptibility");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(item));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Frail"
            });
            Assert.AreEqual(2, res.Calculate(item), "Frail should increase susceptibility");

            item.Adjectives.Clear();
            Assert.AreEqual(1, res.Calculate(item));

            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Frail"
            });
            item.Adjectives.Add(new Adjective(item)
            {
                Name = "Tough"
            });
            Assert.AreEqual(1, res.Calculate(item), "Frail and Tough should cancel out");
        }
Esempio n. 17
0
    public static Resistances operator -(Resistances a, Resistances b)
    {
        Resistances sum = new Resistances();

        Dictionary <DamageType, DamageSource> .KeyCollection keys = a.Dictionary.Keys;

        foreach (DamageType rt in keys)
        {
            float newValue = a.Dictionary[rt].value - b.Dictionary[rt].value;
            sum.Dictionary[rt].value = Mathf.Clamp(newValue, minStat, maxStat);
        }

        return(sum);
    }
Esempio n. 18
0
        private void Awake()
        {
            integrity    = GetComponent <Integrity>();
            lineRenderer = GetComponent <LineRenderer>();

            if (initialSet || integrity == null)
            {
                return;
            }

            initialSet         = true;
            initialArmor       = integrity.Armor;
            initialResistances = integrity.Resistances;
        }
Esempio n. 19
0
		//int cooldown;	

		public Ability( ushort _id,int _customFlags1,    
			int _degatMin, int _degatMax, Resistances _res,DispelType _dis, 
			int _manacost, int _castingtime, byte _range, int _duration, int _cooldown, 
			int _classe	) : base( _id,_customFlags1,  _cooldown )
		{
			degatMin = _degatMin;
			degatMax = _degatMax;
			resistance = _res;
			dispeltype = _dis;
			classe = _classe;
			manaCost = _manacost;
			castingTime = _castingtime;
			range = _range;
			duration = _duration;
		}
Esempio n. 20
0
 public Ability(ushort _id, int _customFlags1,
                int _degatMin, int _degatMax, Resistances _res, DispelType _dis,
                int _manacost, int _castingtime, byte _range, int _duration, int _cooldown,
                int _classe) : base(_id, _customFlags1, _cooldown)
 {
     degatMin    = _degatMin;
     degatMax    = _degatMax;
     resistance  = _res;
     dispeltype  = _dis;
     classe      = _classe;
     manaCost    = _manacost;
     castingTime = _castingtime;
     range       = _range;
     duration    = _duration;
 }
Esempio n. 21
0
        private float Resist(Resistances resistances, Attack.DamageType type, float damage)
        {
            switch (type)
            {
            case (Attack.DamageType.Kinetic):
                return(damage *= resistances.Kinetic);

            case (Attack.DamageType.Fire):
                return(damage *= resistances.Fire);

            case (Attack.DamageType.Electrical):
                return(damage *= resistances.Electrical);

            default:
                return(damage);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Calculate Damage amount from damage and DamageType
        /// Taking into consideration Resistances and Immunities
        /// </summary>
        /// <param name="damage"></param>
        /// <param name="damageType"></param>
        /// <returns></returns>
        public int CalculateDamage(int damage, DamageType damageType)
        {
            double totalDamage = 0d;

            if (Resistances.Contains(damageType))
            {
                totalDamage = Math.Floor((double)damage / 2d);
            }
            else if (Immunities.Contains(damageType))
            {
            }
            else
            {
                totalDamage = damage;
            }

            return(Convert.ToInt32(totalDamage));
        }
Esempio n. 23
0
        public bool IsResistantTo(Element element)
        {
            Element[] barrResists = { Element.Dimension, Element.Fire, Element.Mind, Element.Lightning, Element.Death, Element.Poison, Element.Body, Element.Ice };
            for (int i = 0; i < GetBuffStacks(Buff.Barrier); i++)
            {
                // Ignore Ice unless bug fixes are in effect
                if (!Globals.BUG_FIXES && i == 7)
                {
                    break;
                }

                if (barrResists[i] == element)
                {
                    return(true);
                }
            }

            return(Resistances.Contains(element));
        }
Esempio n. 24
0
        public AspectSpawn(BaseAspect aspect, AIType ai, FightMode mode, double dActiveSpeed, double dPassiveSpeed)
            : base(ai, mode, aspect.RangePerception, aspect.RangeFight, dActiveSpeed, dPassiveSpeed)
        {
            Aspect = aspect;

            Name = "Aspect Spawn";
            Body = 129;

            Hue  = Aspect.Hue;
            Team = Aspect.Team;

            Resistances.SetAll(i => Aspect.Resistances[i]);

            SetDamageType(ResistanceType.Physical, Aspect.PhysicalDamage);
            SetDamageType(ResistanceType.Fire, Aspect.FireDamage);
            SetDamageType(ResistanceType.Cold, Aspect.ColdDamage);
            SetDamageType(ResistanceType.Poison, Aspect.PoisonDamage);
            SetDamageType(ResistanceType.Energy, Aspect.EnergyDamage);

            Aspect.Scale(this);

            SpawnAspectAbility.Register(this);
        }
Esempio n. 25
0
        private void PokemonTypeListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PokemonType temp = (PokemonType)PokemonTypeListBox.SelectedItem;

            PTypeNameTextBox.Text          = temp.Name;
            PTypeInternalNameTextBox.Text  = temp.InternalName;
            PTypePseudoCheckBox.IsChecked  = temp.IsPseudoType;
            PTypeSpecialCheckBox.IsChecked = temp.IsSpecialType;

            PTypeWeaknessListBox.UnselectAll();
            if (temp.Weaknesses != null)
            {
                foreach (String type in temp.Weaknesses)
                {
                    PTypeWeaknessListBox.SelectedItems.Add(Weaknesses.Find(p => p.InternalName.Equals(type)));
                }
            }

            PTypeResistanceListBox.UnselectAll();
            if (temp.Resistances != null)
            {
                foreach (String type in temp.Resistances)
                {
                    PTypeResistanceListBox.SelectedItems.Add(Resistances.Find(p => p.InternalName.Equals(type)));
                }
            }

            PTypeImmunityListBox.UnselectAll();
            if (temp.Immunities != null)
            {
                foreach (String type in temp.Immunities)
                {
                    PTypeImmunityListBox.SelectedItems.Add(Immunities.Find(p => p.InternalName.Equals(type)));
                }
            }
        }
        // FUNCTION: TakeDamage
        // PARAMETERS:
        //    -dt:DamageTypes, an enum representing the type of damage dealt
        //    -damageValue:int, the amount of damage dealt to the Character
        // Calculates damage dealt to the character, factors in if the Character has resistances
        // to the DamageTypes value passed in.  If a Character has Resistance to a damage type,
        // ensures that at minimum 1 damage is dealt, else round down.  If a Character has temporary
        // hp, takes away from TempHp first and any remaining damage gets taken from CurrHp. If damage
        // would put a Character under 0 hp, sets hp to 0.
        public void TakeDamage(DamageTypes dt, int damageValue)
        {
            double tempDamage = Convert.ToDouble(damageValue);

            if (Resistances.ContainsKey(dt))
            {
                double damageMod = 1.0;
                switch (Resistances[dt])
                {
                case ResistanceTypes.Immunity:
                    damageMod = 0.0;
                    break;

                case ResistanceTypes.Resistance:
                    damageMod = 0.5;
                    break;

                case ResistanceTypes.Vulnerable:
                    damageMod = 2.0;
                    break;

                default:
                    damageMod = 1.0;
                    break;
                }
                tempDamage = (Convert.ToDouble(damageValue) * damageMod);
                if (tempDamage > 0.0 && tempDamage < 1.0)
                {
                    tempDamage = 1.0;
                }
                else
                {
                    tempDamage = Math.Floor(tempDamage);
                }
            }

            if (tempDamage > 0.0)
            {
                if (TempHp > 0)
                {
                    if (TempHp >= (int)tempDamage)
                    {
                        TempHp -= (int)tempDamage;
                    }
                    else
                    {
                        int postDamage = (int)tempDamage - TempHp;
                        TempHp  = 0;
                        CurrHp -= postDamage;
                    }
                }
                else
                {
                    CurrHp -= (int)tempDamage;
                    if (CurrHp < 0)
                    {
                        CurrHp = 0;
                    }
                }
            }
        }
Esempio n. 27
0
 public static ActorValue ToActorValue(this Resistances value)
 {
     return(EnumConverter.ConvertByName <ActorValue>(value));
 }
Esempio n. 28
0
 public Damageable()
 {
     BaseResistance   = new Resistances();
     ArmourResistance = new Resistances();
     ShieldResistance = new Resistances();
 }
Esempio n. 29
0
        public AnimaCharacter(ExcelWorksheet excelWorksheet, string player)
        {
            Player    = player;
            IsCurrent = false;
            ImageUrl  = excelWorksheet.Cells["AK1"].Text;

            //Character info
            Name    = excelWorksheet.Cells["E1"].Text;
            Origine = excelWorksheet.Cells["P1"].Text;
            Class   = excelWorksheet.Cells["F3"].Text;
            Level   = Convert.ToInt32(excelWorksheet.Cells["E5"].Value);
            Hp      = Convert.ToInt32(excelWorksheet.Cells["B12"].Value);
            string temp = excelWorksheet.Cells["B13"].Text;

            CurrentHp = string.IsNullOrEmpty(temp) ? Hp : Convert.ToInt32(temp);

            Regeneration   = Convert.ToInt32(excelWorksheet.Cells["J18"].Value);
            Fatigue        = Convert.ToInt32(excelWorksheet.Cells["B18"].Value);
            temp           = excelWorksheet.Cells["B19"].Text;
            CurrentFatigue = string.IsNullOrEmpty(temp) ? Fatigue : Convert.ToInt32(temp);
            Movement       = Convert.ToInt32(excelWorksheet.Cells["F18"].Value);

            TotalKiPoints = Convert.ToInt32(excelWorksheet.Cells["V39"].Value);
            temp          = excelWorksheet.Cells["Z39"].Text;
            CurrentKi     = string.IsNullOrEmpty(temp) ? TotalKiPoints : Convert.ToInt32(temp);

            ArmorPoint = Convert.ToInt32(excelWorksheet.Cells["AC55"].Value);

            ZeonPoints  = Convert.ToInt32(excelWorksheet.Cells["U15"].Value);
            temp        = excelWorksheet.Cells["U16"].Text;
            CurrentZeon = string.IsNullOrEmpty(temp) ? ZeonPoints : Convert.ToInt32(temp);
            Amr         = Convert.ToInt32(excelWorksheet.Cells["U21"].Value);
            AmrRegen    = Convert.ToInt32(excelWorksheet.Cells["U24"].Value);
            InnateMagic = Convert.ToInt32(excelWorksheet.Cells["U27"].Value);
            MagicLevel  = Convert.ToInt32(excelWorksheet.Cells["AD8"].Value);

            PppFree       = Convert.ToInt32(excelWorksheet.Cells["Q21"].Value);
            temp          = excelWorksheet.Cells["Q22"].Text;
            CurrentPpp    = string.IsNullOrEmpty(temp) ? PppFree : Convert.ToInt32(temp);
            IsLucky       = Convert.ToBoolean(excelWorksheet.Cells["DC30"].Value);
            IsUnlucky     = Convert.ToBoolean(excelWorksheet.Cells["DC153"].Value);
            DestinFuneste = Convert.ToBoolean(excelWorksheet.Cells["DC165"].Value);
            //Base stats
            foreach (var cell in excelWorksheet.Cells[22, 2, 30, 2])
            {
                BaseStats.Add(new Roll10Stat(StatGroups[0], cell.Text, Convert.ToInt32(cell.Offset(0, 9).Value)));
            }

            //Resistances
            foreach (var cell in excelWorksheet.Cells[32, 2, 36, 2])
            {
                Resistances.Add(new ResistanceStat(StatGroups[1], cell.Text, Convert.ToInt32(cell.Offset(0, 2).Value)));
            }

            //Battle stats
            BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["B14"].Text, Convert.ToInt32(excelWorksheet.Cells["B15"].Value)));
            BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["B52"].Text, Convert.ToInt32(excelWorksheet.Cells["AC52"].Value)));
            BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["B53"].Text, Convert.ToInt32(excelWorksheet.Cells["AC53"].Value)));
            BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["B54"].Text, Convert.ToInt32(excelWorksheet.Cells["AC54"].Value)));
            Roll100Stat defence = BattleStats.Where(x => x.Name == "Esquive" || x.Name == "Parade").OrderByDescending(x => x.Value).First();

            BattleStats.Add(new Roll100Stat(StatGroups[2], $"Défense : {defence.Name}", defence.Value));
            foreach (var cell in excelWorksheet.Cells[64, 2, 68, 2])
            {
                BattleStats.Add(new Roll100Stat(StatGroups[2], cell.Text, Convert.ToInt32(cell.Offset(0, 27).Value)));
            }

            BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["B71"].Text, Convert.ToInt32(excelWorksheet.Cells["AC71"].Value)));
            try
            {//TODO pourquoi ????
                BattleStats.Add(new Roll100Stat(StatGroups[2], excelWorksheet.Cells["Q23"].Text, Convert.ToInt32(excelWorksheet.Cells["Q24"].Value)));
            }
            catch (Exception ex)
            {
            }

            //Secondary stats
            foreach (var cell in excelWorksheet.Cells[75, 2, 143, 2])
            {
                if (!cell.Style.Font.Bold)
                {
                    SecondaryStats.Add(new Roll100Stat(StatGroups[3], cell.Text, Convert.ToInt32(cell.Offset(0, 27).Value)));
                }
            }
            SecondaryStats.Add(new Roll100Stat(StatGroups[3], excelWorksheet.Cells["G34"].Text, Convert.ToInt32(excelWorksheet.Cells["N34"].Value)));
            SecondaryStats.Add(new Roll100Stat(StatGroups[3], excelWorksheet.Cells["G35"].Text, Convert.ToInt32(excelWorksheet.Cells["N35"].Value)));
            SecondaryStats.RemoveAll(x => string.IsNullOrWhiteSpace(x.Name));

            base.AllStats.AddRange(BaseStats);
            base.AllStats.AddRange(Resistances);
            base.AllStats.AddRange(BattleStats);
            base.AllStats.AddRange(SecondaryStats);
        }
Esempio n. 30
0
 public Damageable(Entity owner, string id) : base(owner, id)
 {
     BaseResistance   = new Resistances();
     ArmourResistance = new Resistances();
     ShieldResistance = new Resistances();
 }
Esempio n. 31
0
 private bool IsResistant(DamageType damageType)
 {
     return(Resistances.Contains(damageType));
 }
Esempio n. 32
0
 public void SetDamage( float min, float max, Resistances res )
 {
     itemDamages[ (int)res ] = new ItemDamage( min, max );
 }
Esempio n. 33
0
 public SpellTemplate( ushort _id, int _customFlags1, 
     int _levelMin, int _levelMax, int _bonus1, int _bonus2, int _s1, int _s2, int _s3,
     int _t1, int _t2, Resistances _res, DispelType _dis,
     int _manacost, int _castingtime, byte _range, int _duration, int _cooldown,
     int _h, int _radius1, int _radius2, int _radius3, int _classe)
     : base(_id,_customFlags1,  _cooldown)
 {
     h = _h;
     levelMin = _levelMin;
     levelMax = _levelMax;
     resistance = _res;
     dispeltype = _dis;
     classe = _classe;
     manaCost = _manacost;
     castingTime = _castingtime;
     range = _range;
     duration = _duration;
     s1 = _s1;
     s2 = _s2;
     s3 = _s3;
     bonus1 = _bonus1;
     bonus2 = _bonus2;
     t1 = _t1;
     t2 = _t2;
     radius1 = _radius1;
     radius2 = _radius2;
     radius3 = _radius3;
 }
Esempio n. 34
0
 public string ResistancesLabel() => Resistances?.Count > 0 ? EnumerableToCSV(Resistances.Select(i => ((Constants.DamageTypes)i).ToString())) : "None";
Esempio n. 35
0
 public void AddResistance(DamageTypes damageType)
 {
     Resistances.Add(damageType);
 }
Esempio n. 36
0
    static int Damage(Ability a, Effect e, Unit owner, Unit target, bool isPrediction)
    {
        // Step 1. Get base attack power
        int baseAttackPower = (a.powerType == Ability.Powers.MPow) ? owner.GetStat(Stats.MPow) : owner.GetStat(Stats.WAtk);

        // Step 1a. Apply the mission item bonus
        baseAttackPower += baseAttackPower * GetMissionItemBonus(owner) / 100;

        // Step 2. Attacker's support check
        baseAttackPower = ReturnEvent <int>(a, owner, target, attackerSupportCheckEvent, baseAttackPower);

        // Step 3. Attacker's status check
        baseAttackPower = ReturnEvent <int>(a, owner, target, attackerStatusCheckEvent, baseAttackPower);

        // Step 4. Attacker's equipment check
        baseAttackPower = ReturnEvent <int>(a, owner, target, attackerEquipmentCheckEvent, baseAttackPower);

        // Step 5. Cap
        baseAttackPower = Mathf.Min(baseAttackPower, 999);

        // Step 6. Get base defense power
        int baseDefensePower = (a.powerType == Ability.Powers.MPow) ? target.GetStat(Stats.MRes) : target.GetStat(Stats.WDef);

        // Step 6.a Apply the mission item bonus
        baseDefensePower += baseDefensePower * GetMissionItemBonus(target) / 100;

        // Step 7. Target's support check
        baseDefensePower = ReturnEvent <int>(a, owner, target, defenderSupportCheckEvent, baseDefensePower);

        // Step 8. Target's status check
        baseDefensePower = ReturnEvent <int>(a, owner, target, defenderStatusCheckEvent, baseDefensePower);

        // Step 9. Target's equipment check
        baseDefensePower = ReturnEvent <int>(a, owner, target, defenderEquipmentCheckEvent, baseDefensePower);

        // Step 10. Defense Cap
        baseDefensePower = Mathf.Min(baseDefensePower, 999);

        // Step 11. Base Damage
        int damage = Mathf.Max(baseAttackPower - (baseDefensePower / 2), 1);

        // Step 12. Get Ability Power
        int power = Mathf.Max(a.power, 1);         // TODO: get weapon power if applicable

        // Step 13. Apply Power Bonus
        damage = Mathf.Max(power * damage / 100, 1);

        // Step 14. Elemental Check
        Elements element = a.element;

        if (element == Elements.None && a.powerType == Ability.Powers.Weapon)
        {
            // TODO: use charge of primary weapon
        }

        if (element != Elements.None)
        {
            // 14 b. Retrieve Target's Resistance (native and equipment)
            Resistances baseResistance = Resistances.Normal;             // TODO: implement

            // 14 c. Element enhancement from equipment
            // 14 d. Geomancy check
            // 14 e. Mission item check
            // 14 f. Apply damage bonus
            switch (baseResistance)
            {
            case Resistances.Weak:
                damage *= 3 / 2;
                break;

            case Resistances.Normal:
                break;

            case Resistances.Resist:
                damage /= 2;
                break;

            case Resistances.Null:
                damage = 0;
                break;

            case Resistances.Absorb:
                damage = -damage;
                break;
            }
        }

        // Step 15. Critical Hit
//		if (false) // TODO: Determine critical hit chance
//			damage *= 3 / 2;

        // Step 16. Expert Guard
//		if (false) // TODO
//			damage = 0;

        // Step 17. Random Variance
        if (true)         // Skip when this is a prediction
        {
            int rnd = damage / 10;
            damage += UnityEngine.Random.Range(0, 2 * rnd) - rnd;
        }

        // Step 18. Unknown
//		if (false)
//			damage *= 3 / 2;

        // Step 19. Weapon Effects
//		if (false) // check weapon drain HP and Undead target
//			damage = -damage;
//		if (false) // check weapon heal on attack
//			damage = -damage;

        // Step 20. Cap Damage
        damage = Mathf.Clamp(damage, -999, 999);

        return(damage);
    }