2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Dtos;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers
|
|
|
|
|
{
|
2018-03-06 02:22:19 -05:00
|
|
|
|
public class ServerController : BaseController
|
2018-02-21 20:29:23 -05:00
|
|
|
|
{
|
|
|
|
|
[HttpGet]
|
2018-02-22 01:06:21 -05:00
|
|
|
|
[ResponseCache(NoStore = true, Duration = 0)]
|
2018-02-21 20:29:23 -05:00
|
|
|
|
public IActionResult ClientActivity(int id)
|
|
|
|
|
{
|
|
|
|
|
|
2018-03-06 02:22:19 -05:00
|
|
|
|
var s = Manager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
|
2018-02-21 20:29:23 -05:00
|
|
|
|
if (s == null)
|
|
|
|
|
return View("Error", "Invalid server!");
|
|
|
|
|
|
|
|
|
|
var serverInfo = new ServerInfo()
|
|
|
|
|
{
|
|
|
|
|
Name = s.Hostname,
|
|
|
|
|
ID = s.GetHashCode(),
|
|
|
|
|
Port = s.GetPort(),
|
|
|
|
|
Map = s.CurrentMap.Alias,
|
|
|
|
|
ClientCount = s.ClientNum,
|
|
|
|
|
MaxClients = s.MaxClients,
|
|
|
|
|
GameType = s.Gametype,
|
|
|
|
|
Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo
|
|
|
|
|
{
|
|
|
|
|
Name = p.Name,
|
2018-03-28 23:01:09 -04:00
|
|
|
|
ClientId = p.ClientId,
|
2018-04-02 01:25:06 -04:00
|
|
|
|
Level = p.Level.ToString(),
|
|
|
|
|
LevelInt = (int)p.Level
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}).ToList(),
|
2018-02-22 01:06:21 -05:00
|
|
|
|
ChatHistory = s.ChatHistory.OrderBy(c => c.Time).Take((int)Math.Ceiling(s.ClientNum / 2.0)).ToArray(),
|
2018-04-05 00:38:45 -04:00
|
|
|
|
PlayerHistory = s.PlayerHistory.ToArray(),
|
2018-02-21 20:29:23 -05:00
|
|
|
|
};
|
|
|
|
|
return PartialView("_ClientActivity", serverInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|