Exemplo n.º 1
0
        void ChugPotion(ItemInst item)
        {
            if (item == null)
            {
                return;
            }

            int hp = this.HP + 50;

            this.SetHealth(hp > HPMax ? HPMax : hp);
            if (item.IsEquipped)
            {
                this.UnequipItem(item);
            }
            item.SetAmount(item.Amount - 1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new item from the old item with the given amount and reduces the old item's amount.
        /// </summary>
        /// <param name="amount"></param>
        /// <returns></returns>
        public ItemInst Split(int amount)
        {
            if (amount <= 0 || this.Amount <= 0)
            {
                return(null);
            }

            int newAmount = this.Amount - amount;

            if (newAmount > 0)
            {
                this.SetAmount(newAmount);
                // split item
                ItemInst newItem = new ItemInst(this.Definition);
                newItem.SetAmount(amount);
                return(newItem);
            }
            else
            {
                this.Remove();
                return(this);
            }
        }