public void SelectSingle_NoReplace() { var result = replacementSelector.SelectSingle("my value"); Assert.That(result, Is.EqualTo("my value")); }
private Weapon SetWeaponAttributes(Weapon weapon) { if (string.IsNullOrEmpty(weapon.Name)) { throw new ArgumentException("Weapon name cannot be empty - it must be filled before calling this method"); } weapon.Size = GetSize(weapon); weapon.Traits.Remove(weapon.Size); weapon.ItemType = ItemTypeConstants.Weapon; if (NameMatches(weapon.Name, WeaponConstants.CompositeLongbow) || NameMatches(weapon.Name, WeaponConstants.CompositeShortbow)) { var oldName = weapon.Name; weapon.Name = replacementSelector.SelectSingle(oldName); var compositeStrengthBonus = GetCompositeBowBonus(oldName); if (!string.IsNullOrEmpty(compositeStrengthBonus)) { weapon.Traits.Add(compositeStrengthBonus); } } var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon); weapon.Attributes = collectionsSelector.SelectFrom(tableName, weapon.Name); var weaponSelection = weaponDataSelector.Select(weapon.Name); if (!weapon.Damages.Any()) { weapon.Damages.Add(weaponSelection.DamagesBySize[weapon.Size][0]); } if (!weapon.CriticalDamages.Any()) { weapon.CriticalDamages.Add(weaponSelection.CriticalDamagesBySize[weapon.Size][0]); } if (weapon.IsDoubleWeapon && !weapon.SecondaryDamages.Any()) { weapon.SecondaryDamages.Add(weaponSelection.DamagesBySize[weapon.Size][1]); } if (weapon.IsDoubleWeapon && !weapon.SecondaryCriticalDamages.Any()) { weapon.SecondaryCriticalDamages.Add(weaponSelection.CriticalDamagesBySize[weapon.Size][1]); } weapon.ThreatRange = weaponSelection.ThreatRange; weapon.Ammunition = weaponSelection.Ammunition; weapon.CriticalMultiplier = weaponSelection.CriticalMultiplier; if (weapon.IsDoubleWeapon && string.IsNullOrEmpty(weapon.SecondaryCriticalMultiplier)) { weapon.SecondaryCriticalMultiplier = weaponSelection.SecondaryCriticalMultiplier; } 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); }