Last change
on this file since 320 was 313, checked in by alloc, 7 years ago |
Common func: Rebased Animals and Hostiles to common base
|
File size:
1.2 KB
|
Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.LiveData;
|
---|
3 | using AllocsFixes.PersistentData;
|
---|
4 | using System;
|
---|
5 | using System.Collections.Generic;
|
---|
6 | using System.Net;
|
---|
7 |
|
---|
8 | namespace 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));
|
---|
23 | result.Add ("hostiles", new JSONNumber (Hostiles.Instance.GetCount ()));
|
---|
24 | result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ()));
|
---|
25 |
|
---|
26 | WriteJSON (resp, result);
|
---|
27 | }
|
---|
28 |
|
---|
29 | public override int DefaultPermissionLevel () {
|
---|
30 | return 2000;
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.