Exemplo n.º 1
0
        /// <summary>
        /// Loses dura when the player is attacked.
        /// </summary>
        /// <param name="damage">The damage.</param>
        public void LoseDefenseDura(uint damage)
        {
            if (Player.Battle != null)
            {
                return;
            }

            if (damage <= 1 && Tools.CalculationTools.ChanceSuccessBig(10) ||
                damage >= (Player.MaxHP / 2) && Tools.CalculationTools.ChanceSuccess(90) ||
                Tools.CalculationTools.ChanceSuccessBig(15))
            {
                Models.Items.Item duraItem = null;
                if (Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Armor, false);
                }

                if (duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Head, false);
                }

                if (duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Necklace, false);
                }

                if (duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Ring, false);
                }

                if (duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Boots, false);
                }

                if (Data.Constants.GameMode.AllowTower && duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Tower, false);
                }

                if (Data.Constants.GameMode.AllowFan && duraItem == null && Tools.CalculationTools.ChanceSuccess(75))
                {
                    duraItem = Player.Equipments.Get(Enums.ItemPosition.Fan, false);
                }

                if (duraItem != null && duraItem.DbOwnerItem.CurrentDura > 0)
                {
                    duraItem.DbOwnerItem.CurrentDura -= 100;
                    duraItem.UpdateDatabase();
                    duraItem.UpdateClient(Player, Enums.ItemUpdateAction.Update);
                    Player.UpdateBaseStats();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Does a normal composition by adding plus.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="minorItem">The minor item.</param>
        /// <param name="mainItem">The main item.</param>
        private static void DoNormalComposition(Models.Entities.Player player, Models.Items.Item minorItem, Models.Items.Item mainItem)
        {
            player.AddActionLog("Composition", mainItem.DbOwnerItem.Id);

            if (player.Inventory.Remove(minorItem.ClientId))
            {
                if (mainItem.DbOwnerItem.Composition > 0)
                {
                    mainItem.DbOwnerItem.Plus++;
                    mainItem.DbOwnerItem.Composition = 0;
                }
                else
                {
                    mainItem.DbOwnerItem.Composition = 1;
                }

                mainItem.UpdateDatabase();
            }
        }