예제 #1
0
 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"
     });
 }
예제 #2
0
        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"
            });
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
                }
            }
        }