diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index b7f80486e..f9d6d3812 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -548,7 +548,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers // sync their stats before they leave if (clientStats != null) { - clientStats = UpdateStats(clientStats); + clientStats = UpdateStats(clientStats, pl); await SaveClientStats(clientStats); if (_configHandler.Configuration().EnableAdvancedMetrics) { @@ -900,7 +900,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers victim.SetAdditionalProperty(ESTIMATED_SCORE, estimatedVictimScore); // calculate for the clients - CalculateKill(attackerStats, victimStats); + CalculateKill(attackerStats, victimStats, attacker, victim); // this should fix the negative SPM // updates their last score after being calculated attackerStats.LastScore = estimatedAttackerScore; @@ -1252,7 +1252,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers /// /// Stats of the attacker /// Stats of the victim - public void CalculateKill(EFClientStatistics attackerStats, EFClientStatistics victimStats) + public void CalculateKill(EFClientStatistics attackerStats, EFClientStatistics victimStats, + EFClient attacker, EFClient victim) { bool suicide = attackerStats.ClientId == victimStats.ClientId; @@ -1271,7 +1272,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers victimStats.KillStreak = 0; // process the attacker's stats after the kills - attackerStats = UpdateStats(attackerStats); + attackerStats = UpdateStats(attackerStats, attacker); // calculate elo var attackerEloDifference = Math.Log(Math.Max(1, victimStats.EloRating)) - @@ -1296,7 +1297,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers /// /// Client statistics /// - private EFClientStatistics UpdateStats(EFClientStatistics clientStats) + private EFClientStatistics UpdateStats(EFClientStatistics clientStats, EFClient client) { // prevent NaN or inactive time lowering SPM if ((DateTime.UtcNow - clientStats.LastStatCalculation).TotalSeconds / 60.0 < 0.01 || @@ -1332,7 +1333,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers killSpm *= Math.Max(1, spmMultiplier); // update this for ac tracking - clientStats.SessionSPM = clientStats.SessionScore / Math.Max(1, clientStats.Client.ToPartialClient().ConnectionLength / 60.0); + clientStats.SessionSPM = clientStats.SessionScore / Math.Max(1, client.ConnectionLength / 60.0); // calculate how much the KDR should weigh // 1.637 is a Eddie-Generated number that weights the KDR nicely diff --git a/SharedLibraryCore/Dtos/PlayerInfo.cs b/SharedLibraryCore/Dtos/PlayerInfo.cs index d5aed2c7d..ba138fcfe 100644 --- a/SharedLibraryCore/Dtos/PlayerInfo.cs +++ b/SharedLibraryCore/Dtos/PlayerInfo.cs @@ -28,5 +28,6 @@ namespace SharedLibraryCore.Dtos public string LastConnectionText => (DateTime.UtcNow - LastConnection).HumanizeForCurrentCulture(); public IDictionary LinkedAccounts { get; set; } public MetaType? MetaFilterType { get; set; } + public double? ZScore { get; set; } } } diff --git a/SharedLibraryCore/Dtos/ServerInfo.cs b/SharedLibraryCore/Dtos/ServerInfo.cs index f1bc891aa..344c3d107 100644 --- a/SharedLibraryCore/Dtos/ServerInfo.cs +++ b/SharedLibraryCore/Dtos/ServerInfo.cs @@ -23,5 +23,21 @@ namespace SharedLibraryCore.Dtos public string IPAddress { get; set; } public bool IsPasswordProtected { get; set; } public string Endpoint => $"{IPAddress}:{Port}"; + + public double? LobbyZScore + { + get + { + var valid = Players.Where(player => player.ZScore != null && player.ZScore != 0) + .ToList(); + + if (!valid.Any()) + { + return null; + } + + return Math.Round(valid.Select(player => player.ZScore.Value).Average(), 2); + } + } } -} +} \ No newline at end of file diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index 3f50f0dec..c65f610d4 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -3,6 +3,7 @@ using SharedLibraryCore; using SharedLibraryCore.Dtos; using SharedLibraryCore.Interfaces; using System.Linq; +using Data.Models.Client.Stats; namespace WebfrontCore.Controllers { @@ -39,7 +40,8 @@ namespace WebfrontCore.Controllers Name = p.Name, ClientId = p.ClientId, Level = p.Level.ToLocalizedLevelName(), - LevelInt = (int)p.Level + 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(), diff --git a/WebfrontCore/ViewComponents/ServerListViewComponent.cs b/WebfrontCore/ViewComponents/ServerListViewComponent.cs index 012f18728..1c2af9ba2 100644 --- a/WebfrontCore/ViewComponents/ServerListViewComponent.cs +++ b/WebfrontCore/ViewComponents/ServerListViewComponent.cs @@ -3,6 +3,7 @@ using SharedLibraryCore; using SharedLibraryCore.Dtos; using System.Linq; using System.Net; +using Data.Models.Client.Stats; using static SharedLibraryCore.Server; namespace WebfrontCore.ViewComponents @@ -30,7 +31,8 @@ namespace WebfrontCore.ViewComponents ClientId = p.ClientId, Level = p.Level.ToLocalizedLevelName(), LevelInt = (int)p.Level, - Tag = p.Tag + Tag = p.Tag, + ZScore = p.GetAdditionalProperty(IW4MAdmin.Plugins.Stats.Helpers.StatManager.CLIENT_STATS_KEY)?.ZScore }).ToList(), ChatHistory = s.ChatHistory.ToList(), Online = !s.Throttled, diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 526c47579..a367581cc 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -22,7 +22,7 @@ } -
+
diff --git a/WebfrontCore/Views/Server/_ClientActivity.cshtml b/WebfrontCore/Views/Server/_ClientActivity.cshtml index de43e762a..ad278ce14 100644 --- a/WebfrontCore/Views/Server/_ClientActivity.cshtml +++ b/WebfrontCore/Views/Server/_ClientActivity.cshtml @@ -92,7 +92,7 @@ @if (ViewBag.Authorized) { - + }
diff --git a/WebfrontCore/Views/Server/_Server.cshtml b/WebfrontCore/Views/Server/_Server.cshtml index e2192de92..c5636eeeb 100644 --- a/WebfrontCore/Views/Server/_Server.cshtml +++ b/WebfrontCore/Views/Server/_Server.cshtml @@ -16,8 +16,26 @@ }
-
@Model.Map
-
@Model.ClientCount/@Model.MaxClients
+
+ @Model.Map + @if (!string.IsNullOrEmpty(Model.GameType) && Model.GameType.Length > 1) + { + + @Model.GameType.ToUpper() + } +
+
+ @if (Model.LobbyZScore != null) + { +
+ @(Model.LobbyZScore ?? 0) + +
+ } +
+ @Model.ClientCount/@Model.MaxClients +
+
@if (ViewBag.Authorized) { @@ -27,10 +45,10 @@ }
-
+
@await Html.PartialAsync("../Server/_ClientActivity", Model)
-
+
\ No newline at end of file diff --git a/WebfrontCore/wwwroot/css/src/main.scss b/WebfrontCore/wwwroot/css/src/main.scss index 2da94265b..0bb7fc820 100644 --- a/WebfrontCore/wwwroot/css/src/main.scss +++ b/WebfrontCore/wwwroot/css/src/main.scss @@ -437,3 +437,7 @@ div.card { #hitlocation_container { background-color: #141414; } + +.cursor-help { + cursor: help; +}