add server scoreboard functionality

This commit is contained in:
RaidMax 2022-01-22 12:49:12 -06:00
parent 7910fc73a3
commit 7fcb2202bd
34 changed files with 278 additions and 100 deletions

View File

@ -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<int>(SessionScores).Sum();
return new List<int>(_sessionScores).Sum();
}
}
}
[NotMapped]
public int RoundScore => SessionScores[SessionScores.Count - 1];
public int RoundScore => _sessionScores[^1];
[NotMapped]
private readonly List<int> SessionScores = new List<int>() { 0 };
private readonly List<int> _sessionScores = new List<int> { 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;
}
}
}

View File

@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -23,7 +23,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -17,7 +17,7 @@
@foreach (SharedLibraryCore.Dtos.ServerInfo server in ViewBag.Servers)
{
<li class="nav-item">
<a asp-controller="Radar" asp-action="Index" asp-route-serverId="@server.ID" class="nav-link @(server.ID == ViewBag.ActiveServerId ? "active": "")" aria-selected="@(server.ID == ViewBag.ActiveServerId ? "true": "false")"><color-code value="@server.Name" allow="@ViewBag.EnableColorCodes"></color-code></a>
<a asp-controller="Radar" asp-action="Index" asp-route-serverId="@server.ID" class="nav-link @(server.ID == ViewBag.ActiveServerId ? "active": "")" aria-selected="@(server.ID == ViewBag.ActiveServerId ? "true": "false")"><color-code value="@server.Name"></color-code></a>
</li>
}
</ul>
@ -467,4 +467,4 @@
})
</script>
}
}

View File

@ -19,7 +19,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -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();
}
}

View File

@ -17,7 +17,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@ -20,7 +20,7 @@
</Target>
<ItemGroup>
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.8.1" PrivateAssets="All" />
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.20.1" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -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<EFClientStatistics>(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<EFClientStatistics>(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<ScoreboardInfo> ProjectScoreboard(IEnumerable<Server> 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<EFClientStatistics>(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();
}
}
}

View File

@ -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<ClientScoreboardInfo> 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; }
}
}

View File

@ -18,7 +18,7 @@
@if (!string.IsNullOrWhiteSpace(Model.CommunityInformation.Name))
{
<h2 class="mb-4 p-0 col-12 text-center text-md-left">
<color-code value="@Model.CommunityInformation.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.CommunityInformation.Name"></color-code>
</h2>
}
@ -26,7 +26,7 @@
{
<div class="p-4 bg-dark border border-primary mb-4 text-white-50 col-12">
<h4 class="text-primary">@ViewBag.Localization["WEBFRONT_ABOUT_TITLE"]</h4>
<color-code value="@Model.CommunityInformation.Description" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.CommunityInformation.Description"></color-code>
<div class="mt-3">
@foreach (var social in Model.CommunityInformation.SocialAccounts ?? new SocialAccountConfiguration[0])
{
@ -66,16 +66,16 @@
var start = 1;
<div class="col-12 bg-dark p-4 border border-primary mb-4 col-12">
<div class="text-primary h4">
<color-code value="@serverName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@serverName"></color-code>
</div>
@foreach (var rule in rules)
{
<div class="text-white-50">
<span class="text-white">@start.</span>
<color-code value="@rule" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@rule"></color-code>
</div>
start++;
}
</div>
}
</div>
</div>

View File

@ -17,7 +17,7 @@
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.OriginId" class="link-inverse">
<color-code value="@info.OriginName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@info.OriginName"></color-code>
</a>
</td>
</tr>
@ -27,7 +27,7 @@
@if (info.TargetId != null)
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.TargetId" class="link-inverse">
<color-code value="@info.TargetName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@info.TargetName"></color-code>
</a>
}
else
@ -68,14 +68,14 @@
</td>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.OriginId" class="link-inverse">
<color-code value="@info.OriginName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@info.OriginName"></color-code>
</a>
</td>
<td>
@if (info.TargetId != null)
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@info.TargetId" class="link-inverse">
<color-code value="@info.TargetName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@info.TargetName"></color-code>
</a>
}
else
@ -96,4 +96,4 @@
@info.When.ToString()
</td>
</tr>
}
}

View File

