/// <summary> /// Opens a virtual CS:GO case, result is sent to Context channel in a method /// </summary> /// <param name="context">Command context used to determine channel to send result</param> /// <returns></returns> public static async Task OpenCase(SocketCommandContext context) { //Test if user has enough credits if (UserCreditsHandler.AddCredits(context, -300) == true) { var result = ItemDropProcessing.CalculateItemCaseRarity(); //Get item var skinItem = ItemDropProcessing.GetItem(result, CsgoDataHandler.rootWeaponSkin, context, false); //Add item to user file inventory var userSkin = XmlManager.FromXmlFile <UserSkinStorageRootobject>(CoreMethod.GetFileLocation("UserSkinStorage.xml")); userSkin.UserSkinEntries.Add(new UserSkinEntry { ClassId = skinItem.Classid, OwnerID = context.Message.Author.Id, UnboxDate = DateTime.UtcNow, MarketName = skinItem.Name }); XmlManager.ToXmlFile(userSkin, CoreMethod.GetFileLocation("UserSkinStorage.xml")); //Send item into await SendOpenedItemInfo(context, skinItem, Convert.ToInt64(skinItem.Price.AllTime.Average), UnboxType.CaseUnboxing); } else { await context.Channel.SendMessageAsync("**" + context.Message.Author.ToString().Substring(0, context.Message.Author.ToString().Length - 5) + ", **You do not have enough credits to unbox a case"); } }
/// <summary> /// virtual CS:GO drop given to user /// </summary> /// <param name="context"></param> /// <returns></returns> public static async Task OpenDrop(SocketCommandContext context) { //Select a rarity, this is slightly modified towards the white side of the spectrum, higher value items are harder to get as this is a drop var rarity = ItemDropProcessing.CalculateItemDropRarity(); //Get item var skinItem = ItemDropProcessing.GetItem(rarity, CsgoDataHandler.rootWeaponSkin, context, true); //Add item to user file inventory var userSkin = XmlManager.FromXmlFile <UserSkinStorageRootobject>(CoreMethod.GetFileLocation("UserSkinStorage.xml")); userSkin.UserSkinEntries.Add(new UserSkinEntry { ClassId = skinItem.Classid, OwnerID = context.Message.Author.Id, UnboxDate = DateTime.UtcNow, MarketName = skinItem.Name }); XmlManager.ToXmlFile(userSkin, CoreMethod.GetFileLocation("UserSkinStorage.xml")); //Send item into await SendOpenedItemInfo(context, skinItem, Convert.ToInt64(skinItem.Price.AllTime.Average), UnboxType.ItemDrop); }