Example #1
0
        private Item GenerateRandomMundaneItem()
        {
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERItems, PowerConstants.Mundane);
            var itemType  = percentileSelector.SelectFrom(tableName);

            return(GenerateMundaneItem(itemType));
        }
        private string GetRandomName()
        {
            var type       = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneWeaponTypes);
            var tableName  = string.Format(TableNameConstants.Percentiles.Formattable.WEAPONTYPEWeapons, type);
            var weaponName = percentileSelector.SelectFrom(tableName);

            return(weaponName);
        }
        private (string Name, string ArmorType) GenerateRandomName(string power)
        {
            var armorTypeTableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERArmorTypes, power, ItemTypeConstants.Armor);
            var armorType          = percentileSelector.SelectFrom(armorTypeTableName);

            var nameTableName = string.Format(TableNameConstants.Percentiles.Formattable.ARMORTYPETypes, armorType);
            var name          = percentileSelector.SelectFrom(nameTableName);

            return(name, armorType);
        }
        public TypeAndAmountSelection SelectFrom(string tableName)
        {
            var percentileResult = percentileSelector.SelectFrom(tableName);
            var result           = ParseResult(percentileResult);

            return(result);
        }
Example #5
0
        private Item GenerateRod(string name, int bonus, params string[] traits)
        {
            var rod = new Item();

            rod.ItemType    = ItemTypeConstants.Rod;
            rod.Name        = name;
            rod.BaseNames   = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, name);
            rod.IsMagical   = true;
            rod.Magic.Bonus = bonus;
            rod.Traits      = new HashSet <string>(traits);

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

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

            if (rod.Attributes.Contains(AttributeConstants.Charged))
            {
                rod.Magic.Charges = chargesGenerator.GenerateFor(ItemTypeConstants.Rod, name);
            }

            if (name == RodConstants.Absorption)
            {
                var containsSpellLevels = percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.RodOfAbsorptionContainsSpellLevels);
                if (containsSpellLevels)
                {
                    var maxCharges           = chargesGenerator.GenerateFor(ItemTypeConstants.Rod, RodConstants.Absorption_Full);
                    var containedSpellLevels = (maxCharges - rod.Magic.Charges) / 2;
                    rod.Contents.Add($"{containedSpellLevels} spell levels");
                }
            }

            rod = GetWeapon(rod);

            return(rod);
        }
Example #6
0
        public Item GenerateRandom(string power)
        {
            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Wand);
            var spell     = percentileSelector.SelectFrom(tablename);
            var name      = $"Wand of {spell}";

            return(GenerateWand(name));
        }
        public void DecoratorSelectsFromInnerSelector()
        {
            mockInnerSelector.Setup(s => s.SelectFrom("table")).Returns("percentile");
            mockReplacementSelector.Setup(s => s.SelectRandom("percentile")).Returns("replacement");

            var result = decorator.SelectFrom("table");

            Assert.That(result, Is.EqualTo("replacement"));
        }
Example #8
0
        public IEnumerable <string> GenerateFor(string itemType, IEnumerable <string> attributes)
        {
            var tableName = GetTableName(itemType, attributes);
            var result    = percentileSelector.SelectFrom(tableName);

            if (string.IsNullOrEmpty(result))
            {
                return(Enumerable.Empty <string>());
            }

            return(result.Split(','));
        }
Example #9
0
        public bool CanHaveSpecialMaterial(string itemType, IEnumerable <string> attributes, IEnumerable <string> traits)
        {
            if (itemType != ItemTypeConstants.Weapon && itemType != ItemTypeConstants.Armor)
            {
                return(false);
            }

            var attributesWithType = attributes.Union(new[] { itemType });

            return(percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.HasSpecialMaterial) &&
                   AttributesAllowForSpecialMaterials(attributesWithType) &&
                   TraitsAllowForSpecialMaterials(attributesWithType, traits));
        }
        private string GenerateRandomName()
        {
            var type      = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MagicalWeaponTypes);
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.WEAPONTYPEWeapons, type);
            var name      = percentileSelector.SelectFrom(tableName);

            return(name);
        }
Example #11
0
        private string GetTraitFor(string name)
        {
            switch (name)
            {
            case WondrousItemConstants.HornOfValhalla: return(percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.HornOfValhallaTypes));

            case WondrousItemConstants.CandleOfInvocation: return(percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IntelligenceAlignments));

            case WondrousItemConstants.RobeOfTheArchmagi: return(percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.RobeOfTheArchmagiColors));

            default: return(string.Empty);
            }
        }