@ -17,7 +17,7 @@
<div class="row pt-2 pb-2 bg-dark">
<div class="col-5">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@client.Name"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
@ -45,7 +45,7 @@
<div class="col-7 bg-dark border-bottom">
<div class="p-2">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId" class="link-inverse">
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@client.Name"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
@ -59,4 +59,4 @@
<div class="p-2 text-white-50">@client.LastConnectionText</div>
</div>
}
</div>
</div>

View File

@ -7,21 +7,21 @@
<tr class="d-none d-lg-table-row">
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@message.ClientId" class="link-inverse">
<color-code value="@message.ClientName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.ClientName"></color-code>
</a>
</td>
<td class="text-light w-50 text-break">
@if (message.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)"></color-code>
}
else
{
<color-code value="@message.Message" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.Message"></color-code>
}
</td>
<td class="text-light">
<color-code value="@(message.ServerName ?? "--")" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@(message.ServerName ?? "--")"></color-code>
</td>
<td class="text-right text-light">
@message.When
@ -33,7 +33,7 @@
<th scope="row" class="bg-primary">@ViewBag.Localization["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td class="text-light">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@message.ClientId" class="link-inverse">
<color-code value="@message.ClientName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.ClientName"></color-code>
</a>
</td>
</tr>
@ -43,11 +43,11 @@
<td class="text-light">
@if (message.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], message.HiddenMessage)"></color-code>
}
else
{
<color-code value="@message.Message" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.Message"></color-code>
}
</td>
</tr>
@ -55,7 +55,7 @@
<tr class="d-table-row d-lg-none bg-dark">
<th scope="row" class="bg-primary">@ViewBag.Localization["WEBFRONT_STATS_MESSAGE_SERVER_NAME"]</th>
<td class="text-light">
<color-code value="@(message.ServerName ?? "--")" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@(message.ServerName ?? "--")"></color-code>
</td>
</tr>
@ -65,4 +65,4 @@
@message.When
</td>
</tr>
}
}

View File

@ -14,11 +14,11 @@
@foreach (var client in Model[key])
{
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@client.Name"></color-code>
</a>
<br />
}
</div>
}
}
</div>
</div>

View File

@ -25,7 +25,7 @@
<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 d-block d-lg-inline-flex @(ViewBag.Authorized ? "" : "flex-fill")">
<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"></color-code>
</div>
@if (ViewBag.Authorized)
{
@ -50,7 +50,7 @@
@foreach (var alias in Model.Aliases)
{
<div>
<color-code value="@alias" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@alias"></color-code>
</div>
}
@ -196,4 +196,4 @@
<script type="text/javascript" src="~/js/profile.js"></script>
</environment>
<script>initLoader('/Client/Meta/@Model.ClientId', '#profile_events', 30, 30, [{ 'name': 'metaFilterType', 'value': '@Model.MetaFilterType' }]);</script>
}
}

View File

@ -18,7 +18,7 @@
{
<span class="text-highlight">
<a class="link-inverse" href="@Model.OffenderClientId">
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.OffenderName"></color-code>
</a>
</span>
}
@ -33,7 +33,7 @@
}
else
{
<color-code value="@Model.Offense" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Offense"></color-code>
}
</span>

View File

@ -15,7 +15,7 @@
break;
case "server":
<span class="text-white">
<color-code value="@Model.ServerName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ServerName"></color-code>
</span>
break;
}
@ -25,4 +25,4 @@
{
<span class="text-muted">@token.MatchValue</span>
}
}
}

View File

@ -22,7 +22,7 @@
{
if (result.IsInterpolation)
{
<span class="profile-meta-value text-primary"><color-code value="@meta.Value" allow="@ViewBag.EnableColorCodes"></color-code></span>
<span class="profile-meta-value text-primary"><color-code value="@meta.Value"></color-code></span>
}
else
@ -34,10 +34,10 @@
else
{
<span class="profile-meta-value text-primary"><color-code value="@meta.Value" allow="@ViewBag.EnableColorCodes"></color-code></span>
<span class="profile-meta-value text-primary"><color-code value="@meta.Value"></color-code></span>
<span class="profile-meta-title text-muted"> @meta.Key</span>
}
</div>
}
</div>
}
}

