public Item GenerateAtPower(string power)
        {
            var tableName    = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Armor);
            var result       = typeAndAmountPercentileSelector.SelectFrom(tableName);
            var abilityCount = 0;

            while (result.Type == "SpecialAbility")
            {
                abilityCount += result.Amount;
                result        = typeAndAmountPercentileSelector.SelectFrom(tableName);
            }

            if (result.Amount == 0)
            {
                return(specificGearGenerator.GenerateFrom(power, result.Type));
            }

            var armor = new Item();

            armor.ItemType    = ItemTypeConstants.Armor;
            armor.Magic.Bonus = result.Amount;

            tableName  = string.Format(TableNameConstants.Percentiles.Formattable.ARMORTYPETypes, result.Type);
            armor.Name = percentileSelector.SelectFrom(tableName);

            tableName                    = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, armor.ItemType);
            armor.Attributes             = collectionsSelector.SelectFrom(tableName, armor.Name);
            armor.Magic.SpecialAbilities = specialAbilitiesSelector.GenerateFor(armor.ItemType, armor.Attributes, power, armor.Magic.Bonus, abilityCount);

            return(armor);
        }
        private Weapon GenerateRandomSpecialAbilities(Weapon weapon, string power)
        {
            weapon.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(weapon, power, weapon.Magic.SpecialAbilities.Count());
            weapon = ApplySpecialAbilities(weapon);

            return(weapon);
        }
        private Item GenerateArmor(string power, string itemName, string armorType, bool isSpecific, params string[] traits)
        {
            var prototype = GeneratePrototype(power, itemName, armorType, isSpecific, traits);
            var armor     = GenerateFromPrototype(prototype);

            if (!specificGearGenerator.IsSpecific(armor))
            {
                var abilityCount = armor.Magic.SpecialAbilities.Count();
                armor.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(armor, power, abilityCount);
            }

            return(armor);
        }
示例#4
0
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            var rod = template.Clone();

            rod.BaseNames = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, rod.Name);
            rod.IsMagical = true;
            rod.Quantity  = 1;
            rod.ItemType  = ItemTypeConstants.Rod;

            var results = GetAllResults();
            var result  = results.First(r => rod.NameMatches(r.Type));

            rod.Magic.Bonus = result.Amount;

            var tablename = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Rod);

            rod.Attributes = collectionsSelector.SelectFrom(tablename, rod.Name);

            rod.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(rod.Magic.SpecialAbilities);

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

            rod = GetWeapon(rod);

            return(rod.SmartClone());
        }
示例#5
0
        private IEnumerable <SpecialAbility> GetSpecialAbilities(string specificGearType, string name)
        {
            var tableName    = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPESpecialAbilities, specificGearType);
            var abilityNames = collectionsSelector.SelectFrom(tableName, name);
            var abilities    = specialAbilitiesGenerator.GenerateFor(abilityNames.ToArray());

            return(abilities);
        }
示例#6
0
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            var staff = template.Clone();

            staff.Magic.Intelligence     = template.Magic.Intelligence.Clone();
            staff.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(template.Magic.SpecialAbilities);

            staff = BuildStaff(staff);

            return(staff.SmartClone());
        }
示例#7
0
        private IEnumerable <SpecialAbility> GetSpecialAbilities(string specificGearType, string name, IEnumerable <SpecialAbility> templateSpecialAbilities)
        {
            var tableName         = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPESpecialAbilities, specificGearType);
            var abilityNames      = collectionsSelector.SelectFrom(tableName, name);
            var abilityPrototypes = abilityNames.Select(n => new SpecialAbility {
                Name = n
            }).Union(templateSpecialAbilities);
            var abilities = specialAbilitiesGenerator.GenerateFor(abilityPrototypes);

            return(abilities);
        }
示例#8
0
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            var tablename = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Rod);

            template.Attributes = attributesSelector.SelectFrom(tablename, template.Name);
            template.ItemType   = ItemTypeConstants.Rod;

            var rod = template.Copy();

            rod.IsMagical = true;
            rod.Quantity  = 1;

            var specialAbilityNames = rod.Magic.SpecialAbilities.Select(a => a.Name);

            rod.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(specialAbilityNames);

            return(rod);
        }
        public Item Generate(Item template, bool allowRandomDecoration = false)
        {
            template.ItemType   = ItemTypeConstants.Staff;
            template.Attributes = new[] { AttributeConstants.Charged, AttributeConstants.OneTimeUse };

            var staff = template.Copy();

            staff = BuildStaff(staff);

            if (staff.CanBeUsedAsWeaponOrArmor)
            {
                staff.Magic.Intelligence = template.Magic.Intelligence.Copy();

                var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);
                staff.Magic.SpecialAbilities = specialAbilitiesGenerator.GenerateFor(specialAbilityNames);
            }

            return(staff);
        }
        public void ReturnEmptyIfBonusLessThanOne()
        {
            var abilities = specialAbilitiesGenerator.GenerateFor(ItemTypeConstants.Armor, itemAttributes, power, 0, 1);

            Assert.That(abilities, Is.Empty);
        }
        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);
        }