private static void ProcessJamPlayer(Dictionary <int, List <PenaltyGroup> > pgMap, Dictionary <int, List <PenaltyGroup> > jamBoxTimeMap, Dictionary <int, int> boxTimeEstimates, int jamID, JamTeamEffectiveness jte1, List <JamPlayerEffectiveness> pjeList, int jamTime, JamPlayer player) { // handle penalties var playerPenaltyGroups = pgMap.ContainsKey(player.PlayerID) ? pgMap[player.PlayerID] : null; ProcessPlayerJamPenalties(jamBoxTimeMap, jamID, playerPenaltyGroups); // try to estimate what portion of a jam someone missed via time in the box int timeInBox = 0; if (jamBoxTimeMap.ContainsKey(jamID)) { foreach (PenaltyGroup group in jamBoxTimeMap[jamID]) { foreach (BoxTime bt in group.BoxTimes) { if (bt.PlayerID == player.PlayerID && bt.JamID == jamID) { // factor in estimated box time timeInBox += boxTimeEstimates[bt.BoxTimeID]; } } } } JamPlayerEffectiveness pje = new JamPlayerEffectiveness { PlayerID = player.PlayerID, TeamID = player.TeamID, JamPortion = ((double)jamTime - timeInBox) / jamTime, BaseQuality = jte1.Percentile, JamID = jamID, IsJammer = player.IsJammer, PenaltyCost = 0 }; pjeList.Add(pje); }
public Dictionary <int, Dictionary <int, JamPlayerEffectiveness> > GetAllJamPlayerEffectiveness() { var data = new Dictionary <int, Dictionary <int, JamPlayerEffectiveness> >(); using (var cmd = new SqlCommand(s_GetAllJamPlayerEffectivenessQuery, _connection, _transaction)) { cmd.Parameters.Clear(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { int jamID = reader.GetInt32(reader.GetOrdinal("JamID")); int playerID = reader.GetInt32(reader.GetOrdinal("PlayerID")); int teamID = reader.GetInt32(reader.GetOrdinal("TeamID")); double jamPortion = reader.GetDouble(reader.GetOrdinal("jamPortion")); double penaltyCost = reader.GetDouble(reader.GetOrdinal("PenaltyCost")); double baseEffectiveness = reader.GetDouble(reader.GetOrdinal("BaseEffectiveness")); bool isJammer = reader.GetBoolean(reader.GetOrdinal("IsJammer")); if (!data.ContainsKey(jamID)) { data[jamID] = new Dictionary <int, JamPlayerEffectiveness>(); } data[jamID][playerID] = new JamPlayerEffectiveness { PlayerID = playerID, JamID = jamID, TeamID = teamID, BaseQuality = baseEffectiveness, IsJammer = isJammer, JamPortion = jamPortion, PenaltyCost = penaltyCost }; } } } return(data); }