コード例 #1
0
ファイル: RodGenerator.cs プロジェクト: DnDGen/TreasureGen
        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);
        }
コード例 #2
0
        public void ChargePercentileRoll(string itemType, int roll, int quantity)
        {
            SetUpRoll(100, roll);
            var charges = generator.GenerateFor(ItemTypeConstants.Staff, string.Empty);

            Assert.That(charges, Is.EqualTo(quantity));
        }
コード例 #3
0
        private Item BuildWondrousItem(string name, params string[] traits)
        {
            var item = new Item();

            item.Name      = name;
            item.BaseNames = new[] { name };
            item.IsMagical = true;
            item.ItemType  = ItemTypeConstants.WondrousItem;
            item.Traits    = new HashSet <string>(traits);

            var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, item.ItemType);

            item.Attributes = collectionsSelector.SelectFrom(tableName, name);

            if (item.Attributes.Contains(AttributeConstants.Charged))
            {
                item.Magic.Charges = chargesGenerator.GenerateFor(item.ItemType, name);
            }

            if (!item.Traits.Any())
            {
                var trait = GetTraitFor(name);
                if (!string.IsNullOrEmpty(trait))
                {
                    item.Traits.Add(trait);
                }
            }

            var contents = GetContentsFor(name);

            item.Contents.AddRange(contents);

            return(item);
        }
コード例 #4
0
        public Item GenerateAtPower(string power)
        {
            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.WondrousItem);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tablename);

            var item = new Item();

            item.Name      = result.Type;
            item.IsMagical = true;
            item.ItemType  = ItemTypeConstants.WondrousItem;

            var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, item.ItemType);

            item.Attributes  = attributesSelector.SelectFrom(tableName, item.Name);
            item.Magic.Bonus = result.Amount;

            if (item.Attributes.Contains(AttributeConstants.Charged))
            {
                item.Magic.Charges = chargesGenerator.GenerateFor(item.ItemType, item.Name);
            }

            var trait = GetTraitFor(item.Name);

            if (!string.IsNullOrEmpty(trait))
            {
                item.Traits.Add(trait);
            }

            var contents = GetContentsFor(item.Name);

            item.Contents.AddRange(contents);

            return(item);
        }
コード例 #5
0
        public Item GenerateAtPower(string power)
        {
            if (power == PowerConstants.Minor)
            {
                throw new ArgumentException("Cannot generate minor staves");
            }

            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Staff);
            var staffName = percentileSelector.SelectFrom(tablename);

            var staff = new Item();

            staff.Name          = staffName;
            staff.ItemType      = ItemTypeConstants.Staff;
            staff.Attributes    = new[] { AttributeConstants.OneTimeUse, AttributeConstants.Charged };
            staff               = BuildStaff(staff);
            staff.Magic.Charges = chargesGenerator.GenerateFor(staff.ItemType, staffName);

            if (staff.Name != StaffConstants.Power)
            {
                return(staff);
            }

            staff.Magic.Bonus = 2;

            return(staff);
        }
コード例 #6
0
ファイル: StaffGenerator.cs プロジェクト: DnDGen/TreasureGen
        private Item GenerateStaff(string name, int bonus, params string[] traits)
        {
            var staff = new Item();

            staff.Name        = name;
            staff.Magic.Bonus = bonus;
            staff.Traits      = new HashSet <string>(traits);

            staff = BuildStaff(staff);
            staff.Magic.Charges = chargesGenerator.GenerateFor(staff.ItemType, name);

            return(staff);
        }
コード例 #7
0
ファイル: WandGenerator.cs プロジェクト: DnDGen/TreasureGen
        private Item GenerateWand(string name, params string[] traits)
        {
            var wand = new Item();

            wand.ItemType      = ItemTypeConstants.Wand;
            wand.IsMagical     = true;
            wand.Name          = name;
            wand.Magic.Charges = chargesGenerator.GenerateFor(ItemTypeConstants.Wand, name);
            wand.BaseNames     = new[] { ItemTypeConstants.Wand };
            wand.Attributes    = new[] { AttributeConstants.Charged, AttributeConstants.OneTimeUse };
            wand.Traits        = new HashSet <string>(traits);

            return(wand);
        }
コード例 #8
0
        public Item GenerateAtPower(string power)
        {
            if (power == PowerConstants.Minor)
            {
                throw new ArgumentException("Cannot generate minor rods");
            }

            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Rod);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tablename);

            var rod = new Item();

            rod.ItemType    = ItemTypeConstants.Rod;
            rod.Name        = result.Type;
            rod.IsMagical   = true;
            rod.Magic.Bonus = result.Amount;
            tablename       = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, rod.ItemType);
            rod.Attributes  = attributesSelector.SelectFrom(tablename, rod.Name);

            if (rod.Attributes.Contains(AttributeConstants.Charged))
            {
                rod.Magic.Charges = chargesGenerator.GenerateFor(rod.ItemType, rod.Name);
            }

            if (rod.Name == RodConstants.Absorption)
            {
                var containsSpellLevels = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.RodOfAbsorptionContainsSpellLevels);
                if (containsSpellLevels)
                {
                    var maxCharges           = chargesGenerator.GenerateFor(rod.ItemType, RodConstants.FullAbsorption);
                    var containedSpellLevels = (maxCharges - rod.Magic.Charges) / 2;
                    rod.Contents.Add($"{containedSpellLevels} spell levels");
                }
            }

            return(rod);
        }
