Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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"));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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 });
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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]));
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        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)
            );


        }
Ejemplo n.º 25
0
        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 })
                );
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        public CharacterStrategyTests()
        {
            var list = CharacterBuildYaml.ParseYaml().Load <CharacterStrategy>();

            strategies = EntityGateway <CharacterStrategy> .LoadFromList(list);
        }
Ejemplo n.º 28
0
 public NameInformationTests()
 {
     gateway = EntityGateway <NameInformation> .LoadFromList(CharacterNamesTestData.ParseYaml().Load <NameInformation>());
 }
Ejemplo n.º 29
0
 public ArmorTests()
 {
     gateway = EntityGateway <Armor> .LoadFromList(ArmorYamlFile.ParseYaml().Load <Armor>());
 }