예제 #1
0
        /// <summary>
        /// Sets the quality of an item.
        /// </summary>
        /// <param name="owner">The owner of the item.</param>
        /// <param name="quality">The quality to set.</param>
        /// <returns>True if the quality was set, false if the quality is below the current quality.</returns>
        public bool SetQuality(Models.Entities.Player owner, Enums.ItemQuality quality)
        {
            byte qualityValue = ((byte)quality);

            if (qualityValue < ((byte)Quality))
            {
                return(false);
            }

            if (IsSteed || IsGarment || IsArrow || IsBottle || IsMountArmor || IsMisc)
            {
                return(false);
            }

            uint newItemId = (uint)DbItem.Id;

            while ((newItemId % 10) > 5)
            {
                newItemId--;
            }

            newItemId += (uint)(qualityValue - 5);

            if (!Collections.ItemCollection.Contains(newItemId))
            {
                return(false);
            }

            var newItem = Collections.ItemCollection.CreateItemById(newItemId);

            if (newItem == null)
            {
                return(false);
            }

            if (newItem.DbItem.Name != DbItem.Name)
            {
                return(false);
            }

            DbItem = newItem.DbItem;
            if (DbOwnerItem == null)
            {
                DbOwnerItem             = new Database.Models.DbOwnerItem();
                DbOwnerItem.MaxDura     = DbItem.Amount;
                DbOwnerItem.CurrentDura = DbOwnerItem.MaxDura;
                Gem1 = Enums.Gem.NoSocket;
                Gem2 = Enums.Gem.NoSocket;
            }
            DbOwnerItem.ItemId = (uint)DbItem.Id;

            if (owner != null)
            {
                UpdateClient(owner, Enums.ItemUpdateAction.Update);
                owner.UpdateBaseStats();
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Upgrades the quality of the item.
        /// </summary>
        /// <param name="owner">The owner of the item.</param>
        /// <returns>True if the item's quality was upgraded, false if the quality is super.</returns>
        public bool UpgradeQuality(Models.Entities.Player owner)
        {
            if (IsSteed || IsGarment || IsArrow || IsBottle || IsMountArmor || IsMisc ||
                Quality == Enums.ItemQuality.Super)
            {
                return(false);
            }

            uint newItemId = (uint)DbItem.Id;

            if (((byte)Quality) >= 5)
            {
                newItemId++;
            }
            else
            {
                while ((newItemId % 10) < 6)
                {
                    newItemId++;
                }
            }

            if (!Collections.ItemCollection.Contains(newItemId))
            {
                return(false);
            }

            var newItem = Collections.ItemCollection.CreateItemById(newItemId);

            if (newItem == null)
            {
                return(false);
            }

            DbItem = newItem.DbItem;
            if (DbOwnerItem == null)
            {
                DbOwnerItem             = new Database.Models.DbOwnerItem();
                DbOwnerItem.MaxDura     = DbItem.Amount;
                DbOwnerItem.CurrentDura = DbOwnerItem.MaxDura;
                Gem1 = Enums.Gem.NoSocket;
                Gem2 = Enums.Gem.NoSocket;
            }
            DbOwnerItem.ItemId = (uint)DbItem.Id;

            if (owner != null)
            {
                UpdateClient(owner, Enums.ItemUpdateAction.Update);
                owner.UpdateBaseStats();
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Upgrades the level of the item.
        /// </summary>
        /// <param name="owner">The owner of the item.</param>
        /// <returns>True if the item was upgraded, false if the item has no more levels.</returns>
        public bool UpgradeLevel(Models.Entities.Player owner)
        {
            if (IsSteed || IsGarment || IsArrow || IsBottle || IsFan || IsTower || IsMountArmor || IsMisc)
            {
                return(false);
            }

            int id = DbItem.Id;

            while (id % 10 < 5)
            {
                id++;
            }

            if (DbItem.Level == 1 && (IsOneHand || IsBow))
            {
                id = ((DbItem.BaseId * 1000) - 10) + 5;
            }

            uint newItemId = (uint)(id + 10);
            int  loop      = 4;

            while (!Collections.ItemCollection.Contains(newItemId))
            {
                newItemId += 10;
                loop--;
                if (loop <= 0)
                {
                    break;
                }
            }

            if (!Collections.ItemCollection.Contains(newItemId))
            {
                return(false);
            }

            var newItem = Collections.ItemCollection.CreateItemById(newItemId);

            if (newItem == null)
            {
                return(false);
            }

            if (newItem.DbItem.Level <= DbItem.Level || DbItem.Level > 1 && newItem.DbItem.TypeName != DbItem.TypeName)
            {
                return(false);
            }

            DbItem = newItem.DbItem;
            if (DbOwnerItem == null)
            {
                DbOwnerItem             = new Database.Models.DbOwnerItem();
                DbOwnerItem.MaxDura     = DbItem.Amount;
                DbOwnerItem.CurrentDura = DbOwnerItem.MaxDura;
                Gem1 = Enums.Gem.NoSocket;
                Gem2 = Enums.Gem.NoSocket;
            }
            DbOwnerItem.ItemId = (uint)DbItem.Id;

            if (owner != null)
            {
                UpdateClient(owner, Enums.ItemUpdateAction.Update);
                owner.UpdateBaseStats();
            }

            return(true);
        }