From e2affb7635f092005abc3ba9b0a927ef93add3b3 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 22 Jan 2022 12:49:12 -0600 Subject: [PATCH] add server scoreboard functionality --- .../Models/Client/Stats/EFClientStatistics.cs | 38 ++++++--- .../AutomessageFeed/AutomessageFeed.csproj | 2 +- .../IW4ScriptCommands.csproj | 2 +- Plugins/LiveRadar/LiveRadar.csproj | 2 +- Plugins/LiveRadar/Views/Radar/Index.cshtml | 4 +- Plugins/Login/Login.csproj | 2 +- .../ProfanityDeterment.csproj | 2 +- Plugins/Stats/Helpers/StatManager.cs | 3 + Plugins/Stats/Stats.csproj | 2 +- Plugins/Welcome/Welcome.csproj | 2 +- WebfrontCore/Controllers/ServerController.cs | 79 +++++++++++++++---- WebfrontCore/ViewModels/ScoreboardInfo.cs | 25 ++++++ WebfrontCore/Views/About/Index.cshtml | 10 +-- WebfrontCore/Views/Admin/_ListAuditLog.cshtml | 10 +-- WebfrontCore/Views/Client/Find/Index.cshtml | 6 +- .../Views/Client/Message/_Item.cshtml | 18 ++--- .../Views/Client/Privileged/Index.cshtml | 4 +- .../Views/Client/Profile/Index.cshtml | 6 +- .../Meta/_AdministeredPenaltyResponse.cshtml | 4 +- .../Meta/_ConnectionHistoryResponse.cshtml | 4 +- .../Client/Profile/Meta/_Information.cshtml | 6 +- .../Profile/Meta/_MessageResponse.cshtml | 6 +- .../Meta/_ReceivedPenaltyResponse.cshtml | 6 +- .../Profile/Meta/_UpdatedAliasResponse.cshtml | 2 +- .../Views/Client/Statistics/Index.cshtml | 2 +- WebfrontCore/Views/Penalty/_Penalty.cshtml | 10 +-- WebfrontCore/Views/Server/Scoreboard.cshtml | 30 +++++++ .../Views/Server/_ClientActivity.cshtml | 22 +++--- WebfrontCore/Views/Server/_Scoreboard.cshtml | 32 ++++++++ WebfrontCore/Views/Server/_Server.cshtml | 16 +++- .../Components/Client/_RecentClients.cshtml | 4 +- WebfrontCore/WebfrontCore.csproj | 1 - WebfrontCore/bundleconfig.json | 1 + WebfrontCore/wwwroot/js/scoreboard.js | 15 ++++ 34 files changed, 278 insertions(+), 100 deletions(-) create mode 100644 WebfrontCore/ViewModels/ScoreboardInfo.cs create mode 100644 WebfrontCore/Views/Server/Scoreboard.cshtml create mode 100644 WebfrontCore/Views/Server/_Scoreboard.cshtml create mode 100644 WebfrontCore/wwwroot/js/scoreboard.js diff --git a/Data/Models/Client/Stats/EFClientStatistics.cs b/Data/Models/Client/Stats/EFClientStatistics.cs index ed6d01c18..38eae6db0 100644 --- a/Data/Models/Client/Stats/EFClientStatistics.cs +++ b/Data/Models/Client/Stats/EFClientStatistics.cs @@ -57,10 +57,11 @@ namespace Data.Models.Client.Stats public double MaxStrain { get; set; } [NotMapped] - public float AverageHitOffset - { - get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / Math.Max(1, HitLocations.Where(c => c.HitOffsetAverage > 0).Count()), 4); - } + public float AverageHitOffset => + (float) Math.Round( + HitLocations.Sum(c => c.HitOffsetAverage) / + Math.Max(1, HitLocations.Count(c => c.HitOffsetAverage > 0)), 4); + [NotMapped] public int SessionKills { get; set; } [NotMapped] @@ -82,26 +83,26 @@ namespace Data.Models.Client.Stats KillStreak = 0; DeathStreak = 0; LastScore = 0; - SessionScores.Add(0); + _sessionScores.Add(0); Team = 0; } [NotMapped] public int SessionScore { - set => SessionScores[SessionScores.Count - 1] = value; + set => _sessionScores[^1] = value; get { - lock (SessionScores) + lock (_sessionScores) { - return new List(SessionScores).Sum(); + return new List(_sessionScores).Sum(); } } } [NotMapped] - public int RoundScore => SessionScores[SessionScores.Count - 1]; + public int RoundScore => _sessionScores[^1]; [NotMapped] - private readonly List SessionScores = new List() { 0 }; + private readonly List _sessionScores = new List { 0 }; [NotMapped] public int Team { get; set; } [NotMapped] @@ -109,6 +110,21 @@ namespace Data.Models.Client.Stats [NotMapped] public double SessionSPM { get; set; } [NotMapped] - public SemaphoreSlim ProcessingHit { get; private set; } + public SemaphoreSlim ProcessingHit { get; } + + [NotMapped] public MatchData MatchData { get; } = new MatchData(); + } + + public class MatchData + { + public int Kills { get; set; } + public int Deaths { get; set; } + public double Kdr => Deaths == 0 ? Kills : Math.Round(Kills / (double) Deaths, 2); + + public void StartNewMatch() + { + Kills = 0; + Deaths = 0; + } } } diff --git a/Plugins/AutomessageFeed/AutomessageFeed.csproj b/Plugins/AutomessageFeed/AutomessageFeed.csproj index 74d65029a..84436442c 100644 --- a/Plugins/AutomessageFeed/AutomessageFeed.csproj +++ b/Plugins/AutomessageFeed/AutomessageFeed.csproj @@ -10,7 +10,7 @@ - + diff --git a/Plugins/IW4ScriptCommands/IW4ScriptCommands.csproj b/Plugins/IW4ScriptCommands/IW4ScriptCommands.csproj index c861e718c..00beedf57 100644 --- a/Plugins/IW4ScriptCommands/IW4ScriptCommands.csproj +++ b/Plugins/IW4ScriptCommands/IW4ScriptCommands.csproj @@ -10,7 +10,7 @@ - + diff --git a/Plugins/LiveRadar/LiveRadar.csproj b/Plugins/LiveRadar/LiveRadar.csproj index 097f0a07b..32c46f165 100644 --- a/Plugins/LiveRadar/LiveRadar.csproj +++ b/Plugins/LiveRadar/LiveRadar.csproj @@ -23,7 +23,7 @@ - + diff --git a/Plugins/LiveRadar/Views/Radar/Index.cshtml b/Plugins/LiveRadar/Views/Radar/Index.cshtml index 80995f202..a4d697071 100644 --- a/Plugins/LiveRadar/Views/Radar/Index.cshtml +++ b/Plugins/LiveRadar/Views/Radar/Index.cshtml @@ -17,7 +17,7 @@ @foreach (SharedLibraryCore.Dtos.ServerInfo server in ViewBag.Servers) { } @@ -467,4 +467,4 @@ }) -} \ No newline at end of file +} diff --git a/Plugins/Login/Login.csproj b/Plugins/Login/Login.csproj index a1254da84..63d4f83ea 100644 --- a/Plugins/Login/Login.csproj +++ b/Plugins/Login/Login.csproj @@ -19,7 +19,7 @@ - + diff --git a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj index 2bbc353df..0aa2fab4f 100644 --- a/Plugins/ProfanityDeterment/ProfanityDeterment.csproj +++ b/Plugins/ProfanityDeterment/ProfanityDeterment.csproj @@ -16,7 +16,7 @@ - + diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 33a6d2363..b3e3ac5c9 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -1289,12 +1289,14 @@ namespace IW4MAdmin.Plugins.Stats.Helpers if (!suicide) { attackerStats.Kills += 1; + attackerStats.MatchData.Kills += 1; attackerStats.SessionKills += 1; attackerStats.KillStreak += 1; attackerStats.DeathStreak = 0; } victimStats.Deaths += 1; + victimStats.MatchData.Deaths += 1; victimStats.SessionDeaths += 1; victimStats.DeathStreak += 1; victimStats.KillStreak = 0; @@ -1444,6 +1446,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers { session.stat?.StartNewSession(); session.detection?.OnMapChange(); + session.stat?.MatchData?.StartNewMatch(); } } diff --git a/Plugins/Stats/Stats.csproj b/Plugins/Stats/Stats.csproj index 261e0f94c..857431984 100644 --- a/Plugins/Stats/Stats.csproj +++ b/Plugins/Stats/Stats.csproj @@ -17,7 +17,7 @@ - + diff --git a/Plugins/Welcome/Welcome.csproj b/Plugins/Welcome/Welcome.csproj index ab081fec1..23970e317 100644 --- a/Plugins/Welcome/Welcome.csproj +++ b/Plugins/Welcome/Welcome.csproj @@ -20,7 +20,7 @@ - + diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index e5681946a..8e766da89 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -1,20 +1,19 @@ -using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; using SharedLibraryCore; using SharedLibraryCore.Dtos; using SharedLibraryCore.Interfaces; using System.Linq; using Data.Models.Client.Stats; -using SharedLibraryCore.Configuration; +using IW4MAdmin.Plugins.Stats.Helpers; +using WebfrontCore.ViewModels; namespace WebfrontCore.Controllers { public class ServerController : BaseController { - private readonly DefaultSettings _defaultSettings; - - public ServerController(IManager manager, DefaultSettings defaultSettings) : base(manager) + public ServerController(IManager manager) : base(manager) { - _defaultSettings = defaultSettings; } [HttpGet] @@ -36,21 +35,71 @@ namespace WebfrontCore.Controllers Map = s.CurrentMap.Alias, ClientCount = s.Clients.Count(client => client != null), MaxClients = s.MaxClients, - GameType = s.GametypeName, + GameType = s.GametypeName, Players = s.GetClientsAsList() - .Select(p => new PlayerInfo - { - Name = p.Name, - ClientId = p.ClientId, - Level = p.Level.ToLocalizedLevelName(), - LevelInt = (int)p.Level, - ZScore = p.GetAdditionalProperty(IW4MAdmin.Plugins.Stats.Helpers.StatManager.CLIENT_STATS_KEY)?.ZScore - }).ToList(), + .Select(p => new PlayerInfo + { + Name = p.Name, + ClientId = p.ClientId, + Level = p.Level.ToLocalizedLevelName(), + LevelInt = (int) p.Level, + ZScore = p.GetAdditionalProperty(IW4MAdmin.Plugins.Stats.Helpers.StatManager + .CLIENT_STATS_KEY)?.ZScore + }).ToList(), ChatHistory = s.ChatHistory.ToList(), PlayerHistory = s.ClientHistory.ToArray(), IsPasswordProtected = !string.IsNullOrEmpty(s.GamePassword) }; return PartialView("_ClientActivity", serverInfo); } + + [HttpGet] + public ActionResult Scoreboard() + { + ViewBag.Title = Localization["WEBFRONT_TITLE_SCOREBOARD"]; + + return View(ProjectScoreboard(Manager.GetServers())); + } + + [HttpGet("[controller]/{id}/scoreboard")] + public ActionResult Scoreboard(long id) + { + var server = Manager.GetServers().FirstOrDefault(srv => srv.EndPoint == id); + + if (server == null) + { + return NotFound(); + } + + return View("_Scoreboard", ProjectScoreboard(new[] {server}).First()); + } + + private IEnumerable ProjectScoreboard(IEnumerable servers) + { + return servers.Select(server => new ScoreboardInfo + { + MapName = server.CurrentMap.ToString(), + ServerName = server.Hostname, + ServerId = server.EndPoint, + ClientInfo = server.GetClientsAsList().Select(client => + new + { + stats = client.GetAdditionalProperty(StatManager.CLIENT_STATS_KEY), + client + }) + .Select(clientData => new ClientScoreboardInfo + { + ClientName = clientData.client.Name, + ClientId = clientData.client.ClientId, + Score = clientData.client.Score, + Ping = clientData.client.Ping, + Kills = clientData.stats?.MatchData?.Kills, + Deaths = clientData.stats?.MatchData?.Deaths, + ScorePerMinute = clientData.stats?.SessionSPM, + Kdr = clientData.stats?.MatchData?.Kdr + }) + .ToList() + }).ToList(); + } } } diff --git a/WebfrontCore/ViewModels/ScoreboardInfo.cs b/WebfrontCore/ViewModels/ScoreboardInfo.cs new file mode 100644 index 000000000..ad4e31c85 --- /dev/null +++ b/WebfrontCore/ViewModels/ScoreboardInfo.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace WebfrontCore.ViewModels +{ + + public class ScoreboardInfo + { + public string ServerName { get; set; } + public long ServerId { get; set; } + public string MapName { get; set; } + public List ClientInfo { get; set; } + } + + public class ClientScoreboardInfo + { + public string ClientName { get; set; } + public long ClientId { get; set; } + public int Score { get; set; } + public int Ping { get; set; } + public int? Kills { get; set; } + public int? Deaths { get; set; } + public double? ScorePerMinute { get; set; } + public double? Kdr { get; set; } + } +} diff --git a/WebfrontCore/Views/About/Index.cshtml b/WebfrontCore/Views/About/Index.cshtml index 1c45e28b8..bf75c46ee 100644 --- a/WebfrontCore/Views/About/Index.cshtml +++ b/WebfrontCore/Views/About/Index.cshtml @@ -18,7 +18,7 @@ @if (!string.IsNullOrWhiteSpace(Model.CommunityInformation.Name)) {

- +

} @@ -26,7 +26,7 @@ {

@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]

