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); }
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); }
public void ReturnSpellLevel() { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpellLevels, power); mockPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns("9266"); var level = generator.GenerateLevel(power); Assert.That(level, Is.EqualTo(9266)); }
public Item GenerateAtPower(string power) { var spellType = spellGenerator.GenerateType(); var scroll = new Item(); scroll.Name = ItemTypeConstants.Scroll; scroll.ItemType = ItemTypeConstants.Scroll; scroll.IsMagical = true; scroll.Attributes = new[] { AttributeConstants.OneTimeUse }; scroll.Traits.Add(spellType); var quantity = GetQuantity(power); while (quantity-- > 0) { var level = spellGenerator.GenerateLevel(power); var spell = spellGenerator.Generate(spellType, level); var spellWithLevel = string.Format("{0} ({1})", spell, level); scroll.Contents.Add(spellWithLevel); } return(scroll); }
private IEnumerable <string> GenerateExtraItemsInRobeOfUsefulItems() { var extraItems = new List <string>(); var quantity = dice.Roll(4).d4().AsSum(); while (quantity-- > 0) { var item = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.RobeOfUsefulItemsExtraItems); if (item == ItemTypeConstants.Scroll) { var spellType = spellGenerator.GenerateType(); var level = spellGenerator.GenerateLevel(PowerConstants.Minor); var spell = spellGenerator.Generate(spellType, level); item = $"{spellType} scroll of {spell} ({level})"; } extraItems.Add(item); } return(extraItems); }
public Item GenerateRandom(string power) { var spellType = spellGenerator.GenerateType(); var scroll = new Item(); scroll.Name = ItemTypeConstants.Scroll; scroll.BaseNames = new[] { ItemTypeConstants.Scroll }; scroll.ItemType = ItemTypeConstants.Scroll; scroll.IsMagical = true; scroll.Attributes = new[] { AttributeConstants.OneTimeUse }; scroll.Traits.Add(spellType); var quantity = GetQuantity(power); while (quantity-- > 0) { var level = spellGenerator.GenerateLevel(power); var spell = spellGenerator.Generate(spellType, level); var spellWithLevel = $"{spell} ({level})"; scroll.Contents.Add(spellWithLevel); } return(scroll); }
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); }
private Weapon ApplySpecialAbilities(Weapon weapon) { if (weapon.Magic.SpecialAbilities.Any(a => a.Name == SpecialAbilityConstants.SpellStoring)) { var shouldStoreSpell = percentileSelector.SelectFrom <bool>(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); } } foreach (var specialAbility in weapon.Magic.SpecialAbilities) { if (specialAbility.Damages.Any()) { var damages = specialAbility.Damages.Select(d => d.Clone()).ToArray(); var damageType = weapon.Damages[0].Type; foreach (var damage in damages) { if (string.IsNullOrEmpty(damage.Type)) { damage.Type = damageType; } } weapon.Damages.AddRange(damages); if (weapon.SecondaryHasAbilities) { var secondaryDamages = specialAbility.Damages.Select(d => d.Clone()).ToArray(); var secondaryDamageType = weapon.SecondaryDamages[0].Type; foreach (var damage in secondaryDamages) { if (string.IsNullOrEmpty(damage.Type)) { damage.Type = secondaryDamageType; } } weapon.SecondaryDamages.AddRange(secondaryDamages); } } if (specialAbility.CriticalDamages.Any()) { var damageType = weapon.CriticalDamages[0].Type; foreach (var damage in specialAbility.CriticalDamages[weapon.CriticalMultiplier]) { if (string.IsNullOrEmpty(damage.Type)) { damage.Type = damageType; } } weapon.CriticalDamages.AddRange(specialAbility.CriticalDamages[weapon.CriticalMultiplier]); if (weapon.SecondaryHasAbilities) { foreach (var damage in specialAbility.CriticalDamages[weapon.SecondaryCriticalMultiplier]) { if (string.IsNullOrEmpty(damage.Type)) { damage.Type = damageType; } } weapon.SecondaryCriticalDamages.AddRange(specialAbility.CriticalDamages[weapon.SecondaryCriticalMultiplier]); } } if (specialAbility.Name == SpecialAbilityConstants.Keen) { weapon.ThreatRange *= 2; } } return(weapon); }
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); }
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); }