Add automated ban offense for anti-cheat

add EFClientStatHistory and EFClientAverageStatHistory for tracking change of stats over time
This commit is contained in:
RaidMax
2018-05-30 20:50:20 -05:00
parent 2204686b08
commit bf68e5672f
22 changed files with 1178 additions and 103 deletions

View File

@ -43,7 +43,8 @@ namespace WebfrontCore.Controllers
PunisherId = p.PunisherId,
Type = p.Type.ToString(),
TimePunished = p.When.ToString(),
TimeRemaining = p.Expires.ToString()
TimeRemaining = p.Expires.ToString(),
AutomatedOffense = p.AutomatedOffense
}).ToList();
return Json(penaltiesDto);

View File

@ -20,11 +20,12 @@ namespace WebfrontCore.ViewComponents
PunisherId = p.PunisherId,
PunisherName = p.Punisher.Name,
PunisherLevel = p.Punisher.Level.ToString(),
Offense = p.Offense,
Offense = User.Identity.IsAuthenticated && !string.IsNullOrEmpty(p.AutomatedOffense) ? p.AutomatedOffense : p.Offense,
Type = p.Type.ToString(),
TimePunished = Utilities.GetTimePassed(p.When, false),
TimeRemaining = DateTime.UtcNow > p.Expires ? "" : Utilities.TimeSpanText(p.Expires - DateTime.UtcNow),
Sensitive = p.Type == Penalty.PenaltyType.Flag
Sensitive = p.Type == Penalty.PenaltyType.Flag,
AutomatedOffense = p.AutomatedOffense
});
penaltiesDto = User.Identity.IsAuthenticated ? penaltiesDto.ToList() : penaltiesDto.Where(p => !p.Sensitive).ToList();

View File

@ -23,7 +23,8 @@
"wwwroot/js/profile.js",
"wwwroot/js/server.js",
"wwwroot/js/search.js",
"wwwroot/js/loader.js"
"wwwroot/js/loader.js",
"wwwroot/js/stats.js"
],
// Optionally specify minification options
"minify": {

View File

@ -179,7 +179,18 @@ select {
margin-top: -3px;
}
.stats-ranking-icon {
width: 32px;
height: 32px;
.striped > div:nth-child(even) {
background-color: rgba(0, 0, 0, 0.125);
}
.striped > div:nth-child(odd) {
background-color: rgba(0, 0, 0, 0.2);
}
.client-rating-graph {
min-height: 100px;
}
.client-rating-icon {
}

View File

@ -1,6 +1,6 @@
let offset = 15;
let loadCount = 15;
let isLoading = false;
let loaderOffset = 25;
let loadCount = 25;
let isLoaderLoading = false;
let loadUri = '';
let loaderResponseId = '';
@ -11,26 +11,26 @@ function initLoader(location, loaderId) {
}
function loadMoreItems() {
if (isLoading) {
if (isLoaderLoading) {
return false;
}
showLoader();
isLoading = true;
$.get(loadUri, { offset: offset, count : loadCount })
isLoaderLoading = true;
$.get(loadUri, { offset: loaderOffset, count : loadCount })
.done(function (response) {
$(loaderResponseId).append(response);
if (response.trim().length === 0) {
staleLoader();
}
hideLoader();
isLoading = false;
isLoaderLoading = false;
})
.fail(function (jqxhr, statis, error) {
errorLoader();
isLoading = false;
isLoaderLoading = false;
});
offset += loadCount;
loaderOffset += loadCount;
}
function setupListeners() {

View File

@ -0,0 +1,61 @@
function getStatsChart(id, width, height) {
const data = $('#' + id).data('history');
let fixedData = [];
data.forEach(function (item, i) {
fixedData[i] = { x: i, y: item };
});
return new CanvasJS.Chart(id, {
backgroundColor: 'transparent',
height: height,
width: width,
animationEnabled: false,
toolTip: {
contentFormatter: function (e) {
return e.entries[0].dataPoint.y;
}
},
axisX: {
interval: 1,
gridThickness: 0,
lineThickness: 0,
tickThickness: 0,
margin: 0,
valueFormatString: " "
},
axisY: {
gridThickness: 0,
lineThickness: 0,
tickThickness: 0,
minimum: Math.min(...data) - 15,
maximum: Math.max(...data) + 15,
margin: 0,
valueFormatString: " ",
labelMaxWidth: 0
},
legend: {
maxWidth: 0,
maxHeight: 0,
dockInsidePlotArea: true
},
data: [{
showInLegend: false,
type: "splineArea",
color: 'rgba(0, 122, 204, 0.25)',
markerSize: 0,
dataPoints: fixedData
}]
});
}
$(document).ready(function () {
$('.client-rating-graph').each(function (i, element) {
getStatsChart($(element).attr('id'), $(element).width(), $(element).height()).render();
});
$(window).resize(function () {
$('.client-rating-graph').each(function (index, element) {
getStatsChart($(element).attr('id'), $(element).width(), $(element).height()).render();
});
});
});