public RaceSelectorTests() { // Create a race elf = new Race(); elf.Name = "Elfy"; elf.SizeSetting = CharacterSize.Medium; elf.HeightRange = DiceStrings.ParseDice("10d6"); elf.WeightRange = DiceStrings.ParseDice("20d8"); elf.KnownLanguages.Add("Common"); elf.KnownLanguages.Add("Elvish"); elf.AvailableLanguages.Add("Draconic"); elf.AvailableLanguages.Add("Celestial"); human = new Race(); human.Name = "Human"; human.SizeSetting = CharacterSize.Medium; human.HeightRange = DiceStrings.ParseDice("2d8+30"); human.WeightRange = DiceStrings.ParseDice("3d6+100"); human.KnownLanguages.Add("Common"); var list = new List <Race>(); list.Add(elf); list.Add(human); // Configure Gateways raceGateway = EntityGateway <Race> .LoadFromList(list); raceSelectorSubject = new RaceSelector(raceGateway); }
public LanguageSelectorTests() { var languages = new List <Language> (); languages.Add(new Language("Elvish", "Foo")); languages.Add(new Language("Boo", "foo")); languages.Add(new Language("Giant", "Rawr")); languages.Add(new Language("Corgi", "woof")); languageGateway = EntityGateway <Language> .LoadFromList(languages); }
public StartingWealthTests() { var list = new List <CharacterWealth>(); var wealth = new CharacterWealth(); wealth.Name = "adventurer"; wealth.Levels.Add(new CharacterWealth.CharacterWealthLevel(1, 0)); wealth.Levels.Add(new CharacterWealth.CharacterWealthLevel(2, 2000)); list.Add(wealth); wealthGateway = EntityGateway <CharacterWealth> .LoadFromList(list); }
public void CanSelectWeaponsBasedOnProficiencies() { var repo = EntityGateway <Weapon> .LoadFromList(WeaponYamlFile.ParseYaml().Load <Weapon>()); var prof = new WeaponProficiency("dagger"); var results = repo.FindByProficient(new WeaponProficiency[] { prof }); Assert.Equal(1, results.Count()); Assert.Equal("Dagger", results.First().Name); }
public void CanForceGatewayToASpecificList() { var list = new List <TestObject>(); list.Add(new TestObject("hello1")); list.Add(new TestObject("hello2")); var gateway = EntityGateway <TestObject> .LoadFromList(list); Assert.Equal(2, gateway.Count()); Assert.NotNull(gateway.Find("hello2")); }
public ClassSelectorTests() { var classes = new List <Class>(); var hero = Class.CreateForTesting("Fighter", DiceSides.d10); var bartender = Class.CreateForTesting("Bartender", DiceSides.d4); classes.Add(hero); classes.Add(bartender); classGateway = EntityGateway <Class> .LoadFromList(classes); subject = new ClassSelector(classGateway); }
public void ProcessCreatesADescriptionCombiningColorAndStyle() { var colors = new HairColor[] { new HairColor("copper") }; var styles = new HairStyle[] { new HairStyle("ponytail") }; styles[0].Descriptors.Add("descriptor", new string[] { "long" }); var subject = new CreateHair(EntityGateway <HairColor> .LoadFromList(colors), EntityGateway <HairStyle> .LoadFromList(styles)); var character = new CharacterSheet(CharacterStrategy.Default()); subject.ExecuteStep(character); Assert.Equal(colors[0], character.Appearance.HairColor); Assert.Equal(styles[0], character.Appearance.HairStyle); }
public SelectRagePowerTests() { var parsed = rageYaml.ParseYaml(); var powers = new List <RagePower>(); foreach (var r in parsed.Children) { powers.Add(new RagePower(r)); } var gateway = EntityGateway <RagePower> .LoadFromList(powers); ragePowerSelector = new SelectRagePower(gateway); barbarian = CharacterTestTemplates.Barbarian(); }
public SelectRogueTalentTests() { var basicData = new MemoryStore(); basicData.SetValue("name", "Basic Talent"); basicTalent = new RogueTalent(basicData); var advData = new MemoryStore(); advData.SetValue("name", "Advanced Talent"); advData.SetValue("advanced-talent", "true"); advancedTalent = new RogueTalent(advData); Talents = EntityGateway <RogueTalent> .LoadFromList(new RogueTalent[] { basicTalent, advancedTalent }); }
public PurchasingAdventuringGearTests() { var gears = new List <Gear>(); gears.Add(new Gear("tool", 20, 1)); gears.Add(new Gear("sack", 20, 1)); gears.Add(new Gear("backpack", 20, 1)); gears.Add(new Gear("Flint and steel", 20, 1)); gears.Add(new Gear("chalk", 20, 1)); gears.Add(new Gear("other thing", 20, 1)); gears.Add(new Gear("some stuff", 20, 1)); gears.Add(new Gear("doodad", 20, 1)); gearGateway = EntityGateway <Gear> .LoadFromList(gears); subject = new PurchaseAdventuringGear(gearGateway); }
public void AddingToCharacterPicksAWeaponCharacterIsProficientWithForBonus(string proficiency, string weaponName) { var longsword = new Weapon("Longsword", 1, "1d6", DamageTypes.Slashing, 20, 2, 0, WeaponType.OneHanded, WeaponGroup.HeavyBlades, WeaponTrainingLevel.Martial); var axe = new Weapon("Axe", 1, "1d6", DamageTypes.Slashing, 20, 2, 0, WeaponType.OneHanded, WeaponGroup.HeavyBlades, WeaponTrainingLevel.Simple); var list = EntityGateway <Weapon> .LoadFromList(new Weapon[] { longsword, axe }); var weaponFocus = WeaponFocus.CreateForTesting(list); //Specific exact weapon proficiency var bob = CharacterTestTemplates.AverageBob(); bob.Offense.AddWeaponProficiency(proficiency); bob.Add(weaponFocus); Assert.Equal(weaponName, weaponFocus.WeaponName); Assert.Equal("Weapon Focus (" + weaponName + ")", weaponFocus.Name); }
public void MaxSpellLevelIsLevel3() { var spellList = SpellList.CreateForTesting("cleric"); spellList.Add(1, "Cure Light Wounds"); spellList.Add(4, "Cure Serious Wounds"); var cureSpell = new Spell("Cure Light Wounds", "healing"); var cureSeriousSpell = new Spell("Cure Serious Wounds", "healing"); var spellLists = EntityGateway <SpellList> .LoadWithSingleItem(spellList); var spells = EntityGateway <Spell> .LoadFromList(new Spell[] { cureSpell, cureSeriousSpell }); var potionCreator = new PotionCreator(spellLists, spells); var potion = potionCreator.Process(); //Always equals cureSpell Assert.Equal(cureSpell, potion.Spell); }
public void SelectsClothingFromOptionsInStrategy() { var clothes = new List <Clothes>() { new Clothes("Outfit", 2000, 5), new Clothes("Ignore", 200, 5) }; var purchase = new PurchaseClothing(EntityGateway <Clothes> .LoadFromList(clothes)); var bob = CharacterTestTemplates.AverageBob(); bob.Inventory.CoinPurse.AddGold(200); var strategy = bob.Strategy; strategy.AddCustomValue("clothes", "Outfit", 1); purchase.ExecuteStep(bob); Assert.NotNull(bob.Inventory.Find(clothes[0])); }
public void AddingASecondTerrainAppendsADifferentOneToTheList() { var forest = new TerrainType("Forest"); var jungle = new TerrainType("Jungle"); var terrainTypes = new TerrainType[] { forest, jungle }; var ctGateway = EntityGateway <TerrainType> .LoadFromList(terrainTypes); var configureStep = new SelectFavoredTerrain(ctGateway); var character = new CharacterSheet(CharacterStrategy.Default()); configureStep.ExecuteStep(character); configureStep.ExecuteStep(character); var favTerrain = character.Get <FavoredTerrain>(); Assert.Contains(forest, favTerrain.TerrainTypes); Assert.Contains(jungle, favTerrain.TerrainTypes); }
public void AddingASecondEnemyAppendsADifferentOneToTheList() { var aberration = new CreatureType("Aberration"); var dragon = new CreatureType("Dragon"); var creatureTypes = new CreatureType[] { aberration, dragon }; var ctGateway = EntityGateway <CreatureType> .LoadFromList(creatureTypes); var configureStep = new SelectFavoredEnemy(ctGateway); var character = new CharacterSheet(CharacterStrategy.Default()); configureStep.ExecuteStep(character); configureStep.ExecuteStep(character); var favEnemy = character.Get <FavoredEnemy>(); Assert.Contains(aberration, favEnemy.CreatureTypes); Assert.Contains(dragon, favEnemy.CreatureTypes); }
public void AllImportantStatsForALongSwordAreAvailable() { var repo = EntityGateway <Weapon> .LoadFromList(WeaponYamlFile.ParseYaml().Load <Weapon>()); var weapons = repo.All(); var longsword = weapons.First(); Assert.Equal("Longsword", longsword.Name); Assert.Equal("1d8", longsword.Damage); Assert.Equal(4, longsword.Weight); Assert.Equal(19, longsword.CriticalThreat); Assert.Equal(3, longsword.CriticalModifier); Assert.Equal(DamageTypes.Slashing, longsword.DamageType); Assert.Equal(WeaponType.OneHanded, longsword.Type); Assert.Equal(WeaponGroup.HeavyBlades, longsword.Group); Assert.Equal(WeaponTrainingLevel.Martial, longsword.Level); Assert.Equal(3200, longsword.Value); }
public void AllImportantStatsForADaggerAreAvailable() { var repo = EntityGateway <Weapon> .LoadFromList(WeaponYamlFile.ParseYaml().Load <Weapon>()); var dagger = repo.All().Last(); Assert.Equal("Dagger", dagger.Name); Assert.Equal("1d4", dagger.Damage); Assert.Equal(1, dagger.Weight); Assert.Equal(20, dagger.CriticalThreat); Assert.Equal(2, dagger.CriticalModifier); Assert.Equal(DamageTypes.Piercing, dagger.DamageType); Assert.Equal(10, dagger.Range); Assert.Equal(WeaponType.Light, dagger.Type); Assert.Equal(WeaponGroup.LightBlades, dagger.Group); Assert.Equal(WeaponTrainingLevel.Simple, dagger.Level); Assert.Equal(40, dagger.Value); }
public void UniversalistSchoolsDontSelectOppositionSchools() { var wizard = CharacterTestTemplates.Wizard().WithWizardCasting(); var casting = wizard.Get <WizardCasting>(); var focusSchool = ArcaneSchool.CreateForTesting("focused", true); casting.SetFocusSchool(focusSchool); var oppSchool1 = ArcaneSchool.CreateForTesting("opp school 1", false); var oppSchool2 = ArcaneSchool.CreateForTesting("opp school 2", false); var gateway = EntityGateway <ArcaneSchool> .LoadFromList( new ArcaneSchool[] { focusSchool, oppSchool1, oppSchool2 } ); var step = new SelectArcaneOppositionSchools(gateway); step.ExecuteStep(wizard); Assert.Empty(casting.OppositionSchools); }
public FeatSelectorTests() { powerattack = Feat.Named("Power Attack"); cleave = Feat.Named("Cleave"); cleave.Prerequisites.Add(new SpecialAbilityPrerequisite("power attack")); empowerspell = Feat.Named("Empower Spell"); empowerspell.Tags.Add("metamagic"); var list = new List <Feat>(); list.Add(powerattack); list.Add(cleave); list.Add(empowerspell); gateway = EntityGateway <Feat> .LoadFromList(list); selector = new FeatSelector(gateway); }
public void SelectsTwoOppositionSchoolsThatAreDifferentFromFocusSchool() { var wizard = CharacterTestTemplates.Wizard().WithWizardCasting(); var casting = wizard.Get <WizardCasting>(); var focusSchool = ArcaneSchool.CreateForTesting("focused", false); casting.SetFocusSchool(focusSchool); var oppSchool1 = ArcaneSchool.CreateForTesting("opp school 1", false); var oppSchool2 = ArcaneSchool.CreateForTesting("opp school 2", false); var gateway = EntityGateway <ArcaneSchool> .LoadFromList( new ArcaneSchool[] { focusSchool, oppSchool1, oppSchool2 } ); var step = new SelectArcaneOppositionSchools(gateway); step.ExecuteStep(wizard); AssertExtensions.Contains(oppSchool1, casting.OppositionSchools); AssertExtensions.Contains(oppSchool2, casting.OppositionSchools); }
public void ChoosesAFewColorsThatTheCharacterMightLike() { var bob = CharacterTestTemplates.AverageBob(); bob.Strategy.FavoriteColorCount = 3; var colors = new Color[] { new Color("Red", 255, 0, 0), new Color("Green", 0, 255, 0), new Color("Blue", 0, 0, 255) }; var pick = new SelectFavoriteColors(EntityGateway <Color> .LoadFromList(colors)); pick.ExecuteStep(bob); var personality = bob.Get <Likes>(); Assert.Contains(colors[0], personality.FavoriteColors); }
public void DoNotUseUniversalistStyleSchoolsForOpposition() { var wizard = CharacterTestTemplates.Wizard().WithWizardCasting(); var casting = wizard.Get <WizardCasting>(); var focusSchool = ArcaneSchool.CreateForTesting("focused", false); casting.SetFocusSchool(focusSchool); var oppSchool1 = ArcaneSchool.CreateForTesting("opp school 1", false); var oppSchool2 = ArcaneSchool.CreateForTesting("opp school 2", false); var ignoreSchool = ArcaneSchool.CreateForTesting("universalist", true); var gateway = EntityGateway <ArcaneSchool> .LoadFromList( new ArcaneSchool[] { focusSchool, oppSchool1, oppSchool2, ignoreSchool } ); var step = new SelectArcaneOppositionSchools(gateway); step.ExecuteStep(wizard); AssertExtensions.Contains(oppSchool1, casting.OppositionSchools); AssertExtensions.Contains(oppSchool2, casting.OppositionSchools); }
public void CombineMultipleDescriptionsTogetherButDoNotRepeat() { var tattoo = new PhysicalFeature(); tattoo.AddDescriptor("color", new string[] { "green" }); tattoo.AddTemplate("Tattoo of a {{descriptor \"color\"}} dragon."); var scar = new PhysicalFeature(); scar.AddDescriptor("location", new string[] { "face" }); scar.AddTemplate("A scar on {{descriptor \"location\"}}."); var gateway = EntityGateway <PhysicalFeature> .LoadFromList(new PhysicalFeature[] { tattoo, scar }); var subject = new CreatePhysicalFeatures(gateway); var character = new CharacterSheet(CharacterStrategy.Default()); subject.ExecuteStep(character); Assert.Contains("Tattoo of a green dragon.", character.Appearance.PhysicalAppearance); Assert.Contains("A scar on face.", character.Appearance.PhysicalAppearance); }
public void IfMultipleTokensAreAvailableTheNextOneShouldChooseSomethingDifferent() { var classes = new Class[] { Class.CreateForTesting("Cleric", SilverNeedle.Dice.DiceSides.d8), Class.CreateForTesting("Bard", SilverNeedle.Dice.DiceSides.d6) }; var cleric = CharacterTestTemplates.Cleric(); cleric.Add(new FavoredClassToken()); cleric.Add(new FavoredClassToken()); var step = new ProcessFavoredClassToken(EntityGateway<Class>.LoadFromList(classes)); step.ExecuteStep(cleric); var allFavored = cleric.GetAll<FavoredClass>(); AssertExtensions.EquivalentLists( new string[] { "Cleric", "Bard" }, allFavored.Select(x => x.ClassName) ); }
public void FiltersSpellsOutBasedOnCriteria() { var spellFiltered = new Spell("Fireball", "fire"); var spellReturned = new Spell("Iceball", "cold"); var gateway = EntityGateway <Spell> .LoadFromList(new Spell[] { spellFiltered, spellReturned }); var spellList = SpellList.CreateForTesting("wizard", gateway); spellList.Add(1, "Fireball"); spellList.Add(1, "Iceball"); var criteria = new Mock <ISpellCastingRule>(); criteria.Setup(x => x.CanCastSpell(spellFiltered)).Returns(false); criteria.Setup(x => x.CanCastSpell(spellReturned)).Returns(true); var rule = criteria.Object; AssertExtensions.EquivalentLists( new string[] { "Iceball" }, spellList.GetSpells(1, new ISpellCastingRule[] { rule }) ); }
public void SelectsAUniqueMercyFromAvailableLevelAndAddsToMerciesAbility() { var mercies = new Mercy[] { new Mercy("Mercy 1", 3), new Mercy("Mercy 2", 3), new Mercy("Mercy 3", 6), new Mercy("Mercy 4", 6) }; var character = CharacterTestTemplates.Paladin(); character.SetLevel(5); var process = new SelectMercy(EntityGateway <Mercy> .LoadFromList(mercies)); process.ExecuteStep(character); process.ExecuteStep(character); var selected = character.Get <Mercies>(); Assert.Equal(selected.MercyList.Count, 2); Assert.Equal(selected.MercyList[0].Level, 3); Assert.Equal(selected.MercyList[1].Level, 3); Assert.NotEqual(selected.MercyList[0].Name, selected.MercyList[1].Name); }
public CharacterStrategyTests() { var list = CharacterBuildYaml.ParseYaml().Load <CharacterStrategy>(); strategies = EntityGateway <CharacterStrategy> .LoadFromList(list); }
public NameInformationTests() { gateway = EntityGateway <NameInformation> .LoadFromList(CharacterNamesTestData.ParseYaml().Load <NameInformation>()); }
public ArmorTests() { gateway = EntityGateway <Armor> .LoadFromList(ArmorYamlFile.ParseYaml().Load <Armor>()); }