static Dice() { rand = new RNGCryptoServiceProvider(); AdvantageTypes = new SortableBindingList <AdvantageType>(); AdvantageTypes.Add(new AdvantageType { RollType = RollType.Normal, RollTypeName = "Normal" }); AdvantageTypes.Add(new AdvantageType { RollType = RollType.Advantage, RollTypeName = "Advantage" }); AdvantageTypes.Add(new AdvantageType { RollType = RollType.Disadvantage, RollTypeName = "Disadvantage" }); }
static LootDataTables() { var bytes = LootData.loot; var stream = new MemoryStream(bytes, false); var reader = new JsonTextReader(new StreamReader(stream)); tables = JsonSerializer.Create().Deserialize <LootTables>(reader); LootTypes = new SortableBindingList <LootTypeDescription>(); LootTypes.Add(new LootTypeDescription { Type = LootType.Money, Description = "Money" }); LootTypes.Add(new LootTypeDescription { Type = LootType.ArtObjects, Description = "Art Object" }); LootTypes.Add(new LootTypeDescription { Type = LootType.Gemstones, Description = "Gem Stone" }); LootTypes.Add(new LootTypeDescription { Type = LootType.MagicItems, Description = "Magic Item" }); }
public SortableBindingList <Monster> SearchForMonsters(string name) { SortableBindingList <Monster> result = new SortableBindingList <Monster>(); name = name.Trim().ToUpper().StripPunctuation(); //This isn't very efficient, but it should work for now foreach (var monster in FilterDic.Keys) { if (monster.Contains(name)) { result.Add(GetMonster(FilterDic[monster])); } } return(result); }
public void LoadMonsters() { Type resType = Type.GetType("CampaignData.BookData"); PropertyInfo[] resProps = resType.GetProperties(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetProperty); Monsters = new SortableBindingList <Monster>(); foreach (PropertyInfo info in resProps) { var value = info.GetValue(null, null); if (value is byte[]) { byte[] bytes = (byte[])value; var stream = new MemoryStream(bytes, false); var reader = new JsonTextReader(new StreamReader(stream)); var loadedmon = JsonSerializer.Create().Deserialize <List <Monster> >(reader); Monsters.AddRange(loadedmon); } } //Append the custom monsters if (customMonsters != null) { foreach (var monster in customMonsters) { Monsters.Add(monster); } } //Build our quick filtering dictionary FilterDic = new Dictionary <string, string>(); foreach (var monster in Monsters) { if (!FilterDic.ContainsKey(monster.Name.StripPunctuationAndSpaces().ToUpper())) { FilterDic.Add(monster.Name.StripPunctuationAndSpaces().ToUpper(), monster.Name); } } }