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 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 IEnumerable <Good> GenerateAtLevel(int level) { 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.LevelXGoods, level); var typeAndAmountSelection = typeAndAmountPercentileSelector.SelectFrom(tableName); if (string.IsNullOrEmpty(typeAndAmountSelection.Type)) { return(Enumerable.Empty <Good>()); } var goods = new List <Good>(); while (typeAndAmountSelection.Amount-- > 0) { var good = GenerateGood(typeAndAmountSelection); goods.Add(good); } return(goods); }
public Item GenerateRandom(string power) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Potion); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); return(GeneratePotion(result.Type, result.Amount)); }
public string GenerateRandomNameFrom(string power, string specificGearType) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, power, specificGearType); var selection = typeAndAmountPercentileSelector.SelectFrom(tableName); return(selection.Type); }
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 IEnumerable <Item> GenerateRandomAtLevel(int level) { 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 items = new List <Item>(); while (result.Amount-- > 0) { var item = GenerateRandomAtPower(result.Type); items.Add(item); } return(items); }
public Item GenerateRandom(string power) { var rodPowers = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, ItemTypeConstants.Rod); var adjustedPower = PowerHelper.AdjustPower(power, rodPowers); var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.Rod); var result = typeAndAmountPercentileSelector.SelectFrom(tablename); return(GenerateRod(result.Type, result.Amount)); }
public Item GenerateRandom(string power) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.WondrousItem); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var item = BuildWondrousItem(result.Type); item.Magic.Bonus = result.Amount; return(item); }
public Item GenerateRandom(string power) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Ring); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var ring = BuildRing(result.Type, power); ring.Magic.Bonus = result.Amount; return(ring); }
public Item Generate() { var result = typeAndAmountPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.AlchemicalItems); var item = new Item(); item.Name = result.Type; item.Quantity = result.Amount; item.ItemType = ItemTypeConstants.AlchemicalItem; return(item); }
public Item GenerateAtPower(string power) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Potion); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var potion = new Item(); potion.Name = result.Type; potion.ItemType = ItemTypeConstants.Potion; potion.Magic.Bonus = result.Amount; potion.IsMagical = true; potion.Attributes = new[] { AttributeConstants.OneTimeUse }; return(potion); }
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 Coin GenerateAtLevel(int level) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXCoins, level); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var coin = new Coin(); if (string.IsNullOrEmpty(result.Type)) { return(coin); } coin.Currency = result.Type; coin.Quantity = result.Amount; return(coin); }
public IEnumerable <Item> GenerateAtLevel(int level) { var tableName = string.Format(TableNameConstants.Percentiles.Formattable.LevelXItems, level); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var items = new List <Item>(); while (result.Amount-- > 0) { var item = GenerateAtPower(result.Type); items.Add(item); } var epicItems = GetEpicItems(level); items.AddRange(epicItems); return(items); }
public Coin GenerateAtLevel(int level) { 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.LevelXCoins, level); var result = typeAndAmountPercentileSelector.SelectFrom(tableName); var coin = new Coin(); if (string.IsNullOrEmpty(result.Type)) { return(coin); } coin.Currency = result.Type; coin.Quantity = result.Amount; return(coin); }
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 Item GenerateRandom() { var result = typeAndAmountPercentileSelector.SelectFrom(TableNameConstants.Percentiles.Set.AlchemicalItems); return(Generate(result.Type)); }
public void AccessesPercentileSelectorWithTableNameAndRoll() { typeAndAmountPercentileSelector.SelectFrom("table name"); mockPercentileSelector.Verify(p => p.SelectFrom("table name"), Times.Once); }
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); }