Example #1
0
        private void EvaluatePp( GameStats game, UnitMatrix offMatrix, UnitMatrix defMatrix, bool bHome )
        {
            decimal avgMetric = AverageMetric( ( Total.AwaySacksAllowed + Total.HomeSacksAllowed )/2 );
            #if DEBUG
            Utility.Announce( string.Format( "League Average Sacks Allowed is {0:###.#} (tot={1:###.#})",
                                                            avgMetric, Total.AwaySacksAllowed + Total.HomeSacksAllowed ) );
            #endif
            //  Multipliers
            var sakAllowed = offMatrix.PpMetrics;
            var saks = defMatrix.PrMetrics;

            var offMult = Multiplier( avgMetric, DivByZeroCheck( sakAllowed, offMatrix.GamesPlayed ) );
            #if DEBUG
            Utility.Announce( string.Format( "Defence {1} averages {0:###.#} Sacks/game",
                                                            DivByZeroCheck( defMatrix.PrMetrics, defMatrix.GamesPlayed ),
                                                            defMatrix.TeamCode ) );
            Utility.Announce( string.Format( "Offense {1} averages {0:###.#} Sacks allowed/game",
                                                            DivByZeroCheck( sakAllowed, offMatrix.GamesPlayed ), offMatrix.TeamCode ) );
            #endif
            var defMult = Multiplier( DivByZeroCheck( saks, defMatrix.GamesPlayed ), avgMetric );

            if ( offMult == 0.0M ) offMult = 1.0M;
            if ( defMult == 0.0M ) defMult = 1.0M;
            #if DEBUG
            Utility.Announce( string.Format( "Offensive multiplier is {0:##.##}", offMult ) );
            Utility.Announce( string.Format( "Defensive multiplier is {0:##.##}", defMult ) );
            #endif
            var metric = ( bHome ) ? game.HomeSacksAllowed : game.AwaySacksAllowed;
            decimal offPoints;
            decimal defPoints;
            var result = ResultOf( metric, 2.0M, 4.0M );
            //RosterLib.Utility.Announce( "Result=" + result );
            switch ( result )
            {
                case "W":
                    offPoints = KPointsLoss;
                    defPoints = KPointsWin;
                    break;
                case "D":
                    offPoints = KPointsDraw;
                    defPoints = KPointsDraw;
                    break;
                default:
                    offPoints = KPointsWin;
                    defPoints = KPointsLoss;
                    break;
            }

            offMatrix.AddPpPoints( offPoints, defMult, game );
            defMatrix.AddPrPoints( defPoints, offMult, game );
            DistributeEp( "PP", offPoints, defMult, game, bHome );
            DistributeEp( "PR", defPoints, offMult, game, bHome );
            #if DEBUG
            Explain( offMatrix, defMatrix, "Pass Protection", offPoints,
                        defPoints, "PP", "PR", offMult, defMult, result,
                        ( offMatrix.PpPoints - offPoints ), ( defMatrix.PrPoints - defPoints ), metric, bHome );
            #endif
        }