Ejemplo n.º 1
0
        public void MartialWeaponProficiencyFoci()
        {
            var foci       = WeaponConstants.GetAllMartial(false, false);
            var ammunition = WeaponConstants.GetAllAmmunition(false, false);

            foci = foci.Except(ammunition);
            base.AssertDistinctCollection(FeatConstants.WeaponProficiency_Martial, foci.ToArray());
        }
Ejemplo n.º 2
0
        public Item SelectFrom(string source)
        {
            var template = new Item();

            template.Name = source;
            template.Name = itemTypeRegex.Replace(template.Name, string.Empty);
            template.Name = itemBonusRegex.Replace(template.Name, string.Empty);
            template.Name = specialAbilityRegex.Replace(template.Name, string.Empty);
            template.Name = traitRegex.Replace(template.Name, string.Empty);
            template.Name = isMagicRegex.Replace(template.Name, string.Empty);

            template.ItemType = GetMatchValue(itemTypeRegex, source, "[", "]");

            if (isMagicRegex.IsMatch(source))
            {
                var rawIsMagic = GetMatchValue(isMagicRegex, source, "@", "@");
                template.IsMagical = Convert.ToBoolean(rawIsMagic);
            }

            if (itemBonusRegex.IsMatch(source))
            {
                var rawBonus = GetMatchValue(itemBonusRegex, source, "(", ")");
                template.Magic.Bonus = Convert.ToInt32(rawBonus);
            }

            if (specialAbilityRegex.IsMatch(source))
            {
                var rawSpecialAbilities = GetMatchValue(specialAbilityRegex, source, "{", "}");
                var specialAbilities    = rawSpecialAbilities.Split(',');
                template.Magic.SpecialAbilities = GetSpecialAbilities(specialAbilities);
            }

            if (traitRegex.IsMatch(source))
            {
                var rawTraits = GetMatchValue(traitRegex, source, "#");
                var traits    = rawTraits.Split(',');

                foreach (var trait in traits)
                {
                    template.Traits.Add(trait);
                }
            }

            var ammunition         = WeaponConstants.GetAllAmmunition(false, false);
            var thrown             = WeaponConstants.GetAllThrown(false, false);
            var simple             = WeaponConstants.GetAllSimple(false, false);
            var melee              = WeaponConstants.GetAllMelee(false, false);
            var thrownRanged       = thrown.Except(melee).Intersect(simple);
            var needRandomQuantity = ammunition.Union(thrownRanged);

            if (needRandomQuantity.Contains(template.Name))
            {
                template.Quantity = 0;
            }

            return(template);
        }
Ejemplo n.º 3
0
        private List <string> GetRangedWithBowTemplates()
        {
            var ranged = WeaponConstants.GetAllRanged(false, true, false).ToList();
            var ammo   = WeaponConstants.GetAllAmmunition(false, false);

            ranged.Remove(WeaponConstants.CompositeShortbow);
            ranged.Remove(WeaponConstants.CompositeLongbow);
            ranged = ranged.Except(ammo).ToList();

            if (!ranged.Contains(WeaponConstants.Shuriken))
            {
                ranged.Add(WeaponConstants.Shuriken);
            }

            return(ranged);
        }
Ejemplo n.º 4
0
        public void SelectWithQuantityOf1_AllOtherWeapons()
        {
            var allWeapons   = WeaponConstants.GetAllWeapons(false, false);
            var ammos        = WeaponConstants.GetAllAmmunition(false, false);
            var thrown       = WeaponConstants.GetAllThrown(false, false);
            var simple       = WeaponConstants.GetAllSimple(false, false);
            var melee        = WeaponConstants.GetAllMelee(false, false);
            var thrownRanged = thrown.Except(melee).Intersect(simple);

            var weapons = allWeapons.Except(ammos).Except(thrownRanged);

            foreach (var weapon in weapons)
            {
                var item = itemSelector.SelectFrom($"{weapon}[{ItemTypeConstants.Weapon}]");
                Assert.That(item.Name, Is.EqualTo(weapon), weapon);
                Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.Weapon), weapon);
                Assert.That(item.Traits, Is.Empty, weapon);
                Assert.That(item.Magic.SpecialAbilities, Is.Empty, weapon);
                Assert.That(item.Magic.Bonus, Is.Zero, weapon);
                Assert.That(item.IsMagical, Is.False, weapon);
                Assert.That(item.Quantity, Is.EqualTo(1), weapon);
            }
        }
