Example #1
0
        public void GetWeaponData()
        {
            var data = new string[4];

            data[DataIndexConstants.Weapon.ThreatRange]                 = 9266.ToString();
            data[DataIndexConstants.Weapon.CriticalMultiplier]          = "sevenfold";
            data[DataIndexConstants.Weapon.SecondaryCriticalMultiplier] = string.Empty;
            data[DataIndexConstants.Weapon.Ammunition] = "dirty laundry";

            mockInnerSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.WeaponData, "weapon")).Returns(data);

            var damages = new string[14];

            damages[0]  = damageHelper.BuildEntry("almost nothing", "emotional", string.Empty);
            damages[1]  = damageHelper.BuildEntry("a little", "emotional", string.Empty);
            damages[2]  = damageHelper.BuildEntry("a normal amount", "emotional", string.Empty);
            damages[3]  = damageHelper.BuildEntry("quite a bit", "emotional", string.Empty);
            damages[4]  = damageHelper.BuildEntry("a ton", "emotional", string.Empty);
            damages[5]  = damageHelper.BuildEntry("way too much", "emotional", string.Empty);
            damages[6]  = damageHelper.BuildEntry("DAYUM", "emotional", string.Empty);
            damages[7]  = damageHelper.BuildEntry("almost nothing but more", "emotional", string.Empty);
            damages[8]  = damageHelper.BuildEntry("a little but more", "emotional", string.Empty);
            damages[9]  = damageHelper.BuildEntry("a normal amount but more", "emotional", string.Empty);
            damages[10] = damageHelper.BuildEntry("quite a bit but more", "emotional", string.Empty);
            damages[11] = damageHelper.BuildEntry("a ton but more", "emotional", string.Empty);
            damages[12] = damageHelper.BuildEntry("way too much but more", "emotional", string.Empty);
            damages[13] = damageHelper.BuildEntry("DAYUM but more", "emotional", string.Empty);

            mockInnerSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.WeaponDamages, "weapon")).Returns(damages);

            var selection = weaponDataSelector.Select("weapon");

            Assert.That(selection.ThreatRange, Is.EqualTo(9266));
            Assert.That(selection.Ammunition, Is.EqualTo("dirty laundry"));
            Assert.That(selection.CriticalMultiplier, Is.EqualTo("sevenfold"));
            Assert.That(selection.SecondaryCriticalMultiplier, Is.Empty);
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Colossal], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Colossal][0].Description, Is.EqualTo("DAYUM emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Gargantuan], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Gargantuan][0].Description, Is.EqualTo("way too much emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Huge], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Huge][0].Description, Is.EqualTo("a ton emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Large], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Large][0].Description, Is.EqualTo("quite a bit emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Medium], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Medium][0].Description, Is.EqualTo("a normal amount emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Small], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Small][0].Description, Is.EqualTo("a little emotional"));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Tiny], Has.Count.EqualTo(1));
            Assert.That(selection.DamagesBySize[TraitConstants.Sizes.Tiny][0].Description, Is.EqualTo("almost nothing emotional"));
            Assert.That(selection.DamagesBySize.Count, Is.EqualTo(7));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Colossal], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Colossal][0].Description, Is.EqualTo("DAYUM but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Gargantuan], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Gargantuan][0].Description, Is.EqualTo("way too much but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Huge], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Huge][0].Description, Is.EqualTo("a ton but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Large], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Large][0].Description, Is.EqualTo("quite a bit but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Medium], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Medium][0].Description, Is.EqualTo("a normal amount but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Small], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Small][0].Description, Is.EqualTo("a little but more emotional"));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Tiny], Has.Count.EqualTo(1));
            Assert.That(selection.CriticalDamagesBySize[TraitConstants.Sizes.Tiny][0].Description, Is.EqualTo("almost nothing but more emotional"));
            Assert.That(selection.CriticalDamagesBySize.Count, Is.EqualTo(7));
        }
        private Weapon SetWeaponAttributes(Weapon weapon)
        {
            if (string.IsNullOrEmpty(weapon.Name))
            {
                throw new ArgumentException("Weapon name cannot be empty - it must be filled before calling this method");
            }

            weapon.Size = GetSize(weapon);
            weapon.Traits.Remove(weapon.Size);
            weapon.ItemType = ItemTypeConstants.Weapon;

            if (NameMatches(weapon.Name, WeaponConstants.CompositeLongbow) ||
                NameMatches(weapon.Name, WeaponConstants.CompositeShortbow))
            {
                var oldName = weapon.Name;
                weapon.Name = replacementSelector.SelectSingle(oldName);
                var compositeStrengthBonus = GetCompositeBowBonus(oldName);

                if (!string.IsNullOrEmpty(compositeStrengthBonus))
                {
                    weapon.Traits.Add(compositeStrengthBonus);
                }
            }

            var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon);

            weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name);

            var weaponSelection = weaponDataSelector.Select(weapon.Name);

            if (!weapon.Damages.Any())
            {
                weapon.Damages.Add(weaponSelection.DamagesBySize[weapon.Size][0]);
            }

            if (!weapon.CriticalDamages.Any())
            {
                weapon.CriticalDamages.Add(weaponSelection.CriticalDamagesBySize[weapon.Size][0]);
            }

            if (weapon.IsDoubleWeapon && !weapon.SecondaryDamages.Any())
            {
                weapon.SecondaryDamages.Add(weaponSelection.DamagesBySize[weapon.Size][1]);
            }

            if (weapon.IsDoubleWeapon && !weapon.SecondaryCriticalDamages.Any())
            {
                weapon.SecondaryCriticalDamages.Add(weaponSelection.CriticalDamagesBySize[weapon.Size][1]);
            }

            weapon.ThreatRange        = weaponSelection.ThreatRange;
            weapon.Ammunition         = weaponSelection.Ammunition;
            weapon.CriticalMultiplier = weaponSelection.CriticalMultiplier;

            if (weapon.IsDoubleWeapon && string.IsNullOrEmpty(weapon.SecondaryCriticalMultiplier))
            {
                weapon.SecondaryCriticalMultiplier = weaponSelection.SecondaryCriticalMultiplier;
            }

            return(weapon);
        }
