Exemplo n.º 1
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);
        }
Exemplo n.º 2
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}"));
        }
Exemplo n.º 3
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!");
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }