Exemplo n.º 1
0
        public static List <uint> ValidateShopSelection()
        {
            List <ShopNode> toReplace = new List <ShopNode>();
            List <uint>     replaced  = new List <uint>();

            foreach (ShopNode i in Shop)
            {
                if (!ItemManager.GetItem(i.ItemID).Buyable)
                {
                    toReplace.Add(i);
                }
            }

            foreach (ShopNode i in toReplace)
            {
                Shop.Remove(i);

                ShopNode t = GetRandomNewSellableItem();

                Shop.Add(t);
                replaced.Add(t.ItemID);
            }

            return(replaced);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method adds an item to the shop.
        /// Precondition: The shop has been cleared.
        /// </summary>
        /// <param name="id">The ID of the item to add</param>
        /// <param name="price">The price of the item</param>
        /// <param name="avail">If the item is available</param>
        public static void AddItem(uint id, int price, bool avail)
        {
            ShopNode sn = new ShopNode(id, price, avail);

            Shop.Add(sn);
        }