Ejemplo n.º 5
0
        public void SelectWithQuantityOf0_Ammunition(string ammo)
        {
            var ammos = WeaponConstants.GetAllAmmunition(false, false);

            Assert.That(ammos, Contains.Item(ammo)
                        .And.EquivalentTo(new[]
            {
                WeaponConstants.Arrow,
                WeaponConstants.CrossbowBolt,
                WeaponConstants.Shuriken,
                WeaponConstants.SlingBullet,
            }));

            var item = itemSelector.SelectFrom($"{ammo}[{ItemTypeConstants.Weapon}]");

            Assert.That(item.Name, Is.EqualTo(ammo), ammo);
            Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.Weapon), ammo);
            Assert.That(item.Traits, Is.Empty, ammo);
            Assert.That(item.Magic.SpecialAbilities, Is.Empty, ammo);
            Assert.That(item.Magic.Bonus, Is.Zero, ammo);
            Assert.That(item.IsMagical, Is.False, ammo);
            Assert.That(item.Quantity, Is.Zero, ammo);
        }
Ejemplo n.º 6
0
        public void AmmunitionWeaponsMatchConstants()
        {
            var ammunitions = WeaponConstants.GetAllAmmunition(false, false);

            VerifyAttribute(ammunitions, AttributeConstants.Ammunition);
        }
