示例#1
0
文件: Rival.cs 项目: minskowl/MY
        /// <summary>
        /// Creates the rival.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public static Rival Create(IE browser, RivalSource source)
        {
            var table = browser.Table(Find.ByClass("attack"));

            if (!table.Exists)
            {
                return(null);
            }
            var rival = new Rival {
                Source = source
            };

            FillUser(rival, table, browser);
            return(rival);
        }
示例#2
0
        /// <summary>
        /// Determines whether this instance can kill the specified user.
        /// </summary>
        /// <param name="rival">The user.</param>
        /// <returns>
        ///     <c>true</c> if this instance can kill the specified user; otherwise, <c>false</c>.
        /// </returns>
        public bool CanKill(Rival rival)
        {
            if (rival.Source != RivalSource.FromHotList &&
                !AppCore.AttackSettings.GetLevelFilter(rival.Source).IsValid(Level, rival.Level))
            {
                AppCore.LogFights.Debug(
                    string.Format("Противник {0} негодиться для атаки/", rival.Name),
                    "Он не прошел фильтр по уровню. См. Настройки > Атака", rival);
                return(false);
            }

            var    skillDifference = GetSkillDifference(rival);
            double minDifference   = AppCore.AttackSettings.MinSkillDifference;

            if (this.Coulomb != Coulomb.SmartBaby)
            {
                minDifference *= 2;
            }
            if (rival.Level > Level)
            {
                minDifference *= 1.5;
            }
            if (skillDifference < minDifference)
            {
                var title   = string.Format("Противник {0} негодиться для атаки.", rival.Name);
                var message = string.Format("Разница в скилах {0} а требуется {1}", skillDifference, minDifference);
                if (rival.Source == RivalSource.FromFarm)
                {
                    AppCore.LogFights.Warn(title, message, rival);
                }
                else
                {
                    AppCore.LogFights.Debug(title, message, rival);
                }
                return(false);
            }

            if (CompareTo(rival) < 0)
            {
                AppCore.LogFights.Warn(
                    string.Format("Противник {0} негодиться для атаки.", rival.Name),
                    string.Format("Разница в скилах {0} а требуется {1}", skillDifference, minDifference), rival);
                return(false);
            }
            return(true);
        }