コード例 #9
0
        public Item GenerateAtPower(string power)
        {
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Ring);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tableName);

            var ring = new Item();

            ring.Name        = result.Type;
            ring.Magic.Bonus = result.Amount;
            ring.IsMagical   = true;
            ring.ItemType    = ItemTypeConstants.Ring;

            tableName       = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ring.ItemType);
            ring.Attributes = attributesSelector.SelectFrom(tableName, result.Type);

            if (ring.Attributes.Contains(AttributeConstants.Charged))
            {
                ring.Magic.Charges = chargesGenerator.GenerateFor(ItemTypeConstants.Ring, result.Type);
            }

            if (ring.Name == RingConstants.Counterspells)
            {
                var level = spellGenerator.GenerateLevel(power);
                if (level <= 6)
                {
                    var type  = spellGenerator.GenerateType();
                    var spell = spellGenerator.Generate(type, level);
                    ring.Contents.Add(spell);
                }
            }
            else if (ring.Name == RingConstants.SpellStoring_Minor)
            {
                var spells = GenerateSpells(power, 3);
                ring.Contents.AddRange(spells);
            }
            else if (ring.Name == RingConstants.SpellStoring_Major)
            {
                var spells = GenerateSpells(power, 10);
                ring.Contents.AddRange(spells);
            }
            else if (ring.Name == RingConstants.SpellStoring)
            {
                var spells = GenerateSpells(power, 5);
                ring.Contents.AddRange(spells);
            }

            return(ring);
        }
コード例 #10
0
        public Item GenerateAtPower(string power)
        {
            var wand = new Item();

            wand.ItemType  = ItemTypeConstants.Wand;
            wand.IsMagical = true;

            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, wand.ItemType);
            var spell     = percentileSelector.SelectFrom(tablename);

            wand.Magic.Charges = chargesGenerator.GenerateFor(wand.ItemType, spell);
            wand.Name          = string.Format("Wand of {0}", spell);
            wand.Attributes    = new[] { AttributeConstants.Charged, AttributeConstants.OneTimeUse };

            return(wand);
        }
コード例 #11
0
ファイル: RingGenerator.cs プロジェクト: DnDGen/TreasureGen
        private Item BuildRing(string name, string power, params string[] traits)
        {
            var ring = new Item();

            ring.Name      = name;
            ring.BaseNames = new[] { name };
            ring.IsMagical = true;
            ring.ItemType  = ItemTypeConstants.Ring;
            ring.Traits    = new HashSet <string>(traits);

            var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ring.ItemType);

            ring.Attributes = collectionsSelector.SelectFrom(tableName, name);

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

            if (ring.Name == RingConstants.Counterspells)
            {
                var level = spellGenerator.GenerateLevel(power);
                if (level <= 6)
                {
                    var type  = spellGenerator.GenerateType();
                    var spell = spellGenerator.Generate(type, level);
                    ring.Contents.Add(spell);
                }
            }
            else if (ring.Name == RingConstants.SpellStoring_Minor)
            {
                var spells = GenerateSpells(power, 3);
                ring.Contents.AddRange(spells);
            }
            else if (ring.Name == RingConstants.SpellStoring_Major)
            {
                var spells = GenerateSpells(power, 10);
                ring.Contents.AddRange(spells);
            }
            else if (ring.Name == RingConstants.SpellStoring)
            {
                var spells = GenerateSpells(power, 5);
                ring.Contents.AddRange(spells);
            }

            return(ring);
        }
コード例 #12
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);
        }
コード例 #13
0
        public Item GenerateFrom(string power, string specificGearType)
        {
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, power, specificGearType);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tableName);

            var gear = new Item();

            gear.Name                   = result.Type;
            gear.Magic.Bonus            = result.Amount;
            gear.Magic.SpecialAbilities = GetSpecialAbilities(specificGearType, gear.Name);
            gear.ItemType               = GetItemType(specificGearType);

            tableName       = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPEAttributes, specificGearType);
            gear.Attributes = collectionsSelector.SelectFrom(tableName, gear.Name);

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

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

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

            if (gear.Name == WeaponConstants.JavelinOfLightning)
            {
                gear.IsMagical = true;
            }
            else if (gear.Name == ArmorConstants.CastersShield)
            {
                var hasSpell = booleanPercentileSelector.SelectFrom(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 = string.Format("{0} ({1}, {2})", spell, spellType, spellLevel);
                    gear.Contents.Add(formattedSpell);
                }
            }

            gear.Name     = RenameGear(gear.Name);
            gear.Quantity = GetQuantity(gear);

            if (gear.Name == WeaponConstants.SlayingArrow || gear.Name == WeaponConstants.GreaterSlayingArrow)
            {
                var designatedFoe = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.DesignatedFoes);
                var trait         = string.Format("Designated Foe: {0}", designatedFoe);
                gear.Traits.Add(trait);
            }

            if (gear.IsMagical == false)
            {
                var size = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes);
                gear.Traits.Add(size);
            }

            return(gear);
        }