示例#1
0
        private async Task GiveItem(SocketGuildUser user)
        {
            UserInventoryManager.GetInventory(user.Id).AddItem(ItemId, Count);
            UserInventoryManager.SaveInventories();

            await ReplyAsync(BotUtils.KamtroText($"Successfully given {user.GetDisplayName()} {Count} of {ItemManager.GetItem(ItemId).Name}"));
        }
示例#2
0
        public static async Task <bool> BuyItem(ulong userid, int shopSlot, int quantity)
        {
            if (shopSlot > Shop.Count || shopSlot < 0)
            {
                return(false);
            }

            SocketGuildUser user     = BotUtils.GetGUser(userid);
            UserDataNode    customer = UserDataManager.GetUserData(user);
            ShopNode        item     = Shop[shopSlot];

            if (quantity > 0 && customer.Kamtrokens >= item.Price * quantity)
            {
                customer.Kamtrokens      -= item.Price * quantity;
                customer.KamtrokensSpent += item.Price * quantity;

                UserInventoryManager.GetInventory(userid).AddItem(item.ItemID, quantity);

                await AchievementManager.OnBuy(user);

                UserDataManager.SaveUserData();
                UserInventoryManager.SaveInventories();
                return(true);
            }

            return(false);
        }
示例#3
0
        private void ParseInventory()
        {
            bool save = false;

            List <uint> remove = new List <uint>();

            foreach (uint k in Items.Keys)
            {
                if (Items[k] <= 0)
                {
                    remove.Add(k);
                    save = true;
                }
            }

            foreach (uint k in remove)
            {
                Items.Remove(k);
            }

            if (save)
            {
                UserInventoryManager.SaveInventories();
            }
        }
示例#4
0
        public async Task Use(SocketGuildUser user, SocketCommandContext ctx, params object[] args)
        {
            UserDataManager.GetUserData(user).ReputationToGive += 3; // give rep
            UserInventoryManager.GetInventory(user.Id).LoseItem(Id); // consume the item
            UserInventoryManager.SaveInventories();                  // now save

            await NotifyChannel(ctx, $"{user.GetDisplayName()} used a Breadstick giving them 3 single-use extra rep points to give!");
        }
示例#5
0
        public CraftingEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            User      = BotUtils.GetGUser(ctx);
            Inventory = UserInventoryManager.GetInventory(User.Id);

            CraftItems = GetCraftableItems();

            if (CraftItems.Count > 0)
            {
                SelectedItem = CraftItems[0];
            }

            AddMenuOptions(ReactionHandler.SELECT, ReactionHandler.UP, ReactionHandler.DOWN, ReactionHandler.BACK);
        }
示例#6
0
        /// <summary>
        /// Attempts to craft an item
        /// </summary>
        /// <remarks>
        /// Only saves on successful crafting
        /// </remarks>
        /// <param name="toCraft">The ID of the item to be crafted</param>
        /// <returns>True if crafting was successful, false otherwise</returns>
        public bool TryCraft(uint toCraft)
        {
            Item i = ItemManager.GetItem(toCraft);

            if (i.IsCraftable() && CanCraft(toCraft))
            {
                Craft(toCraft);
                UserInventoryManager.SaveInventories();
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#7
0
        public bool HasItem(uint id)
        {
            if (!Items.ContainsKey(id))
            {
                return(false);
            }

            if (Items[id] <= 0)
            {
                Items.Remove(id);
                UserInventoryManager.SaveInventories();
                return(false);
            }

            return(true);
        }
示例#8
0
        public static bool SellItem(ulong userid, uint itemid, int quantity)
        {
            UserInventoryNode i = UserInventoryManager.GetInventory(userid);

            if (i.ItemCount(itemid) < quantity)
            {
                return(false);
            }

            int total = ItemManager.GetItem(itemid).GetSellPrice() * quantity;

            UserDataManager.GetUserData(BotUtils.GetGUser(userid)).Kamtrokens += total;
            i.LoseItem(itemid, quantity);
            UserDataManager.SaveUserData();
            UserInventoryManager.SaveInventories();
            return(true);
        }
示例#9
0
        public InventoryEmbed(SocketCommandContext ctx)
        {
            SetCtx(ctx);

            User      = BotUtils.GetGUser(ctx);
            UserData  = UserDataManager.GetUserData(User);
            Inventory = UserInventoryManager.GetInventory(User.Id);

            List <uint> Items = Inventory.Items.Keys.ToList();

            Items.Sort();

            if (Items.Count != 0)
            {
                SelectedItem = Items[0];
            }

            AddMenuOptions(ReactionHandler.SELECT, ReactionHandler.BACK, ReactionHandler.UP, ReactionHandler.DOWN);
        }
示例#10
0
 /// <summary>
 /// Called after OnReady. For anything that needs discord user info
 /// </summary>
 private static void SetupGeneral()
 {
     ServerData.SetupServerData(Settings);
     UserInventoryManager.LoadInventories();
     ReminderManager.LoadReminders();
 }