source: binary-improvements/MapRendering/Web/API/GetStats.cs@ 425

Last change on this file since 425 was 351, checked in by alloc, 6 years ago

Fixed game version compatibility of GamePrefs
Code style cleanup (mostly argument names)

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