RoomController.cs 1003 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Logging;
  4. using Microsoft.Extensions.Configuration;
  5. using gameapi.Library;
  6. using System.Collections.Generic;
  7. namespace gameapi.Controllers
  8. {
  9. [ApiController]
  10. [Route("api/room")]
  11. [Produces("application/json")]
  12. public class RoomController : ControllerBase
  13. {
  14. private readonly ILogger<WorldController> logger;
  15. private readonly IConfiguration configuration;
  16. private JsonFileReader jsonFileReader;
  17. private JsonFileSaver jsonFileSaver;
  18. public RoomController(IConfiguration config, ILogger<WorldController> log)
  19. {
  20. configuration = config;
  21. logger = log;
  22. this.jsonFileReader = new JsonFileReader();
  23. this.jsonFileSaver = new JsonFileSaver();
  24. }
  25. [HttpGet("{x},{y}")]
  26. public IActionResult Get(int x, int y)
  27. {
  28. IEnumerable<Player> population = GameState.GetInstance().GetSectorPopulation(new Tuple<int, int>(x, y));
  29. dynamic response = new { population = population };
  30. return Ok(response);
  31. }
  32. }
  33. }