private IEnumerable <SpellQuantity> GetSpellsPerDay(string caster, int casterLevel, Ability castingAbility, IEnumerable <string> domains) { var spellsForClass = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.SpellsPerDay, $"{caster}:{casterLevel}"); var maxSpellLevel = castingAbility.FullScore - 10; var spellsForCaster = spellsForClass.Where(s => Convert.ToInt32(s.Type) <= maxSpellLevel); var spellsPerDay = new List <SpellQuantity>(); foreach (var typeAndAmount in spellsForCaster) { var spellQuantity = new SpellQuantity(); spellQuantity.Level = Convert.ToInt32(typeAndAmount.Type); spellQuantity.Quantity = typeAndAmount.Amount; spellQuantity.Source = caster; spellQuantity.HasDomainSpell = domains.Any() && spellQuantity.Level > 0; if (spellQuantity.Level > 0 && spellQuantity.Level <= castingAbility.Modifier) { spellQuantity.BonusSpells = (castingAbility.Modifier - spellQuantity.Level) / 4 + 1; } spellsPerDay.Add(spellQuantity); } return(spellsPerDay); }
public void SelectMultipleTypesAndAmounts() { var entries = new[] { TypeAndAmountHelper.Build("type", "9266"), TypeAndAmountHelper.Build("other type", "90210"), }; mockCollectionSelector.Setup(s => s.SelectFrom("table name", "name")).Returns(entries); SetUpRoll("9266", 42); SetUpRoll("90210", 600); var typesAndAmounts = selector.Select("table name", "name"); Assert.That(typesAndAmounts.Count, Is.EqualTo(2)); var first = typesAndAmounts.First(); var last = typesAndAmounts.Last(); Assert.That(first.Type, Is.EqualTo("type")); Assert.That(first.Amount, Is.EqualTo(42)); Assert.That(last.Type, Is.EqualTo("other type")); Assert.That(last.Amount, Is.EqualTo(600)); }
public Dictionary <string, Ability> GenerateFor(string creatureName) { var abilitySelections = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.AbilityAdjustments, creatureName); var allAbilities = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.AbilityAdjustments, GroupConstants.All); var abilities = new Dictionary <string, Ability>(); foreach (var selection in allAbilities) { abilities[selection.Type] = new Ability(selection.Type); } foreach (var selection in abilitySelections) { abilities[selection.Type].RacialAdjustment = selection.Amount; abilities[selection.Type].BaseScore = dice.Roll(3).d6().AsSum(); } var missingAbilities = allAbilities.Select(a => a.Type).Except(abilitySelections.Select(a => a.Type)); foreach (var abilityName in missingAbilities) { abilities[abilityName].BaseScore = 0; } return(abilities); }
private Dictionary <string, int> GetRequiredAbilities(string feat) { var requiredAbilitiesAndValues = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.FeatAbilityRequirements, feat); var requiredAbilities = new Dictionary <string, int>(); foreach (var selection in requiredAbilitiesAndValues) { requiredAbilities[selection.Type] = selection.Amount; } return(requiredAbilities); }
public bool IsCompatible(string creature) { var creatureTypes = collectionSelector.SelectFrom(TableNameConstants.Collection.CreatureTypes, creature); if (creatureTypes.First() != CreatureConstants.Types.Humanoid) { return(false); } var creatureData = creatureDataSelector.SelectFor(creature); if (creatureData.LevelAdjustment.HasValue) { return(true); } if (creatureData.CasterLevel >= PhylacterySpellLevel) { return(true); } var spellcasters = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.Casters, creature); if (spellcasters.Any(s => s.Amount >= PhylacterySpellLevel)) { return(true); } return(false); }
public bool IsCompatible(string creature) { var types = collectionSelector.SelectFrom(TableNameConstants.Collection.CreatureTypes, creature); if (types.Contains(CreatureConstants.Types.Subtypes.Incorporeal)) { return(false); } if (!creatureTypes.Contains(types.First())) { return(false); } var alignments = collectionSelector.SelectFrom(TableNameConstants.Collection.AlignmentGroups, creature); if (!alignments.Any(a => !a.Contains(AlignmentConstants.Good))) { return(false); } var abilityAdjustments = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.AbilityAdjustments, creature); var intelligenceAdjustment = abilityAdjustments.FirstOrDefault(a => a.Type == AbilityConstants.Intelligence); if (intelligenceAdjustment == null) { return(false); } return(intelligenceAdjustment.Amount + Ability.DefaultScore >= 4); }
public IEnumerable <BonusSelection> SelectFor(string tableName, string source) { var typeAndAmountSelections = typeAndAmountSelector.Select(tableName, source); var bonusSelections = typeAndAmountSelections.Select(s => Parse(s)); return(bonusSelections); }
public bool IsCompatible(string creature) { var types = collectionSelector.SelectFrom(TableNameConstants.Collection.CreatureTypes, creature); if (!creatureTypes.Contains(types.First())) { return(false); } var abilityAdjustments = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.AbilityAdjustments, creature); var charismaAdjustment = abilityAdjustments.FirstOrDefault(a => a.Type == AbilityConstants.Charisma); if (charismaAdjustment == null) { return(false); } return(charismaAdjustment.Amount + Ability.DefaultScore >= 6); }
private void UpdateCreatureAbilities(Creature creature) { if (creature.Abilities[AbilityConstants.Wisdom].HasScore) { creature.Abilities[AbilityConstants.Wisdom].TemplateAdjustment = 2; } var animalAbilityAdjustments = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.AbilityAdjustments, AnimalSpecies); var physicalAbilities = new[] { AbilityConstants.Strength, AbilityConstants.Constitution, AbilityConstants.Dexterity }; foreach (var adjustment in animalAbilityAdjustments.Where(a => physicalAbilities.Contains(a.Type))) { creature.Abilities[adjustment.Type].Bonuses.Add(new Bonus { Value = adjustment.Amount, Condition = "In Animal or Hybrid form", }); } }
public Dictionary <string, Measurement> Generate(string creatureName) { var speedTypesAndAmounts = typeAndAmountSelector.Select(TableNameConstants.Collection.Speeds, creatureName); var speeds = new Dictionary <string, Measurement>(); foreach (var speedTypeAndAmount in speedTypesAndAmounts) { var measurement = new Measurement("feet per round"); measurement.Value = speedTypeAndAmount.Amount; if (speedTypeAndAmount.Type == SpeedConstants.Fly) { measurement.Description = collectionSelector.SelectFrom(TableNameConstants.Collection.AerialManeuverability, creatureName).Single(); } speeds[speedTypeAndAmount.Type] = measurement; } return(speeds); }
private IEnumerable <string> FilterByAbilityRequirements(IEnumerable <string> foci, string featName, Dictionary <string, Ability> abilities) { var applicableFoci = new List <string>(foci); foreach (var focus in foci) { var combo = $"{featName}/{focus}"; var abilityRequirements = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.FeatAbilityRequirements, combo); if (!abilityRequirements.Any()) { continue; } if (!abilityRequirements.Any(r => abilities[r.Type].FullScore >= r.Amount)) { applicableFoci.Remove(focus); } } return(applicableFoci); }
public bool IsAdvanced(string creature) { var advancements = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.Advancements, creature); return(percentileSelector.SelectFrom(.9) && advancements.Any()); }
public Magic GenerateWith(string creatureName, Alignment alignment, Dictionary <string, Ability> abilities, Equipment equipment) { var magic = new Magic(); var casters = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.Casters, creatureName); if (!casters.Any()) { return(magic); } var caster = casters.First(); magic.Caster = caster.Type; magic.CasterLevel = caster.Amount; var spellAbility = collectionsSelector.SelectFrom(TableNameConstants.Collection.AbilityGroups, $"{magic.Caster}:Spellcaster").Single(); magic.CastingAbility = abilities[spellAbility]; var domainTypesAndAmounts = typeAndAmountSelector.Select(TableNameConstants.TypeAndAmount.SpellDomains, creatureName); var domains = new List <string>(); if (domainTypesAndAmounts.Any()) { var domainCount = domainTypesAndAmounts.First().Amount; var possibleDomains = domainTypesAndAmounts .Select(d => d.Type) .Except(domains); if (domainCount >= possibleDomains.Count()) { domains.AddRange(possibleDomains); } while (domains.Count < domainCount && possibleDomains.Any()) { var domain = collectionsSelector.SelectRandomFrom(possibleDomains); domains.Add(domain); } } magic.Domains = domains; magic = MakeSpells(creatureName, magic, alignment); if (equipment.Armor == null && equipment.Shield == null) { return(magic); } var arcaneSpellcasters = collectionsSelector.SelectFrom(TableNameConstants.Collection.CasterGroups, SpellConstants.Sources.Arcane); if (!arcaneSpellcasters.Contains(magic.Caster)) { return(magic); } if (equipment.Armor != null) { magic.ArcaneSpellFailure += GetArcaneSpellFailure(equipment.Armor); } if (equipment.Shield != null) { magic.ArcaneSpellFailure += GetArcaneSpellFailure(equipment.Shield); } return(magic); }