internal static EFilter_Mode propertiesDict_getMode() { EFilter_Mode mode = EFilter_Mode.fw; if (App.Current.Properties.ContainsKey("mode")) { string modeString = App.Current.Properties["mode"] as string; switch (modeString) { case "FW": mode = EFilter_Mode.fw; break; case "HSW": mode = EFilter_Mode.hsw; break; case "SW": mode = EFilter_Mode.sw; break; case "BW": mode = EFilter_Mode.bw; break; default: goto case "FW"; } } else { App.Current.Properties.Add("mode", EFilter_ToString.toString(mode)); App.Current.SavePropertiesAsync(); } return(mode); }
internal async Task <PlayerWRsRootObject> GetPlayerWRs(EFilter_Game game, EFilter_Mode mode, EFilter_PlayerWRsType wrType, EFilter_PlayerType playerType, string playerValue, int startIndex) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string wrString = EFilter_ToString.toString(wrType); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/" + playerTypeString + "/" + playerValue + "/" + wrString + "/" + startIndex + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <PlayerWRsRootObject>(response.Content)); } else { return(null); } }
internal async Task <MapTopRootObject> GetMapTop(EFilter_Game game, string map, EFilter_Mode mode, int zone, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "" || map == "" || zone < 0) { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/map/" + map + "/zone/" + zone + "/" + start_index + ",25/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapTopRootObject>(response.Content)); } else { return(null); } }
internal static EFilter_Game propertiesDict_getGame() { EFilter_Game game = EFilter_Game.css; if (App.Current.Properties.ContainsKey("game")) { string gameString = App.Current.Properties["game"] as string; switch (gameString) { case "css": game = EFilter_Game.css; break; case "css100t": game = EFilter_Game.css100t; break; case "csgo": game = EFilter_Game.csgo; break; default: goto case "css"; } } else { App.Current.Properties.Add("game", EFilter_ToString.toString(game)); App.Current.SavePropertiesAsync(); } return(game); }
// KSF API calls ----------------------------------------------------------------------------------------------------------- #region ksf internal async Task <DetailedMapsRootObject> GetDetailedMapsList(EFilter_Game game, EFilter_Sort sort) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string sortString = EFilter_ToString.toString(sort); if (gameString == "" || sortString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/maplist/detailedlist/" + sortString + "/1,999"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <DetailedMapsRootObject>(response.Content)); } else { return(null); } }
internal async Task <MapInfoRootObject> GetMapInfo(EFilter_Game game, string map) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); if (gameString == "" || map == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/map/" + map + "/mapinfo"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapInfoRootObject>(response.Content)); } else { return(null); } }
internal async Task <MapPRInfoRootObject> GetMapPRInfo(EFilter_Game game, EFilter_Mode mode, string map, EFilter_PlayerType playerType, string playerValue) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || map == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/map/" + map + "/zone/0/" + playerTypeString + "/" + playerValue + "/recordinfo/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapPRInfoRootObject>(response.Content)); } else { return(null); } }
internal async Task <RR10RootObject> GetRecentRecords10(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/recentrecords/server/top10/1,10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <RR10RootObject>(response.Content)); } else { return(null); } }
internal async Task <string> GetTopCountry(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/countries/1,1/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { TopCountriesRootObject tcro = JsonConvert.DeserializeObject <TopCountriesRootObject>(response.Content); return(tcro.data[0]?.country); } else { return(null); } }
internal async Task <OldestRecordsRootObject> GetOldestRecords(EFilter_Game game, EFilter_ORType type, EFilter_Mode mode, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string typeString = EFilter_ToString.toString(type); string modeString = ((int)mode).ToString(); if (gameString == "" || typeString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/oldestrecords/server/" + typeString + "/" + start_index + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <OldestRecordsRootObject>(response.Content)); } else { return(null); } }
// KSF API call ------------------------------------------------------------------------- #region ksf internal async Task <KSFServerRootObject> GetServers(EFilter_Game game) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/servers/list"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <KSFServerRootObject>(response.Content)); } else { if (BaseViewModel.client.UserAgent != "" || BaseViewModel.AGENT != "") { BaseViewModel.AGENT = ""; BaseViewModel.client.UserAgent = ""; return(await GetServers(game)); } return(null); } }