Cleanup
This commit is contained in:
@@ -1,341 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data;
|
||||
using Server.Services.Auth;
|
||||
using Server.Game;
|
||||
|
||||
namespace Server.Api;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoints for game items and recipes
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/items")]
|
||||
public class ItemsController : ControllerBase
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
private readonly IItemService _itemService;
|
||||
private readonly IAdminAuthService _adminAuth;
|
||||
|
||||
public ItemsController(GameDbContext db, IItemService itemService, IAdminAuthService adminAuth)
|
||||
{
|
||||
_db = db;
|
||||
_itemService = itemService;
|
||||
_adminAuth = adminAuth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all items (from cache) - public endpoint
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public IActionResult GetAllItems([FromQuery] ItemCategory? category = null)
|
||||
{
|
||||
var items = category.HasValue
|
||||
? _itemService.GetItemsByCategory(category.Value)
|
||||
: _itemService.GetAllItems();
|
||||
|
||||
return Ok(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a specific item - public endpoint
|
||||
/// </summary>
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetItem(int id)
|
||||
{
|
||||
var item = _itemService.GetItem(id);
|
||||
if (item == null)
|
||||
return NotFound(new { error = "Item not found" });
|
||||
|
||||
return Ok(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all recipes (from cache) - public endpoint
|
||||
/// </summary>
|
||||
[HttpGet("recipes")]
|
||||
public IActionResult GetAllRecipes()
|
||||
{
|
||||
var recipes = _itemService.GetAllRecipes();
|
||||
|
||||
// Enrich with item names
|
||||
var enriched = recipes.Select(r => new
|
||||
{
|
||||
r.Id,
|
||||
r.ResultItemId,
|
||||
ResultItemName = _itemService.GetItem(r.ResultItemId)?.Name ?? "Unknown",
|
||||
r.ScrapCost,
|
||||
r.EnergyCost,
|
||||
r.RareCost
|
||||
});
|
||||
|
||||
return Ok(enriched);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force reload the item cache (admin only)
|
||||
/// </summary>
|
||||
[HttpPost("reload")]
|
||||
public async Task<IActionResult> ReloadCache()
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
await _itemService.ReloadCacheAsync();
|
||||
return Ok(new { message = "Cache reloaded", itemCount = _itemService.GetAllItems().Count });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create or update an item (admin only)
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> UpsertItem([FromBody] GameItemDto dto)
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var existing = await _db.GameItems.FindAsync(dto.Id);
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
var item = new GameItem
|
||||
{
|
||||
Id = dto.Id,
|
||||
Name = dto.Name,
|
||||
Category = dto.Category,
|
||||
CraftCost = dto.CraftCost,
|
||||
Description = dto.Description,
|
||||
LootValue = dto.LootValue,
|
||||
Stackable = dto.Stackable,
|
||||
IsEnabled = dto.IsEnabled,
|
||||
Damage = dto.Damage,
|
||||
FireRate = dto.FireRate,
|
||||
ProjectileSpeed = dto.ProjectileSpeed,
|
||||
Range = dto.Range,
|
||||
AmmoType = dto.AmmoType,
|
||||
PelletCount = dto.PelletCount,
|
||||
Spread = dto.Spread,
|
||||
ExplosionRadius = dto.ExplosionRadius,
|
||||
HarvestMultiplier = dto.HarvestMultiplier,
|
||||
ScanRadius = dto.ScanRadius,
|
||||
ScanCooldown = dto.ScanCooldown,
|
||||
ShieldHealth = dto.ShieldHealth,
|
||||
ShieldDuration = dto.ShieldDuration,
|
||||
HealAmount = dto.HealAmount,
|
||||
ShieldBoostDuration = dto.ShieldBoostDuration,
|
||||
DamageReduction = dto.DamageReduction,
|
||||
SpeedBoostDuration = dto.SpeedBoostDuration,
|
||||
SpeedMultiplier = dto.SpeedMultiplier,
|
||||
HealthBonus = dto.HealthBonus,
|
||||
SpeedPenalty = dto.SpeedPenalty,
|
||||
DashDistance = dto.DashDistance,
|
||||
DashCooldown = dto.DashCooldown,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
_db.GameItems.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
existing.Name = dto.Name;
|
||||
existing.Category = dto.Category;
|
||||
existing.CraftCost = dto.CraftCost;
|
||||
existing.Description = dto.Description;
|
||||
existing.LootValue = dto.LootValue;
|
||||
existing.Stackable = dto.Stackable;
|
||||
existing.IsEnabled = dto.IsEnabled;
|
||||
existing.Damage = dto.Damage;
|
||||
existing.FireRate = dto.FireRate;
|
||||
existing.ProjectileSpeed = dto.ProjectileSpeed;
|
||||
existing.Range = dto.Range;
|
||||
existing.AmmoType = dto.AmmoType;
|
||||
existing.PelletCount = dto.PelletCount;
|
||||
existing.Spread = dto.Spread;
|
||||
existing.ExplosionRadius = dto.ExplosionRadius;
|
||||
existing.HarvestMultiplier = dto.HarvestMultiplier;
|
||||
existing.ScanRadius = dto.ScanRadius;
|
||||
existing.ScanCooldown = dto.ScanCooldown;
|
||||
existing.ShieldHealth = dto.ShieldHealth;
|
||||
existing.ShieldDuration = dto.ShieldDuration;
|
||||
existing.HealAmount = dto.HealAmount;
|
||||
existing.ShieldBoostDuration = dto.ShieldBoostDuration;
|
||||
existing.DamageReduction = dto.DamageReduction;
|
||||
existing.SpeedBoostDuration = dto.SpeedBoostDuration;
|
||||
existing.SpeedMultiplier = dto.SpeedMultiplier;
|
||||
existing.HealthBonus = dto.HealthBonus;
|
||||
existing.SpeedPenalty = dto.SpeedPenalty;
|
||||
existing.DashDistance = dto.DashDistance;
|
||||
existing.DashCooldown = dto.DashCooldown;
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
await _itemService.ReloadCacheAsync();
|
||||
|
||||
return Ok(new { message = existing == null ? "Item created" : "Item updated", id = dto.Id });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create or update a recipe (admin only)
|
||||
/// </summary>
|
||||
[HttpPost("recipes")]
|
||||
public async Task<IActionResult> UpsertRecipe([FromBody] GameRecipeDto dto)
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var existing = await _db.GameRecipes.FindAsync(dto.Id);
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
var recipe = new GameRecipe
|
||||
{
|
||||
Id = dto.Id,
|
||||
ResultItemId = dto.ResultItemId,
|
||||
ScrapCost = dto.ScrapCost,
|
||||
EnergyCost = dto.EnergyCost,
|
||||
RareCost = dto.RareCost,
|
||||
IsEnabled = dto.IsEnabled,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
_db.GameRecipes.Add(recipe);
|
||||
}
|
||||
else
|
||||
{
|
||||
existing.ResultItemId = dto.ResultItemId;
|
||||
existing.ScrapCost = dto.ScrapCost;
|
||||
existing.EnergyCost = dto.EnergyCost;
|
||||
existing.RareCost = dto.RareCost;
|
||||
existing.IsEnabled = dto.IsEnabled;
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
await _itemService.ReloadCacheAsync();
|
||||
|
||||
return Ok(new { message = existing == null ? "Recipe created" : "Recipe updated", id = dto.Id });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seed default items if database is empty (admin only)
|
||||
/// </summary>
|
||||
[HttpPost("seed")]
|
||||
public async Task<IActionResult> SeedDefaults()
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var existingItemCount = await _db.GameItems.CountAsync();
|
||||
var existingRecipeCount = await _db.GameRecipes.CountAsync();
|
||||
|
||||
if (existingItemCount > 0 || existingRecipeCount > 0)
|
||||
return BadRequest(new { error = "Database already has items/recipes. Clear first or use upsert." });
|
||||
|
||||
var defaultItems = DefaultItemData.GetDefaultItems();
|
||||
var defaultRecipes = DefaultItemData.GetDefaultRecipes();
|
||||
|
||||
_db.GameItems.AddRange(defaultItems);
|
||||
_db.GameRecipes.AddRange(defaultRecipes);
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
await _itemService.ReloadCacheAsync();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
message = "Default items seeded",
|
||||
itemsAdded = defaultItems.Count,
|
||||
recipesAdded = defaultRecipes.Count
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item (admin only)
|
||||
/// </summary>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteItem(int id)
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var item = await _db.GameItems.FindAsync(id);
|
||||
if (item == null)
|
||||
return NotFound(new { error = "Item not found" });
|
||||
|
||||
_db.GameItems.Remove(item);
|
||||
await _db.SaveChangesAsync();
|
||||
await _itemService.ReloadCacheAsync();
|
||||
|
||||
return Ok(new { message = "Item deleted", id });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a recipe (admin only)
|
||||
/// </summary>
|
||||
[HttpDelete("recipes/{id}")]
|
||||
public async Task<IActionResult> DeleteRecipe(int id)
|
||||
{
|
||||
var auth = await ValidateAdminAsync();
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var recipe = await _db.GameRecipes.FindAsync(id);
|
||||
if (recipe == null)
|
||||
return NotFound(new { error = "Recipe not found" });
|
||||
|
||||
_db.GameRecipes.Remove(recipe);
|
||||
await _db.SaveChangesAsync();
|
||||
await _itemService.ReloadCacheAsync();
|
||||
|
||||
return Ok(new { message = "Recipe deleted", id });
|
||||
}
|
||||
|
||||
private async Task<AdminAuthResult> ValidateAdminAsync()
|
||||
{
|
||||
var token = Request.Headers["Authorization"].FirstOrDefault()?.Replace("Bearer ", "");
|
||||
return await _adminAuth.ValidateAsync(token, AccountRole.Admin);
|
||||
}
|
||||
}
|
||||
|
||||
public class GameItemDto
|
||||
{
|
||||
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;
|
||||
|
||||
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; }
|
||||
|
||||
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; }
|
||||
|
||||
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;
|
||||
|
||||
public int HealthBonus { get; set; }
|
||||
public float SpeedPenalty { get; set; }
|
||||
public float DashDistance { get; set; }
|
||||
public float DashCooldown { get; set; }
|
||||
}
|
||||
|
||||
public class GameRecipeDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ResultItemId { get; set; }
|
||||
public int ScrapCost { get; set; }
|
||||
public int EnergyCost { get; set; }
|
||||
public int RareCost { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data;
|
||||
|
||||
namespace Server.Api;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoints for player statistics and leaderboards
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/stats")]
|
||||
public class StatsController : ControllerBase
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
|
||||
public StatsController(GameDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get stats for a specific player by account ID
|
||||
/// </summary>
|
||||
[HttpGet("player/{accountId}")]
|
||||
public async Task<IActionResult> GetPlayerStats(ulong accountId)
|
||||
{
|
||||
var stats = await _db.PlayerStats
|
||||
.Where(s => s.AccountId == accountId)
|
||||
.Select(s => new PlayerStatsDto
|
||||
{
|
||||
AccountId = s.AccountId,
|
||||
Username = s.Account.Username,
|
||||
MatchesPlayed = s.MatchesPlayed,
|
||||
Wins = s.Wins,
|
||||
Losses = s.Losses,
|
||||
Extractions = s.Extractions,
|
||||
WinRate = s.MatchesPlayed > 0 ? (float)s.Wins / s.MatchesPlayed * 100 : 0,
|
||||
Kills = s.Kills,
|
||||
Deaths = s.Deaths,
|
||||
KdRatio = s.Deaths > 0 ? (float)s.Kills / s.Deaths : s.Kills,
|
||||
TotalDamageDealt = s.TotalDamageDealt,
|
||||
TotalDamageTaken = s.TotalDamageTaken,
|
||||
TotalScrapCollected = s.TotalScrapCollected,
|
||||
TotalEnergyCollected = s.TotalEnergyCollected,
|
||||
TotalRareCollected = s.TotalRareCollected,
|
||||
ItemsCrafted = s.ItemsCrafted,
|
||||
TotalPlayTimeSeconds = s.TotalPlayTimeSeconds,
|
||||
LongestSurvivalSeconds = s.LongestSurvivalSeconds,
|
||||
Elo = s.Elo
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (stats == null)
|
||||
return NotFound(new { error = "Player stats not found" });
|
||||
|
||||
return Ok(stats);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get stats for a player by username
|
||||
/// </summary>
|
||||
[HttpGet("player/name/{username}")]
|
||||
public async Task<IActionResult> GetPlayerStatsByName(string username)
|
||||
{
|
||||
var stats = await _db.PlayerStats
|
||||
.Where(s => s.Account.Username == username)
|
||||
.Select(s => new PlayerStatsDto
|
||||
{
|
||||
AccountId = s.AccountId,
|
||||
Username = s.Account.Username,
|
||||
MatchesPlayed = s.MatchesPlayed,
|
||||
Wins = s.Wins,
|
||||
Losses = s.Losses,
|
||||
Extractions = s.Extractions,
|
||||
WinRate = s.MatchesPlayed > 0 ? (float)s.Wins / s.MatchesPlayed * 100 : 0,
|
||||
Kills = s.Kills,
|
||||
Deaths = s.Deaths,
|
||||
KdRatio = s.Deaths > 0 ? (float)s.Kills / s.Deaths : s.Kills,
|
||||
TotalDamageDealt = s.TotalDamageDealt,
|
||||
TotalDamageTaken = s.TotalDamageTaken,
|
||||
TotalScrapCollected = s.TotalScrapCollected,
|
||||
TotalEnergyCollected = s.TotalEnergyCollected,
|
||||
TotalRareCollected = s.TotalRareCollected,
|
||||
ItemsCrafted = s.ItemsCrafted,
|
||||
TotalPlayTimeSeconds = s.TotalPlayTimeSeconds,
|
||||
LongestSurvivalSeconds = s.LongestSurvivalSeconds,
|
||||
Elo = s.Elo
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (stats == null)
|
||||
return NotFound(new { error = "Player not found" });
|
||||
|
||||
return Ok(stats);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get leaderboard by Elo rating
|
||||
/// </summary>
|
||||
[HttpGet("leaderboard")]
|
||||
public async Task<IActionResult> GetLeaderboard(
|
||||
[FromQuery] string sort = "elo",
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
pageSize = Math.Clamp(pageSize, 1, 100);
|
||||
page = Math.Max(1, page);
|
||||
|
||||
var query = _db.PlayerStats
|
||||
.Where(s => s.MatchesPlayed >= 5); // Minimum games to appear on leaderboard
|
||||
|
||||
query = sort.ToLower() switch
|
||||
{
|
||||
"wins" => query.OrderByDescending(s => s.Wins),
|
||||
"kills" => query.OrderByDescending(s => s.Kills),
|
||||
"winrate" => query.OrderByDescending(s => s.MatchesPlayed > 0 ? (float)s.Wins / s.MatchesPlayed : 0),
|
||||
"kd" => query.OrderByDescending(s => s.Deaths > 0 ? (float)s.Kills / s.Deaths : s.Kills),
|
||||
"extractions" => query.OrderByDescending(s => s.Extractions),
|
||||
"playtime" => query.OrderByDescending(s => s.TotalPlayTimeSeconds),
|
||||
_ => query.OrderByDescending(s => s.Elo)
|
||||
};
|
||||
|
||||
var totalCount = await query.CountAsync();
|
||||
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
|
||||
|
||||
var entries = await query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.Select(s => new LeaderboardEntryDto
|
||||
{
|
||||
Rank = 0, // Calculated below
|
||||
AccountId = s.AccountId,
|
||||
Username = s.Account.Username,
|
||||
Elo = s.Elo,
|
||||
Wins = s.Wins,
|
||||
Losses = s.Losses,
|
||||
WinRate = s.MatchesPlayed > 0 ? (float)s.Wins / s.MatchesPlayed * 100 : 0,
|
||||
Kills = s.Kills,
|
||||
Deaths = s.Deaths,
|
||||
KdRatio = s.Deaths > 0 ? (float)s.Kills / s.Deaths : s.Kills,
|
||||
Extractions = s.Extractions,
|
||||
MatchesPlayed = s.MatchesPlayed
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// Calculate ranks
|
||||
int startRank = (page - 1) * pageSize + 1;
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
entries[i].Rank = startRank + i;
|
||||
}
|
||||
|
||||
return Ok(new LeaderboardResponse
|
||||
{
|
||||
Entries = entries,
|
||||
Page = page,
|
||||
PageSize = pageSize,
|
||||
TotalPages = totalPages,
|
||||
TotalCount = totalCount,
|
||||
SortBy = sort
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get match history for a player
|
||||
/// </summary>
|
||||
[HttpGet("player/{accountId}/history")]
|
||||
public async Task<IActionResult> GetMatchHistory(
|
||||
ulong accountId,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
pageSize = Math.Clamp(pageSize, 1, 50);
|
||||
page = Math.Max(1, page);
|
||||
|
||||
var query = _db.MatchHistory
|
||||
.Where(m => m.AccountId == accountId)
|
||||
.OrderByDescending(m => m.PlayedAt);
|
||||
|
||||
var totalCount = await query.CountAsync();
|
||||
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
|
||||
|
||||
var matches = await query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.Select(m => new MatchHistoryDto
|
||||
{
|
||||
MatchId = m.MatchId,
|
||||
PlayedAt = m.PlayedAt,
|
||||
Result = m.Result.ToString(),
|
||||
Placement = m.Placement,
|
||||
TotalPlayers = m.TotalPlayers,
|
||||
Kills = m.Kills,
|
||||
Deaths = m.Deaths,
|
||||
DamageDealt = m.DamageDealt,
|
||||
DamageTaken = m.DamageTaken,
|
||||
ScrapCollected = m.ScrapCollected,
|
||||
EnergyCollected = m.EnergyCollected,
|
||||
RareCollected = m.RareCollected,
|
||||
ItemsCrafted = m.ItemsCrafted,
|
||||
SurvivalTimeSeconds = m.SurvivalTimeSeconds,
|
||||
EloChange = m.EloChange,
|
||||
EloAfter = m.EloAfter
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new MatchHistoryResponse
|
||||
{
|
||||
Matches = matches,
|
||||
Page = page,
|
||||
PageSize = pageSize,
|
||||
TotalPages = totalPages,
|
||||
TotalCount = totalCount
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get global statistics
|
||||
/// </summary>
|
||||
[HttpGet("global")]
|
||||
public async Task<IActionResult> GetGlobalStats()
|
||||
{
|
||||
var stats = await _db.PlayerStats
|
||||
.GroupBy(s => 1)
|
||||
.Select(g => new GlobalStatsDto
|
||||
{
|
||||
TotalPlayers = g.Count(),
|
||||
TotalMatchesPlayed = g.Sum(s => s.MatchesPlayed),
|
||||
TotalKills = g.Sum(s => s.Kills),
|
||||
TotalExtractions = g.Sum(s => s.Extractions),
|
||||
TotalPlayTimeHours = g.Sum(s => s.TotalPlayTimeSeconds) / 3600.0,
|
||||
AverageElo = g.Average(s => (double)s.Elo),
|
||||
TopElo = g.Max(s => s.Elo)
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (stats == null)
|
||||
{
|
||||
return Ok(new GlobalStatsDto());
|
||||
}
|
||||
|
||||
// Get active players (played in last 7 days)
|
||||
var sevenDaysAgo = DateTime.UtcNow.AddDays(-7);
|
||||
stats.ActivePlayers = await _db.MatchHistory
|
||||
.Where(m => m.PlayedAt >= sevenDaysAgo)
|
||||
.Select(m => m.AccountId)
|
||||
.Distinct()
|
||||
.CountAsync();
|
||||
|
||||
return Ok(stats);
|
||||
}
|
||||
}
|
||||
|
||||
// DTOs
|
||||
public class PlayerStatsDto
|
||||
{
|
||||
public ulong AccountId { get; set; }
|
||||
public string Username { get; set; } = "";
|
||||
public int MatchesPlayed { get; set; }
|
||||
public int Wins { get; set; }
|
||||
public int Losses { get; set; }
|
||||
public int Extractions { get; set; }
|
||||
public float WinRate { get; set; }
|
||||
public int Kills { get; set; }
|
||||
public int Deaths { get; set; }
|
||||
public float KdRatio { get; set; }
|
||||
public long TotalDamageDealt { get; set; }
|
||||
public long TotalDamageTaken { get; set; }
|
||||
public long TotalScrapCollected { get; set; }
|
||||
public long TotalEnergyCollected { get; set; }
|
||||
public long TotalRareCollected { get; set; }
|
||||
public int ItemsCrafted { get; set; }
|
||||
public long TotalPlayTimeSeconds { get; set; }
|
||||
public int LongestSurvivalSeconds { get; set; }
|
||||
public int Elo { get; set; }
|
||||
}
|
||||
|
||||
public class LeaderboardEntryDto
|
||||
{
|
||||
public int Rank { get; set; }
|
||||
public ulong AccountId { get; set; }
|
||||
public string Username { get; set; } = "";
|
||||
public int Elo { get; set; }
|
||||
public int Wins { get; set; }
|
||||
public int Losses { get; set; }
|
||||
public float WinRate { get; set; }
|
||||
public int Kills { get; set; }
|
||||
public int Deaths { get; set; }
|
||||
public float KdRatio { get; set; }
|
||||
public int Extractions { get; set; }
|
||||
public int MatchesPlayed { get; set; }
|
||||
}
|
||||
|
||||
public class LeaderboardResponse
|
||||
{
|
||||
public List<LeaderboardEntryDto> Entries { get; set; } = new();
|
||||
public int Page { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int TotalPages { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public string SortBy { get; set; } = "";
|
||||
}
|
||||
|
||||
public class MatchHistoryDto
|
||||
{
|
||||
public string MatchId { get; set; } = "";
|
||||
public DateTime PlayedAt { get; set; }
|
||||
public string Result { get; set; } = "";
|
||||
public int Placement { get; set; }
|
||||
public int TotalPlayers { 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 EloChange { get; set; }
|
||||
public int EloAfter { get; set; }
|
||||
}
|
||||
|
||||
public class MatchHistoryResponse
|
||||
{
|
||||
public List<MatchHistoryDto> Matches { get; set; } = new();
|
||||
public int Page { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int TotalPages { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
|
||||
public class GlobalStatsDto
|
||||
{
|
||||
public int TotalPlayers { get; set; }
|
||||
public int ActivePlayers { get; set; }
|
||||
public int TotalMatchesPlayed { get; set; }
|
||||
public int TotalKills { get; set; }
|
||||
public int TotalExtractions { get; set; }
|
||||
public double TotalPlayTimeHours { get; set; }
|
||||
public double AverageElo { get; set; }
|
||||
public int TopElo { get; set; }
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
namespace Server.Networking.Messages;
|
||||
|
||||
/// <summary>
|
||||
/// OpCodes for Void Scavengers game - extends base OpCodes
|
||||
/// </summary>
|
||||
public static class GameOpCodes
|
||||
{
|
||||
// ===== Lobby/Matchmaking (400-419) =====
|
||||
public const int LOBBY_JOIN = 400;
|
||||
public const int LOBBY_JOIN_RESULT = 401;
|
||||
public const int LOBBY_STATE = 402; // Periodic update of lobby players
|
||||
public const int LOBBY_READY = 403;
|
||||
public const int LOBBY_COUNTDOWN = 404; // Game starting in X seconds
|
||||
public const int LOBBY_LEAVE = 405;
|
||||
|
||||
// ===== Game State (420-449) =====
|
||||
public const int GAME_START = 420; // Server -> Client: Round begins
|
||||
public const int GAME_STATE = 421; // Server -> Client: Full world snapshot
|
||||
public const int GAME_TICK = 422; // Server -> Client: Delta update
|
||||
public const int GAME_END = 423; // Server -> Client: Round over
|
||||
public const int GAME_STATS = 424; // Server -> Client: End-of-round stats
|
||||
|
||||
// ===== Player Input (450-469) =====
|
||||
public const int INPUT_MOVE = 450; // Client -> Server: Movement input
|
||||
public const int INPUT_ACTION = 451; // Client -> Server: Use/Interact/Pickup
|
||||
public const int INPUT_SHOOT = 452; // Client -> Server: Fire weapon
|
||||
public const int INPUT_DROP = 453; // Client -> Server: Drop item
|
||||
public const int INPUT_CRAFT = 454; // Client -> Server: Craft request
|
||||
|
||||
// ===== World Events (470-499) =====
|
||||
public const int EVENT_SPAWN = 470; // Entity spawned
|
||||
public const int EVENT_DESPAWN = 471; // Entity removed
|
||||
public const int EVENT_DAMAGE = 472; // Damage dealt
|
||||
public const int EVENT_DEATH = 473; // Player/entity died
|
||||
public const int EVENT_PICKUP = 474; // Item picked up
|
||||
public const int EVENT_PROJECTILE = 475; // Projectile created
|
||||
public const int EVENT_EXPLOSION = 476; // Area effect
|
||||
public const int EVENT_CRAFT_COMPLETE = 477; // Crafting finished
|
||||
public const int EVENT_EXTRACT = 478; // Player extracted with loot
|
||||
|
||||
// ===== Chat/Social (500-509) =====
|
||||
public const int CHAT_SEND = 500;
|
||||
public const int CHAT_RECEIVE = 501;
|
||||
public const int CHAT_PROXIMITY = 502; // Location-based chat
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DataServer.Data;
|
||||
|
||||
namespace Server.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for item data access
|
||||
/// </summary>
|
||||
public interface IItemService
|
||||
{
|
||||
GameItemData? GetItem(int id);
|
||||
GameRecipeData? GetRecipe(int id);
|
||||
IReadOnlyList<GameItemData> GetAllItems();
|
||||
IReadOnlyList<GameRecipeData> GetAllRecipes();
|
||||
IReadOnlyList<GameItemData> GetItemsByCategory(ItemCategory category);
|
||||
Task ReloadCacheAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime item data (cached from database)
|
||||
/// </summary>
|
||||
public sealed class GameItemData
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Name { get; init; } = "";
|
||||
public ItemCategory Category { get; init; }
|
||||
public int CraftCost { get; init; }
|
||||
public string Description { get; init; } = "";
|
||||
public int LootValue { get; init; }
|
||||
public bool Stackable { get; init; }
|
||||
|
||||
// Weapon stats
|
||||
public int Damage { get; init; }
|
||||
public float FireRate { get; init; }
|
||||
public float ProjectileSpeed { get; init; }
|
||||
public float Range { get; init; }
|
||||
public int AmmoType { get; init; }
|
||||
public int PelletCount { get; init; } = 1;
|
||||
public float Spread { get; init; }
|
||||
public float ExplosionRadius { get; init; }
|
||||
|
||||
// Tool stats
|
||||
public float HarvestMultiplier { get; init; } = 1f;
|
||||
public float ScanRadius { get; init; }
|
||||
public float ScanCooldown { get; init; }
|
||||
public int ShieldHealth { get; init; }
|
||||
public float ShieldDuration { get; init; }
|
||||
|
||||
// Consumable stats
|
||||
public int HealAmount { get; init; }
|
||||
public float ShieldBoostDuration { get; init; }
|
||||
public float DamageReduction { get; init; }
|
||||
public float SpeedBoostDuration { get; init; }
|
||||
public float SpeedMultiplier { get; init; } = 1f;
|
||||
|
||||
// Armor stats
|
||||
public int HealthBonus { get; init; }
|
||||
public float SpeedPenalty { get; init; }
|
||||
public float DashDistance { get; init; }
|
||||
public float DashCooldown { get; init; }
|
||||
|
||||
public static GameItemData FromEntity(GameItem e) => new()
|
||||
{
|
||||
Id = e.Id,
|
||||
Name = e.Name,
|
||||
Category = e.Category,
|
||||
CraftCost = e.CraftCost,
|
||||
Description = e.Description,
|
||||
LootValue = e.LootValue,
|
||||
Stackable = e.Stackable,
|
||||
Damage = e.Damage,
|
||||
FireRate = e.FireRate,
|
||||
ProjectileSpeed = e.ProjectileSpeed,
|
||||
Range = e.Range,
|
||||
AmmoType = e.AmmoType,
|
||||
PelletCount = e.PelletCount,
|
||||
Spread = e.Spread,
|
||||
ExplosionRadius = e.ExplosionRadius,
|
||||
HarvestMultiplier = e.HarvestMultiplier,
|
||||
ScanRadius = e.ScanRadius,
|
||||
ScanCooldown = e.ScanCooldown,
|
||||
ShieldHealth = e.ShieldHealth,
|
||||
ShieldDuration = e.ShieldDuration,
|
||||
HealAmount = e.HealAmount,
|
||||
ShieldBoostDuration = e.ShieldBoostDuration,
|
||||
DamageReduction = e.DamageReduction,
|
||||
SpeedBoostDuration = e.SpeedBoostDuration,
|
||||
SpeedMultiplier = e.SpeedMultiplier,
|
||||
HealthBonus = e.HealthBonus,
|
||||
SpeedPenalty = e.SpeedPenalty,
|
||||
DashDistance = e.DashDistance,
|
||||
DashCooldown = e.DashCooldown
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime recipe data (cached from database)
|
||||
/// </summary>
|
||||
public sealed class GameRecipeData
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public int ResultItemId { get; init; }
|
||||
public int ScrapCost { get; init; }
|
||||
public int EnergyCost { get; init; }
|
||||
public int RareCost { get; init; }
|
||||
|
||||
public bool CanCraft(int scrap, int energy, int rare)
|
||||
{
|
||||
return scrap >= ScrapCost && energy >= EnergyCost && rare >= RareCost;
|
||||
}
|
||||
|
||||
public static GameRecipeData FromEntity(GameRecipe e) => new()
|
||||
{
|
||||
Id = e.Id,
|
||||
ResultItemId = e.ResultItemId,
|
||||
ScrapCost = e.ScrapCost,
|
||||
EnergyCost = e.EnergyCost,
|
||||
RareCost = e.RareCost
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cached item service that loads from database and refreshes periodically
|
||||
/// </summary>
|
||||
public sealed class CachedItemService : IItemService, IDisposable
|
||||
{
|
||||
private readonly ILogger<CachedItemService> _log;
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
private readonly Timer _refreshTimer;
|
||||
|
||||
private ConcurrentDictionary<int, GameItemData> _items = new();
|
||||
private ConcurrentDictionary<int, GameRecipeData> _recipes = new();
|
||||
private ConcurrentDictionary<ItemCategory, List<GameItemData>> _itemsByCategory = new();
|
||||
|
||||
private static readonly TimeSpan RefreshInterval = TimeSpan.FromMinutes(5);
|
||||
|
||||
public CachedItemService(ILogger<CachedItemService> log, IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_log = log;
|
||||
_scopeFactory = scopeFactory;
|
||||
|
||||
// Initial load
|
||||
_ = ReloadCacheAsync();
|
||||
|
||||
// Periodic refresh
|
||||
_refreshTimer = new Timer(_ => _ = ReloadCacheAsync(), null, RefreshInterval, RefreshInterval);
|
||||
}
|
||||
|
||||
public GameItemData? GetItem(int id) => _items.TryGetValue(id, out var item) ? item : null;
|
||||
|
||||
public GameRecipeData? GetRecipe(int id) => _recipes.TryGetValue(id, out var recipe) ? recipe : null;
|
||||
|
||||
public IReadOnlyList<GameItemData> GetAllItems() => _items.Values.ToList();
|
||||
|
||||
public IReadOnlyList<GameRecipeData> GetAllRecipes() => _recipes.Values.ToList();
|
||||
|
||||
public IReadOnlyList<GameItemData> GetItemsByCategory(ItemCategory category)
|
||||
{
|
||||
return _itemsByCategory.TryGetValue(category, out var items) ? items : new List<GameItemData>();
|
||||
}
|
||||
|
||||
public async Task ReloadCacheAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<GameDbContext>();
|
||||
|
||||
// Load items
|
||||
var items = await db.GameItems
|
||||
.Where(i => i.IsEnabled)
|
||||
.ToListAsync();
|
||||
|
||||
var newItems = new ConcurrentDictionary<int, GameItemData>();
|
||||
var newByCategory = new ConcurrentDictionary<ItemCategory, List<GameItemData>>();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var data = GameItemData.FromEntity(item);
|
||||
newItems[item.Id] = data;
|
||||
|
||||
if (!newByCategory.ContainsKey(item.Category))
|
||||
newByCategory[item.Category] = new List<GameItemData>();
|
||||
newByCategory[item.Category].Add(data);
|
||||
}
|
||||
|
||||
// Load recipes
|
||||
var recipes = await db.GameRecipes
|
||||
.Where(r => r.IsEnabled)
|
||||
.ToListAsync();
|
||||
|
||||
var newRecipes = new ConcurrentDictionary<int, GameRecipeData>();
|
||||
foreach (var recipe in recipes)
|
||||
{
|
||||
newRecipes[recipe.Id] = GameRecipeData.FromEntity(recipe);
|
||||
}
|
||||
|
||||
// Atomic swap
|
||||
_items = newItems;
|
||||
_recipes = newRecipes;
|
||||
_itemsByCategory = newByCategory;
|
||||
|
||||
_log.LogInformation("Loaded {ItemCount} items and {RecipeCount} recipes from database",
|
||||
items.Count, recipes.Count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.LogError(ex, "Failed to reload item cache from database");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_refreshTimer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fallback static item database (used if DB is empty or for seeding)
|
||||
/// </summary>
|
||||
public static class DefaultItemData
|
||||
{
|
||||
public static List<GameItem> GetDefaultItems() => new()
|
||||
{
|
||||
// Resources
|
||||
new() { Id = 1, Name = "Scrap Metal", Category = ItemCategory.Resource, CraftCost = 0, Description = "Basic salvage material", LootValue = 1, Stackable = true },
|
||||
new() { Id = 2, Name = "Energy Cell", Category = ItemCategory.Resource, CraftCost = 0, Description = "Charged power source", LootValue = 2, Stackable = true },
|
||||
new() { Id = 3, Name = "Rare Alloy", Category = ItemCategory.Resource, CraftCost = 0, Description = "Precious refined metal", LootValue = 5, Stackable = true },
|
||||
|
||||
// Weapons
|
||||
new() { Id = 100, Name = "Pulse Pistol", Category = ItemCategory.Weapon, CraftCost = 15, Description = "Basic sidearm", LootValue = 10, Stackable = false, Damage = 10, FireRate = 4f, ProjectileSpeed = 400f, Range = 300f },
|
||||
new() { Id = 101, Name = "Scatter Gun", Category = ItemCategory.Weapon, CraftCost = 25, Description = "Close-range devastation", LootValue = 20, Stackable = false, Damage = 6, FireRate = 1.5f, ProjectileSpeed = 350f, Range = 150f, PelletCount = 5, Spread = 0.4f },
|
||||
new() { Id = 102, Name = "Rail Rifle", Category = ItemCategory.Weapon, CraftCost = 40, Description = "Long-range precision", LootValue = 35, Stackable = false, Damage = 45, FireRate = 0.8f, ProjectileSpeed = 800f, Range = 600f },
|
||||
new() { Id = 103, Name = "Plasma Launcher", Category = ItemCategory.Weapon, CraftCost = 60, Description = "Area damage weapon", LootValue = 50, Stackable = false, Damage = 30, FireRate = 0.5f, ProjectileSpeed = 250f, Range = 400f, ExplosionRadius = 50f },
|
||||
|
||||
// Tools
|
||||
new() { Id = 200, Name = "Mining Laser", Category = ItemCategory.Tool, CraftCost = 15, Description = "Harvests resources faster", LootValue = 12, Stackable = false, HarvestMultiplier = 2.0f },
|
||||
new() { Id = 201, Name = "Scanner", Category = ItemCategory.Tool, CraftCost = 20, Description = "Reveals nearby resources and players", LootValue = 15, Stackable = false, ScanRadius = 200f, ScanCooldown = 10f },
|
||||
new() { Id = 202, Name = "Portable Shield", Category = ItemCategory.Tool, CraftCost = 35, Description = "Deployable cover", LootValue = 25, Stackable = false, ShieldHealth = 100, ShieldDuration = 15f },
|
||||
|
||||
// Consumables
|
||||
new() { Id = 300, Name = "Repair Kit", Category = ItemCategory.Consumable, CraftCost = 10, Description = "Restores 30 health", LootValue = 8, Stackable = true, HealAmount = 30 },
|
||||
new() { Id = 301, Name = "Shield Booster", Category = ItemCategory.Consumable, CraftCost = 15, Description = "Temporary damage reduction", LootValue = 12, Stackable = true, ShieldBoostDuration = 10f, DamageReduction = 0.3f },
|
||||
new() { Id = 302, Name = "Speed Stim", Category = ItemCategory.Consumable, CraftCost = 12, Description = "Temporary speed boost", LootValue = 10, Stackable = true, SpeedBoostDuration = 8f, SpeedMultiplier = 1.5f },
|
||||
|
||||
// Armor
|
||||
new() { Id = 400, Name = "Light Suit", Category = ItemCategory.Armor, CraftCost = 20, Description = "+20 max health", LootValue = 15, Stackable = false, HealthBonus = 20 },
|
||||
new() { Id = 401, Name = "Heavy Suit", Category = ItemCategory.Armor, CraftCost = 45, Description = "+50 max health, slower", LootValue = 35, Stackable = false, HealthBonus = 50, SpeedPenalty = 0.15f },
|
||||
new() { Id = 402, Name = "Thruster Pack", Category = ItemCategory.Armor, CraftCost = 30, Description = "Dash ability", LootValue = 25, Stackable = false, DashDistance = 100f, DashCooldown = 5f }
|
||||
};
|
||||
|
||||
public static List<GameRecipe> GetDefaultRecipes() => new()
|
||||
{
|
||||
// Weapons
|
||||
new() { Id = 1, ResultItemId = 100, ScrapCost = 5, EnergyCost = 2, RareCost = 0 },
|
||||
new() { Id = 2, ResultItemId = 101, ScrapCost = 8, EnergyCost = 3, RareCost = 0 },
|
||||
new() { Id = 3, ResultItemId = 102, ScrapCost = 10, EnergyCost = 5, RareCost = 2 },
|
||||
new() { Id = 4, ResultItemId = 103, ScrapCost = 15, EnergyCost = 8, RareCost = 4 },
|
||||
|
||||
// Tools
|
||||
new() { Id = 10, ResultItemId = 200, ScrapCost = 6, EnergyCost = 3, RareCost = 0 },
|
||||
new() { Id = 11, ResultItemId = 201, ScrapCost = 8, EnergyCost = 4, RareCost = 1 },
|
||||
new() { Id = 12, ResultItemId = 202, ScrapCost = 12, EnergyCost = 6, RareCost = 2 },
|
||||
|
||||
// Consumables
|
||||
new() { Id = 20, ResultItemId = 300, ScrapCost = 3, EnergyCost = 2, RareCost = 0 },
|
||||
new() { Id = 21, ResultItemId = 301, ScrapCost = 4, EnergyCost = 3, RareCost = 0 },
|
||||
new() { Id = 22, ResultItemId = 302, ScrapCost = 3, EnergyCost = 4, RareCost = 0 },
|
||||
|
||||
// Armor
|
||||
new() { Id = 30, ResultItemId = 400, ScrapCost = 8, EnergyCost = 0, RareCost = 1 },
|
||||
new() { Id = 31, ResultItemId = 401, ScrapCost = 15, EnergyCost = 0, RareCost = 3 },
|
||||
new() { Id = 32, ResultItemId = 402, ScrapCost = 10, EnergyCost = 5, RareCost = 2 }
|
||||
};
|
||||
}
|
||||
+1942
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Cleanup : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "game_recipes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "match_history");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "player_stats");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "game_items");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "game_items",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false),
|
||||
AmmoType = table.Column<int>(type: "int", nullable: false),
|
||||
Category = table.Column<int>(type: "int", nullable: false),
|
||||
CraftCost = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
|
||||
Damage = table.Column<int>(type: "int", nullable: false),
|
||||
DamageReduction = table.Column<float>(type: "float", nullable: false),
|
||||
DashCooldown = table.Column<float>(type: "float", nullable: false),
|
||||
DashDistance = table.Column<float>(type: "float", nullable: false),
|
||||
Description = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ExplosionRadius = table.Column<float>(type: "float", nullable: false),
|
||||
FireRate = table.Column<float>(type: "float", nullable: false),
|
||||
HarvestMultiplier = table.Column<float>(type: "float", nullable: false),
|
||||
HealAmount = table.Column<int>(type: "int", nullable: false),
|
||||
HealthBonus = table.Column<int>(type: "int", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true),
|
||||
LootValue = table.Column<int>(type: "int", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PelletCount = table.Column<int>(type: "int", nullable: false),
|
||||
ProjectileSpeed = table.Column<float>(type: "float", nullable: false),
|
||||
Range = table.Column<float>(type: "float", nullable: false),
|
||||
ScanCooldown = table.Column<float>(type: "float", nullable: false),
|
||||
ScanRadius = table.Column<float>(type: "float", nullable: false),
|
||||
ShieldBoostDuration = table.Column<float>(type: "float", nullable: false),
|
||||
ShieldDuration = table.Column<float>(type: "float", nullable: false),
|
||||
ShieldHealth = table.Column<int>(type: "int", nullable: false),
|
||||
SpeedBoostDuration = table.Column<float>(type: "float", nullable: false),
|
||||
SpeedMultiplier = table.Column<float>(type: "float", nullable: false),
|
||||
SpeedPenalty = table.Column<float>(type: "float", nullable: false),
|
||||
Spread = table.Column<float>(type: "float", nullable: false),
|
||||
Stackable = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)")
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_game_items", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "match_history",
|
||||
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),
|
||||
DamageDealt = table.Column<int>(type: "int", nullable: false),
|
||||
DamageTaken = table.Column<int>(type: "int", nullable: false),
|
||||
Deaths = table.Column<int>(type: "int", nullable: false),
|
||||
EloAfter = table.Column<int>(type: "int", nullable: false),
|
||||
EloChange = table.Column<int>(type: "int", nullable: false),
|
||||
EnergyCollected = table.Column<int>(type: "int", nullable: false),
|
||||
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
|
||||
Kills = table.Column<int>(type: "int", nullable: false),
|
||||
MatchDurationSeconds = table.Column<int>(type: "int", nullable: false),
|
||||
MatchId = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Placement = table.Column<int>(type: "int", nullable: false),
|
||||
PlayedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
|
||||
RareCollected = table.Column<int>(type: "int", nullable: false),
|
||||
Result = table.Column<int>(type: "int", nullable: false),
|
||||
ScrapCollected = table.Column<int>(type: "int", nullable: false),
|
||||
SurvivalTimeSeconds = table.Column<int>(type: "int", nullable: false),
|
||||
TotalPlayers = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
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),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
|
||||
Deaths = table.Column<int>(type: "int", nullable: false),
|
||||
Elo = table.Column<int>(type: "int", nullable: false, defaultValue: 1000),
|
||||
Extractions = table.Column<int>(type: "int", nullable: false),
|
||||
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
|
||||
Kills = table.Column<int>(type: "int", nullable: false),
|
||||
LongestSurvivalSeconds = table.Column<int>(type: "int", nullable: false),
|
||||
Losses = table.Column<int>(type: "int", nullable: false),
|
||||
MatchesPlayed = table.Column<int>(type: "int", nullable: false),
|
||||
TotalDamageDealt = table.Column<long>(type: "bigint", nullable: false),
|
||||
TotalDamageTaken = table.Column<long>(type: "bigint", nullable: false),
|
||||
TotalEnergyCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||
TotalPlayTimeSeconds = table.Column<long>(type: "bigint", nullable: false),
|
||||
TotalRareCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||
TotalScrapCollected = table.Column<long>(type: "bigint", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)")
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn),
|
||||
Wins = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
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.CreateTable(
|
||||
name: "game_recipes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false),
|
||||
ResultItemId = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
|
||||
EnergyCost = table.Column<int>(type: "int", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true),
|
||||
RareCost = table.Column<int>(type: "int", nullable: false),
|
||||
ScrapCost = table.Column<int>(type: "int", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)")
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_game_recipes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_game_recipes_game_items_ResultItemId",
|
||||
column: x => x.ResultItemId,
|
||||
principalTable: "game_items",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_game_items_Category",
|
||||
table: "game_items",
|
||||
column: "Category");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_game_items_IsEnabled",
|
||||
table: "game_items",
|
||||
column: "IsEnabled");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_game_recipes_IsEnabled",
|
||||
table: "game_recipes",
|
||||
column: "IsEnabled");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_game_recipes_ResultItemId",
|
||||
table: "game_recipes",
|
||||
column: "ResultItemId");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DataServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using DataServer.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -1269,168 +1269,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.ToTable("equipment", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.GameItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AmmoType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Category")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CraftCost")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
|
||||
b.Property<int>("Damage")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("DamageReduction")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("DashCooldown")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("DashDistance")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<float>("ExplosionRadius")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("FireRate")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("HarvestMultiplier")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("HealAmount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("HealthBonus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasDefaultValue(true);
|
||||
|
||||
b.Property<int>("LootValue")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)");
|
||||
|
||||
b.Property<int>("PelletCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("ProjectileSpeed")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("Range")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("ScanCooldown")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("ScanRadius")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("ShieldBoostDuration")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("ShieldDuration")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("ShieldHealth")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<float>("SpeedBoostDuration")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("SpeedMultiplier")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("SpeedPenalty")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<float>("Spread")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<bool>("Stackable")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Category");
|
||||
|
||||
b.HasIndex("IsEnabled");
|
||||
|
||||
b.ToTable("game_items", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.GameRecipe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
|
||||
b.Property<int>("EnergyCost")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasDefaultValue(true);
|
||||
|
||||
b.Property<int>("RareCost")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ResultItemId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ScrapCost")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsEnabled");
|
||||
|
||||
b.HasIndex("ResultItemId");
|
||||
|
||||
b.ToTable("game_recipes", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.InventoryItem", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
@@ -1523,83 +1361,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.ToTable("item_templates", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.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("DataServer.Data.Old_Character", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
@@ -1695,84 +1456,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.ToTable("characters", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.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("DataServer.Data.Session", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
@@ -2167,17 +1850,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Navigation("Old_Character");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.GameRecipe", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.GameItem", "ResultItem")
|
||||
.WithMany()
|
||||
.HasForeignKey("ResultItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ResultItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.InventoryItem", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.Old_Character", "Old_Character")
|
||||
@@ -2197,17 +1869,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Navigation("Old_Character");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.MatchHistory", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.Account", "Account")
|
||||
.WithMany()
|
||||
.HasForeignKey("AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.Old_Character", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.Account", "Account")
|
||||
@@ -2227,17 +1888,6 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Navigation("Zone");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.PlayerStats", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.Account", "Account")
|
||||
.WithOne()
|
||||
.HasForeignKey("DataServer.Data.PlayerStats", "AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataServer.Data.Session", b =>
|
||||
{
|
||||
b.HasOne("DataServer.Data.Account", "Account")
|
||||
|
||||
@@ -72,16 +72,12 @@ builder.Services.AddSingleton<IMessageSerializer, JsonSerializerAdapter>();
|
||||
// Message handlers
|
||||
builder.Services.AddSingleton<IClientMessageHandler, AuthHandler>();
|
||||
|
||||
// Void Scavengers game
|
||||
//builder.Services.AddSingleton<MatchManager>();
|
||||
//builder.Services.AddSingleton<IClientMessageHandler, GameHandler>();
|
||||
builder.Services.AddSingleton<DungeonHandler>();
|
||||
builder.Services.AddSingleton<IClientMessageHandler>(sp => sp.GetRequiredService<DungeonHandler>());
|
||||
builder.Services.AddSingleton<LootService>();
|
||||
builder.Services.AddSingleton<CraftingHandler>();
|
||||
builder.Services.AddSingleton<MessageRouter>();
|
||||
|
||||
builder.Services.AddSingleton<IItemService, CachedItemService>();
|
||||
builder.Services.AddSingleton<IAdminAuthService, AdminAuthService>();
|
||||
builder.Services.AddSingleton<ICdnBrowserService, MinioCdnBrowserService>();
|
||||
builder.Services.AddSingleton<IServerBroadcastService, ServerBroadcastService>();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 class="text-2xl font-bold text-white">Void Scavengers</h1>
|
||||
<h1 class="text-2xl font-bold text-white">Dungeon Divers</h1>
|
||||
<p class="text-gray-400 mt-1">Admin Panel</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - Void Scavengers Admin</title>
|
||||
<title>@ViewData["Title"] - Dungeon Divers Admin</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
@@ -59,7 +59,7 @@
|
||||
<svg class="w-8 h-8 text-indigo-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
|
||||
</svg>
|
||||
Void Scavengers
|
||||
Dungeon Divers
|
||||
</h1>
|
||||
<p class="text-xs text-gray-500 mt-1">Admin Panel</p>
|
||||
</div>
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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)");
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user