Example #3
0
        public void WeaponCriticalDamagesHaveCorrectMultiplier(string weapon)
        {
            var sizes    = TraitConstants.Sizes.All().ToArray();
            var noDamage = new[]
            {
                WeaponConstants.CrossbowBolt,
                WeaponConstants.Arrow,
                WeaponConstants.SlingBullet,
                WeaponConstants.Net,
            };

            var weaponData  = weaponDataSelector.Select(weapon);
            var damageDatas = table[weapon].Select(d => damageHelper.ParseEntries(d)).ToArray();

            for (var i = 0; i < sizes.Length; i++)
            {
                var normal   = damageDatas[i];
                var critical = damageDatas[i + sizes.Length];

                Assert.That(normal, Has.Length.EqualTo(critical.Length), weapon);
                Assert.That(normal, Has.Length.EqualTo(1).Or.Length.EqualTo(2));
                Assert.That(critical, Has.Length.EqualTo(1).Or.Length.EqualTo(2));

                Assert.That(critical[0][DataIndexConstants.Weapon.DamageData.TypeIndex], Is.EqualTo(normal[0][DataIndexConstants.Weapon.DamageData.TypeIndex]), weapon);
                Assert.That(normal[0][DataIndexConstants.Weapon.DamageData.ConditionIndex], Is.Empty, weapon);
                Assert.That(critical[0][DataIndexConstants.Weapon.DamageData.ConditionIndex], Is.Empty, weapon);

                var normalSections = normal[0][DataIndexConstants.Weapon.DamageData.RollIndex].Split('d');
                var normalQuantity = Convert.ToInt32(normalSections[0]);
                var normalDie      = 1;
                if (normalSections.Length > 1)
                {
                    normalDie = Convert.ToInt32(normalSections[1]);
                }

                var criticalSections = critical[0][DataIndexConstants.Weapon.DamageData.RollIndex].Split('d');
                var criticalQuantity = Convert.ToInt32(criticalSections[0]);
                var criticalDie      = 1;
                if (criticalSections.Length > 1)
                {
                    criticalDie = Convert.ToInt32(criticalSections[1]);
                }

                if (noDamage.Contains(weapon))
                {
                    Assert.That(criticalDie, Is.EqualTo(normalDie).And.EqualTo(1), weapon);
                    Assert.That(criticalQuantity, Is.EqualTo(normalQuantity).And.Zero, $"{weapon}: {weaponData.CriticalMultiplier}");
                    continue;
                }

                var multiplier = Convert.ToInt32(weaponData.CriticalMultiplier.Substring(1, 1));

                Assert.That(multiplier, Is.EqualTo(2).Or.EqualTo(3).Or.EqualTo(4));
                Assert.That(criticalDie, Is.EqualTo(normalDie), weapon);
                Assert.That(criticalQuantity, Is.EqualTo(Math.Max(normalQuantity * multiplier, 1)), $"{weapon}: {weaponData.CriticalMultiplier}");

                if (normal.Length == 1)
                {
                    continue;
                }

                Assert.That(critical[1][DataIndexConstants.Weapon.DamageData.TypeIndex], Is.EqualTo(normal[1][DataIndexConstants.Weapon.DamageData.TypeIndex]), weapon);
                Assert.That(normal[1][DataIndexConstants.Weapon.DamageData.ConditionIndex], Is.Empty, weapon);
                Assert.That(critical[1][DataIndexConstants.Weapon.DamageData.ConditionIndex], Is.Empty, weapon);

                var normalSecondarySections = normal[1][DataIndexConstants.Weapon.DamageData.RollIndex].Split('d');
                var normalSecondaryQuantity = Convert.ToInt32(normalSecondarySections[0]);
                var normalSecondaryDie      = 1;
                if (normalSecondarySections.Length > 1)
                {
                    normalSecondaryDie = Convert.ToInt32(normalSecondarySections[1]);
                }

                var criticalSecondarySections = critical[1][DataIndexConstants.Weapon.DamageData.RollIndex].Split('d');
                var criticalSecondaryQuantity = Convert.ToInt32(criticalSecondarySections[0]);
                var criticalSecondaryDie      = 1;
                if (criticalSecondarySections.Length > 1)
                {
                    criticalSecondaryDie = Convert.ToInt32(criticalSecondarySections[1]);
                }

                var secondaryMultiplier = Convert.ToInt32(weaponData.SecondaryCriticalMultiplier.Substring(1, 1));

                Assert.That(secondaryMultiplier, Is.EqualTo(2).Or.EqualTo(3).Or.EqualTo(4));
                Assert.That(criticalSecondaryDie, Is.EqualTo(normalSecondaryDie), weapon);
                Assert.That(criticalSecondaryQuantity, Is.EqualTo(Math.Max(normalSecondaryQuantity * secondaryMultiplier, 1)), $"{weapon}: {weaponData.SecondaryCriticalMultiplier}");
            }
        }