Example #1
0
        public void BreaksDescriptionIntoIndividualComponentsForMoreFlexibleDescriptions()
        {
            // Set up Descriptors
            var descs = new MemoryStore();

            descs.AddListItem(new MemoryStore("pattern", new string[] { "dragon" }));
            descs.AddListItem(new MemoryStore("color", new string[] { "black" }));

            // Set up Templates
            var temps = new MemoryStore();

            temps.AddListItem(new MemoryStore("template", "{{feature}} of a {{descriptor \"color\"}} {{descriptor \"pattern\"}}."));

            // Set up physical Feature
            var mem = new MemoryStore();

            mem.SetValue("name", "tattoo");
            mem.SetValue("descriptors", descs);
            mem.SetValue("templates", temps);
            var phys = new PhysicalFeature(mem);

            var gateway = EntityGateway <PhysicalFeature> .LoadWithSingleItem(phys);

            var subject = new CreatePhysicalFeatures(gateway);

            var character = new CharacterSheet(CharacterStrategy.Default());

            character.Gender = Gender.Female;

            subject.ExecuteStep(character);

            Assert.Equal(character.Appearance.PhysicalAppearance, "Tattoo of a black dragon.");
        }
Example #2
0
        public void NeedToBeProficientWithAtLeastOneWeapon()
        {
            var longsword = new Weapon("Longsword", 1, "1d6", DamageTypes.Slashing, 20, 2, 0, WeaponType.OneHanded, WeaponGroup.HeavyBlades, WeaponTrainingLevel.Simple);
            var list      = EntityGateway <Weapon> .LoadWithSingleItem(longsword);

            var character   = CharacterTestTemplates.AverageBob();
            var weaponFocus = WeaponFocus.CreateForTesting(list);

            Assert.False(weaponFocus.IsQualified(character));
        }
Example #3
0
        public SpellCastingTests()
        {
            spellList = SpellList.CreateForTesting("bard");
            spellList.Add(1, "magic missile");
            var gateway = EntityGateway <SpellList> .LoadWithSingleItem(spellList);

            bard         = CharacterTestTemplates.BardyBard();
            spellCasting = new SpellCasting(configuration, gateway);
            bard.Add(spellCasting);
        }
Example #4
0
        public void DonotBuyThingsYouCannotAfford()
        {
            var clothes  = new Clothes("Outfit", 2000, 5);
            var purchase = new PurchaseClothing(EntityGateway <Clothes> .LoadWithSingleItem(clothes));
            var bob      = CharacterTestTemplates.AverageBob();

            bob.Inventory.CoinPurse.AddGold(1);

            purchase.ExecuteStep(bob);
            Assert.Null(bob.Inventory.Find(clothes));
        }
Example #5
0
        public void SelectsABackgroundStoryToGenerate()
        {
            var backgroundStoryTemplate = new Descriptor("background-story", new string[] { "{{name}} was born in a shack." });
            var writer    = new BackgroundStorywriter(EntityGateway <Descriptor> .LoadWithSingleItem(backgroundStoryTemplate));
            var character = new CharacterSheet(CharacterStrategy.Default());

            character.FirstName = "Foo";

            writer.ExecuteStep(character);
            Assert.Equal("Foo was born in a shack.", character.Get <BackgroundStory>().GetStory());
        }
Example #6
0
        public void ChoosingADescriptorLoadsFromGatewayDescriptorsMatchingName()
        {
            var color   = new Descriptor("color", new string[] { "Red" });
            var gateway = EntityGateway <Descriptor> .LoadWithSingleItem(color);

            var choose             = ChooseDescriptor.CreateIsolatedForUnitTesting(gateway, "choose-testing");
            var handleBarsTemplate = Handlebars.Compile("{{choose-testing \"color\"}}");
            var result             = handleBarsTemplate(string.Empty);

            Assert.Equal("Red", result);
        }
Example #7
0
        public void ChoosesFromListOfOptionsAndAssignsToHistory()
        {
            var circumstance = new BirthCircumstance("Nothing exciting", 10);
            var character    = CharacterTestTemplates.AverageBob();
            var subject      = new BirthCircumstanceSelector(EntityGateway <BirthCircumstance> .LoadWithSingleItem(circumstance));

            subject.ExecuteStep(character);
            var history = character.Get <History>();

            Assert.Equal(circumstance, history.BirthCircumstance);
        }
