Пример #1
0
        private byte CalculateRating(Player player, PlayerType type, Roles role, ref RatingRoleDebug debug)
        {
            RatingRoleDebug roleDebug;
            var             weights = GetWeights(role);

            //var values = GetValues(player);
            decimal result = RatePlayerInRole(player, type, role, weights, out roleDebug);

            var proportion = result;

            debug = roleDebug;

            /*
             * decimal BestRating = 90;
             * decimal WorstRating = 35;
             * decimal spreadForNewRatings = 98;
             *
             * result = Math.Max(result, WorstRating);
             * result = Math.Min(result, BestRating);
             *
             * // function to reset to 1-99 from above expected range
             * proportion = (((decimal)result - WorstRating) * spreadForNewRatings) / (BestRating - WorstRating);
             * proportion += 1;*/

            return((byte)proportion);
        }
Пример #2
0
        private byte RatePlayerInRole(Player player, PlayerType type, Roles role, byte[] weights, out RatingRoleDebug debug)
        {
            string mentalDebugString, physicalDebugString, technicalDebugString;

            byte mentalWeight    = weights.GW(DP.MentalityWeight);
            byte physicalWeight  = weights.GW(DP.PhysicalityWeight);
            byte technicalWeight = weights.GW(DP.TechnicalWeight);

            byte[] values = GetValues(player);

            var mental    = GetGroupingScore(player._player, MentalWeights, values, weights, false, out mentalDebugString);
            var physical  = GetGroupingScore(player._player, PhysicalWeights, values, weights, false, out physicalDebugString);
            var technical = GetGroupingScore(player._player, TechnicalWeights, values, weights, true, out technicalDebugString);

            decimal mentalScore    = Weight(mental, mentalWeight);
            decimal physicalScore  = Weight(physical, physicalWeight);
            decimal technicalScore = Weight(technical, technicalWeight);
            decimal adjust         = (decimal)(mentalWeight + physicalWeight + technicalWeight) / 100;

            debug = new RatingRoleDebug()
            {
                Position        = type.ToString(),
                Role            = role,
                Mental          = $"{mentalScore} / {mentalWeight}",
                MentalDetail    = mentalDebugString,
                Physical        = $"{physicalScore} / {physicalWeight}",
                PhysicalDetail  = physicalDebugString,
                Technical       = $"{technicalScore} / {technicalWeight}",
                TechnicalDetail = technicalDebugString,
            };

            return((byte)((mentalScore + physicalScore + technicalScore) / adjust));
        }
Пример #3
0
        private PositionRating GetRatingForTypeAndRole(Player player, PlayerType type, Roles role, byte offFieldRating)
        {
            RatingRoleDebug roleDebug = new RatingRoleDebug();
            var             rating    = AdjustScoreForOffField(AdjustScoreForPosition(player, type, CalculateRating(player, type, role, ref roleDebug), roleDebug), offFieldRating, roleDebug);

            return(new PositionRating()
            {
                Rating = rating, Role = role, Debug = roleDebug,
            });
        }
Пример #4
0
        private byte CalculateRating(Player player, PlayerType type, Roles role, ref RatingRoleDebug debug)
        {
            RatingRoleDebug roleDebug;
            var             weights = GetWeights(role);

            //var values = GetValues(player);
            byte result = RatePlayerInRole(player, type, role, weights, out roleDebug);

            debug = roleDebug;
            return(result);
        }
Пример #5
0
        private PositionRating GetRatingForTypeAndRole(Player player, PlayerType type, Roles role, decimal offFieldAdjustment)
        {
            RatingRoleDebug roleDebug           = new RatingRoleDebug();
            var             attributeRating     = CalculateRating(player, type, role, ref roleDebug);
            var             adjustedForPosition = AdjustScoreForPosition(player, type, attributeRating, roleDebug);
            var             adjustedForOffField = AdjustScoreForOffField(adjustedForPosition, offFieldAdjustment, roleDebug);

            roleDebug.OffField = offFieldAdjustment.ToString("0.00");

            var rating = adjustedForOffField;

            return(new PositionRating()
            {
                Rating = rating, Role = role, Debug = roleDebug,
            });
        }
Пример #6
0
 private string GetRoleDebugLine(RatingRoleDebug debug, PlayerType type, byte rating)
 {
     return($"{type.ToString().PadRight(20)} {debug.Role} {rating} - Mental:{debug.Mental} Physical:{debug.Physical} Technical:{debug.Technical} Familiarity:{debug.Position}" + Environment.NewLine);
 }
Пример #7
0
 private string GetRoleDebugLine(RatingRoleDebug debug, PlayerType type, byte rating)
 {
     return($"{type,-20} {debug.Role} {rating} - Mental:{debug.Mental} Physical:{debug.Physical} Technical:{debug.Technical} Familiarity:{debug.Position} OffField:{debug.OffField}" + Environment.NewLine);
 }
Пример #8
0
        private byte AdjustScoreForOffField(byte unadjustedScore, byte offFieldRating, RatingRoleDebug debug)
        {
            decimal offFieldBonus = -5 + (((decimal)offFieldRating) / 10);

            return((byte)Math.Min(99, Math.Max(0, (unadjustedScore + offFieldBonus))));
        }
