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

Last change on this file since 389 was 387, checked in by alloc, 2 years ago

Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time

File size: 1.0 KB
Line 
1using AllocsFixes.JSON;
2using AllocsFixes.LiveData;
3
4namespace AllocsFixes.NetConnections.Servers.Web.API {
5 public class GetStats : AbsWebAPI {
6 public override void HandleRequest (RequestContext _context) {
7 JSONObject result = new JSONObject ();
8
9 JSONObject time = new JSONObject ();
10 time.Add ("days", new JSONNumber (GameUtils.WorldTimeToDays (GameManager.Instance.World.worldTime)));
11 time.Add ("hours", new JSONNumber (GameUtils.WorldTimeToHours (GameManager.Instance.World.worldTime)));
12 time.Add ("minutes", new JSONNumber (GameUtils.WorldTimeToMinutes (GameManager.Instance.World.worldTime)));
13 result.Add ("gametime", time);
14
15 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count));
16 result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
17 result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
18
19 WebUtils.WriteJson (_context.Response, result);
20 }
21
22 public override int DefaultPermissionLevel () {
23 return 2000;
24 }
25 }
26}
Note: See TracBrowser for help on using the repository browser.