top stats info is per server instead of total when selecting each tab

fix issue with ingame name failing to match when using color codes
only show live radar for servers that support it
This commit is contained in:
RaidMax 2019-08-10 09:08:26 -05:00
parent a0266c5e69
commit 85d88815f1
6 changed files with 47 additions and 11 deletions

View File

@ -26,6 +26,7 @@ namespace IW4MAdmin
{
private static readonly Index loc = Utilities.CurrentLocalization.LocalizationIndex;
private GameLogEventDetection LogEvent;
private const int REPORT_FLAG_COUNT = 4;
public int Id { get; private set; }
@ -329,6 +330,14 @@ namespace IW4MAdmin
};
await Manager.GetPenaltyService().Create(newReport);
int reportNum = await Manager.GetClientService().GetClientReportCount(E.Target.ClientId);
bool isAutoFlagged = await Manager.GetClientService().IsAutoFlagged(E.Target.ClientId);
if (reportNum >= REPORT_FLAG_COUNT && !isAutoFlagged)
{
E.Target.Flag(Utilities.CurrentLocalization.LocalizationIndex["SERVER_AUTO_FLAG_REPORT"].FormatExt(reportNum), Utilities.IW4MAdminClient(E.Owner));
}
}
else if (E.Type == GameEvent.EventType.TempBan)

View File

@ -20,13 +20,15 @@ namespace LiveRadar.Web.Controllers
public IActionResult Index(long? serverId = null)
{
ViewBag.IsFluid = true;
ViewBag.Title = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"];
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"];
ViewBag.ActiveServerId = serverId ?? Manager.GetServers().FirstOrDefault()?.EndPoint;
ViewBag.Servers = Manager.GetServers().Select(_server => new ServerInfo()
{
Name = _server.Hostname,
ID = _server.EndPoint
});
ViewBag.Servers = Manager.GetServers()
.Where(_server => _server.GameName == Server.Game.IW4)
.Select(_server => new ServerInfo()
{
Name = _server.Hostname,
ID = _server.EndPoint
});
return View();
}

View File

@ -132,6 +132,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
var iqStatsInfo = (from stat in context.Set<EFClientStatistics>()
where clientIds.Contains(stat.ClientId)
where stat.Kills > 0 || stat.Deaths > 0
where serverId == null ? true : stat.ServerId == serverId
group stat by stat.ClientId into s
select new
{
@ -139,7 +140,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
Kills = s.Sum(c => c.Kills),
Deaths = s.Sum(c => c.Deaths),
KDR = s.Sum(c => (c.Kills / (double)(c.Deaths == 0 ? 1 : c.Deaths)) * c.TimePlayed) / s.Sum(c => c.TimePlayed),
TotalTimePlayed = s.Sum(c => c.TimePlayed)
TotalTimePlayed = s.Sum(c => c.TimePlayed),
});
#if DEBUG == true

View File

@ -96,7 +96,7 @@ namespace SharedLibraryCore.Commands
{
E.Target = matchingPlayers.First();
string escapedName = Regex.Escape(E.Target.Name);
string escapedName = Regex.Escape(E.Target.CleanedName);
var reg = new Regex($"(\"{escapedName}\")|({escapedName})", RegexOptions.IgnoreCase);
E.Data = reg.Replace(E.Data, "", 1).Trim();
@ -126,12 +126,12 @@ namespace SharedLibraryCore.Commands
{
E.Target = matchingPlayers.First();
string escapedName = Regex.Escape(E.Target.Name);
string escapedName = Regex.Escape(E.Target.CleanedName);
string escapedArg = Regex.Escape(Args[0]);
var reg = new Regex($"({escapedName})|({escapedArg})", RegexOptions.IgnoreCase);
E.Data = reg.Replace(E.Data, "", 1).Trim();
if ((E.Data.Trim() == E.Target.Name.ToLower().Trim() ||
if ((E.Data.Trim() == E.Target.CleanedName.ToLower().Trim() ||
E.Data == String.Empty) &&
C.RequiresTarget)
{

View File

@ -94,6 +94,10 @@ namespace SharedLibraryCore.Database.Models
get { return CurrentAlias?.Name ?? "--"; }
set { if (CurrentAlias != null) CurrentAlias.Name = value; }
}
[NotMapped]
public string CleanedName => Name.StripColors();
[NotMapped]
public virtual int? IPAddress
{

View File

@ -594,7 +594,7 @@ namespace SharedLibraryCore.Services
#endregion
/// <summary>
/// retrieves the number of time the given client id has been reported
/// retrieves the number of times the given client id has been reported
/// </summary>
/// <param name="clientId">client id to search for report counts of</param>
/// <returns></returns>
@ -609,5 +609,25 @@ namespace SharedLibraryCore.Services
.CountAsync();
}
}
/// <summary>
/// indicates if the given clientid has been autoflagged
/// </summary>
/// <param name="clientId"></param>
/// <returns></returns>
public async Task<bool> IsAutoFlagged(int clientId)
{
using (var ctx = new DatabaseContext(true))
{
var now = DateTime.UtcNow;
return await ctx.Penalties
.Where(_penalty => _penalty.Active)
.Where(_penalty => _penalty.OffenderId == clientId)
.Where(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag)
.Where(_penalty => _penalty.PunisherId == 1)
.Where(_penalty => _penalty.Expires == null || _penalty.Expires > now)
.AnyAsync();
}
}
}
}