public void ChoosingClassFromWeightedOptionTableSelectsFromThoseClasses() { var character = new CharacterSheet(CharacterStrategy.Default()); var choices = new WeightedOptionTable <string>(); choices.AddEntry("Fighter", 10); subject.ChooseClass(character, choices); Assert.Equal("Fighter", character.Class.Name); }
public WeightedOptionTable <Homeland> GetRacialOptions(string race) { var table = new WeightedOptionTable <Homeland>(); var options = homelands.Where(x => string.Equals(x.Race, race, StringComparison.OrdinalIgnoreCase)); foreach (var opt in options) { table.AddEntry(opt, opt.Weighting); } return(table); }
public WeightedOptionTable <ClassOrigin> GetClassOriginOptions(string cls) { var table = new WeightedOptionTable <ClassOrigin>(); var origins = classOrigins.Where(x => string.Equals(x.Class, cls, StringComparison.OrdinalIgnoreCase)); foreach (var origin in origins) { table.AddEntry(origin, origin.Weighting); } return(table); }
private void FillInMissingAbilities(WeightedOptionTable <AbilityScoreTypes> abilityTable) { //build empty table foreach (var a in EnumHelpers.GetValues <AbilityScoreTypes>()) { if (!abilityTable.HasOption(a)) { abilityTable.AddEntry(a, 1); } } }
public ClassOriginGroup(IObjectStore data) { Origins = new WeightedOptionTable <ClassOrigin>(); Name = data.GetString("class"); var table = data.GetObjectList("table"); foreach (var entry in table) { var origin = new ClassOrigin(Name, entry); Origins.AddEntry(origin, origin.Weighting); } }
private void ParseYaml(YamlNodeWrapper yaml) { drawbacks = new WeightedOptionTable <Drawback>(); foreach (var node in yaml.Children()) { var drawback = new Drawback(); drawback.Name = node.GetString("name"); drawback.Weighting = node.GetInteger("weight"); drawback.Traits.Add(node.GetCommaStringOptional("traits")); drawbacks.AddEntry(drawback, drawback.Weighting); } }
public HomelandGroup(IObjectStore data) { Homelands = new WeightedOptionTable <Homeland>(); Name = data.GetString("race"); var table = data.GetObjectList("table"); foreach (var entry in table) { var homeland = new Homeland(Name, entry); Homelands.AddEntry(homeland, homeland.Weighting); } }
private void BuildAbilityTable(WeightedOptionTable <AbilityScoreTypes> abilityTable, IEnumerable <IObjectStore> nodes) { if (nodes != null) { foreach (var child in nodes) { abilityTable.AddEntry(child.GetEnum <AbilityScoreTypes>("name"), child.GetInteger("weight")); } } FillInMissingAbilities(abilityTable); }
public void IfAllPreferredSkillsAreMaxedAssignAPointToRemainingClassSkills() { var strategy = new WeightedOptionTable <string>(); strategy.AddEntry("Climb", 1); //Set Knowledge (Arcana) as a class skill skills.SetClassSkill("Knowledge (Arcana)"); distributor.AssignSkillPoints(skills, strategy, 2, 1); Assert.Equal(1, skills.GetSkill("Climb").Ranks); Assert.Equal(1, skills.GetSkill("Knowledge (Arcana)").Ranks); }
public void DisabledEntriesCanBeReenabled() { var table = new WeightedOptionTable <string>(); table.AddEntry("Foo", 483); var entry = table.All.First(); var originalMax = entry.MaximumValue; table.Disable("Foo"); Assert.True(entry.Disabled); table.Enable("Foo"); Assert.False(entry.Disabled); Assert.Equal(originalMax, entry.MaximumValue); }
public void RandomlySelectsOptionBasedOnWeightedValue() { var table = new WeightedOptionTable<string>(); table.AddEntry("Foo", 30); table.AddEntry("Bar", 10); var foo = 0; var bar = 0; // Run ten thousand times and it should select FOO a few more times for (int i = 0; i < 10000; i++) { string option = table.ChooseRandomly(); if (option == "Foo") { foo++; } else { bar++; } } }