View File

@ -11,12 +11,12 @@
@if (Model.IsHidden && !ViewBag.Authorized)
{
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], Model.HiddenMessage)" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@SharedLibraryCore.Utilities.FormatExt(ViewBag.Localization["WEBFRONT_CLIENT_META_CHAT_HIDDEN"], Model.HiddenMessage)"></color-code>
}
else
{
<color-code value="@Model.Message" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Message"></color-code>
}
</span>
</span>
</span>

View File

@ -19,7 +19,7 @@
{
<span class="text-highlight">
<a class="link-inverse" href="@Model.PunisherClientId">
<color-code value="@Model.PunisherName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.PunisherName"></color-code>
</a>
</span>
}
@ -34,7 +34,7 @@
}
else
{
<color-code value="@Model.Offense" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Offense"></color-code>
}
</span>
@ -65,7 +65,7 @@
else
{
<a class="link-inverse" href="@Model.OffenderClientId">
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.OffenderName"></color-code>
</a>
}
}

View File

@ -13,7 +13,7 @@
break;
case "alias":
<span class="text-white">
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Name"></color-code>
[@Model.IPAddress]
</span>
break;

View File

@ -7,7 +7,7 @@
{
<li class="nav-item ">
<a class="nav-link top-players-link" href="#server_@server.ID" role="tab" data-toggle="tab" aria-selected="false" data-serverid="@server.ID">
<color-code value="@server.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@server.Name"></color-code>
</a>
</li>
}

View File

@ -9,7 +9,7 @@
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</th>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.OffenderId" class="link-inverse">
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.OffenderName"></color-code>
</a>
</td>
</tr>
@ -24,7 +24,7 @@
<tr class="d-table-row d-lg-none bg-dark">
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_OFFENSE"]</th>
<td class="text-light">
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")"></color-code>
</td>
</tr>
@ -59,14 +59,14 @@
<tr class="d-none d-lg-table-row">
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.OffenderId" class="link-inverse">
<color-code value="@Model.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.OffenderName"></color-code>
</a>
</td>
<td class="penalties-color-@Model.PenaltyTypeText.ToLower()">
@Model.PenaltyType
</td>
<td class="text-light w-50">
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")"></color-code>
</td>
<td>
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync",
@ -88,4 +88,4 @@
}
}
</td>
</tr>
</tr>

View File

@ -0,0 +1,30 @@
@model IEnumerable<WebfrontCore.ViewModels.ScoreboardInfo>
<ul class="nav nav-tabs border-top border-bottom nav-fill row" role="tablist" id="scoreboard_servers">
@{ var i = 0; }
@foreach (var server in Model)
{
<li class="nav-item">
<a class="nav-link" href="#server_@server.ServerId" role="tab" data-toggle="tab" id="server_@(server.ServerId)_nav" data-serverid="@server.ServerId">
<color-code value="@server.ServerName"></color-code>
</a>
</li>
i++;
}
</ul>
<div class="tab-content border-bottom row">
@{ i = 0; }
@foreach (var server in Model)
{
<div role="tabpanel" class="scoreboard-container tab-pane striped flex-fill" id="server_@server.ServerId" data-server-id="@server.ServerId">
@await Html.PartialAsync("_Scoreboard", server)
</div>
i++;
}
</div>
@section scripts {
<environment include="Development">
<script type="text/javascript" src="~/js/scoreboard.js" defer="defer"></script>
</environment>
}

View File

@ -21,24 +21,24 @@
{
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span>
<span>
&mdash;
<color-code value="@message.CapClientName(48)" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.CapClientName(48)"></color-code>
</span><br />
}
}
@ -63,7 +63,7 @@
}
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.Players[i].ClientId" class="@levelColorClass">
<color-code value="@Model.Players[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Players[i].Name"></color-code>
</a>
@if (ViewBag.Authorized)
@ -88,7 +88,7 @@
<div>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@Model.Players[i].ClientId" class="@levelColorClass">
<color-code value="@Model.Players[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.Players[i].Name"></color-code>
</a>
@if (ViewBag.Authorized)
{
@ -122,26 +122,26 @@
{
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@Model.ChatHistory[i].Name"></color-code>
</span>
<span>
&mdash;
<color-code value="@message.CapClientName(48)" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@message.CapClientName(48)"></color-code>
</span><br />
}
}
}
</div>
</div>

