public void RtvMatchDetails(Object source, System.Timers.ElapsedEventArgs e) { if (WvwMatch.Options.active_match == null) return; _matchDetails = JsonConvert.DeserializeObject<Match_Details_>(Utils.GetJson("https://api.guildwars2.com/v1/wvw/match_details.json?match_id=" + WvwMatch.Options.active_match)); if (WvwMatch.Details == null || _resetMatch) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { LogWindow.ResetText(); })); WvwMatch.Details = _matchDetails; _resetMatch = false; WvwMatch.GetBLID(); } else { WvwMatch.Details.match_id = _matchDetails.match_id; WvwMatch.Details.Scores = _matchDetails.Scores; for (int i = 0; i < WvwMatch.Details.Maps.Count; i++) { int map = i; WvwMatch.Details.Maps[map].Scores = _matchDetails.Maps[map].Scores; for (int m = 0; m < _matchDetails.Maps[map].Objectives.Count; m++) { int obj = m; //Caching Guild info if(_matchDetails.Maps[map].Objectives[obj].owner_guild != null) { GuildData.GetGuildById(_matchDetails.Maps[map].Objectives[obj].owner_guild); } if (WvwMatch.Details.Maps[map].Objectives[obj].owner != _matchDetails.Maps[map].Objectives[obj].owner) { if (WvwMatch.Options.active_bl == WvwMatch.Details.Maps[map].Type) { var dict = new Dictionary<string, string> { {"time", DateTime.Now.ToString("t")}, {"objective", WvwMatch.Details.Maps[map].Objectives[obj].ObjData.name}, {"from", WvwMatch.getServerName(WvwMatch.Details.Maps[map].Objectives[obj].owner)}, {"from_color", WvwMatch.Details.Maps[map].Objectives[obj].owner}, {"to", WvwMatch.getServerName(_matchDetails.Maps[map].Objectives[obj].owner)}, {"to_color", _matchDetails.Maps[map].Objectives[obj].owner}, }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => LogWindow.AddEventLog(dict, false))); } WvwMatch.Details.Maps[map].Objectives[obj].owner = _matchDetails.Maps[map].Objectives[obj].owner; WvwMatch.Details.Maps[map].Objectives[obj].owner_guild = _matchDetails.Maps[map].Objectives[obj].owner_guild; WvwMatch.Details.Maps[map].Objectives[obj].last_change = DateTime.Now; } if (WvwMatch.Details.Maps[map].Objectives[obj].owner_guild != _matchDetails.Maps[map].Objectives[obj].owner_guild && WvwMatch.Details.Maps[map].Objectives[obj].owner == _matchDetails.Maps[map].Objectives[obj].owner) { WvwMatch.Details.Maps[map].Objectives[obj].owner_guild = _matchDetails.Maps[map].Objectives[obj].owner_guild; if (WvwMatch.Options.active_bl == WvwMatch.Details.Maps[map].Type) { var guildInfo = GuildData.GetGuildById(WvwMatch.Details.Maps[map].Objectives[obj].owner_guild); var dict = new Dictionary<string, string> { {"time", DateTime.Now.ToString("t")}, {"objective", WvwMatch.Details.Maps[map].Objectives[obj].ObjData.name}, {"owner_color", WvwMatch.Details.Maps[map].Objectives[obj].owner}, {"owner", guildInfo == null ? "released" : string.Format("[{1}] {0}", guildInfo[0], guildInfo[1])} }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => LogWindow.AddEventLog(dict, true))); } } } } } // Fill objective names and icons positions if(WvwMatch.Details.Maps[3].Objectives[0].ObjData.name == null) { for (int i = 0; i < WvwMatch.Details.Maps.Count; i++) { int map = i; var objData = JsonConvert.DeserializeObject<List<WvwObjective>>(Utils.GetJson(string.Format("Resources/obj_{0}.json", WvwMatch.Details.Maps[map].Type))); foreach (var obj in objData) { for (int y = 0; y < WvwMatch.Details.Maps[map].Objectives.Count; y++) { var objct = y; if (obj.id == WvwMatch.Details.Maps[map].Objectives[objct].id) WvwMatch.Details.Maps[map].Objectives[objct].ObjData = obj; } } } } _t3.Start(); }
public void RtvMatchDetails(Object source, System.Timers.ElapsedEventArgs e) { if (WvwMatch.Options.active_match == null) { return; } _matchDetails = JsonConvert.DeserializeObject <Match_Details_>(Utils.GetJson("https://api.guildwars2.com/v1/wvw/match_details.json?match_id=" + WvwMatch.Options.active_match)); if (WvwMatch.Details == null || _resetMatch) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { LogWindow.ResetText(); })); WvwMatch.Details = _matchDetails; _resetMatch = false; WvwMatch.GetBLID(); } else { WvwMatch.Details.match_id = _matchDetails.match_id; WvwMatch.Details.Scores = _matchDetails.Scores; for (int i = 0; i < WvwMatch.Details.Maps.Count; i++) { int map = i; WvwMatch.Details.Maps[map].Scores = _matchDetails.Maps[map].Scores; for (int m = 0; m < _matchDetails.Maps[map].Objectives.Count; m++) { int obj = m; //Caching Guild info if (_matchDetails.Maps[map].Objectives[obj].owner_guild != null) { GuildData.GetGuildById(_matchDetails.Maps[map].Objectives[obj].owner_guild); } if (WvwMatch.Details.Maps[map].Objectives[obj].owner != _matchDetails.Maps[map].Objectives[obj].owner) { if (WvwMatch.Options.active_bl == WvwMatch.Details.Maps[map].Type) { var dict = new Dictionary <string, string> { { "time", DateTime.Now.ToString("t") }, { "objective", WvwMatch.Details.Maps[map].Objectives[obj].ObjData.name }, { "from", WvwMatch.getServerName(WvwMatch.Details.Maps[map].Objectives[obj].owner) }, { "from_color", WvwMatch.Details.Maps[map].Objectives[obj].owner }, { "to", WvwMatch.getServerName(_matchDetails.Maps[map].Objectives[obj].owner) }, { "to_color", _matchDetails.Maps[map].Objectives[obj].owner }, }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => LogWindow.AddEventLog(dict, false))); } WvwMatch.Details.Maps[map].Objectives[obj].owner = _matchDetails.Maps[map].Objectives[obj].owner; WvwMatch.Details.Maps[map].Objectives[obj].owner_guild = _matchDetails.Maps[map].Objectives[obj].owner_guild; WvwMatch.Details.Maps[map].Objectives[obj].last_change = DateTime.Now; } if (WvwMatch.Details.Maps[map].Objectives[obj].owner_guild != _matchDetails.Maps[map].Objectives[obj].owner_guild && WvwMatch.Details.Maps[map].Objectives[obj].owner == _matchDetails.Maps[map].Objectives[obj].owner) { WvwMatch.Details.Maps[map].Objectives[obj].owner_guild = _matchDetails.Maps[map].Objectives[obj].owner_guild; if (WvwMatch.Options.active_bl == WvwMatch.Details.Maps[map].Type) { var guildInfo = GuildData.GetGuildById(WvwMatch.Details.Maps[map].Objectives[obj].owner_guild); var dict = new Dictionary <string, string> { { "time", DateTime.Now.ToString("t") }, { "objective", WvwMatch.Details.Maps[map].Objectives[obj].ObjData.name }, { "owner_color", WvwMatch.Details.Maps[map].Objectives[obj].owner }, { "owner", guildInfo == null ? "released" : string.Format("[{1}] {0}", guildInfo[0], guildInfo[1]) } }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => LogWindow.AddEventLog(dict, true))); } } } } } // Fill objective names and icons positions if (WvwMatch.Details.Maps[3].Objectives[0].ObjData.name == null) { for (int i = 0; i < WvwMatch.Details.Maps.Count; i++) { int map = i; var objData = JsonConvert.DeserializeObject <List <WvwObjective> >(Utils.GetJson(string.Format("Resources/obj_{0}.json", WvwMatch.Details.Maps[map].Type))); foreach (var obj in objData) { for (int y = 0; y < WvwMatch.Details.Maps[map].Objectives.Count; y++) { var objct = y; if (obj.id == WvwMatch.Details.Maps[map].Objectives[objct].id) { WvwMatch.Details.Maps[map].Objectives[objct].ObjData = obj; } } } } } _t3.Start(); }