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); }
public Item Generate() { var armor = new Item(); armor.Name = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneArmors); if (armor.Name == AttributeConstants.Shield) { armor.Name = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneShields); } armor.ItemType = ItemTypeConstants.Armor; var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, armor.ItemType); armor.Attributes = attributesSelector.SelectFrom(tableName, armor.Name); var isMasterwork = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IsMasterwork); if (isMasterwork) { armor.Traits.Add(TraitConstants.Masterwork); } var size = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes); armor.Traits.Add(size); return(armor); }
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); }
public Item GenerateSpecificCursedItem() { var specificCursedItem = new Item(); specificCursedItem.Name = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems); specificCursedItem.Magic.Curse = CurseConstants.SpecificCursedItem; specificCursedItem.ItemType = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.SpecificCursedItemItemTypes, specificCursedItem.Name).Single(); specificCursedItem.Attributes = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.SpecificCursedItemAttributes, specificCursedItem.Name); return(specificCursedItem); }
public Item Generate() { var roll = dice.Roll().Percentile().AsSum(); var ammunition = new Item(); ammunition.Name = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.Ammunitions); ammunition.Quantity = Math.Max(1, roll / 2); ammunition.Attributes = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.AmmunitionAttributes, ammunition.Name); ammunition.ItemType = ItemTypeConstants.Weapon; return(ammunition); }
public ReplacePercentileSelectorDecorator(IPercentileSelector innerSelector, ICollectionsSelector attributesSelector) { this.innerSelector = innerSelector; var replaceTargets = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.ReplacementStrings, TableNameConstants.Collections.Set.ReplacementStrings); replacementTables = new Dictionary <string, string>(); foreach (var replaceTarget in replaceTargets) { replacementTables[replaceTarget] = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.ReplacementStrings, replaceTarget).Single(); } }
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); }
public IEnumerable <Good> GenerateAtLevel(int level) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXGoods, level); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); if (string.IsNullOrEmpty(result.Type)) { return(Enumerable.Empty <Good>()); } var goods = new List <Good>(); var valueTableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, result.Type); var descriptionTableName = string.Format(TableNameConstants.Collections.Formattable.GOODTYPEDescriptions, result.Type); while (result.Amount-- > 0) { var valueResult = typeAndAmountPercentileSelector.SelectFrom(valueTableName); var descriptions = attributesSelector.SelectFrom(descriptionTableName, valueResult.Type); var descriptionIndex = dice.Roll().d(descriptions.Count()).AsSum() - 1; var good = new Good(); good.Description = descriptions.ElementAt(descriptionIndex); good.ValueInGold = valueResult.Amount; goods.Add(good); } return(goods); }
public Item Generate() { var type = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneWeapons); var tableName = string.Format(TableNameConstants.Percentiles.Formattable.WEAPONTYPEWeapons, type); var weaponName = percentileSelector.SelectFrom(tableName); var weapon = new Item(); if (weaponName == AttributeConstants.Ammunition) { weapon = ammunitionGenerator.Generate(); } else { weapon.Name = weaponName; if (weapon.Name.Contains("Composite")) { weapon.Name = GetCompositeBowName(weaponName); var compositeStrengthBonus = GetCompositeBowBonus(weaponName); weapon.Traits.Add(compositeStrengthBonus); } weapon.ItemType = ItemTypeConstants.Weapon; tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, weapon.ItemType); weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name); } var isMasterwork = booleanPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IsMasterwork); if (isMasterwork) { weapon.Traits.Add(TraitConstants.Masterwork); } if (weapon.Attributes.Contains(AttributeConstants.Thrown) && weapon.Attributes.Contains(AttributeConstants.Melee) == false) { weapon.Quantity = dice.Roll().d20().AsSum(); } var size = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes); weapon.Traits.Add(size); return(weapon); }
private SpecialAbility GetSpecialAbility(string abilityName) { var ability = new SpecialAbility(); var abilityResult = specialAbilityAttributesSelector.SelectFrom(TableNameConstants.Collections.Set.SpecialAbilityAttributes, abilityName); ability.Name = abilityName; ability.BaseName = abilityResult.BaseName; ability.AttributeRequirements = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.SpecialAbilityAttributeRequirements, ability.BaseName); ability.BonusEquivalent = abilityResult.BonusEquivalent; ability.Power = abilityResult.Power; return(ability); }
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); }
public SpecialMaterialGenerator(Dice dice, ICollectionsSelector attributesSelector, IBooleanPercentileSelector booleanPercentileSelector) { this.dice = dice; this.booleanPercentileSelector = booleanPercentileSelector; specialMaterialAttributes = new Dictionary <string, IEnumerable <string> >(); var materials = TraitConstants.SpecialMaterials.All(); foreach (var material in materials) { var attributeRequirements = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.SpecialMaterials, material); specialMaterialAttributes.Add(material, attributeRequirements); } }
private Item BuildStaff(Item staff) { staff.Quantity = 1; staff.IsMagical = true; if (staff.Name != StaffConstants.Power) { return(staff); } var tablename = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon); var quarterstaffAttributes = attributesSelector.SelectFrom(tablename, WeaponConstants.Quarterstaff); staff.Attributes = staff.Attributes.Union(quarterstaffAttributes).Except(new[] { AttributeConstants.OneTimeUse }); return(staff); }
public SpecialAbilityAttributesResult SelectFrom(string tableName, string name) { var attributes = innerSelector.SelectFrom(tableName, name).ToList(); if (attributes.Count < 3) { throw new Exception("Attributes are not formatted for special abilities"); } var result = new SpecialAbilityAttributesResult(); result.BaseName = attributes[1]; result.BonusEquivalent = Convert.ToInt32(attributes[0]); result.Power = Convert.ToInt32(attributes[2]); return(result); }
public IntelligenceAttributesResult SelectFrom(string tableName, string name) { var attributes = innerSelector.SelectFrom(tableName, name).ToList(); if (attributes.Count < 3) { throw new Exception("Attributes are not formatted for intelligence"); } var result = new IntelligenceAttributesResult(); result.Senses = attributes[0]; result.LesserPowersCount = Convert.ToInt32(attributes[1]); result.GreaterPowersCount = Convert.ToInt32(attributes[2]); return(result); }
public RangeAttributesResult SelectFrom(string tableName, string name) { var attributes = innerSelector.SelectFrom(tableName, name); if (attributes.Count() < 2) { throw new Exception("Attributes are not in format for range"); } var minimum = attributes.First(); var maximum = attributes.Last(); var result = new RangeAttributesResult(); result.Minimum = Convert.ToInt32(minimum); result.Maximum = Convert.ToInt32(maximum); return(result); }
public Intelligence GenerateFor(Item item) { var highStatResult = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IntelligenceStrongStats); var highStat = Convert.ToInt32(highStatResult); var intelligence = new Intelligence(); intelligence.Ego += highStat - 10 - highStat % 2; intelligence.Ego += item.Magic.Bonus; foreach (var ability in item.Magic.SpecialAbilities) { intelligence.Ego += ability.BonusEquivalent; } switch (dice.Roll().d3().AsSum()) { case 1: intelligence.CharismaStat = 10; break; case 2: intelligence.IntelligenceStat = 10; break; case 3: intelligence.WisdomStat = 10; break; } intelligence.CharismaStat = SetHighStat(highStat, intelligence.CharismaStat); intelligence.IntelligenceStat = SetHighStat(highStat, intelligence.IntelligenceStat); intelligence.WisdomStat = SetHighStat(highStat, intelligence.WisdomStat); intelligence.Communication = attributesSelector.SelectFrom(TableNameConstants.Collections.Set.IntelligenceCommunication, highStatResult); if (intelligence.Communication.Contains("Speech")) { intelligence.Languages = GenerateLanguages(intelligence.IntelligenceStat); } intelligence.Ego += BoostEgoByCommunication(intelligence.Communication, "Read"); intelligence.Ego += BoostEgoByCommunication(intelligence.Communication, "Read magic"); intelligence.Ego += BoostEgoByCommunication(intelligence.Communication, "Telepathy"); var intelligenceAttributesResult = intelligenceAttributesSelector.SelectFrom(TableNameConstants.Collections.Set.IntelligenceAttributes, highStatResult); intelligence.Senses = intelligenceAttributesResult.Senses; var lesserPowers = GeneratePowers("Lesser", intelligenceAttributesResult.LesserPowersCount); intelligence.Ego += lesserPowers.Count; intelligence.Powers.AddRange(lesserPowers); var greaterPowers = GeneratePowers("Greater", intelligenceAttributesResult.GreaterPowersCount); var roll = dice.Roll().d4().AsSum(); if (roll <= intelligenceAttributesResult.GreaterPowersCount) { greaterPowers.RemoveAt(greaterPowers.Count - 1); intelligence.SpecialPurpose = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IntelligenceSpecialPurposes); intelligence.DedicatedPower = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.IntelligenceDedicatedPowers); intelligence.Ego += 4; } intelligence.Ego += greaterPowers.Count * 2; intelligence.Powers.AddRange(greaterPowers); intelligence.Alignment = GetAlignment(item); intelligence.Personality = percentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.PersonalityTraits); return(intelligence); }
public void GetAttributesFromMapper() { var attributes = attributesSelector.SelectFrom("table name", "name"); Assert.That(attributes, Is.EqualTo(expected)); }
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); }
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); }