mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
Add libraries for EntityFramework
Stats plugin work Allow plugins to dynamically add EF classes to the context
This commit is contained in:
40
Plugins/SimpleStats/Models/EFClientKill.cs
Normal file
40
Plugins/SimpleStats/Models/EFClientKill.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SharedLibrary.Database.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SharedLibrary.Helpers;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace StatsPlugin.Models
|
||||
{
|
||||
public class EFClientKill : SharedEntity
|
||||
{
|
||||
public EFClientKill() { }
|
||||
|
||||
[Key]
|
||||
public long KillId { get; set; }
|
||||
public int VictimId { get; set; }
|
||||
[ForeignKey("VictimId")]
|
||||
public virtual EFClient Victim { get; set; }
|
||||
public int AttackerId { get; set; }
|
||||
[ForeignKey("AttackerId")]
|
||||
public virtual EFClient Attacker { get; set; }
|
||||
public int ServerId { get; set; }
|
||||
[ForeignKey("ServerId")]
|
||||
public virtual EFServer Server { get; set; }
|
||||
public IW4Info.HitLocation HitLoc { get; set; }
|
||||
public IW4Info.MeansOfDeath DeathType { get; set; }
|
||||
public int Damage { get; set; }
|
||||
public IW4Info.WeaponName Weapon { get; set; }
|
||||
public Vector3 KillOrigin { get; set; }
|
||||
public Vector3 DeathOrigin { get; set; }
|
||||
// http://wiki.modsrepository.com/index.php?title=Call_of_Duty_5:_Gameplay_standards for conversion to meters
|
||||
[NotMapped]
|
||||
public double Distance => Vector3.Distance(KillOrigin, DeathOrigin) * 0.0254;
|
||||
public IW4Info.MapName Map { get; set; }
|
||||
}
|
||||
}
|
38
Plugins/SimpleStats/Models/EFClientStatistics.cs
Normal file
38
Plugins/SimpleStats/Models/EFClientStatistics.cs
Normal file
@ -0,0 +1,38 @@
|
||||
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;
|
||||
|
||||
using SharedLibrary.Database.Models;
|
||||
|
||||
namespace StatsPlugin.Models
|
||||
{
|
||||
public class EFClientStatistics : SharedEntity
|
||||
{
|
||||
[Key, Column(Order = 0)]
|
||||
public int ClientId { get; set; }
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual EFClient Client { get; set; }
|
||||
[Key, Column(Order = 1)]
|
||||
public int ServerId { get; set; }
|
||||
[ForeignKey("ServerId")]
|
||||
public virtual EFServer Server { get; set; }
|
||||
[Required]
|
||||
public int Kills { get; set; }
|
||||
[Required]
|
||||
public int Deaths { get; set; }
|
||||
[Required]
|
||||
[NotMapped]
|
||||
public double KDR
|
||||
{
|
||||
get => Deaths == 0 ? 0.0 : Math.Round((float)Kills / (float)Deaths, 2);
|
||||
}
|
||||
[Required]
|
||||
public double SPM { get; set; }
|
||||
[Required]
|
||||
public double Skill { get; set; }
|
||||
}
|
||||
}
|
16
Plugins/SimpleStats/Models/EFServer.cs
Normal file
16
Plugins/SimpleStats/Models/EFServer.cs
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
using SharedLibrary.Database.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace StatsPlugin.Models
|
||||
{
|
||||
public class EFServer : SharedEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int ServerId { get; set; }
|
||||
[Required]
|
||||
public int Port { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user