Example #8
0
        public PurchaseShieldTests()
        {
            shield           = new Armor();
            shield.ArmorType = ArmorType.Shield;
            gateway          = EntityGateway <Armor> .LoadWithSingleItem(shield);

            proficientCharacter = CharacterTestTemplates.AverageBob();
            proficientCharacter.Defense.AddArmorProficiencies(new string[] { "shield" });
            incapableCharacter = CharacterTestTemplates.AverageBob();

            subject = new PurchaseShield(gateway);
        }
Example #9
0
 public SpontaneousCastingTests()
 {
     spellList = SpellList.CreateForTesting("bard");
     spellList.Add(0, "cantrip1");
     spellList.Add(0, "cantrip2");
     spellList.Add(1, "level1.1");
     spellList.Add(1, "level1.2");
     spellList.Add(2, "level2.1");
     spellList.Add(2, "level2.2");
     bard         = CharacterTestTemplates.BardyBard();
     spellCasting = new SpontaneousCasting(configuration, EntityGateway <SpellList> .LoadWithSingleItem(spellList));
     bard.Add(spellCasting);
 }
Example #10
0
        public void SelectFromFavoredTerrainList()
        {
            var forest    = new TerrainType("Forest");
            var ctGateway = EntityGateway <TerrainType> .LoadWithSingleItem(forest);

            var configureStep = new SelectFavoredTerrain(ctGateway);
            var character     = new CharacterSheet(CharacterStrategy.Default());

            configureStep.ExecuteStep(character);

            var favTerrain = character.Get <FavoredTerrain>();

            Assert.Contains(forest, favTerrain.TerrainTypes);
        }
Example #11
0
        public void ChoosingAWordAddsToContextIfPossible()
        {
            var color   = new Descriptor("color", new string[] { "Red" });
            var gateway = EntityGateway <Descriptor> .LoadWithSingleItem(color);

            var     choose             = ChooseDescriptor.CreateIsolatedForUnitTesting(gateway, "choose-testing");
            var     handleBarsTemplate = Handlebars.Compile("{{choose-testing \"color\"}}");
            var     context            = new PhraseContext();
            dynamic contextObj         = context.CreateObject();
            var     result             = handleBarsTemplate(contextObj);

            Assert.Equal("Red", context.GetValue <string>("color"));
            Assert.Equal("Red", contextObj.color);
        }
Example #12
0
        public void FlagAsUnqualifiedIfAlreadyHasWeaponFocus()
        {
            var longsword = new Weapon("Longsword", 1, "1d6", DamageTypes.Slashing, 20, 2, 0, WeaponType.OneHanded, WeaponGroup.HeavyBlades, WeaponTrainingLevel.Simple);
            var list      = EntityGateway <Weapon> .LoadWithSingleItem(longsword);

            var weaponFocus = WeaponFocus.CreateForTesting(list);
            var bob         = CharacterTestTemplates.AverageBob();

            bob.Offense.AddWeaponProficiency("simple");
            bob.Add(weaponFocus);
            var newFocus = WeaponFocus.CreateForTesting(list);

            Assert.False(newFocus.IsQualified(bob));
        }
Example #13
0
        public void ChooseFromFavoredEnemyList()
        {
            var aberration = new CreatureType("Aberration");
            var ctGateway  = EntityGateway <CreatureType> .LoadWithSingleItem(aberration);

            var configureStep = new SelectFavoredEnemy(ctGateway);
            var character     = new CharacterSheet(CharacterStrategy.Default());

            configureStep.ExecuteStep(character);

            var favEnemy = character.Get <FavoredEnemy>();

            Assert.Contains(aberration, favEnemy.CreatureTypes);
        }
Example #14
0
        public void RegistersHelperForSelectingGatewayObject()
        {
            var red = new Color();

            red.Name = "Red";
            var gateway = EntityGateway <Color> .LoadWithSingleItem(red);

            var helper = new ChooseWordFromGatewayObject <Color>(gateway);

            var handleBarsTemplate = Handlebars.Compile("{{choose-color}}");
            var result             = handleBarsTemplate(string.Empty);

            Assert.Equal("Red", result);
        }
Example #15
0
        public void IfNoTemplateOrLocationJustDoesASimpleFormat()
        {
            var mem = new MemoryStore();

            mem.SetValue("name", "crooked nose");
            var phys    = new PhysicalFeature(mem);
            var gateway = EntityGateway <PhysicalFeature> .LoadWithSingleItem(phys);

            var subject   = new CreatePhysicalFeatures(gateway);
            var character = new CharacterSheet(CharacterStrategy.Default());

            subject.ExecuteStep(character);

            Assert.Equal(character.Appearance.PhysicalAppearance, "He has a crooked nose.");
        }
