예제 #1
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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);
        }
예제 #2
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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;
        }
예제 #3
0
파일: GwEvent.cs 프로젝트: Rohansi/GwSharp
 internal GwEvent(string id, string name, GwWorld world, GwMap map, GwEventState state)
 {
     Id = id;
     Name = name;
     World = world;
     Map = map;
     State = state;
 }
예제 #4
0
 internal GwEvent(string id, string name, GwWorld world, GwMap map, GwEventState state)
 {
     Id    = id;
     Name  = name;
     World = world;
     Map   = map;
     State = state;
 }
예제 #5
0
파일: GwMatch.cs 프로젝트: Rohansi/GwSharp
        internal GwMatch(Api api, string id, GwWorld red, GwWorld blue, GwWorld green)
        {
            this.api = api;

            Id = id;
            Red = red;
            Blue = blue;
            Green = green;
        }
예제 #6
0
        internal GwMatch(Api api, string id, GwWorld red, GwWorld blue, GwWorld green)
        {
            this.api = api;

            Id    = id;
            Red   = red;
            Blue  = blue;
            Green = green;
        }
예제 #7
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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);
            }
        }
예제 #8
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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));
            }
        }
예제 #9
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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);
        }
예제 #10
0
파일: Api.cs 프로젝트: Rohansi/GwSharp
        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;
        }