Example #1
0
        /// <summary>
        /// Returns value for horse using its properties and filter settings
        /// </summary>
        /// <param name="sourceItem">Horse item</param>
        /// <returns>calculated value for horse</returns>
        public float CalculateHorseValue(EquipmentElement sourceItem, FilterMountSettings filterMount)
        {
            HorseComponent horseComponentItem = sourceItem.Item.HorseComponent;

            float sum =
                Math.Abs(filterMount.ChargeDamage) +
                Math.Abs(filterMount.HitPoints) +
                Math.Abs(filterMount.Maneuver) +
                Math.Abs(filterMount.Speed);

            int ChargeDamage = horseComponentItem.ChargeDamage,
                HitPoints    = horseComponentItem.HitPoints,
                Maneuver     = horseComponentItem.Maneuver,
                Speed        = horseComponentItem.Speed;

            ItemModifier mod = sourceItem.ItemModifier;

            if (mod != null)
            {
                ChargeDamage = mod.ModifyMountCharge(ChargeDamage);
                Maneuver     = mod.ModifyMountManeuver(Maneuver);
                Speed        = mod.ModifyMountSpeed(Speed);
            }

            var   weights = filterMount;
            float value   = (
                ChargeDamage * weights.ChargeDamage +
                HitPoints * weights.HitPoints +
                Maneuver * weights.Maneuver +
                Speed * weights.Speed
                ) / sum;

#if DEBUG
            InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: CD {1}, HP {2}, MR {3}, SD {4}",
                                                                                   sourceItem.Item.Name, ChargeDamage, HitPoints, Maneuver, Speed)));

            InformationManager.DisplayMessage(new InformationMessage("Total score: " + value));
#endif

            return(value);
        }