public static void Main(string[] args) { TypeDescriptor.AddAttributes(typeof(Uuid), new TypeConverterAttribute(typeof(StringToUuidConv))); // Init Logging var log = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File("logs/debug.txt", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, fileSizeLimitBytes: 8338607, outputTemplate: "{Timestamp:HH:mm:ss.fff} [{Level:u3}] {Message:lj}{NewLine}{Exception}") .MinimumLevel.Debug() .CreateLogger(); Log.Logger = log; //Initialize state singleton from config StateSingleton.Instance.config = ServerConfig.getFromFile(); StateSingleton.Instance.catalog = CatalogResponse.FromFiles(StateSingleton.Instance.config.itemsFolderLocation, StateSingleton.Instance.config.efficiencyCategoriesFolderLocation); StateSingleton.Instance.recipes = Recipes.FromFile(StateSingleton.Instance.config.recipesFileLocation); StateSingleton.Instance.settings = SettingsResponse.FromFile(StateSingleton.Instance.config.settingsFileLocation); StateSingleton.Instance.seasonChallenges = ChallengesResponse.FromFile(StateSingleton.Instance.config.seasonChallengesFileLocation); StateSingleton.Instance.productCatalog = ProductCatalogResponse.FromFile(StateSingleton.Instance.config.productCatalogFileLocation); StateSingleton.Instance.tappableData = TappableUtils.loadAllTappableSets(); StateSingleton.Instance.activeTappableTypes = new Dictionary <Guid, string>(); //Start api CreateHostBuilder(args).Build().Run(); Log.Information("Server started!"); }
public ContentResult Get(double latitude, double longitude) { var currentTime = DateTime.UtcNow; //Nab tile loc int[] cords = Tile.getTileForCords(latitude, longitude); List <LocationResponse.ActiveLocation> tappables = new List <LocationResponse.ActiveLocation>(); int numTappablesToSpawn = random.Next(StateSingleton.Instance.config.minTappableSpawnAmount, StateSingleton.Instance.config.maxTappableSpawnAmount); for (int i = 0; i < numTappablesToSpawn; i++) { var tappable = TappableUtils.createTappableInRadiusOfCoordinates(longitude, latitude); //add the tappable to the list tappables.Add(tappable); //add its GUID to the singleton so we can grab the correct reward pool later StateSingleton.Instance.activeTappableTypes.Add(Guid.Parse(tappable.id), tappable.icon); } //Create our final response LocationResponse.Root locationResp = new LocationResponse.Root { result = new LocationResponse.Result { killSwitchedTileIds = new List <object> { }, //havent seen this used. Debugging thing maybe? activeLocations = tappables, }, expiration = null, continuationToken = null, updates = new Updates() }; //serialize var response = JsonConvert.SerializeObject(locationResp); //Send return(Content(response, "application/json")); }