Exemple #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);
        }
Exemple #2
0
        public override MagicArmorAndShield Create(Enums.ItemQuality quality)
        {
            //1. Roll pour avoir l'alteration
            AbstractArmorAndShieldsTableLine secondRoll;

            do
            {
                int alteration = MagicItemCreation.Instance.Dices.d100();

                secondRoll = ArmorCreation.ArmorAndShieldsTable.GetLineFromDice(alteration, quality);
            } while (secondRoll.GetType() != typeof(ArmorTableLine) &&
                     secondRoll.GetType() != typeof(ShieldTableLine));   //On reroll tant qu'on a pas trouvé une ligne qu'on peut utiliser en tant que deuxième roll (si Create existe c'est un cas spécial et donc on ne peut pas l'utiliser)

            MagicArmorAndShield baseArmorAndShield = new MagicArmorAndShield(quality);

            //On ne devrait pas avoir de cas speciaux au deuxieme roll
            baseArmorAndShield.AlterationBonus = secondRoll.AlterationBonus;
            baseArmorAndShield.Type            = (secondRoll.GetType() == typeof(ArmorTableLine)) ? ItemType.Armor : ItemType.Shield;

            //2. Ajout de capa speciale
            //Roll sur la table des capa melee
            int capa = MagicItemCreation.Instance.Dices.d100();
            ArmorAndShieldSpecialAbilitiesTableLine ligne;

            if (baseArmorAndShield.Type == Enums.ItemType.Armor)
            {
                ligne = ArmorSpecialAbilitiesTable.GetLineFromDice(capa, quality);
            }
            else
            {
                ligne = ShieldSpecialAbilitiesTable.GetLineFromDice(capa, quality);
            }

            if (ligne.Modify != null) //Cas speciaux on appelle la fonction pour modifier
            {
                ligne.Modify(baseArmorAndShield);
            }
            else //Sinon on modifie a la main
            {
                baseArmorAndShield.Abilities = new List <String> {
                    ligne.Name
                };
                baseArmorAndShield.BasePriceModifier      = ligne.BasePriceModifier;
                baseArmorAndShield.BaseAlterationModifier = ligne.BaseAlterationModifier;
            }

            //3. On trouve le prix
            baseArmorAndShield.Price  = ArmorCreation.ArmorAndShieldsTable.GetLineFromAlterationBonus(baseArmorAndShield.AlterationBonus + baseArmorAndShield.BaseAlterationModifier).Price;
            baseArmorAndShield.Price += baseArmorAndShield.BasePriceModifier;

            return(baseArmorAndShield);
        }
Exemple #3
0
        public override MagicArmorAndShield Create(Enums.ItemQuality quality)
        {
            int de = MagicItemCreation.Instance.Dices.d100();

            SpecificArmorAndShieldTableLine ligne = SpecificArmorTable.GetLineFromDice(de, quality);

            MagicArmorAndShield armor = new MagicArmorAndShield(quality);

            armor.Name  = ligne.Name;
            armor.Price = ligne.Price;
            armor.Type  = Enums.ItemType.Armor;

            return(armor);
        }
Exemple #4
0
        public void QualityChange(Enums.ItemQuality NewQuality)
        {
            uint ID = Info.ID - (Info.ID % 10);

            ID += (byte)NewQuality;
            if (Kernel.ItemTypes.TryGetValue(ID, out Info))
            {
                writer.Fill(Info.ID, 8);
                if (_plus > 0)
                {
                    if (Kernel.ItemPlusInfos.ContainsKey(Info.ID))
                    {
                        Kernel.ItemPlusInfos[Info.ID].TryGetValue(_plus, out PlusInfo);
                    }
                    else
                    {
                        _plus = 0;
                    }
                }
            }
        }