View File

@ -0,0 +1,32 @@
@model WebfrontCore.ViewModels.ScoreboardInfo
@{
Layout = null;
}
<table class="table table-striped thead-light bg-dark mb-0 table-responsive-md">
<tr class="bg-dark border-bottom">
<th>@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PLAYER"]</th>
<th>@ViewBag.Localization["WEBFRONT_ADV_STATS_SCORE"]</th>
<th>@ViewBag.Localization["WEBFRONT_ADV_STATS_KILLS"]</th>
<th>@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_DEATHS"]</th>
<th>@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_RATIO"]</th>
<th>@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_SPM"]</th>
<th class="text-right">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PING"]</th>
</tr>
@foreach (var client in Model.ClientInfo.OrderByDescending(c => c.Score))
{
<tr>
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.ClientName"></color-code>
</a>
</td>
<td>@client.Score</td>
<td>@(client.Kills ?? 0)</td>
<td>@(client.Deaths ?? 0)</td>
<td>@Math.Round(client.Kdr ?? 0, 2)</td>
<td>@Math.Round(client.ScorePerMinute ?? 0)</td>
<td class="text-right">@client.Ping</td>
</tr>
}
</table>

View File

@ -5,15 +5,19 @@
<div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID">
<div class="col-md-4 text-center text-md-left d-inline-flex justify-content-center justify-content-md-start">
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<color-code value="@Model.Name"></color-code>
<a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<span class="oi oi-play-circle mr-1 align-self-center"></span>
<span class="server-header-ip-address" style="display:none;">@Model.IPAddress</span>
</a>
@if (ViewBag.Authorized)
{
<span class="oi oi-chat align-self-center profile-action d-none d-md-flex" data-action="chat" data-action-id="@Model.ID"></span>
<span class="oi oi-chat align-self-center profile-action d-none d-md-flex mr-2" data-action="chat" data-action-id="@Model.ID"></span>
}
<a asp-controller="Server" asp-action="Scoreboard" asp-fragment="server_@Model.ID" title="@ViewBag.Localization["WEBFRONT_TITLE_SCOREBOARD"]"
class="align-self-center d-none d-md-flex">
<span class="oi oi-spreadsheet ml-1"></span>
</a>
</div>
<div class="text-center col-md-4 align-self-center">
@ -39,10 +43,14 @@
@if (ViewBag.Authorized)
{
<div class=" p-1 d-flex d-md-none justify-content-center col-12">
<div class="p-1 d-flex d-md-none justify-content-center col-12">
<span class="oi oi-chat align-self-center profile-action d-flex d-md-none" data-action="chat" data-action-id="@Model.ID"></span>
</div>
}
<a asp-controller="Server" asp-action="Scoreboard" title="@ViewBag.Localization["WEBFRONT_TITLE_SCOREBOARD"]"
class="p-1 d-flex d-md-none justify-content-center col-12">
<span class="oi oi-spreadsheet ml-1"></span>
</a>
</div>
<div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity @(Model.ClientCount > 0 ? "pt-2 pb-2" : "")">

View File

@ -40,7 +40,7 @@
<div class="p-2 mb-3 border-bottom" style="background-color: #222;">
<div class="d-flex flex-row">
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId" class="h4 mr-auto">
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
<color-code value="@client.Name"></color-code>
</a>
<div class="client-location-flag align-self-center" data-ip="@client.IPAddress"></div>
</div>
@ -49,4 +49,4 @@
<div class="align-self-center">@client.LastConnectionText</div>
</div>
</div>
}
}

View File

@ -45,7 +45,6 @@
<None Include="wwwroot\css\global.min.css" CopyToPublishDirectory="PreserveNewest" />
<None Include="wwwroot\js\global.min.js" CopyToPublishDirectory="PreserveNewest" />
<None Include="wwwroot\images\**\*.*" CopyToPublishDirectory="PreserveNewest" />
<Content Remove="wwwroot\images\icons\crosshair.png" />
</ItemGroup>
<ItemGroup>

View File

@ -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"
],

View File

@ -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);