public SavingThrows GenerateWith(CharacterClass characterClass, IEnumerable<Feat> feats, Dictionary<string, Stat> stats) { var savingThrows = new SavingThrows(); savingThrows.HasFortitudeSave = stats.ContainsKey(StatConstants.Constitution); savingThrows.Reflex = stats[StatConstants.Dexterity].Bonus; savingThrows.Will = stats[StatConstants.Wisdom].Bonus; savingThrows.Reflex += GetClassSavingThrowBonus(characterClass, SavingThrowConstants.Reflex); savingThrows.Will += GetClassSavingThrowBonus(characterClass, SavingThrowConstants.Will); savingThrows.Reflex += GetFeatSavingThrowBonus(feats, SavingThrowConstants.Reflex); savingThrows.Will += GetFeatSavingThrowBonus(feats, SavingThrowConstants.Will); var anySavingThrowFeatNames = collectionsSelector.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, GroupConstants.SavingThrows); var anySavingThrowFeats = feats.Where(f => anySavingThrowFeatNames.Contains(f.Name)); foreach (var feat in anySavingThrowFeats) { savingThrows.Reflex += GetBonus(feat, SavingThrowConstants.Reflex); savingThrows.Will += GetBonus(feat, SavingThrowConstants.Will); savingThrows.CircumstantialBonus |= HasCircumstantialBonus(feat); } if (savingThrows.HasFortitudeSave) { savingThrows.Fortitude = stats[StatConstants.Constitution].Bonus; savingThrows.Fortitude += GetClassSavingThrowBonus(characterClass, SavingThrowConstants.Fortitude); savingThrows.Fortitude += GetFeatSavingThrowBonus(feats, SavingThrowConstants.Fortitude); foreach (var feat in anySavingThrowFeats) { savingThrows.Fortitude += GetBonus(feat, SavingThrowConstants.Fortitude); savingThrows.CircumstantialBonus |= HasCircumstantialBonus(feat); } } return savingThrows; }
public void GetSavingThrowsFromGenerator() { var savingThrows = new SavingThrows(); mockSavingThrowsGenerator.Setup(g => g.GenerateWith(characterClass, feats, stats)).Returns(savingThrows); var baseAttack = combatGenerator.GenerateBaseAttackWith(characterClass, race, stats); var combat = combatGenerator.GenerateWith(baseAttack, characterClass, race, feats, stats, equipment); Assert.That(combat.SavingThrows, Is.EqualTo(savingThrows)); }
public void Setup() { savingThrows = new SavingThrows(); }