Resistance System

This commit is contained in:
dingo
2025-12-26 10:40:09 -05:00
parent 2d847c91dd
commit fd056692df
16 changed files with 2862 additions and 8 deletions
+35
View File
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using DataServer.Data;
using DataServer.Data.Entities;
using Server.Services.Auth;
namespace Server.Api;
@@ -342,3 +343,37 @@ public class BootstrapRequest
public string Username { get; set; } = "";
public string BootstrapKey { get; set; } = "";
}
/// <summary>
/// Get all resistance types for dropdowns
/// </summary>
[ApiController]
[Route("api/admin/resistances")]
public class ResistanceTypesController : ControllerBase
{
private readonly GameDbContext _db;
public ResistanceTypesController(GameDbContext db)
{
_db = db;
}
[HttpGet]
public async Task<IActionResult> GetAll()
{
var types = await _db.DamageResistanceTypes
.Where(t => t.IsEnabled)
.OrderBy(t => t.SortOrder)
.Select(t => new { t.Key, t.DisplayName, t.Color })
.ToListAsync();
return Ok(types);
}
[HttpGet("check/{key}")]
public async Task<IActionResult> CheckExists(string key)
{
var exists = await _db.DamageResistanceTypes
.AnyAsync(t => t.Key.ToLower() == key.ToLower() && t.IsEnabled);
return Ok(new { exists });
}
}