Exemple #1
0
        public void SelectWithQuantityOf0_Thrown(string weapon)
        {
            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);

            Assert.That(thrownRanged, Contains.Item(weapon)
                        .And.EquivalentTo(new[]
            {
                WeaponConstants.Javelin,
                WeaponConstants.Dart,
            }));

            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.Zero, weapon);
        }
Exemple #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);
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        public void ThrownWeaponsMatchConstants()
        {
            var thrown = WeaponConstants.GetAllThrown(false, false);

            VerifyAttribute(thrown, AttributeConstants.Thrown);
        }