Example #12
0
        private SpecialAbility GenerateAbilityFrom(IEnumerable <SpecialAbility> availableAbilities, IEnumerable <string> tableNames)
        {
            var abilityName = string.Empty;

            do
            {
                var tableName = collectionsSelector.SelectRandomFrom(tableNames);

                abilityName = percentileSelector.SelectFrom(tableName);

                if (abilityName == "BonusSpecialAbility")
                {
                    return new SpecialAbility {
                               Name = abilityName
                    }
                }
                ;
            } while (!availableAbilities.Any(a => a.Name == abilityName));

            return(availableAbilities.First(a => a.Name == abilityName));
        }
Example #13
0
        public bool IsIntelligent(string itemType, IEnumerable <string> attributes, bool isMagical)
        {
            if (!CanBeIntelligent(attributes, isMagical))
            {
                return(false);
            }

            if (attributes.Contains(AttributeConstants.Melee))
            {
                itemType = AttributeConstants.Melee;
            }
            else if (attributes.Contains(AttributeConstants.Ranged))
            {
                itemType = AttributeConstants.Ranged;
            }

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.IsITEMTYPEIntelligent, itemType);

            return(percentileSelector.SelectFrom <bool>(tableName));
        }
Example #14
0
        public int GenerateFor(string itemType, string name)
        {
            if (itemType == ItemTypeConstants.Wand || itemType == ItemTypeConstants.Staff)
            {
                return(PercentileCharges());
            }

            if (name == WondrousItemConstants.DeckOfIllusions)
            {
                var isFullyCharged = percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.IsDeckOfIllusionsFullyCharged);

                if (isFullyCharged)
                {
                    name = WondrousItemConstants.DeckOfIllusions_Full;
                }
            }

            var result = rangeDataSelector.SelectFrom(TableNameConstants.Collections.Set.ChargeLimits, name);
            var roll   = RollHelper.GetRollWithMostEvenDistribution(result.Minimum, result.Maximum);

            return(dice.Roll(roll).AsSum());
        }
Example #15
0
        private Item SetPrototypeAttributes(Item prototype, string specificGearType)
        {
            var gear = prototype.Clone();

            if (gear.Name == WeaponConstants.JavelinOfLightning)
            {
                gear.IsMagical = true;
            }
            else if (gear.Name == ArmorConstants.CastersShield)
            {
                var hasSpell = percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.CastersShieldContainsSpell);

                if (hasSpell)
                {
                    var spellType      = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.CastersShieldSpellTypes);
                    var spellLevel     = spellGenerator.GenerateLevel(PowerConstants.Medium);
                    var spell          = spellGenerator.Generate(spellType, spellLevel);
                    var formattedSpell = $"{spell} ({spellType}, {spellLevel})";
                    gear.Contents.Add(formattedSpell);
                }
            }

            var templateName = gear.Name;

            gear.Name = replacementSelector.SelectSingle(templateName);

            gear.Magic.SpecialAbilities = GetSpecialAbilities(specificGearType, templateName, prototype.Magic.SpecialAbilities);

            var tableName = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPEAttributes, specificGearType);

            gear.Attributes = collectionsSelector.SelectFrom(tableName, templateName);

            tableName = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPETraits, specificGearType);
            var traits = collectionsSelector.SelectFrom(tableName, templateName);

            foreach (var trait in traits)
            {
                gear.Traits.Add(trait);
            }

            if (gear.Attributes.Contains(AttributeConstants.Charged))
            {
                gear.Magic.Charges = chargesGenerator.GenerateFor(specificGearType, templateName);
            }

            if (gear.Name == WeaponConstants.SlayingArrow || gear.Name == WeaponConstants.GreaterSlayingArrow)
            {
                var designatedFoe = collectionsSelector.SelectRandomFrom(TableNameConstants.Collections.Set.ReplacementStrings, ReplacementStringConstants.DesignatedFoe);
                var trait         = $"Designated Foe: {designatedFoe}";
                gear.Traits.Add(trait);
            }

            if (gear.IsMagical)
            {
                gear.Traits.Add(TraitConstants.Masterwork);
            }

            if (gear.ItemType == ItemTypeConstants.Armor)
            {
                return(GetArmor(gear));
            }

            if (gear.ItemType == ItemTypeConstants.Weapon)
            {
                return(GetWeapon(gear));
            }

            if (gear.Quantity == 0)
            {
                gear.Quantity = 1;
            }

            return(gear);
        }
Example #16
0
 private string GetRandomSize()
 {
     return(percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes));
 }
Example #17
0
 public string GenerateType()
 {
     return(percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.SpellTypes));
 }
Example #18
0
        public Item GenerateRandom()
        {
            var name = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.Tools);

            return(Generate(name));
        }
Example #19
0
 public bool HasCurse(Item item)
 {
     return(item.IsMagical && percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.IsItemCursed));
 }