/// <summary> /// Gets all goals scored by a team, including those scored by the /// whole alliance and global goals. /// </summary> /// <param name="team">Team whose goals to retrieve</param> /// <returns>List of goals scored by the team</returns> public List <Goal> GetGoalsByTeam(Team team) { AllianceColor color = GetTeamColor(team); if (Goals == null) { return(new List <Goal>()); } return(Goals.FindAll((g) => { if (g.Global) { return true; } if (g.FullAlliance) { if (g.ScoringAlliance.HasValue) { return g.ScoringAlliance == color; } return false; // INVALID } return g.ScoringTeam == team; })); }
/// <summary> /// Instantiates a new penalty object /// </summary> /// <param name="time">Time the penalty was scored</param> /// <param name="reason">Reason given for the penalty</param> /// <param name="penalizedAlliance">Alliance penalized</param> /// <param name="teamID">ID of team at fault</param> public Penalty(int time, string reason, AllianceColor penalizedAlliance, Team team) { TimeOfPenaltyInt = time; Reasoning = reason; PenalizedAlliance = penalizedAlliance; BlamedTeam = team; if (BlamedTeam != null) { BlamedTeamID = team.Number; } }
/// <summary> /// Gets the alliance based on color /// </summary> /// <param name="color">Color of the resulting alliance</param> /// <returns>Alliance based on color</returns> public Alliance GetAlliance(AllianceColor color) { switch (color) { case AllianceColor.Blue: return(BlueAlliance); case AllianceColor.Red: return(RedAlliance); default: return(null); } }
/// <summary> /// Instantiates a pregame recording of a match /// </summary> /// <param name="number">Match number</param> /// <param name="team">Team number</param> /// <param name="alliance">Alliance number</param> public RecordedMatch(int number, Team team, AllianceColor alliance) { MatchNumber = number; TrackedTeam = team; TrackedTeamID = team.Number; TeamDescription = team.Description; TeamExpectations = team.Expectations; Alliance = alliance; ScoredGoals = new List <Goal>(); AlliancePenalties = new List <Penalty>(); Working = true; // default Defense = -1; // default Winner = AllianceColor.Indeterminate; // indeterminate AllianceFinalScore = -1; // starting value }
/// <summary> /// Gets the defense rating of a team. /// </summary> /// <param name="team">Team in question</param> /// <returns>Defense rating of team</returns> public int GetDefense(Team team) { AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { AlliancePosition pos = BlueAlliance.GetPositionOf(team); return(BlueDefense[pos]); } else if (color == AllianceColor.Red) { AlliancePosition pos = RedAlliance.GetPositionOf(team); return(RedDefense[pos]); } else { Util.DebugLog(LogLevel.Error, "Invalid alliance color: " + color.ToString()); return(-1); } }
/// <summary> /// Gets whether a team was functioning properly in this match. /// </summary> /// <param name="team">Team in question</param> /// <returns>True if working, false if malfunctioning</returns> public bool GetWorking(Team team) { AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { AlliancePosition pos = BlueAlliance.GetPositionOf(team); return(BlueWorking[pos]); } else if (color == AllianceColor.Red) { AlliancePosition pos = RedAlliance.GetPositionOf(team); return(RedWorking[pos]); } else { Util.DebugLog(LogLevel.Critical, "Invalid alliance color: " + color.ToString()); throw new IndexOutOfRangeException("Invalid alliance color: " + color.ToString()); } }
public AlliancePosition GetTeamPosition(Team team) { if (team == null) { Util.DebugLog(LogLevel.Critical, "Team is null."); return(AlliancePosition.A); } AllianceColor color = GetTeamColor(team); if (color == AllianceColor.Blue) { return(BlueAlliance.GetIndexOf(team)); } else if (color == AllianceColor.Red) { return(RedAlliance.GetIndexOf(team)); } else { Util.DebugLog(LogLevel.Error, "Neither alliance contains team."); return(AlliancePosition.A); } }
/// <summary> /// Gets the alliance based on color /// </summary> /// <param name="color">Color of the resulting alliance</param> /// <returns>Alliance based on color</returns> public Alliance GetAlliance(AllianceColor color) { switch (color) { case AllianceColor.Blue: return BlueAlliance; case AllianceColor.Red: return RedAlliance; default: return null; } }
public void Save() { if (_filestream == null) { return; } var xml = new XDocument(new XElement("window")); xml.Root.Add(new XElement("location")); xml.Root.Element("location").Add(new XElement("x", Location.X.ToString(CultureInfo.InvariantCulture))); xml.Root.Element("location").Add(new XElement("y", Location.Y.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("language", Language)); xml.Root.Add(new XElement("ui_language", UILanguage)); xml.Root.Add(new XElement("opacity")); xml.Root.Element("opacity").Add(new XElement("mainWindow", MainWindowOpacity * 100)); xml.Root.Element("opacity").Add(new XElement("skillWindow", SkillWindowOpacity * 100)); xml.Root.Add(new XElement("autoupdate", AutoUpdate)); xml.Root.Add(new XElement("remember_position", RememberPosition)); xml.Root.Add(new XElement("winpcap", Winpcap)); xml.Root.Add(new XElement("invisible_ui_when_no_stats", InvisibleUi)); xml.Root.Add(new XElement("allow_transparency", AllowTransparency)); xml.Root.Add(new XElement("topmost", Topmost)); xml.Root.Add(new XElement("teradps.io")); xml.Root.Element("teradps.io").Add(new XElement("user", TeraDpsUser)); xml.Root.Element("teradps.io").Add(new XElement("token", TeraDpsToken)); xml.Root.Element("teradps.io").Add(new XElement("enabled", SiteExport)); xml.Root.Add(new XElement("debug", Debug)); xml.Root.Add(new XElement("excel", Excel)); xml.Root.Add(new XElement("date_in_excel_path", DateInExcelPath)); xml.Root.Add(new XElement("excel_save_directory", ExcelSaveDirectory)); xml.Root.Add(new XElement("always_visible", AlwaysVisible)); xml.Root.Add(new XElement("scale", Scale.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("lf_delay", LFDelay)); xml.Root.Add(new XElement("partyonly", PartyOnly)); xml.Root.Add(new XElement("showhealcrit", ShowHealCrit)); xml.Root.Add(new XElement("detect_bosses_only_by_hp_bar", DetectBosses)); xml.Root.Add(new XElement("only_bosses", OnlyBoss)); xml.Root.Add(new XElement("low_priority", LowPriority)); xml.Root.Add(new XElement("number_of_players_displayed", NumberOfPlayersDisplayed)); xml.Root.Add(new XElement("notify_sound", NotifySound)); xml.Root.Add(new XElement("volume", Volume)); xml.Root.Add(new XElement("popup_display_time", PopupDisplayTime)); xml.Root.Add(new XElement("sound_notify_duration", SoundNotifyDuration)); xml.Root.Add(new XElement("say_color", SayColor.ToString())); xml.Root.Add(new XElement("alliance_color", AllianceColor.ToString())); xml.Root.Add(new XElement("area_color", AreaColor.ToString())); xml.Root.Add(new XElement("guild_color", GuildColor.ToString())); xml.Root.Add(new XElement("whisper_color", WhisperColor.ToString())); xml.Root.Add(new XElement("general_color", GeneralColor.ToString())); xml.Root.Add(new XElement("group_color", GroupColor.ToString())); xml.Root.Add(new XElement("trading_color", TradingColor.ToString())); xml.Root.Add(new XElement("emotes_color", EmotesColor.ToString())); xml.Root.Add(new XElement("private_channel_color", PrivateChannelColor.ToString())); xml.Root.Add(new XElement("remove_tera_alt_enter_hotkey", RemoveTeraAltEnterHotkey)); xml.Root.Add(new XElement("enable_chat_and_notifications", EnableChat)); xml.Root.Add(new XElement("copy_inspect", CopyInspect)); _filestream.SetLength(0); using (var sr = new StreamWriter(_filestream)) { // File writing as usual sr.Write(xml); } _filestream.Close(); }
/// <summary> /// Instantiates a Recycled Litter goal (RECYCLED LITTER). /// </summary> /// <param name="team">Team who recycled the litter</param> /// <param name="time">Time at which the litter was recycled</param> /// <returns>New Goal of type Recycled Litter</returns> public static Goal MakeRecycledLitter(Team team, int time, AllianceColor col) { return new Goal(GoalType.RecycledLitter, time, team, col, false, null, null, false, false, 0); }
/// <summary> /// Instantiates a Tote goal (TOTE). /// </summary> /// <param name="team">Team who placed the tote</param> /// <param name="time">Time at which the tote was placed</param> /// <returns>New Goal of type Gray Tote</returns> public static Goal MakeGrayTote(Team team, int time, AllianceColor col) { return new Goal(GoalType.GrayTote, time, team, col, false, null, null, false, false, 0); }
/// <summary> /// Instantiates a Tote goal (TOTE). /// </summary> /// <param name="team">Team who placed the tote</param> /// <param name="time">Time at which the tote was placed</param> /// <returns>New Goal of type Gray Tote</returns> public static Goal MakeGrayTote(Team team, int time, AllianceColor col) { return(new Goal(GoalType.GrayTote, time, team, col, false, null, null, false, false, 0)); }
/// <summary> /// Instantiates a Container Set goal (CONTAINER SET). [AUTO] /// </summary> /// <param name="alliance">Alliance who transported the containers</param> /// <returns>New Goal of type Container Set</returns> public static Goal MakeContainerSet(AllianceColor alliance) { return(new Goal(GoalType.ContainerSet, Util.TELEOP.CountedSeconds(), null, alliance, true, null, null, true, false, 0)); }
/// <summary> /// Instantiates a (Yellow) Tote Set goal (TOTE SET). Can be stacked. [AUTO] /// </summary> /// <param name="stacked">True if totes are stacked (STACKED TOTE SET)</param> /// <param name="alliance">Alliance who transported the totes</param> /// <returns>New Goal of type Yellow Tote Set</returns> public static Goal MakeYellowToteSet(bool stacked, AllianceColor alliance) { return(new Goal(GoalType.YellowToteSet, Util.TELEOP.CountedSeconds(), null, alliance, true, stacked, null, true, false, 0)); }
/// <summary> /// Instantiates a (Yellow) Tote Set goal (TOTE SET). Can be stacked. [AUTO] /// </summary> /// <param name="stacked">True if totes are stacked (STACKED TOTE SET)</param> /// <param name="alliance">Alliance who transported the totes</param> /// <returns>New Goal of type Yellow Tote Set</returns> public static Goal MakeYellowToteSet(bool stacked, AllianceColor alliance) { return new Goal(GoalType.YellowToteSet, Util.TELEOP.CountedSeconds(), null, alliance, true, stacked, null, true, false, 0); }
/// <summary> /// Instantiates a Container Set goal (CONTAINER SET). [AUTO] /// </summary> /// <param name="alliance">Alliance who transported the containers</param> /// <returns>New Goal of type Container Set</returns> public static Goal MakeContainerSet(AllianceColor alliance) { return new Goal(GoalType.ContainerSet, Util.TELEOP.CountedSeconds(), null, alliance, true, null, null, true, false, 0); }
/// <summary> /// Instantiates a Contanier goal (CONTAINER). /// </summary> /// <param name="level">Vertical level of the container</param> /// <param name="team">Team who placed the container</param> /// <param name="time">Time at which the container was placed</param> /// <returns>New Goal of type Container</returns> public static Goal MakeContainerTeleop(int level, Team team, int time, AllianceColor col) { return(new Goal(GoalType.ContainerTeleop, time, team, col, false, null, level, false, false, 0)); }
/// <summary> /// Instantiates a Contanier goal (CONTAINER). /// </summary> /// <param name="level">Vertical level of the container</param> /// <param name="team">Team who placed the container</param> /// <param name="time">Time at which the container was placed</param> /// <returns>New Goal of type Container</returns> public static Goal MakeContainerTeleop(int level, Team team, int time, AllianceColor col) { return new Goal(GoalType.ContainerTeleop, time, team, col, false, null, level, false, false, 0); }
/// <summary> /// Instantiates a Recycled Litter goal (RECYCLED LITTER). /// </summary> /// <param name="team">Team who recycled the litter</param> /// <param name="time">Time at which the litter was recycled</param> /// <returns>New Goal of type Recycled Litter</returns> public static Goal MakeRecycledLitter(Team team, int time, AllianceColor col) { return(new Goal(GoalType.RecycledLitter, time, team, col, false, null, null, false, false, 0)); }
/// <summary> /// Instantiates an Unprocessed Litter goal (UNPROCESSED LITTER). /// </summary> /// <param name="alliance"> /// Alliance who threw the litter, opposite of alliance whose /// side contains the litter. /// </param> /// <returns>New Goal of type Unprocessed Litter</returns> public static Goal MakeUnprocessedLitter(AllianceColor alliance) { return new Goal(GoalType.UnprocessedLitter, Util.MATCH_LENGTH.CountedSeconds(), null, alliance, false, null, null, true, false, 0); }
/// <summary> /// Instantiates an Unprocessed Litter goal (UNPROCESSED LITTER). /// </summary> /// <param name="alliance"> /// Alliance who threw the litter, opposite of alliance whose /// side contains the litter. /// </param> /// <returns>New Goal of type Unprocessed Litter</returns> public static Goal MakeUnprocessedLitter(AllianceColor alliance) { return(new Goal(GoalType.UnprocessedLitter, Util.MATCH_LENGTH.CountedSeconds(), null, alliance, false, null, null, true, false, 0)); }
public TeamDataContext(Team t, AllianceColor col) { Team = t; Color = col; }
public void Save() { if (_filestream == null) { return; } var xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("window")); xml.Root.Add(new XElement("location")); xml.Root.Element("location").Add(new XElement("x", Location.X.ToString(CultureInfo.InvariantCulture))); xml.Root.Element("location").Add(new XElement("y", Location.Y.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("language", Language)); xml.Root.Add(new XElement("ui_language", UILanguage)); xml.Root.Add(new XElement("opacity")); xml.Root.Element("opacity").Add(new XElement("mainWindow", MainWindowOpacity * 100)); xml.Root.Element("opacity").Add(new XElement("skillWindow", SkillWindowOpacity * 100)); xml.Root.Add(new XElement("autoupdate", AutoUpdate)); xml.Root.Add(new XElement("remember_position", RememberPosition)); xml.Root.Add(new XElement("winpcap", Winpcap)); xml.Root.Add(new XElement("invisible_ui_when_no_stats", InvisibleUi)); xml.Root.Add(new XElement("allow_transparency", AllowTransparency)); xml.Root.Add(new XElement("topmost", Topmost)); xml.Root.Add(new XElement("debug", Debug)); xml.Root.Add(new XElement("excel", Excel)); xml.Root.Add(new XElement("date_in_excel_path", DateInExcelPath)); xml.Root.Add(new XElement("excel_save_directory", ExcelSaveDirectory)); xml.Root.Add(new XElement("excel_cma_dps_seconds", ExcelCMADPSSeconds)); xml.Root.Add(new XElement("always_visible", AlwaysVisible)); xml.Root.Add(new XElement("scale", Scale.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("lf_delay", LFDelay)); xml.Root.Add(new XElement("partyonly", PartyOnly)); xml.Root.Add(new XElement("showhealcrit", ShowHealCrit)); xml.Root.Add(new XElement("detect_bosses_only_by_hp_bar", DetectBosses)); xml.Root.Add(new XElement("only_bosses", OnlyBoss)); xml.Root.Add(new XElement("low_priority", LowPriority)); xml.Root.Add(new XElement("number_of_players_displayed", NumberOfPlayersDisplayed)); xml.Root.Add(new XElement("remove_tera_alt_enter_hotkey", RemoveTeraAltEnterHotkey)); xml.Root.Add(new XElement("enable_chat_and_notifications", EnableChat)); xml.Root.Add(new XElement("mute_sound", MuteSound)); xml.Root.Add(new XElement("copy_inspect", CopyInspect)); xml.Root.Add(new XElement("format_paste_string", FormatPasteString)); xml.Root.Add(new XElement("say_color", SayColor.ToString())); xml.Root.Add(new XElement("alliance_color", AllianceColor.ToString())); xml.Root.Add(new XElement("area_color", AreaColor.ToString())); xml.Root.Add(new XElement("guild_color", GuildColor.ToString())); xml.Root.Add(new XElement("whisper_color", WhisperColor.ToString())); xml.Root.Add(new XElement("general_color", GeneralColor.ToString())); xml.Root.Add(new XElement("group_color", GroupColor.ToString())); xml.Root.Add(new XElement("trading_color", TradingColor.ToString())); xml.Root.Add(new XElement("emotes_color", EmotesColor.ToString())); xml.Root.Add(new XElement("private_channel_color", PrivateChannelColor.ToString())); xml.Root.Add(new XElement("disable_party_event", DisablePartyEvent)); xml.Root.Add(new XElement("show_afk_events_ingame", ShowAfkEventsIngame)); xml.Root.Add(new XElement("teradps.io")); xml.Root.Element("teradps.io").Add(new XElement("user", TeraDpsUser)); xml.Root.Element("teradps.io").Add(new XElement("token", TeraDpsToken)); xml.Root.Element("teradps.io").Add(new XElement("enabled", SiteExport)); xml.Root.Element("teradps.io").Add(new XElement("private_servers", new XAttribute("enabled", PrivateServerExport))); PrivateDpsServers.ForEach(x => xml.Root.Element("teradps.io").Element("private_servers").Add(new XElement("server", x)) ); xml.Root.Add(new XElement("discord")); xml.Root.Element("discord").Add(new XElement("login", DiscordLogin)); xml.Root.Element("discord").Add(new XElement("password", DiscordPassword)); xml.Root.Element("discord").Add(new XElement("guilds")); foreach (var discordData in DiscordInfoByGuild) { var name = discordData.Key.ToString().ToLowerInvariant(); xml.Root.Element("discord").Element("guilds").Add(new XElement(name)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("guild_infos_channel", discordData.Value.DiscordChannelGuildInfo)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("guild_quests_channel", discordData.Value.DiscordChannelGuildQuest)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("server", discordData.Value.DiscordServer)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("guild_infos_text", discordData.Value.GuildInfosText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("quest_infos_text", discordData.Value.QuestInfoText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("quest_list_infos_text", discordData.Value.QuestListInfoText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("quest_list_infos_header_text", discordData.Value.QuestListHeaderText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("reward_footer_text", discordData.Value.RewardFooterText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("reward_content_text", discordData.Value.RewardContentText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("reward_header_text", discordData.Value.RewardHeaderText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("target_header_text", discordData.Value.TargetHeaderText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("target_content_text", discordData.Value.TargetContentText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("target_footer_text", discordData.Value.TargetFooterText)); xml.Root.Element("discord").Element("guilds").Element(name).Add(new XElement("no_active_quest_text", discordData.Value.QuestNoActiveText)); } _filestream.SetLength(0); using (var sw = new StreamWriter(_filestream, new UTF8Encoding(true))) { sw.Write(xml.Declaration + Environment.NewLine + xml); } _filestream.Close(); }
/// <summary> /// Creates an instance of goal. Using the static methods is preferrable. /// </summary> /// <param name="type">Type of goal scored</param> /// <param name="timeScored">Time at which the goal was scored, in seconds</param> /// <param name="scorer">Scoring team, null if an alliance or all teams</param> /// <param name="scorerAl">Alliance color of scoring team/alliance, null if all teams</param> /// <param name="auto">True if scored in autonomous, false if in teleop</param> /// <param name="stack">True if a stacked form of the goal, null if inapplicable</param> /// <param name="level"> /// Level the container was at when scored, null for all other /// goal types. /// </param> /// <param name="alliance">True if scored by the entire alliance</param> /// <param name="global">True if scored by all participating teams (coopertition)</param> internal Goal(GoalType type, int timeScored, Team scorer, AllianceColor? scorerAl, bool auto, bool? stack, int? level, bool alliance, bool global, int dummy) { Type = type; TimeScoredInt = timeScored; ScoringTeam = scorer; if (scorer != null) { ScoringTeamID = scorer.Number; } ScoringAlliance = scorerAl; Autonomous = auto; Stack = stack; FullAlliance = alliance; Global = global; Level = level; }
/// <summary> /// Instantiates a pregame recording of a match /// </summary> /// <param name="number">Match number</param> /// <param name="team">Team number</param> /// <param name="alliance">Alliance number</param> public RecordedMatch(int number, Team team, AllianceColor alliance) { MatchNumber = number; TrackedTeam = team; TrackedTeamID = team.Number; TeamDescription = team.Description; TeamExpectations = team.Expectations; Alliance = alliance; ScoredGoals = new List<Goal>(); AlliancePenalties = new List<Penalty>(); Working = true; // default Defense = -1; // default Winner = AllianceColor.Indeterminate; // indeterminate AllianceFinalScore = -1; // starting value }
internal Goal(GoalType Type, int TimeScoredInt, int? ScoringTeamID, AllianceColor? ScoringAlliance, bool Autonomous, bool? Stack, int? Level, bool FullAlliance, bool Global) { this.Type = Type; this.TimeScoredInt = TimeScoredInt; this.ScoringTeamID = ScoringTeamID; this.ScoringAlliance = ScoringAlliance; this.Autonomous = Autonomous; this.Stack = Stack; this.Level = Level; this.FullAlliance = FullAlliance; this.Global = Global; }
public void Save() { if (_filestream == null) { return; } var xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("window")); xml.Root.Add(new XElement("location")); xml.Root.Element("location").Add(new XElement("x", Location.X.ToString(CultureInfo.InvariantCulture))); xml.Root.Element("location").Add(new XElement("y", Location.Y.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("language", Language)); xml.Root.Add(new XElement("ui_language", UILanguage)); xml.Root.Add(new XElement("opacity")); xml.Root.Element("opacity").Add(new XElement("mainWindow", MainWindowOpacity * 100)); xml.Root.Element("opacity").Add(new XElement("skillWindow", SkillWindowOpacity * 100)); xml.Root.Add(new XElement("autoupdate", AutoUpdate)); xml.Root.Add(new XElement("remember_position", RememberPosition)); xml.Root.Add(new XElement("winpcap", Winpcap)); xml.Root.Add(new XElement("invisible_ui_when_no_stats", InvisibleUi)); xml.Root.Add(new XElement("allow_transparency", AllowTransparency)); xml.Root.Add(new XElement("topmost", Topmost)); xml.Root.Add(new XElement("debug", Debug)); xml.Root.Add(new XElement("excel", Excel)); xml.Root.Add(new XElement("excel_path_template", ExcelPathTemplate)); xml.Root.Add(new XElement("excel_save_directory", ExcelSaveDirectory)); xml.Root.Add(new XElement("excel_cma_dps_seconds", ExcelCMADPSSeconds)); xml.Root.Add(new XElement("always_visible", AlwaysVisible)); xml.Root.Add(new XElement("scale", Scale.ToString(CultureInfo.InvariantCulture))); xml.Root.Add(new XElement("lf_delay", LFDelay)); xml.Root.Add(new XElement("partyonly", PartyOnly)); xml.Root.Add(new XElement("showhealcrit", ShowHealCrit)); xml.Root.Add(new XElement("showtimeleft", ShowTimeLeft)); xml.Root.Add(new XElement("show_crit_damage_rate", ShowCritDamageRate)); xml.Root.Add(new XElement("detect_bosses_only_by_hp_bar", DetectBosses)); xml.Root.Add(new XElement("only_bosses", OnlyBoss)); xml.Root.Add(new XElement("low_priority", LowPriority)); xml.Root.Add(new XElement("number_of_players_displayed", NumberOfPlayersDisplayed)); xml.Root.Add(new XElement("meter_user_on_top", MeterUserOnTop)); xml.Root.Add(new XElement("remove_tera_alt_enter_hotkey", RemoveTeraAltEnterHotkey)); xml.Root.Add(new XElement("enable_chat_and_notifications", EnableChat)); xml.Root.Add(new XElement("mute_sound", MuteSound)); xml.Root.Add(new XElement("copy_inspect", CopyInspect)); xml.Root.Add(new XElement("format_paste_string", FormatPasteString)); xml.Root.Add(new XElement("say_color", SayColor.ToString())); xml.Root.Add(new XElement("alliance_color", AllianceColor.ToString())); xml.Root.Add(new XElement("area_color", AreaColor.ToString())); xml.Root.Add(new XElement("guild_color", GuildColor.ToString())); xml.Root.Add(new XElement("whisper_color", WhisperColor.ToString())); xml.Root.Add(new XElement("general_color", GeneralColor.ToString())); xml.Root.Add(new XElement("group_color", GroupColor.ToString())); xml.Root.Add(new XElement("trading_color", TradingColor.ToString())); xml.Root.Add(new XElement("emotes_color", EmotesColor.ToString())); xml.Root.Add(new XElement("private_channel_color", PrivateChannelColor.ToString())); xml.Root.Add(new XElement("disable_party_event", DisablePartyEvent)); xml.Root.Add(new XElement("show_afk_events_ingame", ShowAfkEventsIngame)); xml.Root.Add(new XElement("idle_reset_timeout", IdleResetTimeout)); xml.Root.Add(new XElement("teradps.io")); xml.Root.Element("teradps.io").Add(new XElement("user", TeraDpsUser)); xml.Root.Element("teradps.io").Add(new XElement("token", TeraDpsToken)); xml.Root.Element("teradps.io").Add(new XElement("enabled", SiteExport)); xml.Root.Element("teradps.io").Add(new XElement("private_servers", new XAttribute("enabled", PrivateServerExport))); PrivateDpsServers.ForEach(x => xml.Root.Element("teradps.io").Element("private_servers").Add(new XElement("server", x)) ); _filestream.SetLength(0); using (var sw = new StreamWriter(_filestream, new UTF8Encoding(true))) { sw.Write(xml.Declaration + Environment.NewLine + xml); } _filestream.Close(); }
/// <summary> /// Forms a match from recorded data /// </summary> /// <param name="frc">Event to load additional data from</param> /// <param name="redData">Group of recordings from red's data</param> /// <param name="blueData">Group of recordings from blue's data</param> /// <returns></returns> public static Match FormMatch(FrcEvent frc, AllianceGroup <RecordedMatch> redData, AllianceGroup <RecordedMatch> blueData) { // Team data count (reliability) int redTeamsCount = redData.Count((rec) => rec != null); int blueTeamsCount = blueData.Count((rec) => rec != null); if (redTeamsCount + blueTeamsCount < 3 || redTeamsCount == 0 || blueTeamsCount == 0) // not enough data { return(null); // Give up } Alliance red = new Alliance(redData.A.TrackedTeam, redData.B.TrackedTeam, redData.C.TrackedTeam); Alliance blue = new Alliance(blueData.A.TrackedTeam, blueData.B.TrackedTeam, blueData.C.TrackedTeam); List <RecordedMatch> allData = new List <RecordedMatch>(); foreach (RecordedMatch rec in redData) { allData.Add(rec); } foreach (RecordedMatch rec in blueData) { allData.Add(rec); } // MATCH ID (quadruple lambda!) int matchID = allData.ConvertAll <int>((rec) => rec.MatchNumber).Mode((modes) => { try { return(modes.First((n) => { return !(frc.Matches.Exists((m) => m.Number == n && !m.Pregame)); })); } catch (InvalidOperationException) { Util.DebugLog(LogLevel.Warning, "SYNC", "Completed match with this ID is already present in event"); return(modes.First()); } }); Match result = new Match(matchID, blue, red); result.Pregame = false; // This section is because Unprocessed and Landfill Litter type goals are shared, but // come more than one per match. double dRedLfLitter = redData.ToList().ConvertAll <int>((rec) => rec.ScoredGoals.Count( (g) => g.Type == GoalType.LandfillLitter)).Mean(); int nRedLfLitter = (int)dRedLfLitter; double dRedUnpLitter = redData.ToList().ConvertAll <int>((rec) => rec.ScoredGoals.Count( (g) => g.Type == GoalType.UnprocessedLitter)).Mean(); int nRedUnpLitter = (int)dRedUnpLitter; double dBlueLfLitter = blueData.ToList().ConvertAll <int>((rec) => rec.ScoredGoals.Count( (g) => g.Type == GoalType.UnprocessedLitter)).Mean(); int nBlueLfLitter = (int)dBlueLfLitter; double dBlueUnpLitter = blueData.ToList().ConvertAll <int>((rec) => rec.ScoredGoals.Count( (g) => g.Type == GoalType.UnprocessedLitter)).Mean(); int nBlueUnpLitter = (int)dBlueUnpLitter; // GOALS LIST List <Goal> goals = new List <Goal>(); goals.Sort((g1, g2) => g1.TimeScoredInt - g2.TimeScoredInt); foreach (RecordedMatch rec in allData) { foreach (Goal addedGoal in rec.ScoredGoals) { #region add by goal type switch (addedGoal.Type) { #region RobotSet case GoalType.RobotSet: bool alreadyHasRobotSet = goals.Exists((g) => { return(g.Type == GoalType.RobotSet && g.ScoringAlliance == addedGoal.ScoringAlliance); }); if (!alreadyHasRobotSet) { goals.Add(addedGoal); } break; #endregion #region YellowToteSet case GoalType.YellowToteSet: bool alreadyHasYTS = goals.Exists((g) => { return(g.Type == GoalType.YellowToteSet && g.ScoringAlliance == addedGoal.ScoringAlliance); }); if (!alreadyHasYTS) { goals.Add(addedGoal); } break; #endregion #region ContainerSet case GoalType.ContainerSet: bool alreadyHasContainerSet = goals.Exists((g) => { return(g.Type == GoalType.ContainerSet && g.ScoringAlliance == addedGoal.ScoringAlliance); }); if (!alreadyHasContainerSet) { goals.Add(addedGoal); } break; #endregion #region Coopertition case GoalType.Coopertition: bool alreadyHasCoopertition = goals.Exists((g) => { return(g.Type == GoalType.Coopertition); }); if (!alreadyHasCoopertition) { goals.Add(addedGoal); } break; #endregion case GoalType.GrayTote: goals.Add(addedGoal); break; case GoalType.ContainerTeleop: goals.Add(addedGoal); break; case GoalType.RecycledLitter: goals.Add(addedGoal); break; default: break; } #endregion } } for (int i = 0; i < nRedLfLitter; i++) { goals.Add(Goal.MakeLandfillLitter(AllianceColor.Red)); } for (int i = 0; i < nRedUnpLitter; i++) { goals.Add(Goal.MakeUnprocessedLitter(AllianceColor.Red)); } for (int i = 0; i < nBlueLfLitter; i++) { goals.Add(Goal.MakeLandfillLitter(AllianceColor.Blue)); } for (int i = 0; i < nBlueUnpLitter; i++) { goals.Add(Goal.MakeUnprocessedLitter(AllianceColor.Blue)); } result.Goals = goals; // PENALTIES List <Penalty> penalties = new List <Penalty>(); foreach (RecordedMatch rec in allData) { foreach (Penalty pen in rec.AlliancePenalties) { bool nearbyPenalty = penalties.Exists((p) => { return(Math.Abs(p.TimeOfPenaltyInt - pen.TimeOfPenaltyInt) < PENALTY_THRESHOLD); }); if (!nearbyPenalty) { penalties.Add(pen); } } } result.Penalties = penalties; List <Goal> redGoals = result.RedGoals; int redGoalScore = redGoals.Aggregate(0, (total, g) => total + g.PointValue()); redGoalScore = result.RedPenalties.Aggregate(redGoalScore, (total, p) => total + p.ScoreChange()); List <Goal> blueGoals = result.BlueGoals; int blueGoalScore = blueGoals.Aggregate(0, (total, g) => total + g.PointValue()); blueGoalScore = result.BluePenalties.Aggregate(blueGoalScore, (total, p) => total + p.ScoreChange()); // WINNER List <AllianceColor> winnerRecords = allData.ConvertAll <AllianceColor>((rec) => rec.Winner); AllianceColor winner = winnerRecords.Mode((modes) => redGoalScore > blueGoalScore ? AllianceColor.Red : AllianceColor.Blue); // Incredibly unlikely result.Winner = winner; // WORKING result.RedWorking = new AllianceGroup <bool>(); result.RedWorking.A = redData.A != null ? redData.A.Working : true; result.RedWorking.B = redData.B != null ? redData.B.Working : true; result.RedWorking.C = redData.C != null ? redData.C.Working : true; result.BlueWorking = new AllianceGroup <bool>(); result.BlueWorking.A = blueData.A != null ? blueData.A.Working : true; result.BlueWorking.B = blueData.B != null ? blueData.B.Working : true; result.BlueWorking.C = blueData.C != null ? blueData.C.Working : true; // DEFENSE result.RedDefense = new AllianceGroup <int>(); result.RedDefense.A = redData.A != null ? redData.A.Defense : 5; result.RedDefense.B = redData.B != null ? redData.B.Defense : 5; result.RedDefense.C = redData.C != null ? redData.C.Defense : 5; result.BlueDefense = new AllianceGroup <int>(); result.BlueDefense.A = blueData.A != null ? blueData.A.Defense : 5; result.BlueDefense.B = blueData.B != null ? blueData.B.Defense : 5; result.BlueDefense.C = blueData.C != null ? blueData.C.Defense : 5; // DISCREPANCY POINTS int finalScoreRed = (int)redData.ToList().ConvertAll <int>((rec) => rec.AllianceFinalScore).Mean(); int finalScoreBlue = (int)blueData.ToList().ConvertAll <int>((rec) => rec.AllianceFinalScore).Mean(); // round down result.RedFinalScore = finalScoreRed; result.BlueFinalScore = finalScoreBlue; int dpRed = finalScoreRed - redGoalScore; int dpBlue = finalScoreBlue - blueGoalScore; result.RedDiscrepancyPoints = dpRed; result.BlueDiscrepancyPoints = dpBlue; return(result); }