add lobby rating to home

add gametype (WIP) to home
misc UI tweaks
This commit is contained in:
RaidMax 2021-06-30 09:57:07 -05:00
parent fc0bed2405
commit bccbcce3c1
9 changed files with 59 additions and 15 deletions

View File

@ -548,7 +548,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// sync their stats before they leave // sync their stats before they leave
if (clientStats != null) if (clientStats != null)
{ {
clientStats = UpdateStats(clientStats); clientStats = UpdateStats(clientStats, pl);
await SaveClientStats(clientStats); await SaveClientStats(clientStats);
if (_configHandler.Configuration().EnableAdvancedMetrics) if (_configHandler.Configuration().EnableAdvancedMetrics)
{ {
@ -900,7 +900,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
victim.SetAdditionalProperty(ESTIMATED_SCORE, estimatedVictimScore); victim.SetAdditionalProperty(ESTIMATED_SCORE, estimatedVictimScore);
// calculate for the clients // calculate for the clients
CalculateKill(attackerStats, victimStats); CalculateKill(attackerStats, victimStats, attacker, victim);
// this should fix the negative SPM // this should fix the negative SPM
// updates their last score after being calculated // updates their last score after being calculated
attackerStats.LastScore = estimatedAttackerScore; attackerStats.LastScore = estimatedAttackerScore;
@ -1252,7 +1252,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
/// </summary> /// </summary>
/// <param name="attackerStats">Stats of the attacker</param> /// <param name="attackerStats">Stats of the attacker</param>
/// <param name="victimStats">Stats of the victim</param> /// <param name="victimStats">Stats of the victim</param>
public void CalculateKill(EFClientStatistics attackerStats, EFClientStatistics victimStats) public void CalculateKill(EFClientStatistics attackerStats, EFClientStatistics victimStats,
EFClient attacker, EFClient victim)
{ {
bool suicide = attackerStats.ClientId == victimStats.ClientId; bool suicide = attackerStats.ClientId == victimStats.ClientId;
@ -1271,7 +1272,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
victimStats.KillStreak = 0; victimStats.KillStreak = 0;
// process the attacker's stats after the kills // process the attacker's stats after the kills
attackerStats = UpdateStats(attackerStats); attackerStats = UpdateStats(attackerStats, attacker);
// calculate elo // calculate elo
var attackerEloDifference = Math.Log(Math.Max(1, victimStats.EloRating)) - var attackerEloDifference = Math.Log(Math.Max(1, victimStats.EloRating)) -
@ -1296,7 +1297,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
/// </summary> /// </summary>
/// <param name="clientStats">Client statistics</param> /// <param name="clientStats">Client statistics</param>
/// <returns></returns> /// <returns></returns>
private EFClientStatistics UpdateStats(EFClientStatistics clientStats) private EFClientStatistics UpdateStats(EFClientStatistics clientStats, EFClient client)
{ {
// prevent NaN or inactive time lowering SPM // prevent NaN or inactive time lowering SPM
if ((DateTime.UtcNow - clientStats.LastStatCalculation).TotalSeconds / 60.0 < 0.01 || if ((DateTime.UtcNow - clientStats.LastStatCalculation).TotalSeconds / 60.0 < 0.01 ||
@ -1332,7 +1333,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
killSpm *= Math.Max(1, spmMultiplier); killSpm *= Math.Max(1, spmMultiplier);
// update this for ac tracking // 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 // calculate how much the KDR should weigh
// 1.637 is a Eddie-Generated number that weights the KDR nicely // 1.637 is a Eddie-Generated number that weights the KDR nicely

View File

@ -28,5 +28,6 @@ namespace SharedLibraryCore.Dtos
public string LastConnectionText => (DateTime.UtcNow - LastConnection).HumanizeForCurrentCulture(); public string LastConnectionText => (DateTime.UtcNow - LastConnection).HumanizeForCurrentCulture();
public IDictionary<int, long> LinkedAccounts { get; set; } public IDictionary<int, long> LinkedAccounts { get; set; }
public MetaType? MetaFilterType { get; set; } public MetaType? MetaFilterType { get; set; }
public double? ZScore { get; set; }
} }
} }

View File

@ -23,5 +23,21 @@ namespace SharedLibraryCore.Dtos
public string IPAddress { get; set; } public string IPAddress { get; set; }
public bool IsPasswordProtected { get; set; } public bool IsPasswordProtected { get; set; }
public string Endpoint => $"{IPAddress}:{Port}"; 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);
}
}
} }
} }

View File

@ -3,6 +3,7 @@ using SharedLibraryCore;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using System.Linq; using System.Linq;
using Data.Models.Client.Stats;
namespace WebfrontCore.Controllers namespace WebfrontCore.Controllers
{ {
@ -39,7 +40,8 @@ namespace WebfrontCore.Controllers
Name = p.Name, Name = p.Name,
ClientId = p.ClientId, ClientId = p.ClientId,
Level = p.Level.ToLocalizedLevelName(), Level = p.Level.ToLocalizedLevelName(),
LevelInt = (int)p.Level LevelInt = (int)p.Level,
ZScore = p.GetAdditionalProperty<EFClientStatistics>(IW4MAdmin.Plugins.Stats.Helpers.StatManager.CLIENT_STATS_KEY)?.ZScore
}).ToList(), }).ToList(),
ChatHistory = s.ChatHistory.ToList(), ChatHistory = s.ChatHistory.ToList(),
PlayerHistory = s.ClientHistory.ToArray(), PlayerHistory = s.ClientHistory.ToArray(),

