Пример #1
0
        public void GenerateAmmunition()
        {
            mockPercentileSelector.Setup(p => p.SelectFrom(TableNameConstants.Percentiles.Set.Ammunitions)).Returns("ammunition name");

            var ammunition = ammunitionGenerator.Generate();

            Assert.That(ammunition.Name, Is.EqualTo("ammunition name"));
            Assert.That(ammunition.ItemType, Is.EqualTo(ItemTypeConstants.Weapon));
        }
Пример #2
0
        public Item Generate()
        {
            var type       = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneWeapons);
            var tableName  = string.Format(TableNameConstants.Percentiles.Formattable.WEAPONTYPEWeapons, type);
            var weaponName = percentileSelector.SelectFrom(tableName);

            var weapon = new Item();

            if (weaponName == AttributeConstants.Ammunition)
            {
                weapon = ammunitionGenerator.Generate();
            }
            else
            {
                weapon.Name = weaponName;

                if (weapon.Name.Contains("Composite"))
                {
                    weapon.Name = GetCompositeBowName(weaponName);
                    var compositeStrengthBonus = GetCompositeBowBonus(weaponName);
                    weapon.Traits.Add(compositeStrengthBonus);
                }

                weapon.ItemType   = ItemTypeConstants.Weapon;
                tableName         = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, weapon.ItemType);
                weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name);
            }

            var isMasterwork = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IsMasterwork);

            if (isMasterwork)
            {
                weapon.Traits.Add(TraitConstants.Masterwork);
            }

            if (weapon.Attributes.Contains(AttributeConstants.Thrown) && weapon.Attributes.Contains(AttributeConstants.Melee) == false)
            {
                weapon.Quantity = dice.Roll().d20().AsSum();
            }

            var size = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes);

            weapon.Traits.Add(size);

            return(weapon);
        }
        public Item GenerateAtPower(string power)
        {
            var tablename             = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Weapon);
            var bonus                 = percentileSelector.SelectFrom(tablename);
            var specialAbilitiesCount = 0;

            while (bonus == "SpecialAbility")
            {
                specialAbilitiesCount++;
                bonus = percentileSelector.SelectFrom(tablename);
            }

            if (bonus == ItemTypeConstants.Weapon)
            {
                return(specificGearGenerator.GenerateFrom(power, bonus));
            }

            var type = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.WeaponTypes);

            tablename = string.Format(TableNameConstants.Percentiles.Formattable.WEAPONTYPEWeapons, type);
            var name = percentileSelector.SelectFrom(tablename);

            var weapon = new Item();

            if (name == AttributeConstants.Ammunition)
            {
                weapon = ammunitionGenerator.Generate();
            }
            else
            {
                weapon.ItemType = ItemTypeConstants.Weapon;
                weapon.Name     = name;

                if (weapon.Name.Contains("Composite"))
                {
                    weapon.Name = GetCompositeBowName(name);
                    var compositeStrengthBonus = GetCompositeBowBonus(name);
                    weapon.Traits.Add(compositeStrengthBonus);
                }

                tablename         = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, weapon.ItemType);
                weapon.Attributes = collectionsSelector.SelectFrom(tablename, weapon.Name);
            }

            weapon.Magic.Bonus            = Convert.ToInt32(bonus);
            weapon.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(weapon.ItemType, weapon.Attributes, power, weapon.Magic.Bonus, specialAbilitiesCount);

            if (weapon.Magic.SpecialAbilities.Any(a => a.Name == SpecialAbilityConstants.SpellStoring))
            {
                var shouldStoreSpell = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.SpellStoringContainsSpell);

                if (shouldStoreSpell)
                {
                    var spellType = spellGenerator.GenerateType();
                    var level     = spellGenerator.GenerateLevel(PowerConstants.Minor);
                    var spell     = spellGenerator.Generate(spellType, level);

                    weapon.Contents.Add(spell);
                }
            }

            if (weapon.Attributes.Contains(AttributeConstants.Thrown) && weapon.Attributes.Contains(AttributeConstants.Melee) == false)
            {
                weapon.Quantity = dice.Roll().d20().AsSum();
            }

            return(weapon);
        }