Ejemplo n.º 7
0
        private (IEnumerable <string> Common, IEnumerable <string> Uncommon) GetProficientWeaponNames(
            IEnumerable <Feat> feats,
            IEnumerable <Feat> proficiencyFeats,
            IEnumerable <string> baseWeapons,
            bool twoHandedAllowed)
        {
            var common   = new List <string>();
            var uncommon = new List <string>();

            var nonProficiencyFoci = feats
                                     .Except(proficiencyFeats)
                                     .SelectMany(f => f.Foci);

            nonProficiencyFoci = SwapForTemplates(nonProficiencyFoci, WeaponConstants.CompositeShortbow,
                                                  WeaponConstants.CompositeShortbow_StrengthPlus0,
                                                  WeaponConstants.CompositeShortbow_StrengthPlus1,
                                                  WeaponConstants.CompositeShortbow_StrengthPlus2);

            nonProficiencyFoci = SwapForTemplates(nonProficiencyFoci, WeaponConstants.CompositeLongbow,
                                                  WeaponConstants.CompositeLongbow_StrengthPlus0,
                                                  WeaponConstants.CompositeLongbow_StrengthPlus1,
                                                  WeaponConstants.CompositeLongbow_StrengthPlus2,
                                                  WeaponConstants.CompositeLongbow_StrengthPlus3,
                                                  WeaponConstants.CompositeLongbow_StrengthPlus4);

            var nonProficiencyWeaponFoci = nonProficiencyFoci.Intersect(baseWeapons);

            if (nonProficiencyWeaponFoci.Any())
            {
                common.AddRange(nonProficiencyWeaponFoci);
            }

            var proficiencyFoci = proficiencyFeats.SelectMany(f => f.Foci);

            proficiencyFoci = SwapForTemplates(proficiencyFoci, WeaponConstants.CompositeShortbow,
                                               WeaponConstants.CompositeShortbow_StrengthPlus0,
                                               WeaponConstants.CompositeShortbow_StrengthPlus1,
                                               WeaponConstants.CompositeShortbow_StrengthPlus2);

            proficiencyFoci = SwapForTemplates(proficiencyFoci, WeaponConstants.CompositeLongbow,
                                               WeaponConstants.CompositeLongbow_StrengthPlus0,
                                               WeaponConstants.CompositeLongbow_StrengthPlus1,
                                               WeaponConstants.CompositeLongbow_StrengthPlus2,
                                               WeaponConstants.CompositeLongbow_StrengthPlus3,
                                               WeaponConstants.CompositeLongbow_StrengthPlus4);

            var proficiencyWeaponFoci = proficiencyFoci.Intersect(baseWeapons);

            if (proficiencyWeaponFoci.Any())
            {
                uncommon.AddRange(proficiencyWeaponFoci);
            }

            if (proficiencyFeats.Any(f => f.Name == FeatConstants.WeaponProficiency_Simple &&
                                     f.Foci.Contains(GroupConstants.All)))
            {
                var simpleWeapons = WeaponConstants.GetAllSimple(false, false);
                simpleWeapons = simpleWeapons.Intersect(baseWeapons);
                uncommon.AddRange(simpleWeapons);
            }

            if (proficiencyFeats.Any(f => f.Name == FeatConstants.WeaponProficiency_Martial &&
                                     f.Foci.Contains(GroupConstants.All)))
            {
                var martialWeapons = WeaponConstants.GetAllMartial(false, true);

                martialWeapons = martialWeapons.Intersect(baseWeapons);
                uncommon.AddRange(martialWeapons);
            }

            if (proficiencyFeats.Any(f => f.Name == FeatConstants.WeaponProficiency_Exotic &&
                                     f.Foci.Contains(GroupConstants.All)))
            {
                var exoticWeapons = WeaponConstants.GetAllExotic(false, false);
                exoticWeapons = exoticWeapons.Intersect(baseWeapons);
                uncommon.AddRange(exoticWeapons);
            }

            var ammunition = WeaponConstants.GetAllAmmunition(false, false)
                             .Except(new[] { WeaponConstants.Shuriken });

            common   = common.Except(ammunition).ToList();
            uncommon = uncommon.Except(ammunition).ToList();

            if (!twoHandedAllowed)
            {
                var twoHandedWeapons = WeaponConstants.GetAllTwoHandedMelee(false, false);
                common   = common.Except(twoHandedWeapons).ToList();
                uncommon = uncommon.Except(twoHandedWeapons).ToList();
            }

            common = SwapForTemplates(common, WeaponConstants.CompositeShortbow,
                                      WeaponConstants.CompositeShortbow_StrengthPlus0,
                                      WeaponConstants.CompositeShortbow_StrengthPlus1,
                                      WeaponConstants.CompositeShortbow_StrengthPlus2);

            common = SwapForTemplates(common, WeaponConstants.CompositeLongbow,
                                      WeaponConstants.CompositeLongbow_StrengthPlus0,
                                      WeaponConstants.CompositeLongbow_StrengthPlus1,
                                      WeaponConstants.CompositeLongbow_StrengthPlus2,
                                      WeaponConstants.CompositeLongbow_StrengthPlus3,
                                      WeaponConstants.CompositeLongbow_StrengthPlus4);

            uncommon = SwapForTemplates(uncommon, WeaponConstants.CompositeShortbow,
                                        WeaponConstants.CompositeShortbow_StrengthPlus0,
                                        WeaponConstants.CompositeShortbow_StrengthPlus1,
                                        WeaponConstants.CompositeShortbow_StrengthPlus2);

            uncommon = SwapForTemplates(uncommon, WeaponConstants.CompositeLongbow,
                                        WeaponConstants.CompositeLongbow_StrengthPlus0,
                                        WeaponConstants.CompositeLongbow_StrengthPlus1,
                                        WeaponConstants.CompositeLongbow_StrengthPlus2,
                                        WeaponConstants.CompositeLongbow_StrengthPlus3,
                                        WeaponConstants.CompositeLongbow_StrengthPlus4);

            return(common, uncommon);
        }