Example #16
0
        public void ExecutesTheDesignerRequested()
        {
            var build        = new CharacterStrategy();
            var character    = new CharacterSheet(build);
            var mockDesigner = new Mock <CharacterDesigner>();

            // Set up a character designer
            mockDesigner.Setup(x => x.ExecuteStep(character));
            mockDesigner.Setup(x => x.Matches("hello")).Returns(true);
            var gateway = EntityGateway <CharacterDesigner> .LoadWithSingleItem(mockDesigner.Object);

            var executer = new DesignerExecuterStep("hello", gateway);

            executer.ExecuteStep(character);
            mockDesigner.VerifyAll();
        }
Example #17
0
        public void WandsGetMoreExpensiveWithLevels(int level, int expectedValue)
        {
            var spellList = SpellList.CreateForTesting("wizard");

            spellList.Add(level, "Cure Light Wounds");
            var cure         = new Spell("Cure Light Wounds", "healing");
            var spellGateway = EntityGateway <Spell> .LoadWithSingleItem(cure);

            var spellListGateway = EntityGateway <SpellList> .LoadWithSingleItem(spellList);

            var createwands = new WandCreator(spellGateway, spellListGateway);

            var wand = createwands.Process();

            Assert.Equal(expectedValue, wand.Value);
        }
Example #18
0
        public void HavingWeaponFocusIncreasesAttackBonusByOne()
        {
            var longsword = new Weapon("Longsword", 1, "1d6", DamageTypes.Slashing, 20, 2, 0, WeaponType.OneHanded, WeaponGroup.HeavyBlades, WeaponTrainingLevel.Simple);
            var list      = EntityGateway <Weapon> .LoadWithSingleItem(longsword);

            var weaponFocus = WeaponFocus.CreateForTesting(list);

            var bob = CharacterTestTemplates.AverageBob();

            bob.Offense.AddWeaponProficiency("simple");
            bob.Add(weaponFocus);
            bob.Inventory.EquipItem(longsword);
            var attackStats = bob.Offense.GetAttack(longsword);

            Assert.Equal(1, attackStats.AttackBonus.TotalValue);
        }
Example #19
0
        public void SelectsFromALimitedListOfDomains()
        {
            var airDomain = DomainTemplates.AirDomain();

            var configure = new MemoryStore();

            configure.SetValue("domain-options", new string[] { "Air" });
            var chooser = new SelectNaturesBond(configure, EntityGateway <Domain> .LoadWithSingleItem(airDomain));


            var donna = CharacterTestTemplates.DruidDonna();

            chooser.ExecuteStep(donna);

            Assert.Equal(airDomain, donna.Get <Domain>());
        }
Example #20
0
        public void SelectAPotionFromAListOfSpellsAndChargesProperly(int level, int value)
        {
            var spellList = SpellList.CreateForTesting("cleric");

            spellList.Add(level, "Cure Light Wounds");
            var cureSpell  = new Spell("Cure Light Wounds", "healing");
            var spellLists = EntityGateway <SpellList> .LoadWithSingleItem(spellList);

            var spells = EntityGateway <Spell> .LoadWithSingleItem(cureSpell);

            var potionCreator = new PotionCreator(spellLists, spells);
            var potion        = potionCreator.Process();

            Assert.Equal(cureSpell, potion.Spell);
            Assert.Equal(value, potion.Value);
        }
Example #21
0
        public void SelectsAnEnergyTypeToGenerateResistanceTo()
        {
            var wizard     = CharacterTestTemplates.Wizard();
            var energyType = new EnergyType();

            energyType.Name = "fire";
            var abjRes = new AbjurationResistance(EntityGateway <EnergyType> .LoadWithSingleItem(energyType));

            wizard.Add(abjRes);
            AssertCharacter.HasDamageResistance("fire", 5, wizard);

            wizard.SetLevel(11);
            AssertCharacter.HasDamageResistance("fire", 10, wizard);

            wizard.SetLevel(20);
            AssertCharacter.IsImmuneTo("fire", wizard);
        }
Example #22
0
        public void AddSomeWeightingToSkillsTableForParentOccupation()
        {
            var bob = CharacterTestTemplates.AverageBob().OfRace("Human");

            bob.History.BirthCircumstance.ParentProfessions = new string[] { "lower-class" };

            var peasant = new Occupation("peasant", "commoner", new string[] { "lower-class" });

            peasant.Skills = new string[] { "Perception" };
            var occGateway = EntityGateway <Occupation> .LoadWithSingleItem(peasant);

            var historyCreator = new FamilyHistoryCreator(occGateway);

            historyCreator.ExecuteStep(bob);

            Assert.True(bob.Strategy.FavoredSkills.HasOption("Perception"));
        }
