Example #1
0
        public void TemplateIsAmmunition()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var ammunitions = new[] { "other ammunition", name };

            mockPercentileSelector.Setup(s => s.SelectAllFrom(TableNameConstants.Percentiles.Set.Ammunitions)).Returns(ammunitions);

            var isAmmunition = ammunitionGenerator.TemplateIsAmmunition(template);

            Assert.That(isAmmunition, Is.True);
        }
Example #2
0
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            template.ItemType = ItemTypeConstants.Weapon;
            var weapon = template.CopyWithoutMagic();

            if (ammunitionGenerator.TemplateIsAmmunition(template))
            {
                weapon = ammunitionGenerator.GenerateFrom(template);
                weapon = weapon.CopyWithoutMagic();
            }
            else
            {
                var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, weapon.ItemType);
                weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name);
            }

            var sizes = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes);

            if (weapon.Traits.Intersect(sizes).Any() == false)
            {
                var size = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes);
                weapon.Traits.Add(size);
            }

            if (allowRandomDecoration)
            {
                var isMasterwork = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IsMasterwork);
                if (isMasterwork)
                {
                    weapon.Traits.Add(TraitConstants.Masterwork);
                }
            }

            return(weapon);
        }
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            template.ItemType = ItemTypeConstants.Weapon;
            var weapon = template.Copy();

            if (specificGearGenerator.TemplateIsSpecific(template))
            {
                weapon = specificGearGenerator.GenerateFrom(template);
            }
            else if (ammunitionGenerator.TemplateIsAmmunition(template))
            {
                weapon = ammunitionGenerator.GenerateFrom(template);
            }
            else
            {
                var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, weapon.ItemType);
                weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name);
            }

            var abilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);

            weapon.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(abilityNames);

            return(weapon);
        }