source: binary-improvements2/MapRendering/Web/API/GetStats.cs@ 384

Last change on this file since 384 was 383, checked in by alloc, 2 years ago

Fixed a bunch of warnings

File size: 1.2 KB
RevLine 
[251]1using AllocsFixes.JSON;
2using AllocsFixes.LiveData;
[382]3using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
4using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
[251]5
[325]6namespace AllocsFixes.NetConnections.Servers.Web.API {
7 public class GetStats : WebAPI {
[351]8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
9 int _permissionLevel) {
[251]10 JSONObject result = new JSONObject ();
11
12 JSONObject time = new JSONObject ();
13 time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
14 time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
15 time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
16 result.Add ("gametime", time);
17
18 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
[313]19 result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
20 result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
[251]21
[351]22 WriteJSON (_resp, result);
[251]23 }
[279]24
25 public override int DefaultPermissionLevel () {
26 return 2000;
27 }
[251]28 }
[325]29}
Note: See TracBrowser for help on using the repository browser.