public static void AssignRevenue(FileTraceManagment.SessionStats Current_session, LogFileManagment.SessionVariables session, OverlayWriter writer, Dictionary <string, Dictionary <string, Translate.Translation> > translation) { DateTime time_cutoff = DateTime.Now.AddDays(Current_session.TwitchSettings.OverviewTimeRange * -1); Dictionary <string, int> rewards = new Dictionary <string, int> { }; foreach (FileTraceManagment.MatchRecord match in Current_session.MatchHistory) { if (match.MatchData.MatchStart < time_cutoff) { continue; } if (match.MatchData.MatchRewards.Count() == 0) { continue; } foreach (KeyValuePair <string, int> value in match.MatchData.MatchRewards.Where(x => !x.Key.Contains("exp") && x.Key != "score")) { if (rewards.ContainsKey(value.Key)) { rewards[value.Key] += value.Value; } else { rewards.Add(value.Key, value.Value); } } } if (rewards.Count > 0) { writer.AddEmptyRow(); writer.AddHeader("Resource Breakdown", "resource_breakdown"); writer.AddHorizontalRow(); foreach (KeyValuePair <string, int> value in rewards.OrderByDescending(x => x.Value)) { writer.AddLine(string.Format(@"{0,16} {1}", Translate.TranslateString(value.Key, session, translation), value.Value), "resource_breakdown reward"); } } }
public static void AssignNemesisVictim(FileTraceManagment.SessionStats currentSession, OverlayWriter writer, Dictionary <string, Dictionary <string, Translate.Translation> > translation) { DateTime timeCutoff = DateTime.Now.AddDays(currentSession.TwitchSettings.OverviewTimeRange * -1); Dictionary <string, Opponent> opponentDictionary = new Dictionary <string, Opponent> { }; int count; foreach (FileTraceManagment.MatchRecord match in currentSession.MatchHistory) { if (match.MatchData.MatchStart < timeCutoff) { continue; } if (match.MatchData.MatchClassification == GlobalData.CUSTOM_CLASSIFICATION) { continue; } if (match.MatchData.Nemesis != "") { if (!opponentDictionary.ContainsKey(match.MatchData.Nemesis)) { opponentDictionary.Add(match.MatchData.Nemesis, new Opponent { Nickname = match.MatchData.Nemesis, BeenKilled = 1, Killed = 0 }); } else { opponentDictionary[match.MatchData.Nemesis].BeenKilled += 1; } } foreach (string victim in match.MatchData.Victims) { if (!opponentDictionary.ContainsKey(victim)) { opponentDictionary.Add(victim, new Opponent { Nickname = victim, BeenKilled = 0, Killed = 1 }); } else { opponentDictionary[victim].Killed += 1; } } } if (currentSession.TwitchSettings.ShowNemesis) { count = 0; writer.AddEmptyRow(); writer.AddHeader(string.Format(@"Top {0} Nemesis", currentSession.TwitchSettings.NemesisCount), "top_nemesis"); writer.AddHorizontalRow(); foreach (KeyValuePair <string, Opponent> nemesis in opponentDictionary.OrderByDescending(x => x.Value.Killed).ThenByDescending(x => x.Value.BeenKilled)) { if (count >= currentSession.TwitchSettings.NemesisCount) { break; } writer.AddLine(string.Format(@"{0,16} {1,4}/{2,-4}", nemesis.Key, nemesis.Value.Killed, nemesis.Value.BeenKilled), "top_nemesis entry"); //TODO add formatted input option for writer with divs for each entry count += 1; } } if (currentSession.TwitchSettings.ShowVictims) { count = 0; writer.AddEmptyRow(); writer.AddHeader(string.Format(@"Top {0} Victims", currentSession.TwitchSettings.NemesisCount), "top_victims"); writer.AddHorizontalRow(); foreach (KeyValuePair <string, Opponent> nemesis in opponentDictionary.OrderByDescending(x => x.Value.BeenKilled).ThenByDescending(x => x.Value.Killed)) { if (count >= currentSession.TwitchSettings.NemesisCount) { break; } writer.AddLine(string.Format(@"{0,16} {1,4}/{2,-4}", nemesis.Key, nemesis.Value.Killed, nemesis.Value.BeenKilled), "top_victims entry"); count += 1; } } }
public static void AssignCurrentMatch(FileTraceManagment.SessionStats currentSession, LogFileManagment.SessionVariables session, OverlayWriter writer, Dictionary <string, Dictionary <string, Translate.Translation> > translation) { if (!currentSession.InMatch) { return; } FileTraceManagment.MatchData current_match = currentSession.CurrentMatch; if (!current_match.PlayerRecords.ContainsKey(currentSession.LocalUserUID)) { return; } if (current_match == null) { return; } if (currentSession.TwitchSettings.InGameKD) { writer.AddHeader(string.Format(@"Current match on {0}", Translate.TranslateString(current_match.MapName, session, translation)), "current_match"); writer.AddHorizontalRow(); writer.AddLine(string.Format(@"{0,16} {1:N0}", "Kills", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Kills), "current_match kills"); writer.AddLine(string.Format(@"{0,16} {1:N0}", "Assists", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Assists), "current_match assists"); writer.AddLine(string.Format(@"{0,16} {1:N0}", "Deaths", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Deaths), "current_match deaths"); writer.AddLine(string.Format(@"{0,16} {1:N0}", "Drone Kills", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.DroneKills), "current_match drone_kils"); writer.AddLine(string.Format(@"{0,16} {1:N0}", "Score", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Score), "current_match score"); } if (currentSession.TwitchSettings.InGameDamage) { Dictionary <string, double> damageBreakdown = new Dictionary <string, double> { }; if (current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Damage > 0) { writer.AddEmptyRow(); writer.AddHeader("Damage Breakdown", "damage_breakdown"); writer.AddHorizontalRow(); writer.AddLine(string.Format(@"{0,16} {1:N1}", "Total", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Damage), "damage_breakdown total"); foreach (FileTraceManagment.DamageRecord record in currentSession.CurrentMatch.DamageRecord.Where(x => x.Attacker == currentSession.LocalUser)) { if (damageBreakdown.ContainsKey(record.Weapon)) { damageBreakdown[record.Weapon] += record.Damage; } else { damageBreakdown.Add(record.Weapon, record.Damage); } } if (damageBreakdown.Count > 0) { foreach (KeyValuePair <string, double> record in damageBreakdown) { writer.AddLine(string.Format(@"{0,16} {1:N1}", Translate.TranslateString(record.Key, session, translation), record.Value), "damage_breakdown weapon"); } } } if (current_match.PlayerRecords[currentSession.LocalUserUID].Stats.DamageTaken > 0) { damageBreakdown = new Dictionary <string, double> { }; writer.AddEmptyRow(); writer.AddHeader("Damage Recieved Breakdown", "damage_recieved_breakdown"); writer.AddHorizontalRow(); writer.AddLine(string.Format(@"{0,16} {1:N1}", "Total", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.DamageTaken), "damage_recieved_breakdown total"); foreach (FileTraceManagment.DamageRecord record in currentSession.CurrentMatch.DamageRecord.Where(x => x.Victim == currentSession.LocalUser)) { if (damageBreakdown.ContainsKey(record.Weapon)) { damageBreakdown[record.Weapon] += record.Damage; } else { damageBreakdown.Add(record.Weapon, record.Damage); } } if (damageBreakdown.Count > 0) { foreach (KeyValuePair <string, double> record in damageBreakdown) { writer.AddLine(string.Format(@"{0,16} {1:N1}", Translate.TranslateString(record.Key, session, translation), record.Value), "damage_recieved_breakdown weapon"); } } } } if (currentSession.TwitchSettings.InGameVictims && current_match.Victims.Count > 0) { writer.AddEmptyRow(); writer.AddHeader("Victims", "victims"); writer.AddHorizontalRow(); foreach (string victim in current_match.Victims) { writer.AddLine(string.Format(@"{0,16}", victim), "victims name"); } if (current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Kills - current_match.Victims.Count == 1) { writer.AddLine(string.Format(@"{0,16}", "Bot"), "victims bot"); } else if (current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Kills - current_match.Victims.Count > 1) { writer.AddLine(string.Format(@"{0,16}{1}", "Bots X", current_match.PlayerRecords[currentSession.LocalUserUID].Stats.Kills - current_match.Victims.Count), "victims bot"); } } if (currentSession.TwitchSettings.InGameKiller && current_match.Nemesis != "") { writer.AddEmptyRow(); writer.AddHeader("Killed by", "killed_by"); writer.AddHorizontalRow(); writer.AddLine(string.Format(@"{0,16}", current_match.Nemesis), "killed_by name"); } }
public static void AssignStats(FileTraceManagment.SessionStats currentSession, OverlayWriter writer, Dictionary <string, Dictionary <string, Translate.Translation> > translation, string game_mode) { FileTraceManagment.Stats stats = FileTraceManagment.NewStats(); if (currentSession.TwitchSettings.ToggleOverviewTimeRanges) { if (currentSession.TwitchSettings.OverviewTimeRange == 7.0) { currentSession.TwitchSettings.OverviewTimeRange = 31.0; } else if (currentSession.TwitchSettings.OverviewTimeRange == 31.0) { currentSession.TwitchSettings.OverviewTimeRange = 365.0; } else if (currentSession.TwitchSettings.OverviewTimeRange == 365.0) { currentSession.TwitchSettings.OverviewTimeRange = 1.0; } else if (currentSession.TwitchSettings.OverviewTimeRange == 1.0) { currentSession.TwitchSettings.OverviewTimeRange = 7.0; } } else { currentSession.TwitchSettings.OverviewTimeRange = currentSession.TwitchSettings.DefaultTimeRange; } DateTime timeCutoff = DateTime.Now.AddDays(currentSession.TwitchSettings.OverviewTimeRange * -1); foreach (FileTraceManagment.MatchRecord match in currentSession.MatchHistory) { if (match.MatchData.MatchStart < timeCutoff) { continue; } if (match.MatchData.MatchTypeDesc != game_mode) { continue; } stats = FileTraceManagment.SumStats(stats, match.MatchData.LocalPlayer.Stats); } if (stats.Games > 0) { writer.AddHeader(string.Format(@"{0,3} Day Stats for {1}", currentSession.TwitchSettings.OverviewTimeRange, game_mode), "day_stats"); writer.AddHorizontalRow(); writer.AddLine(string.Format(@"{0,16} {1,8}", "Games", stats.Games), "day_stats games"); writer.AddLine(string.Format(@"{0,16} {1,8} {2:P1}", "W/L %", string.Format(@"{0,4}/{1,-4}", stats.Wins, stats.Losses), (double)stats.Wins / (double)stats.Games), "day_stats win_lose_ratio"); writer.AddLine(string.Format(@"{0,16} {1,8} {2:N1}", "K/D ", string.Format(@"{0,4}/{1,-4}", stats.Kills, stats.Deaths), (double)stats.Kills / (double)stats.Deaths), "day_stats kill_death_ratio"); writer.AddLine(string.Format(@"{0,16} {1,8} {2:N1}", "K/G ", string.Format(@"{0,4}/{1,-4}", stats.Kills, stats.Games), (double)stats.Kills / (double)stats.Games), "day_stats kill_game_ratio"); writer.AddLine(string.Format(@"{0,16} {1,8:N1}", "Avg Dmg", stats.Damage / (double)stats.Rounds), "day_stats avg_dmg"); writer.AddLine(string.Format(@"{0,16} {1,8:N1}", "Avg Dmg Rec", stats.DamageTaken / (double)stats.Rounds), "day_stats avg_dmg_rec"); writer.AddLine(string.Format(@"{0,16} {1,8:N1}", "Avg Score", stats.Score / (double)stats.Rounds), "day_stats avg_score"); } }