Пример #9
0
        private byte AdjustScoreForPosition(Player player, PlayerType type, decimal unadjustedScore, RatingRoleDebug debug)
        {
            decimal positionModifier = (decimal)PositionalFamiliarity(type, player) / 100;

            debug.Position = positionModifier.ToString("0.00");

            return((byte)(unadjustedScore * positionModifier));
        }
Пример #10
0
 private byte AdjustScoreForOffField(byte unadjustedScore, decimal offFieldRating, RatingRoleDebug debug)
 {
     return((byte)Math.Min(99, Math.Max(0, (unadjustedScore + offFieldRating))));
 }
Пример #11
0
        private byte RatePlayerInRole(Player player, PlayerType type, Roles role, byte[] weights, out RatingRoleDebug debug)
        {
            string mentalDebugString, physicalDebugString, technicalDebugString;

            byte[] values = GetValues(player);

            /*
             * byte mentalWeight = weights.GW(DP.MentalityWeight);
             * byte physicalWeight = weights.GW(DP.PhysicalityWeight);
             * byte technicalWeight = weights.GW(DP.TechnicalWeight);
             *
             *
             * var mental = GetGroupingScore(MentalAttributes, values, weights, false, out mentalDebugString);
             * var physical = GetGroupingScore(PhysicalAttributes, values, weights, false, out physicalDebugString);
             * var technical = GetGroupingScore(TechnicalAttributes, values, weights, true, out technicalDebugString);
             *
             * decimal mentalScore = Weight(mental, mentalWeight);
             * decimal physicalScore = Weight(physical, physicalWeight, weights.GW(DP.PhysicalInflation));
             * decimal technicalScore = Weight(technical, technicalWeight, weights.GW(DP.TechnicalInflation));
             *
             * decimal adjust = (decimal)(mentalWeight + physicalWeight + technicalWeight) / 100;
             */

            var impactRating      = GetAndWeightGroupingScore(ImpactAttributes, values, weights[(int)AG.Impact]);
            var reliabilityRating = GetAndWeightGroupingScore(ReliabilityAttributes, values, weights[(int)AG.Reliability]);
            var playmakingRating  = GetAndWeightGroupingScore(PlaymakingAttributes, values, weights[(int)AG.Playmaking]);
            var wideplayRating    = GetAndWeightGroupingScore(WidePlayAttributes, values, weights[(int)AG.Wideplay]);
            var scoringRating     = GetAndWeightGroupingScore(ScoringAttributes, values, weights[(int)AG.Scoring]);
            var defendingRating   = GetAndWeightGroupingScore(DefendingAttributes, values, weights[(int)AG.Defending]);
            var goalkeepingRating = GetAndWeightGroupingScore(GoalkeepingAttributes, values, weights[(int)AG.Goalkeeping]);
            var speedRating       = GetAndWeightGroupingScore(SpeedAttributes, values, weights[(int)AG.Speed]);
            var strengthRating    = GetAndWeightGroupingScore(StrengthAttributes, values, weights[(int)AG.Strength]);

            decimal mentalRating    = impactRating + reliabilityRating;
            decimal mentalWeighting = weights[(int)AG.Impact] + weights[(int)AG.Reliability];

            decimal technicalRating    = playmakingRating + wideplayRating + scoringRating + defendingRating + goalkeepingRating;
            decimal technicalWeighting = weights[(int)AG.Playmaking] + weights[(int)AG.Wideplay] + weights[(int)AG.Scoring] + weights[(int)AG.Defending] + weights[(int)AG.Goalkeeping];

            switch (role)
            {
            case Roles.GK:
                technicalRating = technicalRating * 0.85m;
                break;

            case Roles.CB:
                technicalRating = technicalRating * 0.80m;
                break;

            case Roles.TM:
                technicalRating = technicalRating * 0.95m;
                break;
            }

            decimal physicalRating    = speedRating + strengthRating;
            decimal physicalWeighting = weights[(int)AG.Speed] + weights[(int)AG.Strength];

            decimal rating = mentalRating + technicalRating + physicalRating;

            debug = new RatingRoleDebug()
            {
                Position        = type.ToString(),
                Role            = role,
                Mental          = $"{mentalRating} / {mentalWeighting} ({(100 * mentalRating / mentalWeighting).ToString("N0")})",
                MentalDetail    = $"{mentalRating} / {mentalWeighting} ({(100 * mentalRating / mentalWeighting).ToString("N0")})",
                Physical        = $"{physicalRating} / {physicalWeighting} ({(100 * physicalRating / physicalWeighting).ToString("N0")})",
                PhysicalDetail  = $"{physicalRating} / {physicalWeighting} ({(100 * physicalRating / physicalWeighting).ToString("N0")})",
                Technical       = $"{technicalRating} / {technicalWeighting} ({(100 * technicalRating / technicalWeighting).ToString("N0")})",
                TechnicalDetail = $"{technicalRating} / {technicalWeighting} ({(100 * technicalRating / technicalWeighting).ToString("N0")})",
            };

            return((byte)rating);
        }