public Dictionary <string, GwEvent> GetEvents(string worldId) { var request = new RestRequest(RequestUrls["Events"], Method.GET); request.AddParameter("world_id", worldId); var response = client.Execute <EventsResult>(request); var events = response.Data.events; var result = new Dictionary <string, GwEvent>(); foreach (var id in nameCache.GetEvents()) { Event ev; GwEvent newEv; if ((ev = events.FirstOrDefault(e => e.event_id == id)) == null) { newEv = new GwEvent(id, nameCache.GetEvent(id), null, null, GwEventState.Inactive); } else { var world = new GwWorld(this, ev.world_id, nameCache.GetWorld(ev.world_id)); var map = new GwMap(ev.map_id, nameCache.GetMap(ev.map_id)); newEv = new GwEvent(ev.event_id, nameCache.GetEvent(ev.event_id), world, map, ev.state); } result.Add(newEv.Id, newEv); } return(result); }
public Dictionary<string, GwEvent> GetEvents(string worldId) { var request = new RestRequest(RequestUrls["Events"], Method.GET); request.AddParameter("world_id", worldId); var response = client.Execute<EventsResult>(request); var events = response.Data.events; var result = new Dictionary<string, GwEvent>(); foreach (var id in nameCache.GetEvents()) { Event ev; GwEvent newEv; if ((ev = events.FirstOrDefault(e => e.event_id == id)) == null) { newEv = new GwEvent(id, nameCache.GetEvent(id), null, null, GwEventState.Inactive); } else { var world = new GwWorld(this, ev.world_id, nameCache.GetWorld(ev.world_id)); var map = new GwMap(ev.map_id, nameCache.GetMap(ev.map_id)); newEv = new GwEvent(ev.event_id, nameCache.GetEvent(ev.event_id), world, map, ev.state); } result.Add(newEv.Id, newEv); } return result; }
internal GwEvent(string id, string name, GwWorld world, GwMap map, GwEventState state) { Id = id; Name = name; World = world; Map = map; State = state; }
internal GwMatch(Api api, string id, GwWorld red, GwWorld blue, GwWorld green) { this.api = api; Id = id; Red = red; Blue = blue; Green = green; }
public GwMatch FindMatch(GwWorld world) { lock (matchesLock) { if (matches == null) matches = FetchMatches(); return matches.Values.First(m => m.Red == world || m.Blue == world || m.Green == world); } }
public GwMatch FindMatch(GwWorld world) { lock (matchesLock) { if (matches == null) { matches = FetchMatches(); } return(matches.Values.First(m => m.Red == world || m.Blue == world || m.Green == world)); } }
private Dictionary <string, GwMatch> FetchMatches() { var request = new RestRequest(RequestUrls["Matches"], Method.GET); var response = client.Execute <MatchesResult>(request); var result = new Dictionary <string, GwMatch>(); foreach (var i in response.Data.wvw_matches) { var red = new GwWorld(this, i.red_world_id, nameCache.GetWorld(i.red_world_id)); var blue = new GwWorld(this, i.blue_world_id, nameCache.GetWorld(i.blue_world_id)); var green = new GwWorld(this, i.green_world_id, nameCache.GetWorld(i.green_world_id)); var match = new GwMatch(this, i.wvw_match_id, red, blue, green); result.Add(match.Id, match); } return(result); }
private Dictionary<string, GwMatch> FetchMatches() { var request = new RestRequest(RequestUrls["Matches"], Method.GET); var response = client.Execute<MatchesResult>(request); var result = new Dictionary<string, GwMatch>(); foreach (var i in response.Data.wvw_matches) { var red = new GwWorld(this, i.red_world_id, nameCache.GetWorld(i.red_world_id)); var blue = new GwWorld(this, i.blue_world_id, nameCache.GetWorld(i.blue_world_id)); var green = new GwWorld(this, i.green_world_id, nameCache.GetWorld(i.green_world_id)); var match = new GwMatch(this, i.wvw_match_id, red, blue, green); result.Add(match.Id, match); } return result; }