This commit is contained in:
dingo
2025-12-26 10:00:34 -05:00
parent 244635ca3f
commit 2d847c91dd
15 changed files with 2167 additions and 1646 deletions
-4
View File
@@ -16,10 +16,6 @@ public sealed class GameDbContext : DbContext
public DbSet<ItemTemplate> ItemTemplates => Set<ItemTemplate>();
public DbSet<InventoryItem> Inventory => Set<InventoryItem>();
public DbSet<EquipmentSlot> Equipment => Set<EquipmentSlot>();
public DbSet<PlayerStats> PlayerStats => Set<PlayerStats>();
public DbSet<MatchHistory> MatchHistory => Set<MatchHistory>();
public DbSet<GameItem> GameItems => Set<GameItem>();
public DbSet<GameRecipe> GameRecipes => Set<GameRecipe>();
public DbSet<DungeonCharacter> DungeonCharacters => Set<DungeonCharacter>();
public DbSet<DungeonCharacterItem> DungeonCharacterItems => Set<DungeonCharacterItem>();
public DbSet<DungeonStashItem> DungeonStashItems => Set<DungeonStashItem>();
-84
View File
@@ -1,84 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace DataServer.Data;
/// <summary>
/// Database-backed item definition for Void Scavengers
/// </summary>
public sealed class GameItem
{
public int Id { get; set; }
public string Name { get; set; } = "";
public ItemCategory Category { get; set; }
public int CraftCost { get; set; }
public string Description { get; set; } = "";
public int LootValue { get; set; }
public bool Stackable { get; set; }
public bool IsEnabled { get; set; } = true;
// Weapon stats (JSON or individual columns)
public int Damage { get; set; }
public float FireRate { get; set; }
public float ProjectileSpeed { get; set; }
public float Range { get; set; }
public int AmmoType { get; set; }
public int PelletCount { get; set; } = 1;
public float Spread { get; set; }
public float ExplosionRadius { get; set; }
// Tool stats
public float HarvestMultiplier { get; set; } = 1f;
public float ScanRadius { get; set; }
public float ScanCooldown { get; set; }
public int ShieldHealth { get; set; }
public float ShieldDuration { get; set; }
// Consumable stats
public int HealAmount { get; set; }
public float ShieldBoostDuration { get; set; }
public float DamageReduction { get; set; }
public float SpeedBoostDuration { get; set; }
public float SpeedMultiplier { get; set; } = 1f;
// Armor stats
public int HealthBonus { get; set; }
public float SpeedPenalty { get; set; }
public float DashDistance { get; set; }
public float DashCooldown { get; set; }
// Timestamps
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public enum ItemCategory
{
Resource = 0,
Weapon = 1,
Tool = 2,
Consumable = 3,
Armor = 4
}
public sealed class GameItemConfig : IEntityTypeConfiguration<GameItem>
{
public void Configure(EntityTypeBuilder<GameItem> e)
{
e.ToTable("game_items");
e.HasKey(x => x.Id);
// Not auto-generated - we want specific IDs
e.Property(x => x.Id).ValueGeneratedNever();
e.Property(x => x.Name).HasMaxLength(64).IsRequired();
e.Property(x => x.Description).HasMaxLength(256);
e.Property(x => x.IsEnabled).HasDefaultValue(true);
e.HasIndex(x => x.Category);
e.HasIndex(x => x.IsEnabled);
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
.ValueGeneratedOnAddOrUpdate();
}
}
-49
View File
@@ -1,49 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace DataServer.Data;
/// <summary>
/// Database-backed crafting recipe for Void Scavengers
/// </summary>
public sealed class GameRecipe
{
public int Id { get; set; }
public int ResultItemId { get; set; }
public bool IsEnabled { get; set; } = true;
// Resource costs
public int ScrapCost { get; set; }
public int EnergyCost { get; set; }
public int RareCost { get; set; }
// Timestamps
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
// Navigation
public GameItem? ResultItem { get; set; }
}
public sealed class GameRecipeConfig : IEntityTypeConfiguration<GameRecipe>
{
public void Configure(EntityTypeBuilder<GameRecipe> e)
{
e.ToTable("game_recipes");
e.HasKey(x => x.Id);
e.Property(x => x.Id).ValueGeneratedNever();
e.HasIndex(x => x.ResultItemId);
e.HasIndex(x => x.IsEnabled);
e.HasOne(x => x.ResultItem)
.WithMany()
.HasForeignKey(x => x.ResultItemId)
.OnDelete(DeleteBehavior.Cascade);
e.Property(x => x.IsEnabled).HasDefaultValue(true);
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
.ValueGeneratedOnAddOrUpdate();
}
}
-76
View File
@@ -1,76 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace DataServer.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)");
}
}
-67
View File
@@ -1,67 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace DataServer.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();
}
}