added top player stats
fix for some commands returning multiple matches found when target not required
28
Plugins/Stats/Web/Controllers/StatsController.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WebfrontCore.Controllers;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Stats.Web.Controllers
|
||||
{
|
||||
public class StatsController : BaseController
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> TopPlayersAsync()
|
||||
{
|
||||
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_TITLE"];
|
||||
ViewBag.Description = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_DESC"];
|
||||
|
||||
return View("Index", await Plugin.Manager.GetTopStats(0, 15));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetTopPlayersAsync(int count, int offset)
|
||||
{
|
||||
return View("_List", await Plugin.Manager.GetTopStats(offset, count));
|
||||
}
|
||||
}
|
||||
}
|
20
Plugins/Stats/Web/Dtos/TopStatsInfo.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using SharedLibraryCore.Dtos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Stats.Web.Dtos
|
||||
{
|
||||
public class TopStatsInfo : SharedInfo
|
||||
{
|
||||
public int Ranking { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public double KDR { get; set; }
|
||||
public double Performance { get; set; }
|
||||
public string TimePlayed { get; set; }
|
||||
public string LastSeen { get; set; }
|
||||
public int Kills { get; set; }
|
||||
public int Deaths { get; set; }
|
||||
}
|
||||
}
|
13
Plugins/Stats/Web/Views/Stats/Index.cshtml
Normal file
@ -0,0 +1,13 @@
|
||||
@model List<IW4MAdmin.Plugins.Stats.Web.Dtos.TopStatsInfo>
|
||||
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>
|
||||
|
||||
<div id="stats_top_players" class="row border-top border-bottom">
|
||||
@await Html.PartialAsync("_List", Model)
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<environment include="Development">
|
||||
<script type="text/javascript" src="~/js/loader.js"></script>
|
||||
</environment>
|
||||
<script>initLoader('/Stats/GetTopPlayersAsync', '#stats_top_players');</script>
|
||||
}
|
50
Plugins/Stats/Web/Views/Stats/_List.cshtml
Normal file
@ -0,0 +1,50 @@
|
||||
@model List<IW4MAdmin.Plugins.Stats.Web.Dtos.TopStatsInfo>
|
||||
@{
|
||||
Layout = null;
|
||||
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex.Set;
|
||||
double getDeviation(double deviations) => Math.Pow(Math.E, 5.0813 + (deviations * 0.8694));
|
||||
string rankIcon(double elo)
|
||||
{
|
||||
if (elo >= getDeviation(-1) && elo < getDeviation(-0.25))
|
||||
return "0_no-place/menu_div_no_place.png";
|
||||
if (elo >= getDeviation(-0.25) && elo < getDeviation(0.25))
|
||||
return "1_iron/menu_div_iron_sub03.png";
|
||||
if (elo >= getDeviation(0.25) && elo < getDeviation(0.6875))
|
||||
return "2_bronze/menu_div_bronze_sub03.png";
|
||||
if (elo >= getDeviation(0.6875) && elo < getDeviation(1))
|
||||
return "3_silver/menu_div_silver_sub03.png";
|
||||
if (elo >= getDeviation(1) && elo < getDeviation(1.25))
|
||||
return "4_gold/menu_div_gold_sub03.png";
|
||||
if (elo >= getDeviation(1.25) && elo < getDeviation(1.5))
|
||||
return "5_platinum/menu_div_platinum_sub03.png";
|
||||
if (elo >= getDeviation(1.5) && elo < getDeviation(1.75))
|
||||
return "6_semipro/menu_div_semipro_sub03.png";
|
||||
if (elo >= getDeviation(1.75))
|
||||
return "7_pro/menu_div_pro_sub03.png";
|
||||
|
||||
return "0_no-place/menu_div_no_place.png";
|
||||
}
|
||||
}
|
||||
<table class="table table-striped mb-0" style="background-color:rgba(0, 0, 0, 0.1)">
|
||||
@foreach (var stat in Model)
|
||||
{
|
||||
<tr>
|
||||
<td style="vertical-align: middle">
|
||||
<div class="">
|
||||
<h2 class="text-muted">#@stat.Ranking — @Html.ActionLink(stat.Name, "ProfileAsync", "Client", new { id = stat.ClientId })</h2>
|
||||
<span class="text-primary">@stat.Performance</span><span class="text-muted"> @loc["PLUGINS_STATS_COMMANDS_PERFORMANCE"]</span><br />
|
||||
<span class="text-primary">@stat.KDR</span><span class="text-muted"> @loc["PLUGINS_STATS_TEXT_KDR"]</span>
|
||||
<span class="text-primary">@stat.Kills</span><span class="text-muted"> @loc["PLUGINS_STATS_TEXT_KILLS"]</span>
|
||||
<span class="text-primary">@stat.Deaths</span><span class="text-muted"> @loc["PLUGINS_STATS_TEXT_DEATHS"]</span><br />
|
||||
<span class="text-muted">@loc["WEBFRONT_PROFILE_PLAYER"]</span> <span class="text-primary"> @stat.TimePlayed </span><span class="text-muted">@loc["GLOBAL_HOURS"]</span><br />
|
||||
<span class="text-muted">@loc["WEBFRONT_PROFILE_LSEEN"]</span><span class="text-primary"> @stat.LastSeen </span><span class="text-muted">@loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right ml-0 pl-0" style="vertical-align: middle">
|
||||
<div>
|
||||
<img src="/images/icons/@rankIcon(stat.Performance)" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 1.5 KiB |
BIN
Plugins/Stats/Web/wwwroot/images/icons/1_iron/menu_div_iron.png
Normal file
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.9 KiB |
BIN
Plugins/Stats/Web/wwwroot/images/icons/4_gold/menu_div_gold.png
Normal file
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 2.3 KiB |