Example #23
0
        public void MotherAndFatherAreGivenJobsDependingOnTagsFromBirthCircumstance()
        {
            //Bob's parents were lower-class
            var bob = CharacterTestTemplates.AverageBob().OfRace("Human");

            bob.History.BirthCircumstance.ParentProfessions = new string[] { "lower-class" };

            var peasant    = new Occupation("peasant", "commoner", new string[] { "lower-class" });
            var occGateway = EntityGateway <Occupation> .LoadWithSingleItem(peasant);

            var historyCreator = new FamilyHistoryCreator(occGateway);

            historyCreator.ExecuteStep(bob);

            Assert.Equal(peasant, bob.Get <History>().FamilyTree.Father.Get <Occupation>());
            Assert.Equal(peasant, bob.Get <History>().FamilyTree.Mother.Get <Occupation>());
        }
Example #24
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);
        }
Example #25
0
        public void WandsUtilizeAvailableListsToMakeWandsThatMakeSense()
        {
            var spellList = SpellList.CreateForTesting("wizard");

            spellList.Add(1, "Cure Light Wounds");
            var cure         = new Spell("Cure Light Wounds", "healing");
            var spellGateway = EntityGateway <Spell> .LoadWithSingleItem(cure);

            var spellListGateway = EntityGateway <SpellList> .LoadWithSingleItem(spellList);

            var createwands = new WandCreator(spellGateway, spellListGateway);

            var wand = createwands.Process();

            Assert.Equal(cure, wand.Spell);
            Assert.Equal(50, wand.Charges);
            Assert.Equal(75000, wand.Value);
        }
Example #26
0
        public static CharacterSheet WithWizardCasting(this CharacterSheet character)
        {
            var spellcastingConfigurationYaml = @"---
list: " + character.Class.Name + @"
spell-type: arcane
casting-ability: intelligence
spell-slots:
  1: [3, 2]
  2: [4, 3]
  3: [4, 3, 2]
";
            var spellList = CreateGenericSpellList(character.Class.Name);
            var casting   = new WizardCasting(
                spellcastingConfigurationYaml.ParseYaml(),
                EntityGateway <SpellList> .LoadWithSingleItem(spellList)
                );

            character.Add(casting);

            return(character);
        }
Example #27
0
        public static CharacterSheet WithSpontaneousCasting(this CharacterSheet character, int spellsPerLevel)
        {
            var spellcastingConfigurationYaml = @"---
list: " + character.Class.Name + @"
spell-type: arcane
casting-ability: charisma
spell-slots:
  1: [4, 1]
  2: [5, 2]
  3: [6, 3, 2]
spells-known:
  1: [4, 2]
  2: [5, 3]
  3: [6, 4, 1]
";
            var spellcastingConfiguration     = spellcastingConfigurationYaml.ParseYaml();
            var spellList    = CreateGenericSpellList(character.Class.Name, spellsPerLevel);
            var spellCasting = new SpontaneousCasting(spellcastingConfiguration, EntityGateway <SpellList> .LoadWithSingleItem(spellList));

            character.Add(spellCasting);
            return(character);
        }
Example #28
0
        public void UsesDescriptorsIfAvailable()
        {
            var descs = new MemoryStore();

            descs.AddListItem(new MemoryStore("descriptor", new string[] { "dragon" }));
            var mem = new MemoryStore();

            mem.SetValue("name", "tattoo");
            mem.SetValue("descriptors", descs);
            var phys = new PhysicalFeature(mem);

            var gateway = EntityGateway <PhysicalFeature> .LoadWithSingleItem(phys);

            var subject = new CreatePhysicalFeatures(gateway);

            var character = new CharacterSheet(CharacterStrategy.Default());

            character.Gender = Gender.Female;

            subject.ExecuteStep(character);

            Assert.Equal(character.Appearance.PhysicalAppearance, "She has a dragon tattoo.");
        }
Example #29
0
 public ConfigureSummonFamiliarTests()
 {
     bat     = new Familiar("Bat");
     subject = new ConfigureSummonFamiliar(EntityGateway <Familiar> .LoadWithSingleItem(bat));
 }
Example #30
0
        public void ThrowsNotFoundExceptionIfObjectIsnotFound()
        {
            var gateway = EntityGateway <TestObject> .LoadWithSingleItem(new TestObject("Bar"));

            Assert.Throws(typeof(EntityNotFoundException), () => { gateway.Find("Foo"); });
        }