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

Last change on this file since 306 was 306, checked in by alloc, 7 years ago

Fixes update A16.2

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