Stats
This commit is contained in:
+120
-2
@@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Server.Networking;
|
using Server.Networking;
|
||||||
using Server.Networking.Handling;
|
using Server.Networking.Handling;
|
||||||
@@ -292,6 +294,7 @@ public sealed class MatchManager : IDisposable
|
|||||||
{
|
{
|
||||||
private readonly ILogger<MatchManager> _log;
|
private readonly ILogger<MatchManager> _log;
|
||||||
private readonly IMessageSerializer _ser;
|
private readonly IMessageSerializer _ser;
|
||||||
|
private readonly IServiceScopeFactory _scopeFactory;
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, Lobby> _lobbies = new();
|
private readonly ConcurrentDictionary<string, Lobby> _lobbies = new();
|
||||||
private readonly ConcurrentDictionary<string, MatchInstance> _matches = new();
|
private readonly ConcurrentDictionary<string, MatchInstance> _matches = new();
|
||||||
@@ -306,10 +309,11 @@ public sealed class MatchManager : IDisposable
|
|||||||
private const int MaxPlayersPerLobby = 8;
|
private const int MaxPlayersPerLobby = 8;
|
||||||
private const int LobbyCountdownSeconds = 10;
|
private const int LobbyCountdownSeconds = 10;
|
||||||
|
|
||||||
public MatchManager(ILogger<MatchManager> log, IMessageSerializer ser)
|
public MatchManager(ILogger<MatchManager> log, IMessageSerializer ser, IServiceScopeFactory scopeFactory)
|
||||||
{
|
{
|
||||||
_log = log;
|
_log = log;
|
||||||
_ser = ser;
|
_ser = ser;
|
||||||
|
_scopeFactory = scopeFactory;
|
||||||
|
|
||||||
// Game tick timer (20 Hz)
|
// Game tick timer (20 Hz)
|
||||||
_tickTimer = new Timer(OnGameTick, null, 50, 50);
|
_tickTimer = new Timer(OnGameTick, null, 50, 50);
|
||||||
@@ -722,6 +726,19 @@ public sealed class MatchManager : IDisposable
|
|||||||
|
|
||||||
private async Task EndMatchAsync(MatchInstance match)
|
private async Task EndMatchAsync(MatchInstance match)
|
||||||
{
|
{
|
||||||
|
// Get match results before cleanup
|
||||||
|
var results = match.Simulation.GetMatchResults();
|
||||||
|
|
||||||
|
// Persist stats to database
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PersistMatchResultsAsync(match.Id, results);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.LogError(ex, "Failed to persist match results for {MatchId}", match.Id);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove players from match tracking
|
// Remove players from match tracking
|
||||||
foreach (var accountId in match.Connections.Keys)
|
foreach (var accountId in match.Connections.Keys)
|
||||||
{
|
{
|
||||||
@@ -729,7 +746,108 @@ public sealed class MatchManager : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
_matches.TryRemove(match.Id, out _);
|
_matches.TryRemove(match.Id, out _);
|
||||||
_log.LogInformation("Match {MatchId} ended", match.Id);
|
_log.LogInformation("Match {MatchId} ended with {PlayerCount} players", match.Id, results.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task PersistMatchResultsAsync(string matchId, List<MatchPlayerResult> results)
|
||||||
|
{
|
||||||
|
using var scope = _scopeFactory.CreateScope();
|
||||||
|
var db = scope.ServiceProvider.GetRequiredService<Server.Data.GameDbContext>();
|
||||||
|
|
||||||
|
foreach (var result in results)
|
||||||
|
{
|
||||||
|
// Get or create player stats
|
||||||
|
var stats = await db.PlayerStats.FirstOrDefaultAsync(s => s.AccountId == result.AccountId);
|
||||||
|
if (stats == null)
|
||||||
|
{
|
||||||
|
stats = new Server.Data.PlayerStats
|
||||||
|
{
|
||||||
|
AccountId = result.AccountId,
|
||||||
|
CreatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
db.PlayerStats.Add(stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update lifetime stats
|
||||||
|
stats.MatchesPlayed++;
|
||||||
|
stats.Kills += result.Kills;
|
||||||
|
stats.Deaths += result.Deaths;
|
||||||
|
stats.TotalDamageDealt += result.DamageDealt;
|
||||||
|
stats.TotalDamageTaken += result.DamageTaken;
|
||||||
|
stats.TotalScrapCollected += result.ScrapCollected;
|
||||||
|
stats.TotalEnergyCollected += result.EnergyCollected;
|
||||||
|
stats.TotalRareCollected += result.RareCollected;
|
||||||
|
stats.ItemsCrafted += result.ItemsCrafted;
|
||||||
|
stats.TotalPlayTimeSeconds += result.SurvivalTimeSeconds;
|
||||||
|
|
||||||
|
if (result.SurvivalTimeSeconds > stats.LongestSurvivalSeconds)
|
||||||
|
stats.LongestSurvivalSeconds = result.SurvivalTimeSeconds;
|
||||||
|
|
||||||
|
// Win/loss tracking
|
||||||
|
bool isWin = result.Result == MatchPlayerResultType.Won || result.Result == MatchPlayerResultType.Extracted;
|
||||||
|
if (isWin)
|
||||||
|
stats.Wins++;
|
||||||
|
else
|
||||||
|
stats.Losses++;
|
||||||
|
|
||||||
|
if (result.Result == MatchPlayerResultType.Extracted)
|
||||||
|
stats.Extractions++;
|
||||||
|
|
||||||
|
// Simple Elo calculation (can be made more sophisticated)
|
||||||
|
int eloChange = CalculateEloChange(stats.Elo, result.Placement, result.TotalPlayers, isWin);
|
||||||
|
stats.Elo = Math.Max(0, stats.Elo + eloChange);
|
||||||
|
|
||||||
|
// Record match history
|
||||||
|
var history = new Server.Data.MatchHistory
|
||||||
|
{
|
||||||
|
MatchId = matchId,
|
||||||
|
AccountId = result.AccountId,
|
||||||
|
Result = isWin
|
||||||
|
? (result.Result == MatchPlayerResultType.Extracted
|
||||||
|
? Server.Data.MatchResult.Extracted
|
||||||
|
: Server.Data.MatchResult.Win)
|
||||||
|
: Server.Data.MatchResult.Loss,
|
||||||
|
Placement = result.Placement,
|
||||||
|
TotalPlayers = result.TotalPlayers,
|
||||||
|
Kills = result.Kills,
|
||||||
|
Deaths = result.Deaths,
|
||||||
|
DamageDealt = result.DamageDealt,
|
||||||
|
DamageTaken = result.DamageTaken,
|
||||||
|
ScrapCollected = result.ScrapCollected,
|
||||||
|
EnergyCollected = result.EnergyCollected,
|
||||||
|
RareCollected = result.RareCollected,
|
||||||
|
ItemsCrafted = result.ItemsCrafted,
|
||||||
|
SurvivalTimeSeconds = result.SurvivalTimeSeconds,
|
||||||
|
MatchDurationSeconds = result.MatchDurationSeconds,
|
||||||
|
EloChange = eloChange,
|
||||||
|
EloAfter = stats.Elo,
|
||||||
|
PlayedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
db.MatchHistory.Add(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
_log.LogInformation("Persisted stats for match {MatchId}", matchId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CalculateEloChange(int currentElo, int placement, int totalPlayers, bool isWin)
|
||||||
|
{
|
||||||
|
// Simple Elo-like system based on placement
|
||||||
|
// K-factor varies by Elo (higher K for lower Elo = faster adjustment)
|
||||||
|
int kFactor = currentElo < 1200 ? 32 : (currentElo < 1600 ? 24 : 16);
|
||||||
|
|
||||||
|
// Expected score based on placement (1st = 1.0, last = 0.0)
|
||||||
|
float expectedPlacement = totalPlayers / 2f;
|
||||||
|
float actualScore = (totalPlayers - placement) / (float)(totalPlayers - 1);
|
||||||
|
float expectedScore = 0.5f; // Assume average performance expected
|
||||||
|
|
||||||
|
// Bonus for winning
|
||||||
|
if (isWin) actualScore = Math.Max(actualScore, 0.75f);
|
||||||
|
|
||||||
|
int change = (int)(kFactor * (actualScore - expectedScore));
|
||||||
|
|
||||||
|
// Clamp to reasonable range
|
||||||
|
return Math.Clamp(change, -50, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task BroadcastLobbyStateAsync(Lobby lobby)
|
private async Task BroadcastLobbyStateAsync(Lobby lobby)
|
||||||
|
|||||||
+119
-5
@@ -311,19 +311,20 @@ public sealed class GameSimulation
|
|||||||
int amount = resource.Amount;
|
int amount = resource.Amount;
|
||||||
switch (resource.ResourceType)
|
switch (resource.ResourceType)
|
||||||
{
|
{
|
||||||
case 0: player.Scrap += amount; break;
|
case 0: player.Scrap += amount; player.TotalScrapCollected += amount; break;
|
||||||
case 1: player.Energy += amount; break;
|
case 1: player.Energy += amount; player.TotalEnergyCollected += amount; break;
|
||||||
case 2: player.Rare += amount; break;
|
case 2: player.Rare += amount; player.TotalRareCollected += amount; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
resource.Amount = 0;
|
// Remove the resource node entirely
|
||||||
|
_resources.Remove(resource.Id);
|
||||||
|
|
||||||
_pendingEvents.Add(new GameEvent
|
_pendingEvents.Add(new GameEvent
|
||||||
{
|
{
|
||||||
Type = EventType.Pickup,
|
Type = EventType.Pickup,
|
||||||
PlayerId = player.Id,
|
PlayerId = player.Id,
|
||||||
TargetId = resource.Id,
|
TargetId = resource.Id,
|
||||||
Data = new { resourceType = resource.ResourceType, amount }
|
Data = new { resourceType = resource.ResourceType, amount, removed = true }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,6 +417,7 @@ public sealed class GameSimulation
|
|||||||
{
|
{
|
||||||
player.Alive = false;
|
player.Alive = false;
|
||||||
player.Extracted = true;
|
player.Extracted = true;
|
||||||
|
player.ExtractedAtTick = CurrentTick;
|
||||||
|
|
||||||
// Calculate total loot value
|
// Calculate total loot value
|
||||||
int totalValue = player.Scrap * 1 + player.Energy * 2 + player.Rare * 5;
|
int totalValue = player.Scrap * 1 + player.Energy * 2 + player.Rare * 5;
|
||||||
@@ -585,6 +587,13 @@ public sealed class GameSimulation
|
|||||||
private void DealDamage(PlayerEntity target, int damage, ulong? sourceId)
|
private void DealDamage(PlayerEntity target, int damage, ulong? sourceId)
|
||||||
{
|
{
|
||||||
target.Health -= damage;
|
target.Health -= damage;
|
||||||
|
target.DamageTaken += damage;
|
||||||
|
|
||||||
|
// Track damage dealt by source
|
||||||
|
if (sourceId.HasValue && _players.TryGetValue(sourceId.Value, out var source))
|
||||||
|
{
|
||||||
|
source.DamageDealt += damage;
|
||||||
|
}
|
||||||
|
|
||||||
_pendingEvents.Add(new GameEvent
|
_pendingEvents.Add(new GameEvent
|
||||||
{
|
{
|
||||||
@@ -604,6 +613,7 @@ public sealed class GameSimulation
|
|||||||
{
|
{
|
||||||
player.Alive = false;
|
player.Alive = false;
|
||||||
player.Health = 0;
|
player.Health = 0;
|
||||||
|
player.DiedAtTick = CurrentTick;
|
||||||
|
|
||||||
var drops = DropPlayerLoot(player);
|
var drops = DropPlayerLoot(player);
|
||||||
|
|
||||||
@@ -864,6 +874,98 @@ public sealed class GameSimulation
|
|||||||
public IReadOnlyDictionary<int, DroppedItem> DroppedItems => _droppedItems;
|
public IReadOnlyDictionary<int, DroppedItem> DroppedItems => _droppedItems;
|
||||||
public IReadOnlyDictionary<int, Projectile> Projectiles => _projectiles;
|
public IReadOnlyDictionary<int, Projectile> Projectiles => _projectiles;
|
||||||
public IReadOnlyDictionary<int, ExtractionZone> ExtractionZones => _extractionZones;
|
public IReadOnlyDictionary<int, ExtractionZone> ExtractionZones => _extractionZones;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets match results for all players, sorted by placement
|
||||||
|
/// </summary>
|
||||||
|
public List<MatchPlayerResult> GetMatchResults()
|
||||||
|
{
|
||||||
|
var results = new List<MatchPlayerResult>();
|
||||||
|
int totalPlayers = _players.Count;
|
||||||
|
int matchDurationSeconds = (int)(MatchDuration - TimeRemaining);
|
||||||
|
|
||||||
|
// Calculate placements based on: extracted > alive > death order
|
||||||
|
var sortedPlayers = _players.Values
|
||||||
|
.OrderByDescending(p => p.Extracted)
|
||||||
|
.ThenByDescending(p => p.Alive)
|
||||||
|
.ThenByDescending(p => p.DiedAtTick == 0 ? long.MaxValue : p.DiedAtTick)
|
||||||
|
.ThenByDescending(p => p.Kills)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
for (int i = 0; i < sortedPlayers.Count; i++)
|
||||||
|
{
|
||||||
|
var p = sortedPlayers[i];
|
||||||
|
int placement = i + 1;
|
||||||
|
|
||||||
|
// Determine result
|
||||||
|
MatchPlayerResultType resultType;
|
||||||
|
if (p.Extracted)
|
||||||
|
resultType = MatchPlayerResultType.Extracted;
|
||||||
|
else if (p.Alive && placement == 1)
|
||||||
|
resultType = MatchPlayerResultType.Won;
|
||||||
|
else
|
||||||
|
resultType = MatchPlayerResultType.Lost;
|
||||||
|
|
||||||
|
// Calculate survival time
|
||||||
|
int survivalSeconds;
|
||||||
|
if (p.Extracted)
|
||||||
|
survivalSeconds = (int)(p.ExtractedAtTick / TickRate);
|
||||||
|
else if (!p.Alive && p.DiedAtTick > 0)
|
||||||
|
survivalSeconds = (int)(p.DiedAtTick / TickRate);
|
||||||
|
else
|
||||||
|
survivalSeconds = matchDurationSeconds;
|
||||||
|
|
||||||
|
results.Add(new MatchPlayerResult
|
||||||
|
{
|
||||||
|
AccountId = p.Id,
|
||||||
|
PlayerName = p.Name,
|
||||||
|
Placement = placement,
|
||||||
|
TotalPlayers = totalPlayers,
|
||||||
|
Result = resultType,
|
||||||
|
Kills = p.Kills,
|
||||||
|
Deaths = p.Deaths,
|
||||||
|
DamageDealt = p.DamageDealt,
|
||||||
|
DamageTaken = p.DamageTaken,
|
||||||
|
ScrapCollected = p.TotalScrapCollected,
|
||||||
|
EnergyCollected = p.TotalEnergyCollected,
|
||||||
|
RareCollected = p.TotalRareCollected,
|
||||||
|
ItemsCrafted = p.ItemsCrafted,
|
||||||
|
SurvivalTimeSeconds = survivalSeconds,
|
||||||
|
MatchDurationSeconds = matchDurationSeconds
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Result data for a single player in a match
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MatchPlayerResult
|
||||||
|
{
|
||||||
|
public ulong AccountId { get; set; }
|
||||||
|
public string PlayerName { get; set; } = "";
|
||||||
|
public int Placement { get; set; }
|
||||||
|
public int TotalPlayers { get; set; }
|
||||||
|
public MatchPlayerResultType Result { get; set; }
|
||||||
|
public int Kills { get; set; }
|
||||||
|
public int Deaths { get; set; }
|
||||||
|
public int DamageDealt { get; set; }
|
||||||
|
public int DamageTaken { get; set; }
|
||||||
|
public int ScrapCollected { get; set; }
|
||||||
|
public int EnergyCollected { get; set; }
|
||||||
|
public int RareCollected { get; set; }
|
||||||
|
public int ItemsCrafted { get; set; }
|
||||||
|
public int SurvivalTimeSeconds { get; set; }
|
||||||
|
public int MatchDurationSeconds { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MatchPlayerResultType
|
||||||
|
{
|
||||||
|
Lost,
|
||||||
|
Won,
|
||||||
|
Extracted
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== Entity Classes =====
|
// ===== Entity Classes =====
|
||||||
@@ -891,10 +993,22 @@ public sealed class PlayerEntity
|
|||||||
public long LastShotTick { get; set; }
|
public long LastShotTick { get; set; }
|
||||||
public float ExtractionProgress { get; set; }
|
public float ExtractionProgress { get; set; }
|
||||||
|
|
||||||
|
// Match statistics
|
||||||
public int Kills { get; set; }
|
public int Kills { get; set; }
|
||||||
public int Deaths { get; set; }
|
public int Deaths { get; set; }
|
||||||
public int DamageDealt { get; set; }
|
public int DamageDealt { get; set; }
|
||||||
|
public int DamageTaken { get; set; }
|
||||||
public int ItemsCrafted { get; set; }
|
public int ItemsCrafted { get; set; }
|
||||||
|
|
||||||
|
// Lifetime resource tracking (for this match)
|
||||||
|
public int TotalScrapCollected { get; set; }
|
||||||
|
public int TotalEnergyCollected { get; set; }
|
||||||
|
public int TotalRareCollected { get; set; }
|
||||||
|
|
||||||
|
// Time tracking
|
||||||
|
public long JoinedAtTick { get; set; }
|
||||||
|
public long DiedAtTick { get; set; }
|
||||||
|
public long ExtractedAtTick { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class Asteroid
|
public sealed class Asteroid
|
||||||
|
|||||||
@@ -0,0 +1,658 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Server.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SystemRevivalServer.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(GameDbContext))]
|
||||||
|
[Migration("20251204134242_AddVoidScavengersStats")]
|
||||||
|
partial class AddVoidScavengersStats
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "9.0.10")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Account", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime?>("BannedUntil")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("varchar(255)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsBanned")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<byte[]>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varbinary(64)");
|
||||||
|
|
||||||
|
b.Property<byte[]>("PasswordSalt")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varbinary(32)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Email")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Username")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("accounts", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Character", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<string>("AppearanceJson")
|
||||||
|
.HasColumnType("json");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<float>("FacingDeg")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<uint>("HpCurrent")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("HpMax")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("Level")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("MpCurrent")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("MpMax")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
|
b.Property<double>("PosX")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("PosY")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("PosZ")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<uint>("StaminaCurrent")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StaminaMax")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StatDexterity")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StatEndurance")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StatIntelligence")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StatStrength")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("StatWisdom")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.Property<ulong>("Xp")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<ulong>("ZoneId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ZoneId");
|
||||||
|
|
||||||
|
b.ToTable("characters", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.EquipmentSlot", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("CharacterId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<ulong>("ItemTemplateId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<byte>("SlotCode")
|
||||||
|
.HasColumnType("tinyint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ItemTemplateId");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId", "SlotCode")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("equipment", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.InventoryItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("CharacterId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<ulong>("ItemTemplateId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("Quantity")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("SlotIndex")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId");
|
||||||
|
|
||||||
|
b.HasIndex("ItemTemplateId");
|
||||||
|
|
||||||
|
b.HasIndex("CharacterId", "SlotIndex")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("inventories", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.ItemTemplate", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<byte>("ItemType")
|
||||||
|
.HasColumnType("tinyint unsigned");
|
||||||
|
|
||||||
|
b.Property<uint>("MaxStack")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("varchar(64)");
|
||||||
|
|
||||||
|
b.Property<byte>("Rarity")
|
||||||
|
.HasColumnType("tinyint unsigned");
|
||||||
|
|
||||||
|
b.Property<string>("StatsJson")
|
||||||
|
.HasColumnType("json");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.Property<uint>("Weight")
|
||||||
|
.HasColumnType("int unsigned");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Name")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("item_templates", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.MatchHistory", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<int>("DamageDealt")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DamageTaken")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Deaths")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EloAfter")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EloChange")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EnergyCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ItemsCrafted")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Kills")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("MatchDurationSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("MatchId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
|
b.Property<int>("Placement")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PlayedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<int>("RareCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Result")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ScrapCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SurvivalTimeSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("TotalPlayers")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("MatchId");
|
||||||
|
|
||||||
|
b.HasIndex("PlayedAt");
|
||||||
|
|
||||||
|
b.ToTable("match_history", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.PlayerStats", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<int>("Deaths")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Elo")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasDefaultValue(1000);
|
||||||
|
|
||||||
|
b.Property<int>("Extractions")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ItemsCrafted")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Kills")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("LongestSurvivalSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Losses")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("MatchesPlayed")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<long>("TotalDamageDealt")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalDamageTaken")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalEnergyCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalPlayTimeSeconds")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalRareCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalScrapCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.Property<int>("Wins")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("player_stats", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Session", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedIp")
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("varchar(64)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiresAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("RevokedAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("TokenHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(128)
|
||||||
|
.HasColumnType("varchar(128)");
|
||||||
|
|
||||||
|
b.Property<string>("UserAgent")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("TokenHash")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("sessions", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Zone", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<double>("MaxX")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("MaxY")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("MaxZ")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("MinX")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("MinY")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<double>("MinZ")
|
||||||
|
.HasColumnType("double");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("varchar(64)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Name")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("zones", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Character", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithMany("Characters")
|
||||||
|
.HasForeignKey("AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Server.Data.Zone", "Zone")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ZoneId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
|
||||||
|
b.Navigation("Zone");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.EquipmentSlot", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Character", "Character")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Server.Data.ItemTemplate", "ItemTemplate")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ItemTemplateId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
|
||||||
|
b.Navigation("ItemTemplate");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.InventoryItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Character", "Character")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CharacterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Server.Data.ItemTemplate", "ItemTemplate")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ItemTemplateId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Character");
|
||||||
|
|
||||||
|
b.Navigation("ItemTemplate");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.MatchHistory", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.PlayerStats", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey("Server.Data.PlayerStats", "AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Session", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithMany("Sessions")
|
||||||
|
.HasForeignKey("AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.Account", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Characters");
|
||||||
|
|
||||||
|
b.Navigation("Sessions");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SystemRevivalServer.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddVoidScavengersStats : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "match_history",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
MatchId = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AccountId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
||||||
|
Result = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Placement = table.Column<int>(type: "int", nullable: false),
|
||||||
|
TotalPlayers = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Kills = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Deaths = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DamageDealt = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DamageTaken = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ScrapCollected = table.Column<int>(type: "int", nullable: false),
|
||||||
|
EnergyCollected = table.Column<int>(type: "int", nullable: false),
|
||||||
|
RareCollected = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SurvivalTimeSeconds = table.Column<int>(type: "int", nullable: false),
|
||||||
|
MatchDurationSeconds = table.Column<int>(type: "int", nullable: false),
|
||||||
|
EloChange = table.Column<int>(type: "int", nullable: false),
|
||||||
|
EloAfter = table.Column<int>(type: "int", nullable: false),
|
||||||
|
PlayedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_match_history", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_match_history_accounts_AccountId",
|
||||||
|
column: x => x.AccountId,
|
||||||
|
principalTable: "accounts",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "player_stats",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
AccountId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
||||||
|
MatchesPlayed = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Wins = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Losses = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Extractions = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Kills = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Deaths = table.Column<int>(type: "int", nullable: false),
|
||||||
|
TotalDamageDealt = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
TotalDamageTaken = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
TotalScrapCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
TotalEnergyCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
TotalRareCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
|
||||||
|
TotalPlayTimeSeconds = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
LongestSurvivalSeconds = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Elo = table.Column<int>(type: "int", nullable: false, defaultValue: 1000),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
|
||||||
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)")
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_player_stats", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_player_stats_accounts_AccountId",
|
||||||
|
column: x => x.AccountId,
|
||||||
|
principalTable: "accounts",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_match_history_AccountId",
|
||||||
|
table: "match_history",
|
||||||
|
column: "AccountId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_match_history_MatchId",
|
||||||
|
table: "match_history",
|
||||||
|
column: "MatchId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_match_history_PlayedAt",
|
||||||
|
table: "match_history",
|
||||||
|
column: "PlayedAt");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_player_stats_AccountId",
|
||||||
|
table: "player_stats",
|
||||||
|
column: "AccountId",
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "match_history");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "player_stats");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -302,6 +302,161 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.ToTable("item_templates", (string)null);
|
b.ToTable("item_templates", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.MatchHistory", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<int>("DamageDealt")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DamageTaken")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Deaths")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EloAfter")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EloChange")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("EnergyCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ItemsCrafted")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Kills")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("MatchDurationSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("MatchId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
|
b.Property<int>("Placement")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PlayedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<int>("RareCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Result")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ScrapCollected")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SurvivalTimeSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("TotalPlayers")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId");
|
||||||
|
|
||||||
|
b.HasIndex("MatchId");
|
||||||
|
|
||||||
|
b.HasIndex("PlayedAt");
|
||||||
|
|
||||||
|
b.ToTable("match_history", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.PlayerStats", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<ulong>("Id"));
|
||||||
|
|
||||||
|
b.Property<ulong>("AccountId")
|
||||||
|
.HasColumnType("bigint unsigned");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
b.Property<int>("Deaths")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Elo")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasDefaultValue(1000);
|
||||||
|
|
||||||
|
b.Property<int>("Extractions")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ItemsCrafted")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Kills")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("LongestSurvivalSeconds")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Losses")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("MatchesPlayed")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<long>("TotalDamageDealt")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalDamageTaken")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalEnergyCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalPlayTimeSeconds")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalRareCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("TotalScrapCollected")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
|
||||||
|
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||||
|
|
||||||
|
b.Property<int>("Wins")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AccountId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("player_stats", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Server.Data.Session", b =>
|
modelBuilder.Entity("Server.Data.Session", b =>
|
||||||
{
|
{
|
||||||
b.Property<ulong>("Id")
|
b.Property<ulong>("Id")
|
||||||
@@ -455,6 +610,28 @@ namespace SystemRevivalServer.Migrations
|
|||||||
b.Navigation("ItemTemplate");
|
b.Navigation("ItemTemplate");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.MatchHistory", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Server.Data.PlayerStats", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey("Server.Data.PlayerStats", "AccountId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Account");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Server.Data.Session", b =>
|
modelBuilder.Entity("Server.Data.Session", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Server.Data.Account", "Account")
|
b.HasOne("Server.Data.Account", "Account")
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public sealed class GameDbContext : DbContext
|
|||||||
public DbSet<ItemTemplate> ItemTemplates => Set<ItemTemplate>();
|
public DbSet<ItemTemplate> ItemTemplates => Set<ItemTemplate>();
|
||||||
public DbSet<InventoryItem> Inventory => Set<InventoryItem>();
|
public DbSet<InventoryItem> Inventory => Set<InventoryItem>();
|
||||||
public DbSet<EquipmentSlot> Equipment => Set<EquipmentSlot>();
|
public DbSet<EquipmentSlot> Equipment => Set<EquipmentSlot>();
|
||||||
|
public DbSet<PlayerStats> PlayerStats => Set<PlayerStats>();
|
||||||
|
public DbSet<MatchHistory> MatchHistory => Set<MatchHistory>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder b)
|
protected override void OnModelCreating(ModelBuilder b)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace Server.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Records individual match results for Void Scavengers
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MatchHistory
|
||||||
|
{
|
||||||
|
public ulong Id { get; set; }
|
||||||
|
public string MatchId { get; set; } = ""; // The game's match ID
|
||||||
|
public ulong AccountId { get; set; }
|
||||||
|
|
||||||
|
// Result
|
||||||
|
public MatchResult Result { get; set; }
|
||||||
|
public int Placement { get; set; } // 1st, 2nd, etc.
|
||||||
|
public int TotalPlayers { get; set; }
|
||||||
|
|
||||||
|
// Match performance
|
||||||
|
public int Kills { get; set; }
|
||||||
|
public int Deaths { get; set; }
|
||||||
|
public int DamageDealt { get; set; }
|
||||||
|
public int DamageTaken { get; set; }
|
||||||
|
|
||||||
|
// Resources
|
||||||
|
public int ScrapCollected { get; set; }
|
||||||
|
public int EnergyCollected { get; set; }
|
||||||
|
public int RareCollected { get; set; }
|
||||||
|
public int ItemsCrafted { get; set; }
|
||||||
|
|
||||||
|
// Time
|
||||||
|
public int SurvivalTimeSeconds { get; set; }
|
||||||
|
public int MatchDurationSeconds { get; set; }
|
||||||
|
|
||||||
|
// Elo change
|
||||||
|
public int EloChange { get; set; }
|
||||||
|
public int EloAfter { get; set; }
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
public DateTime PlayedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation
|
||||||
|
public Account Account { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MatchResult
|
||||||
|
{
|
||||||
|
Loss = 0,
|
||||||
|
Win = 1,
|
||||||
|
Extracted = 2, // Special win type
|
||||||
|
Disconnected = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class MatchHistoryConfig : IEntityTypeConfiguration<MatchHistory>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<MatchHistory> e)
|
||||||
|
{
|
||||||
|
e.ToTable("match_history");
|
||||||
|
e.HasKey(x => x.Id);
|
||||||
|
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
e.HasIndex(x => x.AccountId);
|
||||||
|
e.HasIndex(x => x.MatchId);
|
||||||
|
e.HasIndex(x => x.PlayedAt);
|
||||||
|
|
||||||
|
e.Property(x => x.MatchId).HasMaxLength(32).IsRequired();
|
||||||
|
|
||||||
|
e.HasOne(x => x.Account)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.AccountId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
e.Property(x => x.PlayedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace Server.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tracks player statistics for Void Scavengers
|
||||||
|
/// </summary>
|
||||||
|
public sealed class PlayerStats
|
||||||
|
{
|
||||||
|
public ulong Id { get; set; }
|
||||||
|
public ulong AccountId { get; set; }
|
||||||
|
|
||||||
|
// Match stats
|
||||||
|
public int MatchesPlayed { get; set; }
|
||||||
|
public int Wins { get; set; }
|
||||||
|
public int Losses { get; set; }
|
||||||
|
public int Extractions { get; set; } // Successful extractions (counts as win)
|
||||||
|
|
||||||
|
// Combat stats
|
||||||
|
public int Kills { get; set; }
|
||||||
|
public int Deaths { get; set; }
|
||||||
|
public long TotalDamageDealt { get; set; }
|
||||||
|
public long TotalDamageTaken { get; set; }
|
||||||
|
|
||||||
|
// Resource stats
|
||||||
|
public long TotalScrapCollected { get; set; }
|
||||||
|
public long TotalEnergyCollected { get; set; }
|
||||||
|
public long TotalRareCollected { get; set; }
|
||||||
|
public int ItemsCrafted { get; set; }
|
||||||
|
|
||||||
|
// Time stats
|
||||||
|
public long TotalPlayTimeSeconds { get; set; }
|
||||||
|
public int LongestSurvivalSeconds { get; set; }
|
||||||
|
|
||||||
|
// Ratings
|
||||||
|
public int Elo { get; set; } = 1000; // Starting Elo rating
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
// Navigation
|
||||||
|
public Account Account { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class PlayerStatsConfig : IEntityTypeConfiguration<PlayerStats>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PlayerStats> e)
|
||||||
|
{
|
||||||
|
e.ToTable("player_stats");
|
||||||
|
e.HasKey(x => x.Id);
|
||||||
|
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
e.HasIndex(x => x.AccountId).IsUnique();
|
||||||
|
|
||||||
|
e.HasOne(x => x.Account)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey<PlayerStats>(x => x.AccountId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
e.Property(x => x.Elo).HasDefaultValue(1000);
|
||||||
|
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||||
|
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||||
|
.ValueGeneratedOnAddOrUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user