- +
@foreach (var social in Model.CommunityInformation.SocialAccounts ?? new SocialAccountConfiguration[0]) { @@ -66,16 +66,16 @@ var start = 1;
- +
@foreach (var rule in rules) {
@start. - +
start++; }
} -
\ No newline at end of file +
diff --git a/WebfrontCore/Views/Admin/_ListAuditLog.cshtml b/WebfrontCore/Views/Admin/_ListAuditLog.cshtml index 8d8a68025..0204c2f68 100644 --- a/WebfrontCore/Views/Admin/_ListAuditLog.cshtml +++ b/WebfrontCore/Views/Admin/_ListAuditLog.cshtml @@ -17,7 +17,7 @@ @loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"] - + @@ -27,7 +27,7 @@ @if (info.TargetId != null) { - + } else @@ -68,14 +68,14 @@ - + @if (info.TargetId != null) { - + } else @@ -96,4 +96,4 @@ @info.When.ToString() -} \ No newline at end of file +} diff --git a/WebfrontCore/Views/Client/Find/Index.cshtml b/WebfrontCore/Views/Client/Find/Index.cshtml index a0fc389e3..d301f0310 100644 --- a/WebfrontCore/Views/Client/Find/Index.cshtml +++ b/WebfrontCore/Views/Client/Find/Index.cshtml @@ -17,7 +17,7 @@
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy) @@ -45,7 +45,7 @@
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy) @@ -59,4 +59,4 @@
@client.LastConnectionText
} -
\ No newline at end of file + diff --git a/WebfrontCore/Views/Client/Message/_Item.cshtml b/WebfrontCore/Views/Client/Message/_Item.cshtml index 45b3670fb..67deebb34 100644 --- a/WebfrontCore/Views/Client/Message/_Item.cshtml +++ b/WebfrontCore/Views/Client/Message/_Item.cshtml @@ -7,21 +7,21 @@ - + @if (message.IsHidden && !ViewBag.Authorized) { - + } else { - + } - + @message.When @@ -33,7 +33,7 @@ @ViewBag.Localization["WEBFRONT_PENALTY_TEMPLATE_ADMIN"] - + @@ -43,11 +43,11 @@ @if (message.IsHidden && !ViewBag.Authorized) { - + } else { - + } @@ -55,7 +55,7 @@ @ViewBag.Localization["WEBFRONT_STATS_MESSAGE_SERVER_NAME"] - + @@ -65,4 +65,4 @@ @message.When -} \ No newline at end of file +} diff --git a/WebfrontCore/Views/Client/Privileged/Index.cshtml b/WebfrontCore/Views/Client/Privileged/Index.cshtml index f9a303518..35204ead0 100644 --- a/WebfrontCore/Views/Client/Privileged/Index.cshtml +++ b/WebfrontCore/Views/Client/Privileged/Index.cshtml @@ -14,11 +14,11 @@ @foreach (var client in Model[key]) { - +
} } } - \ No newline at end of file + diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 415e75b41..450ced47a 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -25,7 +25,7 @@
- +
@if (ViewBag.Authorized) { @@ -50,7 +50,7 @@ @foreach (var alias in Model.Aliases) {
- +
} @@ -196,4 +196,4 @@ -} \ No newline at end of file +} diff --git a/WebfrontCore/Views/Client/Profile/Meta/_AdministeredPenaltyResponse.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_AdministeredPenaltyResponse.cshtml index 3023b51ad..a3f592d6d 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_AdministeredPenaltyResponse.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_AdministeredPenaltyResponse.cshtml @@ -18,7 +18,7 @@ { - + } @@ -33,7 +33,7 @@ } else { - + } diff --git a/WebfrontCore/Views/Client/Profile/Meta/_ConnectionHistoryResponse.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_ConnectionHistoryResponse.cshtml index a036aacea..c8bb5d3bf 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_ConnectionHistoryResponse.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_ConnectionHistoryResponse.cshtml @@ -15,7 +15,7 @@ break; case "server": - + break; } @@ -25,4 +25,4 @@ { @token.MatchValue } -} \ No newline at end of file +} diff --git a/WebfrontCore/Views/Client/Profile/Meta/_Information.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_Information.cshtml index 9004f9d19..73db2ef79 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_Information.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_Information.cshtml @@ -22,7 +22,7 @@ { if (result.IsInterpolation) { - + } else @@ -34,10 +34,10 @@ else { - + @meta.Key }
}
-} \ No newline at end of file +} diff --git a/WebfrontCore/Views/Client/Profile/Meta/_MessageResponse.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_MessageResponse.cshtml index 0302d75c4..dd71a207a 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_MessageResponse.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_MessageResponse.cshtml @@ -11,12 +11,12 @@ @if (Model.IsHidden && !ViewBag.Authorized) { - + } else { - + } - \ No newline at end of file + diff --git a/WebfrontCore/Views/Client/Profile/Meta/_ReceivedPenaltyResponse.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_ReceivedPenaltyResponse.cshtml index 709bf63e9..23c4d8313 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_ReceivedPenaltyResponse.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_ReceivedPenaltyResponse.cshtml @@ -19,7 +19,7 @@ { - + } @@ -34,7 +34,7 @@ } else { - + } @@ -65,7 +65,7 @@ else { - + } } diff --git a/WebfrontCore/Views/Client/Profile/Meta/_UpdatedAliasResponse.cshtml b/WebfrontCore/Views/Client/Profile/Meta/_UpdatedAliasResponse.cshtml index 5094a7126..e2feb2391 100644 --- a/WebfrontCore/Views/Client/Profile/Meta/_UpdatedAliasResponse.cshtml +++ b/WebfrontCore/Views/Client/Profile/Meta/_UpdatedAliasResponse.cshtml @@ -13,7 +13,7 @@ break; case "alias": - + [@Model.IPAddress] break; diff --git a/WebfrontCore/Views/Client/Statistics/Index.cshtml b/WebfrontCore/Views/Client/Statistics/Index.cshtml index 64d931fe1..73b2c47d9 100644 --- a/WebfrontCore/Views/Client/Statistics/Index.cshtml +++ b/WebfrontCore/Views/Client/Statistics/Index.cshtml @@ -7,7 +7,7 @@ { } diff --git a/WebfrontCore/Views/Penalty/_Penalty.cshtml b/WebfrontCore/Views/Penalty/_Penalty.cshtml index fa9d0e5de..75cda93b5 100644 --- a/WebfrontCore/Views/Penalty/_Penalty.cshtml +++ b/WebfrontCore/Views/Penalty/_Penalty.cshtml @@ -9,7 +9,7 @@ @loc["WEBFRONT_PENALTY_TEMPLATE_NAME"] - + @@ -24,7 +24,7 @@ @loc["WEBFRONT_PENALTY_TEMPLATE_OFFENSE"] - + @@ -59,14 +59,14 @@ - + @Model.PenaltyType - + @Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync", @@ -88,4 +88,4 @@ } } - \ No newline at end of file + diff --git a/WebfrontCore/Views/Server/Scoreboard.cshtml b/WebfrontCore/Views/Server/Scoreboard.cshtml new file mode 100644 index 000000000..6c687699c --- /dev/null +++ b/WebfrontCore/Views/Server/Scoreboard.cshtml @@ -0,0 +1,30 @@ +@model IEnumerable + + +
+ @{ i = 0; } + @foreach (var server in Model) + { +
+ @await Html.PartialAsync("_Scoreboard", server) +
+ i++; + } +
+ +@section scripts { + + + +} diff --git a/WebfrontCore/Views/Server/_ClientActivity.cshtml b/WebfrontCore/Views/Server/_ClientActivity.cshtml index ad278ce14..791502fde 100644 --- a/WebfrontCore/Views/Server/_ClientActivity.cshtml +++ b/WebfrontCore/Views/Server/_ClientActivity.cshtml @@ -21,24 +21,24 @@ { - +
} if (Model.ChatHistory[i].Message == "DISCONNECTED") { - +
} if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED") { - + — - +
} } @@ -63,7 +63,7 @@ } - + @if (ViewBag.Authorized) @@ -88,7 +88,7 @@
- + @if (ViewBag.Authorized) { @@ -122,26 +122,26 @@ { - +
} if (Model.ChatHistory[i].Message == "DISCONNECTED") { - +
} if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED") { - + — - +
} } } -
\ No newline at end of file + diff --git a/WebfrontCore/Views/Server/_Scoreboard.cshtml b/WebfrontCore/Views/Server/_Scoreboard.cshtml new file mode 100644 index 000000000..317a0212b --- /dev/null +++ b/WebfrontCore/Views/Server/_Scoreboard.cshtml @@ -0,0 +1,32 @@ +@model WebfrontCore.ViewModels.ScoreboardInfo +@{ + Layout = null; +} + + + + + + + + + + + + @foreach (var client in Model.ClientInfo.OrderByDescending(c => c.Score)) + { + + + + + + + + + + } +
@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PLAYER"]@ViewBag.Localization["WEBFRONT_ADV_STATS_SCORE"]@ViewBag.Localization["WEBFRONT_ADV_STATS_KILLS"]@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_DEATHS"]@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_RATIO"]@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_SPM"]@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PING"]
+ + + + @client.Score@(client.Kills ?? 0)@(client.Deaths ?? 0)@Math.Round(client.Kdr ?? 0, 2)@Math.Round(client.ScorePerMinute ?? 0)@client.Ping
diff --git a/WebfrontCore/Views/Server/_Server.cshtml b/WebfrontCore/Views/Server/_Server.cshtml index b65986c52..06a8d8482 100644 --- a/WebfrontCore/Views/Server/_Server.cshtml +++ b/WebfrontCore/Views/Server/_Server.cshtml @@ -5,15 +5,19 @@
- - + + @if (ViewBag.Authorized) { - + } + + +
@@ -39,10 +43,14 @@ @if (ViewBag.Authorized) { -
+
} + + +
diff --git a/WebfrontCore/Views/Shared/Components/Client/_RecentClients.cshtml b/WebfrontCore/Views/Shared/Components/Client/_RecentClients.cshtml index b5a6a0451..734809226 100644 --- a/WebfrontCore/Views/Shared/Components/Client/_RecentClients.cshtml +++ b/WebfrontCore/Views/Shared/Components/Client/_RecentClients.cshtml @@ -40,7 +40,7 @@
@@ -49,4 +49,4 @@
@client.LastConnectionText
-} \ No newline at end of file +} diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 3d55f87a3..e5cf83a64 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -45,7 +45,6 @@ - diff --git a/WebfrontCore/bundleconfig.json b/WebfrontCore/bundleconfig.json index fd2af65d8..b38abb570 100644 --- a/WebfrontCore/bundleconfig.json +++ b/WebfrontCore/bundleconfig.json @@ -27,6 +27,7 @@ "wwwroot/js/search.js", "wwwroot/js/loader.js", "wwwroot/js/stats.js", + "wwwroot/js/scoreboard.js", "wwwroot/js/configuration.js", "wwwroot/js/advanced_stats.js" ], diff --git a/WebfrontCore/wwwroot/js/scoreboard.js b/WebfrontCore/wwwroot/js/scoreboard.js new file mode 100644 index 000000000..c4db64517 --- /dev/null +++ b/WebfrontCore/wwwroot/js/scoreboard.js @@ -0,0 +1,15 @@ +function refreshScoreboard() { + const serverPanel = $('.scoreboard-container.active'); + const serverId = $(serverPanel).data('server-id'); + + $.get(`../Server/${serverId}/Scoreboard`, (response) => { + $(serverPanel).html(response); + }); +} + +$(document).ready(() => { + $(window.location.hash).tab('show'); + $(`${window.location.hash}_nav`).addClass('active'); +}) + +setInterval(refreshScoreboard, 5000);