Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.LiveData;
|
---|
3 | using JetBrains.Annotations;
|
---|
4 |
|
---|
5 | namespace Webserver.WebAPI {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class GetStats : AbsWebAPI {
|
---|
8 | public override void HandleRequest (RequestContext _context) {
|
---|
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));
|
---|
18 | result.Add ("hostiles", new JsonNumber (Hostiles.Instance.GetCount ()));
|
---|
19 | result.Add ("animals", new JsonNumber (Animals.Instance.GetCount ()));
|
---|
20 |
|
---|
21 | WebUtils.WriteJson (_context.Response, result);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override int DefaultPermissionLevel () {
|
---|
25 | return 2000;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.