GambleItem GetRandomItem() { string rarityName = GetRandomRarity(); string itemName = GetRandomItemOfRarityClass(rarityName); GambleRarityClass rarity = LookUpRarityClass(rarityName); return(LookUpItem(itemName, rarity)); }
GambleRarityClass LookUpRarityClass(string classKey) { if (RarityClasses.ContainsKey(classKey)) { GambleRarityClass rc = new GambleRarityClass(); var rClass = (Dictionary <string, object>)RarityClasses[classKey]; rc.name = Convert.ToString(rClass["name"]); rc.color = Convert.ToString(rClass["color"]); rc.chance = Convert.ToInt32(rClass["chance"]); rc.items = (List <object>)rClass["items"]; return(rc); } else { PrintWarning($"Could not find rarity {classKey}"); return(null); } }
GambleItem LookUpItem(string itemKey, GambleRarityClass rClass) { if (Items.ContainsKey(itemKey)) { GambleItem gi = new GambleItem(); var item = (Dictionary <string, object>)Items[itemKey]; gi.itemID = Convert.ToInt32(item["itemid"]); gi.itemImg = Convert.ToString(item["img"]); gi.itemName = Convert.ToString(item["name"]); gi.skinID = Convert.ToInt32(item["skinid"]); gi.color = rClass.color; return(gi); } else { PrintWarning($"Could not find item {itemKey}"); return(null); } }