コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                if (Stellaris != null)
                {
                    hashCode += 1000000007 * Stellaris.GetHashCode();
                }
            }
            return(hashCode);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public IEnumerable <string> GetMostRecentSaves([FromQuery] int?limit = null)
 {
     return(Stellaris.GetMostRecentSaves(saveGamesPath, limit));
 }