View File

@ -3,6 +3,7 @@ using SharedLibraryCore;
using SharedLibraryCore.Dtos; using SharedLibraryCore.Dtos;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using Data.Models.Client.Stats;
using static SharedLibraryCore.Server; using static SharedLibraryCore.Server;
namespace WebfrontCore.ViewComponents namespace WebfrontCore.ViewComponents
@ -30,7 +31,8 @@ namespace WebfrontCore.ViewComponents
ClientId = p.ClientId, ClientId = p.ClientId,
Level = p.Level.ToLocalizedLevelName(), Level = p.Level.ToLocalizedLevelName(),
LevelInt = (int)p.Level, LevelInt = (int)p.Level,
Tag = p.Tag Tag = p.Tag,
ZScore = p.GetAdditionalProperty<EFClientStatistics>(IW4MAdmin.Plugins.Stats.Helpers.StatManager.CLIENT_STATS_KEY)?.ZScore
}).ToList(), }).ToList(),
ChatHistory = s.ChatHistory.ToList(), ChatHistory = s.ChatHistory.ToList(),
Online = !s.Throttled, Online = !s.Throttled,

View File

@ -22,7 +22,7 @@
} }
</div> </div>
<!-- Name/Level Column --> <!-- Name/Level Column -->
<div class="w-75 d-block d-lg-inline-flex flex-column flex-fill text-center text-lg-left pb-3 pb-lg-0 pt-3 pt-lg-0 pl-3 pr-3 ml-auto mr-auto" style="overflow-wrap: anywhere"> <div class="w-50 d-block d-lg-inline-flex flex-column flex-fill text-center text-lg-left pb-3 pb-lg-0 pt-3 pt-lg-0 pl-3 pr-3 ml-auto mr-auto" style="overflow-wrap: anywhere">
<div class="mt-n2 flex-fill d-block d-lg-inline-flex"> <div class="mt-n2 flex-fill d-block d-lg-inline-flex">
<div id="profile_name" class="client-name h1 mb-0"> <div id="profile_name" class="client-name h1 mb-0">
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code> <color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>

View File

@ -92,7 +92,7 @@
</a> </a>
@if (ViewBag.Authorized) @if (ViewBag.Authorized)
{ {
<span class="oi oi-circle-x ml-1 profile-action align-baseline action-kick-button flex-column" data-action="kick" data-action-id="@Model.Players[i].ClientId" aria-hidden="true"></span> <span class="oi oi-circle-x profile-action align-baseline action-kick-button flex-column mt-0" data-action="kick" data-action-id="@Model.Players[i].ClientId" aria-hidden="true"></span>
} }
<br /> <br />
</div> </div>

View File

@ -16,8 +16,26 @@
} }
</div> </div>
<div class="text-center col-md-4">@Model.Map</div> <div class="text-center col-md-4">
<div class="text-center text-md-right col-md-4"><span class="server-clientcount">@Model.ClientCount</span>/<span class="server-maxclients">@Model.MaxClients</span></div> <span>@Model.Map</span>
@if (!string.IsNullOrEmpty(Model.GameType) && Model.GameType.Length > 1)
{
<span>&ndash;</span>
<span>@Model.GameType.ToUpper()</span>
}
</div>
<div class="text-center text-md-right col-md-4 d-flex justify-content-center justify-content-md-end flex-column-reverse flex-sm-row">
@if (Model.LobbyZScore != null)
{
<div title="@ViewBag.Localization["WEBFRONT_HOME_RATING_DESC"]" class="cursor-help d-flex flex-row-reverse flex-md-row justify-content-center">
<span>@(Model.LobbyZScore ?? 0)</span>
<span class="oi oi-bolt align-self-center mr-1 ml-1"></span>
</div>
}
<div>
<span class="server-clientcount">@Model.ClientCount</span>/<span class="server-maxclients">@Model.MaxClients</span>
</div>
</div>
@if (ViewBag.Authorized) @if (ViewBag.Authorized)
{ {
@ -27,10 +45,10 @@
} }
</div> </div>
<div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity pt-2 pb-2"> <div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity @(Model.ClientCount > 0 ? "pt-2 pb-2" : "")">
@await Html.PartialAsync("../Server/_ClientActivity", Model) @await Html.PartialAsync("../Server/_ClientActivity", Model)
</div> </div>
<div class="row server-history mb-4"> <div class="row server-history mb-4">
<div class="server-history-row" id="server_history_@Model.ID" data-serverid="@Model.ID" data-clienthistory='@Html.Raw(Json.Serialize(Model.PlayerHistory))' data-online="@Model.Online"></div> <div class="server-history-row" id="server_history_@Model.ID" data-serverid="@Model.ID" data-clienthistory='@Html.Raw(Json.Serialize(Model.PlayerHistory))' data-online="@Model.Online"></div>
</div> </div>

View File

@ -437,3 +437,7 @@ div.card {
#hitlocation_container { #hitlocation_container {
background-color: #141414; background-color: #141414;
} }
.cursor-help {
cursor: help;
}