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
Line 
1using AllocsFixes.JSON;
2using AllocsFixes.LiveData;
3using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
4using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
5
6namespace AllocsFixes.NetConnections.Servers.Web.API {
7 public class GetStats : WebAPI {
8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
9 int _permissionLevel) {
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));
19 result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
20 result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
21
22 WriteJSON (_resp, result);
23 }
24
25 public override int DefaultPermissionLevel () {
26 return 2000;
27 }
28 }
29}
Note: See TracBrowser for help on using the repository browser.