Pageing on CDN Assets Page, and Player management
This commit is contained in:
@@ -174,6 +174,59 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Resistances -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700">
|
||||
<h2 class="text-lg font-semibold text-white">Damage Resistances</h2>
|
||||
<p class="text-sm text-gray-400 mt-1">Negative = weakness (takes more damage), Positive = resistance, 1.0 = immune</p>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
@foreach (var dt in Enum.GetValues<DamageType>())
|
||||
{
|
||||
var currentValue = Model.GetResistance(dt.ToString().ToLower());
|
||||
var bgColor = currentValue < 0 ? "bg-red-900/30 border-red-700" :
|
||||
currentValue > 0 ? "bg-green-900/30 border-green-700" :
|
||||
"bg-gray-800 border-gray-700";
|
||||
<div class="@bgColor border rounded-lg p-3">
|
||||
<label class="label text-sm mb-1">@dt</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="range"
|
||||
name="resistance_@dt.ToString().ToLower()"
|
||||
value="@currentValue"
|
||||
min="-1" max="1" step="0.1"
|
||||
class="flex-1"
|
||||
oninput="this.nextElementSibling.value = this.value; updateResistColor(this.parentElement.parentElement, this.value)" />
|
||||
<input type="number"
|
||||
value="@currentValue"
|
||||
min="-1" max="1" step="0.1"
|
||||
class="input w-20 text-center text-sm"
|
||||
oninput="this.previousElementSibling.value = this.value; updateResistColor(this.parentElement.parentElement, this.value)" />
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
@if (currentValue < 0)
|
||||
{
|
||||
<span class="text-red-400">+@((-currentValue * 100).ToString("0"))% damage taken</span>
|
||||
}
|
||||
else if (currentValue > 0 && currentValue < 1)
|
||||
{
|
||||
<span class="text-green-400">-@((currentValue * 100).ToString("0"))% damage taken</span>
|
||||
}
|
||||
else if (currentValue >= 1)
|
||||
{
|
||||
<span class="text-blue-400">Immune</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Normal damage</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Visual -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700">
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Server.Data;
|
||||
using Server.Data.Entities;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace VoidScavengers.Services.Admin.Pages.Mobs;
|
||||
|
||||
@@ -23,6 +24,19 @@ public class EditModel : AdminPageModel
|
||||
public bool IsNew => Mob.Id == 0;
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
|
||||
// Helper to get resistance value for a damage type
|
||||
public float GetResistance(string damageType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resistances = JsonSerializer.Deserialize<Dictionary<string, float>>(Mob.ResistancesJson ?? "{}");
|
||||
if (resistances != null && resistances.TryGetValue(damageType, out var value))
|
||||
return value;
|
||||
}
|
||||
catch { }
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync(int? id)
|
||||
{
|
||||
@@ -79,6 +93,18 @@ public class EditModel : AdminPageModel
|
||||
// Ensure nullable strings are never null
|
||||
Mob.Description ??= "";
|
||||
Mob.TintColor ??= "#ffffff";
|
||||
|
||||
// Parse resistances from form
|
||||
var resistances = new Dictionary<string, float>();
|
||||
foreach (var key in Request.Form.Keys.Where(k => k.StartsWith("resistance_")))
|
||||
{
|
||||
var damageType = key.Replace("resistance_", "");
|
||||
if (float.TryParse(Request.Form[key], out var value) && value != 0)
|
||||
{
|
||||
resistances[damageType] = value;
|
||||
}
|
||||
}
|
||||
Mob.ResistancesJson = JsonSerializer.Serialize(resistances);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Mob.Name))
|
||||
{
|
||||
@@ -171,6 +197,7 @@ public class EditModel : AdminPageModel
|
||||
existing.Scale = Mob.Scale;
|
||||
existing.AnimationSpeed = Mob.AnimationSpeed;
|
||||
existing.SpriteConfigJson = Mob.SpriteConfigJson;
|
||||
existing.ResistancesJson = Mob.ResistancesJson;
|
||||
existing.IsEnabled = Mob.IsEnabled;
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
|
||||
Reference in New Issue
Block a user