public IActionResult Character(string strategy, int level, string scores) { var build = strategyGateway.Find(strategy); var roller = GatewayProvider.Find <AbilityScoreGenerator>(scores); build.TargetLevel = level; build.AbilityScoreRoller = roller.Generator; var gen = GatewayProvider.Find <CharacterDesigner>(build.Designer); var character = new CharacterSheet(build); gen.ExecuteStep(character); ViewData["character"] = new CharacterSheetTextView(character); ViewData["characterFull"] = character; ViewData["strategy"] = strategy; ViewData["scores"] = scores; ViewData["level"] = level; var saveObj = new YamlObjectStore(); character.Save(saveObj); ViewData["save-data"] = saveObj.WriteToString(); return(View()); }
public void YouCanAccessASpecificSetOfArmor() { var leather = gateway.Find("Leather Armor"); Assert.NotNull(leather); Assert.Equal("Leather Armor", leather.Name); var plate = gateway.Find("Full Plate"); Assert.NotNull(plate); Assert.Equal("Full Plate", plate.Name); }
public void ExecuteStep(CharacterSheet character) { var storyTemplate = descriptors.Find("character-appearance").Words.ChooseOne(); var expansion = new PhraseTemplate(storyTemplate); character.Appearance.Description = expansion.WritePhrase(new CharacterContext(character)); }
private void UseStartingWealthTable(CharacterSheet character) { var table = wealthGateway.Find("adventurer"); var wealth = table.Levels.First(x => x.Level == character.Level); character.Inventory.CoinPurse.SetValue(wealth.Value); }
public IEnumerable <string> GetSpells(int level, IEnumerable <ISpellCastingRule> rules) { return(GetAllSpells(level) .Where(spellName => rules.All(rule => rule.CanCastSpell(spellInformation.Find(spellName))) )); }
public void ExecuteStep(CharacterSheet character) { var configure = setups.Find("default"); character.Components.AddNoInitialize(new object[] { configure }); character.InitializeComponents(); character.SkillRanks.FillSkills(skills.All()); }
public void ExecuteStep(CharacterSheet character) { var storyTemplate = descriptors.Find("background-story").Words.ChooseOne(); var expansion = new PhraseTemplate(storyTemplate); var story = new BackgroundStory(expansion.WritePhrase(new CharacterContext(character))); character.Add(story); }
private CharacterDesigner FindDesigner(string name) { if (gateway == null) { gateway = GatewayProvider.Get <CharacterDesigner>(); } return(gateway.Find(designerName)); }
public IPotion Process() { var list = spellLists.Where(x => classes.Any(cls => x.Matches(cls))).ChooseOne(); var spellLevel = list.FilterByMaxLevel(maxSpellLevel).ChooseOne(); var spellName = spellLevel.Value.ChooseOne(); var spell = spells.Find(spellName); var value = 5000 * (spellLevel.Key) * (spellLevel.Key + spellLevel.Key - 1); var potion = new Potion(spell, value); return(potion); }
public Wand Process() { // choose from available spell Lists. var list = spellLists.Where(x => classes.Any(cls => x.Matches(cls))).ChooseOne(); var spellLevel = Randomly.Range(list.GetLowestSpellLevel(), list.GetHighestSpellLevel()); var spellName = list.GetAllSpells(spellLevel).ChooseOne(); var spell = spells.Find(spellName); var value = 75000 * (spellLevel) * (spellLevel + spellLevel - 1); var wand = new Wand(spell, 50, value); return(wand); }
public IActionResult Settlement(string strategy) { var strat = strategyGateway.Find(strategy); var settlement = new Settlement(strat); var settlementBuilder = GatewayProvider.Find <SettlementDesigner>("create-settlement"); settlementBuilder.Execute(settlement); this.ViewData["settlement"] = settlement; this.ViewData["strategy"] = strategy; return(this.View()); }
public void ChooseClass(CharacterSheet character, WeightedOptionTable <string> classChoices) { if (classChoices.IsEmpty) { ChooseAny(character); return; } var choice = classChoices.ChooseRandomly(); var cls = classes.Find(choice); AssignClass(character, cls); }
private void ChooseRace(CharacterSheet character, WeightedOptionTable <string> options) { if (options.IsEmpty) { this.SetRace(character, raceGateway.All().ToList().ChooseOne()); return; } var choice = options.ChooseRandomly(); var race = raceGateway.Find(choice); this.SetRace(character, race); }
public SpellCasting(IObjectStore configuration, EntityGateway <SpellList> spellLists) { this.SpellListName = configuration.GetString("list"); this.SpellList = spellLists.Find(this.SpellListName); this.SpellType = configuration.GetEnum <SpellType>("spell-type"); this.castingAbilityType = configuration.GetEnum <AbilityScoreTypes>("casting-ability"); var slots = configuration.GetObject("spell-slots"); foreach (var slot in slots.Keys) { var spellCounts = slots.GetList(slot).Select(x => x.ToInteger()).ToArray(); spellSlots.Add(slot.ToInteger(), spellCounts); } }
private void SelectFeats(CharacterSheet character, WeightedOptionTable <string> preferredFeats) { foreach (var token in character.GetAndRemoveAll <FeatToken>()) { FilterPreferredFeats(character, preferredFeats, token); Feat feat; if (preferredFeats.IsEmpty) { var feats = this.feats.Where(x => FeatIsValid(x, token, character)); if (feats.HasChoices() == false) { throw new CharacterGeneratorStepFailedException(this, "Could not choose feat from token ({0})".Formatted(token.ToString())); } feat = feats.ChooseOne(); } else { var selection = preferredFeats.ChooseRandomly(); feat = feats.Find(selection); } character.Add(feat); } }
public void LoadsWeightedTablesForRacesAndClasses() { var archer = strategies.Find("Archer"); Assert.Equal(10, archer.Races.All.First().MaximumValue); Assert.Equal("elf", archer.Races.All.First().Option); Assert.Equal(10, archer.Classes.All.First().MaximumValue); Assert.Equal("Fighter", archer.Classes.All.First().Option); }
public void ExecuteStep(CharacterSheet character) { character.Age = RandomAge(character.Class.ClassDevelopmentAge, maturityGateway.Find(character.Race.Name)); }