2018-02-06 23:19:06 -06:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-04-08 16:50:58 -05:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2018-02-06 23:19:06 -06:00
|
|
|
|
|
2018-04-08 16:50:58 -05:00
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Models
|
2018-02-06 23:19:06 -06:00
|
|
|
|
{
|
|
|
|
|
public class EFClientStatistics : SharedEntity
|
|
|
|
|
{
|
|
|
|
|
public int ClientId { get; set; }
|
|
|
|
|
[ForeignKey("ClientId")]
|
|
|
|
|
public virtual EFClient Client { get; set; }
|
2018-11-27 18:31:48 -06:00
|
|
|
|
public long ServerId { get; set; }
|
2018-02-06 23:19:06 -06:00
|
|
|
|
[ForeignKey("ServerId")]
|
|
|
|
|
public virtual EFServer Server { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int Kills { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int Deaths { get; set; }
|
2018-05-15 23:57:37 -05:00
|
|
|
|
public double EloRating { get; set; }
|
2018-03-06 01:22:19 -06:00
|
|
|
|
public virtual ICollection<EFHitLocationCount> HitLocations { get; set; }
|
2018-05-17 18:31:58 -05:00
|
|
|
|
public double RollingWeightedKDR { get; set; }
|
2018-09-07 22:29:42 -05:00
|
|
|
|
public double VisionAverage { get; set; }
|
2018-05-17 18:31:58 -05:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public double Performance
|
|
|
|
|
{
|
|
|
|
|
get => Math.Round((EloRating + Skill) / 2.0, 2);
|
|
|
|
|
}
|
2018-02-06 23:19:06 -06:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public double KDR
|
|
|
|
|
{
|
2018-02-10 22:33:42 -06:00
|
|
|
|
get => Deaths == 0 ? Kills : Math.Round(Kills / (double)Deaths, 2);
|
2018-02-06 23:19:06 -06:00
|
|
|
|
}
|
|
|
|
|
[Required]
|
|
|
|
|
public double SPM { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public double Skill { get; set; }
|
2018-02-10 22:33:42 -06:00
|
|
|
|
[Required]
|
|
|
|
|
public int TimePlayed { get; set; }
|
2018-05-03 00:25:49 -05:00
|
|
|
|
[Required]
|
|
|
|
|
public double MaxStrain { get; set; }
|
2018-03-27 19:27:01 -05:00
|
|
|
|
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public float AverageHitOffset
|
|
|
|
|
{
|
2018-03-28 22:01:09 -05:00
|
|
|
|
get => (float)Math.Round(HitLocations.Sum(c => c.HitOffsetAverage) / Math.Max(1, HitLocations.Where(c => c.HitOffsetAverage > 0).Count()), 4);
|
2018-03-27 19:27:01 -05:00
|
|
|
|
}
|
2018-02-08 01:23:45 -06:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public int SessionKills { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public int SessionDeaths { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public int KillStreak { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public int DeathStreak { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public DateTime LastStatCalculation { get; set; }
|
2018-02-09 01:21:25 -06:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public int LastScore { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public DateTime LastActive { get; set; }
|
2018-05-17 18:31:58 -05:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public double MaxSessionStrain { get; set; }
|
2018-04-28 00:22:18 -05:00
|
|
|
|
public void StartNewSession()
|
|
|
|
|
{
|
|
|
|
|
KillStreak = 0;
|
|
|
|
|
DeathStreak = 0;
|
|
|
|
|
LastScore = 0;
|
|
|
|
|
SessionScores.Add(0);
|
2018-06-05 16:31:36 -05:00
|
|
|
|
Team = IW4Info.Team.None;
|
2018-04-28 00:22:18 -05:00
|
|
|
|
}
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public int SessionScore
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
SessionScores[SessionScores.Count - 1] = value;
|
|
|
|
|
}
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return SessionScores.Sum();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public int RoundScore
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return SessionScores[SessionScores.Count - 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-06 01:22:19 -06:00
|
|
|
|
[NotMapped]
|
2018-04-28 00:22:18 -05:00
|
|
|
|
private List<int> SessionScores = new List<int>() { 0 };
|
2018-05-24 14:48:57 -05:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public IW4Info.Team Team { get; set; }
|
2018-05-30 20:50:20 -05:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public DateTime LastStatHistoryUpdate { get; set; } = DateTime.UtcNow;
|
2018-06-05 16:31:36 -05:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public double SessionSPM { get; set; }
|
2018-02-06 23:19:06 -06:00
|
|
|
|
}
|
|
|
|
|
}
|