Esempio n. 1
0
        public Item GenerateAtLevel(int level, string itemType, string itemName, params string[] traits)
        {
            if (level < LevelLimits.Minimum || level > LevelLimits.Maximum)
            {
                throw new ArgumentException($"Level {level} is not a valid level for treasure generation");
            }

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXItems, level);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tableName);
            var powers    = collectionSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, itemType);

            if (itemType != ItemTypeConstants.Scroll && itemType != ItemTypeConstants.Wand)
            {
                powers = collectionSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, itemName);
            }

            var power = PowerHelper.AdjustPower(result.Type, powers);

            if (power == PowerConstants.Mundane)
            {
                return(GenerateMundaneItem(itemType, itemName, traits));
            }

            return(GenerateMagicalItemAtPower(power, itemType, itemName, traits));
        }
Esempio n. 2
0
        public Item GeneratePrototypeFrom(string power, string specificGearType, string name, params string[] traits)
        {
            var possiblePowers = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, name);
            var adjustedPower  = PowerHelper.AdjustPower(power, possiblePowers);

            var tableName  = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, adjustedPower, specificGearType);
            var selections = typeAndAmountPercentileSelector.SelectAllFrom(tableName);

            selections = selections.Where(s => NameMatchesWithReplacements(name, s.Type));

            var selection = collectionsSelector.SelectRandomFrom(selections);

            var gear = new Item();

            gear.Name        = selection.Type;
            gear.BaseNames   = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, selection.Type);
            gear.ItemType    = GetItemType(specificGearType);
            gear.Magic.Bonus = selection.Amount;
            gear.Quantity    = 0;
            gear.Traits      = new HashSet <string>(traits);

            return(gear);
        }