public LeagueStats GetTeamStatsAvg(int top, int div) { if (div != -1) { top = 4; } List <int> OFFENSE_YARDS = new List <int>(); List <int> OFFENSE_PASS_ATT = new List <int>(); List <int> OFFENSE_PASS_YDS = new List <int>(); List <int> OFFENSE_RUSH_YARDS = new List <int>(); List <int> OFFENSE_RUSH_ATT = new List <int>(); List <int> OFFENSE_RUSH_TD = new List <int>(); List <int> OFFENSE_SACKS_ALLOWED = new List <int>(); List <int> OFFENSE_PASS_INT = new List <int>(); List <int> OFFENSE_PASS_TDS = new List <int>(); List <int> TOTAL_YARDS = new List <int>(); List <int> FIRST_DOWNS = new List <int>(); List <int> THIRD_DOWN_CONVERSIONS = new List <int>(); List <int> THIRD_DOWN_ATTEMPTS = new List <int>(); List <int> FOURTH_DOWN_CONVERSIONS = new List <int>(); List <int> FOURTH_DOWN_ATTEMPTS = new List <int>(); List <int> OFFENSE_REDZONE_ATT = new List <int>(); List <int> OFFENSE_REDZONE_TD = new List <int>(); List <int> OFFENSE_REDZONE_FG = new List <int>(); List <int> OFFENSE_TURNOVERS = new List <int>(); List <int> FUMBLES_LOST = new List <int>(); List <int> DEFENSE_REDZONE_FG = new List <int>(); List <int> DEFENSIVE_INT = new List <int>(); List <int> DEFENSE_PASS_YDS = new List <int>(); List <int> DEFENSE_REDZONE_ATT = new List <int>(); List <int> DEFENSE_REDZONE_TD = new List <int>(); List <int> DEFENSE_RUSH_YDS = new List <int>(); List <int> FUMBLES_RECOVERED = new List <int>(); List <int> DEFENSE_SACKS = new List <int>(); List <int> DEFENSE_TURNOVERS = new List <int>(); List <int> PENALTIES = new List <int>(); List <int> PENALTY_YARDS = new List <int>(); LeagueStats Averages = new LeagueStats(); //foreach (TeamSeasonStatsRecord rec in TeamStats) //{ // // TOTAL_YARDS.Add(rec.TotalYards); // OFFENSE_PASS_ATT.Add(rec.OffensePassAtt); // OFFENSE_PASS_YDS.Add(rec.OffensePassYards); //} foreach (KeyValuePair <int, Team> kvp in this.Teams) { Team t = kvp.Value; if (div != -1 && div != t.team.DivisionId) { continue; } TeamSeasonStatsRecord tssr = t.SeasonStats[model.CurrentYear]; OFFENSE_YARDS.Add(tssr.OffenseYards); OFFENSE_PASS_ATT.Add(tssr.OffensePassAtt); OFFENSE_PASS_YDS.Add(tssr.OffensePassYards); } // Need to sort these from highest to lowest somehow OFFENSE_YARDS.Sort((x, y) => y.CompareTo(x)); OFFENSE_PASS_ATT.Sort((x, y) => y.CompareTo(x)); OFFENSE_PASS_YDS.Sort((x, y) => y.CompareTo(x)); for (int c = 0; c < top; c++) { Averages.OFFENSE_YARDS += OFFENSE_YARDS[c]; Averages.OFFENSE_PASS_ATT += OFFENSE_PASS_ATT[c]; Averages.OFFENSE_PASS_YDS += OFFENSE_PASS_YDS[c]; } Averages.OFFENSE_YARDS = Averages.OFFENSE_YARDS / top; Averages.OFFENSE_PASS_ATT = Averages.OFFENSE_PASS_ATT / top; Averages.OFFENSE_PASS_YDS = Averages.OFFENSE_PASS_YDS / top; return(Averages); }
public void EvaluateCoach(Coach ecoach, Team eteam) { double evaluation = 0; Team coachteam = null; if (ecoach.TEAM_ID != 1009 && ecoach.TEAM_ID != 1010 && ecoach.TEAM_ID != 1011) { coachteam = this.Teams[ecoach.TEAM_ID]; } CoachRecord coachrec = model.CoachModel.GetCoachById(ecoach.COACH_ID); double cw_perc = 0; if (coachrec.CareerWins + coachrec.CareerLosses + coachrec.CareerTies != 0) { cw_perc = (double)(coachrec.CareerWins + coachrec.CareerTies / 2) / (coachrec.CareerWins + coachrec.CareerLosses + coachrec.CareerTies); } double po_perc = 0; if (coachrec.PlayoffWins + coachrec.PlayoffLosses != 0) { po_perc = (double)(coachrec.PlayoffWins / (coachrec.PlayoffWins + coachrec.PlayoffLosses)); } double sb_perc = 0; if (coachrec.SuperBowlWins + coachrec.SuperBowlLoses != 0) { sb_perc = (double)(coachrec.SuperBowlWins / (coachrec.SuperBowlWins + coachrec.SuperBowlLoses)); } double po_made = (double)coachrec.PlayoffsMade; double po_exp = 0; if (ecoach.years_exp != 0) { po_exp = (double)coachrec.PlayoffsMade / ecoach.years_exp; } double avg_wins = 0; if (ecoach.years_exp != 0) { avg_wins = (double)(coachrec.CareerWins / ecoach.years_exp); } double season = 0; double previous = 0; double season_playoff = 0; if (coachteam != null) { season = (double)(coachteam.team.SeasonWins + coachteam.team.SeasonTies / 2) / (coachteam.team.SeasonLosses + coachteam.team.SeasonTies / 2); // Previous Season Record previous = (double)(coachteam.team.PreviousSeasonWins + coachteam.team.PreviousSeasonTies / 2) / (coachteam.team.PreviousSeasonLosses + coachteam.team.PreviousSeasonTies / 2); season_playoff = 0; if (coachteam.team.SeasonConfStanding <= 5) { season_playoff += 500; } } LeagueStats league10 = GetTeamStatsAvg(10, -1); double probowlplayers = 0; #region Pro Bowl Players Bonus foreach (TableRecordModel rec in model.TableModels[EditorModel.PRO_BOWL_PLAYERS].GetRecords()) { if (rec.Deleted) { continue; } ProBowlPlayer pbp = (ProBowlPlayer)rec; if (pbp.TeamID != ecoach.TEAM_ID) { continue; } if (ecoach.POSITION == 0) { probowlplayers += .5; } if (ecoach.POSITION == 1 && pbp.Position <= 9) { probowlplayers += 1; } if (ecoach.POSITION == 2 && pbp.Position >= 10 && pbp.Position <= 18) { probowlplayers += 1; } if (ecoach.POSITION == 3 && pbp.Position >= 19) { probowlplayers += 1; } if (ecoach.POSITION == 3 && pbp.Position <= 18) { probowlplayers += .25; } } #endregion #region Loyalty/Patience for Current Coaches double loyalty = 0; double patience = 0; if (ecoach.TEAM_ID == eteam.team.TeamId) { // Adjusting current staff with loyalty and patience // If this is not a HC, and there is an employed HC that Acts as GM // evaluate the coach using the HC ratings bool done = false; if (ecoach.POSITION != 0) { if (eteam.Coaches.ContainsKey(0)) { if (eteam.Coaches[0].CONTRACT_LENGTH > 0 && eteam.Coaches[0].HC_GM) { loyalty = (double)eteam.Coaches[0].LOYALTY / 300; // max bonus of 33% patience = (double)eteam.Coaches[0].PATIENCE - 50 / 150; // max bonus +/- 33% done = true; } } } if (!done) { // Owner/GM does the eval loyalty = (double)eteam.Owner_GM.LOYALTY / 300; // max bonus of 33% patience = (double)eteam.Owner_GM.PATIENCE - 50 / 150; // max bonus +/- 33% } } #endregion }