public HttpResponseMessage GetPlayerCountry(string gameId, string saveName) { var fileName = Path.Combine(saveGamesPath, gameId, saveName); if (System.IO.File.Exists(fileName) == false) { Response.StatusCode = 404; return(null); } var content = Stellaris.GetGameSaveContent(fileName); var analyst = new Analyst(content); var country = analyst.GetCountry(analyst.PlayerTag); GC.Collect(); string json = JsonConvert.SerializeObject(country, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new SerializePopContractResolver() }); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); #pragma warning disable DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. response.Content = new StringContent(json); #pragma warning restore DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. return(response); }
public HttpResponseMessage GetCountries(string gameId, string saveName) { var fileName = Path.Combine(saveGamesPath, gameId, saveName); if (System.IO.File.Exists(fileName) == false) { Response.StatusCode = 404; return(null); } var content = Stellaris.GetGameSaveContent(fileName); var analyst = new Analyst(content); var countries = analyst.GetCountries(); GC.Collect(); memoryCache.GetOrUpdateTag0IsMachineEmpire(true, () => countries[0].IsMachineEmpire, () => analyst.GetInGameDate()); string json = JsonConvert.SerializeObject(countries, new JsonSerializerSettings { ContractResolver = new SerializePopContractResolver(), Formatting = serializerSettings.Formatting }); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); #pragma warning disable DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. response.Content = new StringContent(json); #pragma warning restore DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. return(response); }
public override int GetHashCode() { int hashCode = 0; unchecked { if (Stellaris != null) { hashCode += 1000000007 * Stellaris.GetHashCode(); } } return(hashCode); }
public HttpResponseMessage GetPlanetTile(string gameId, string saveName, string planetId) { var content = Stellaris.GetGameSaveContent(Path.Combine(saveGamesPath, gameId, saveName)); var analyst = new Analyst(content); var planetTiles = analyst.GetPlanetTitles(planetId); string json = JsonConvert.SerializeObject(planetTiles, new JsonSerializerSettings { Formatting = serializerSettings.Formatting }); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); #pragma warning disable DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. response.Content = new StringContent(json); #pragma warning restore DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. return(response); }
public ActionResult Index() { var fileName = Stellaris.GetMostRecentSaves(saveGamesPath, 1).FirstOrDefault(); var model = new StellarisLedger.Models.PlanetsIndexViewModel(); model.LatestSaveGamesPath = fileName; Lazy <Analyst> analyst = new Lazy <Analyst>(() => { var content = Stellaris.GetGameSaveContent(Path.Combine(saveGamesPath, fileName)); return(new Analyst(content)); }); model.IsMachineEmpire = memoryCache.GetOrUpdateTag0IsMachineEmpire(false, () => analyst.Value.GetCountry(0).IsMachineEmpire, () => analyst.Value.GetInGameDate()); return(View(model)); }
public HttpResponseMessage GetPlanetTilesData(string gameId, string saveName, string tag) { if (tag.Equals("me", StringComparison.OrdinalIgnoreCase)) { tag = "0"; } var content = Stellaris.GetGameSaveContent(Path.Combine(saveGamesPath, gameId, saveName)); var analyst = new Analyst(content); var planetTilesData = analyst.GetCountryPlanetTiles(tag); string json = JsonConvert.SerializeObject(planetTilesData, new JsonSerializerSettings { Formatting = serializerSettings.Formatting }); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); #pragma warning disable DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. response.Content = new StringContent(json); #pragma warning restore DF0022 // Marks undisposed objects assinged to a property, originated in an object creation. return(response); }
public IEnumerable <string> GetMostRecentSaves([FromQuery] int?limit = null) { return(Stellaris.GetMostRecentSaves(saveGamesPath, limit)); }