881 lines
50 KiB
Plaintext
881 lines
50 KiB
Plaintext
@page "/admin/mobs/edit"
|
|
@model Mobs.EditModel
|
|
@using DataServer.Data.Enums
|
|
@{
|
|
ViewData["Title"] = Model.IsNew ? "Create Mob" : $"Edit: {Model.Mob.Name}";
|
|
}
|
|
|
|
<div class="space-y-6 max-w-5xl">
|
|
<!-- Header -->
|
|
<div class="flex items-center gap-4">
|
|
<a href="/admin/mobs" class="p-2 hover:bg-gray-800 rounded-lg">
|
|
<svg class="w-6 h-6 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
|
|
</svg>
|
|
</a>
|
|
<div>
|
|
<h1 class="text-3xl font-bold text-white">@(Model.IsNew ? "Create Mob" : "Edit Mob")</h1>
|
|
<p class="text-gray-400 mt-1">@(Model.IsNew ? "Add a new mob definition" : $"ID: {Model.Mob.Id}")</p>
|
|
</div>
|
|
</div>
|
|
|
|
@if (!string.IsNullOrEmpty(Model.Message))
|
|
{
|
|
<div class="p-4 rounded-lg @(Model.IsError ? "bg-red-900/50 border border-red-700 text-red-200" : "bg-green-900/50 border border-green-700 text-green-200")">
|
|
@Model.Message
|
|
</div>
|
|
}
|
|
|
|
<form method="post" class="space-y-6">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="Mob.Id" value="@Model.Mob.Id" />
|
|
|
|
<!-- Basic Info -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700">
|
|
<h2 class="text-lg font-semibold text-white">Basic Information</h2>
|
|
</div>
|
|
<div class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
<div class="lg:col-span-2">
|
|
<label class="label">Name *</label>
|
|
<input type="text" name="Mob.Name" value="@Model.Mob.Name" class="input" required maxlength="64" />
|
|
</div>
|
|
|
|
<div>
|
|
<label class="label">Type</label>
|
|
<select name="Mob.Type" class="input">
|
|
@foreach (var t in Enum.GetValues<MobType>())
|
|
{
|
|
<option value="@t" selected="@(Model.Mob.Type == t)">@t</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="label">Category</label>
|
|
<select name="Mob.Category" class="input">
|
|
@foreach (var c in Enum.GetValues<MobCategory>())
|
|
{
|
|
<option value="@c" selected="@(Model.Mob.Category == c)">@c</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="lg:col-span-4">
|
|
<label class="label">Description</label>
|
|
<textarea name="Mob.Description" class="input" rows="2" maxlength="256">@Model.Mob.Description</textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="label">Min Tier</label>
|
|
<input type="number" name="Mob.MinTier" value="@Model.Mob.MinTier" class="input" min="1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Max Tier</label>
|
|
<input type="number" name="Mob.MaxTier" value="@Model.Mob.MaxTier" class="input" min="1" />
|
|
</div>
|
|
<div class="flex items-center pt-6">
|
|
<label class="flex items-center gap-2 cursor-pointer">
|
|
<input type="checkbox" name="Mob.IsEnabled" value="true" checked="@Model.Mob.IsEnabled" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
|
|
<span class="text-gray-300">Enabled</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Combat Stats -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700">
|
|
<h2 class="text-lg font-semibold text-white">Base Combat Stats</h2>
|
|
</div>
|
|
<div class="p-6 grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
<div>
|
|
<label class="label">Health</label>
|
|
<input type="number" name="Mob.BaseHealth" value="@Model.Mob.BaseHealth" class="input" min="1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Mana</label>
|
|
<input type="number" name="Mob.BaseMana" value="@Model.Mob.BaseMana" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Phys Damage</label>
|
|
<input type="number" name="Mob.BasePhysicalDamage" value="@Model.Mob.BasePhysicalDamage" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Magic Damage</label>
|
|
<input type="number" name="Mob.BaseMagicDamage" value="@Model.Mob.BaseMagicDamage" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Damage Type</label>
|
|
<select name="Mob.DamageTypeKey" class="input">
|
|
@foreach (var rt in Model.ResistanceTypes)
|
|
{
|
|
<option value="@rt.Key" selected="@(Model.Mob.DamageTypeKey == rt.Key)" style="color: @rt.Color">@rt.DisplayName</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="label">Armor</label>
|
|
<input type="number" name="Mob.BaseArmor" value="@Model.Mob.BaseArmor" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Magic Resist</label>
|
|
<input type="number" name="Mob.BaseMagicResist" value="@Model.Mob.BaseMagicResist" class="input" min="0" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Movement & Behavior -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700">
|
|
<h2 class="text-lg font-semibold text-white">Movement & Behavior</h2>
|
|
</div>
|
|
<div class="p-6 grid grid-cols-2 md:grid-cols-5 gap-4">
|
|
<div>
|
|
<label class="label">AI Behavior</label>
|
|
<select name="Mob.Behavior" class="input">
|
|
@foreach (var b in Enum.GetValues<MobBehavior>())
|
|
{
|
|
<option value="@b" selected="@(Model.Mob.Behavior == b)">@b</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="label">Move Speed</label>
|
|
<input type="number" name="Mob.MoveSpeed" value="@Model.Mob.MoveSpeed" class="input" min="0" step="1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Attack Range</label>
|
|
<input type="number" name="Mob.AttackRange" value="@Model.Mob.AttackRange" class="input" min="0" step="1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Attack Speed</label>
|
|
<input type="number" name="Mob.AttackSpeed" value="@Model.Mob.AttackSpeed" class="input" min="0.1" step="0.1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Preferred Range</label>
|
|
<input type="number" name="Mob.PreferredRange" value="@Model.Mob.PreferredRange" class="input" min="0" step="1" />
|
|
<p class="text-xs text-gray-500 mt-1">For ranged/kiting</p>
|
|
</div>
|
|
<div>
|
|
<label class="label">Flee Threshold</label>
|
|
<input type="number" name="Mob.FleeThreshold" value="@Model.Mob.FleeThreshold" class="input" min="0" max="1" step="0.05" />
|
|
<p class="text-xs text-gray-500 mt-1">HP% to flee (0-1)</p>
|
|
</div>
|
|
<div>
|
|
<label class="label">Aggro Range</label>
|
|
<input type="number" name="Mob.AggroRange" value="@Model.Mob.AggroRange" class="input" min="0" step="1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Leash Range</label>
|
|
<input type="number" name="Mob.LeashRange" value="@Model.Mob.LeashRange" class="input" min="0" step="1" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Scaling -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700">
|
|
<h2 class="text-lg font-semibold text-white">Tier Scaling (Multipliers)</h2>
|
|
</div>
|
|
<div class="p-6 grid grid-cols-2 md:grid-cols-5 gap-4">
|
|
<div>
|
|
<label class="label">Health/Tier</label>
|
|
<input type="number" name="Mob.HealthPerTier" value="@Model.Mob.HealthPerTier" class="input" min="1" step="0.05" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Damage/Tier</label>
|
|
<input type="number" name="Mob.DamagePerTier" value="@Model.Mob.DamagePerTier" class="input" min="1" step="0.05" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Armor/Tier</label>
|
|
<input type="number" name="Mob.ArmorPerTier" value="@Model.Mob.ArmorPerTier" class="input" min="1" step="0.05" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Base XP</label>
|
|
<input type="number" name="Mob.BaseXp" value="@Model.Mob.BaseXp" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">XP/Tier</label>
|
|
<input type="number" name="Mob.XpPerTier" value="@Model.Mob.XpPerTier" class="input" min="1" step="0.05" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Resistances -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<div>
|
|
<h2 class="text-lg font-semibold text-white">Damage Resistances</h2>
|
|
<p class="text-sm text-gray-400 mt-1">Negative % = weakness, Positive % = resistance, 100% = immune</p>
|
|
</div>
|
|
<a href="/admin/resistances" class="text-sm text-indigo-400 hover:underline">Manage Types →</a>
|
|
</div>
|
|
<div class="p-6">
|
|
<!-- Current Resistances -->
|
|
<div id="resistancesList" class="space-y-2 mb-4">
|
|
@foreach (var resist in Model.Resistances)
|
|
{
|
|
var bgColor = resist.Value < 0 ? "bg-red-900/30 border-red-700" :
|
|
resist.Value > 0 ? "bg-green-900/30 border-green-700" :
|
|
"bg-gray-800 border-gray-700";
|
|
<div class="@bgColor border rounded-lg p-3 flex items-center gap-4 resistance-row">
|
|
<select name="resist_name[]" class="input w-40">
|
|
@foreach (var rt in Model.ResistanceTypes)
|
|
{
|
|
<option value="@rt.Key" selected="@(resist.Key == rt.Key)" style="color: @rt.Color">@rt.DisplayName</option>
|
|
}
|
|
</select>
|
|
<div class="flex items-center gap-2 flex-1">
|
|
<input type="range"
|
|
name="resist_value[]"
|
|
value="@resist.Value"
|
|
min="-1" max="1" step="0.05"
|
|
class="flex-1"
|
|
oninput="this.nextElementSibling.value = Math.round(this.value * 100)" />
|
|
<div class="flex items-center gap-1">
|
|
<input type="number"
|
|
value="@((resist.Value * 100).ToString("0"))"
|
|
min="-100" max="100" step="5"
|
|
class="input w-20 text-center text-sm"
|
|
oninput="this.parentElement.previousElementSibling.value = this.value / 100" />
|
|
<span class="text-gray-400">%</span>
|
|
</div>
|
|
</div>
|
|
<button type="button" onclick="this.closest('.resistance-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@if (!Model.Resistances.Any())
|
|
{
|
|
<p class="text-gray-500 text-sm mb-4">No resistances configured. Add one below.</p>
|
|
}
|
|
|
|
<!-- Add New Resistance -->
|
|
<div class="flex items-center gap-4 pt-4 border-t border-gray-700">
|
|
<select id="newResistType" class="input w-40">
|
|
<option value="">Select type...</option>
|
|
@foreach (var rt in Model.ResistanceTypes)
|
|
{
|
|
<option value="@rt.Key" data-color="@rt.Color">@rt.DisplayName</option>
|
|
}
|
|
</select>
|
|
<input type="number" id="newResistValue" class="input w-24" value="50" min="-100" max="100" step="5" />
|
|
<span class="text-gray-400">%</span>
|
|
<button type="button" onclick="addResistance()" class="btn btn-secondary">Add</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Visual -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700">
|
|
<h2 class="text-lg font-semibold text-white">Visual Settings</h2>
|
|
</div>
|
|
<div class="p-6 grid grid-cols-1 md:grid-cols-4 gap-4">
|
|
<div>
|
|
<label class="label">Tint Color</label>
|
|
<div class="flex gap-2">
|
|
<input type="color" value="@Model.Mob.TintColor" class="w-10 h-10 rounded border border-gray-700 bg-gray-800 cursor-pointer" oninput="document.getElementById('tintColor').value=this.value" />
|
|
<input type="text" id="tintColor" name="Mob.TintColor" value="@Model.Mob.TintColor" class="input flex-1" />
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<label class="label">Scale</label>
|
|
<input type="number" name="Mob.Scale" value="@Model.Mob.Scale" class="input" min="0.1" step="0.1" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Frame Width</label>
|
|
<input type="number" name="sprite_frameWidth" value="@Model.SpriteConfig.FrameWidth" class="input" min="8" step="8" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Frame Height</label>
|
|
<input type="number" name="sprite_frameHeight" value="@Model.SpriteConfig.FrameHeight" class="input" min="8" step="8" />
|
|
</div>
|
|
<div>
|
|
<label class="label">FPS</label>
|
|
<input type="number" name="sprite_fps" value="@Model.SpriteConfig.Fps" class="input" min="1" max="60" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Animation Speed</label>
|
|
<input type="number" name="Mob.AnimationSpeed" value="@Model.Mob.AnimationSpeed" class="input" min="1" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Sprite Sheets -->
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<div>
|
|
<h2 class="text-lg font-semibold text-white">Sprite Sheets</h2>
|
|
<p class="text-sm text-gray-400">Configure sprite sheets for different directions and states</p>
|
|
</div>
|
|
</div>
|
|
<div class="p-6">
|
|
<div id="spritesList" class="space-y-2 mb-4">
|
|
@foreach (var sprite in Model.SpriteConfig.Sprites)
|
|
{
|
|
<div class="bg-gray-800 border border-gray-700 rounded-lg p-3 flex items-center gap-3 sprite-row">
|
|
<select name="sprite_key[]" class="input w-36">
|
|
@foreach (var key in new[] { "idle_front", "idle_back", "idle_left", "idle_right", "run_front", "run_back", "run_left", "run_right", "attack_front", "attack_back", "death" })
|
|
{
|
|
<option value="@key" selected="@(sprite.Key == key)">@key</option>
|
|
}
|
|
</select>
|
|
<input type="text" name="sprite_path[]" value="@sprite.Value" class="input flex-1" placeholder="textures/mobs/skeleton_idle_front.png" />
|
|
<input type="number" name="sprite_frames[]" value="@Model.SpriteConfig.GetFrameCount(sprite.Key)" class="input w-20" min="1" placeholder="Frames" title="Frame count" />
|
|
<label class="flex items-center gap-1 text-sm text-gray-400">
|
|
<input type="checkbox" name="sprite_loop[]" value="@sprite.Key" checked="@Model.SpriteConfig.IsLooping(sprite.Key)" class="rounded border-gray-600 bg-gray-800" />
|
|
Loop
|
|
</label>
|
|
<button type="button" onclick="this.closest('.sprite-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@if (!Model.SpriteConfig.Sprites.Any())
|
|
{
|
|
<p class="text-gray-500 text-sm mb-4">No sprites configured. Add sprite sheets below.</p>
|
|
}
|
|
|
|
<button type="button" onclick="addSprite()" class="btn btn-secondary">
|
|
<svg class="w-4 h-4 mr-1 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
Add Sprite Sheet
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Save -->
|
|
<div class="flex items-center gap-4">
|
|
<button type="submit" class="btn btn-primary">@(Model.IsNew ? "Create Mob" : "Save Changes")</button>
|
|
<a href="/admin/mobs" class="btn btn-secondary">Cancel</a>
|
|
@if (!Model.IsNew)
|
|
{
|
|
<div class="flex-1"></div>
|
|
<button type="submit" name="action" value="duplicate" class="btn btn-secondary">Duplicate</button>
|
|
}
|
|
</div>
|
|
</form>
|
|
|
|
<!-- Abilities Section -->
|
|
@if (!Model.IsNew)
|
|
{
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<h2 class="text-lg font-semibold text-white">Abilities (@Model.MobAbilities.Count)</h2>
|
|
<button type="button" onclick="showAddAbilityModal()" class="btn btn-sm btn-primary">+ Add Ability</button>
|
|
</div>
|
|
<div class="p-4">
|
|
@if (Model.MobAbilities.Count > 0)
|
|
{
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr class="border-b border-gray-700">
|
|
<th class="py-2 text-left text-gray-400">Ability</th>
|
|
<th class="py-2 text-left text-gray-400">Type</th>
|
|
<th class="py-2 text-left text-gray-400">Animation</th>
|
|
<th class="py-2 text-left text-gray-400">Damage</th>
|
|
<th class="py-2 text-left text-gray-400">Range</th>
|
|
<th class="py-2 text-left text-gray-400">Cooldown</th>
|
|
<th class="py-2 text-left text-gray-400">Phase</th>
|
|
<th class="py-2 text-left text-gray-400">Status</th>
|
|
<th class="py-2 text-right text-gray-400">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700/50">
|
|
@foreach (var assignment in Model.MobAbilities)
|
|
{
|
|
var ability = assignment.AbilityDefinition;
|
|
var hasMappedAnimation = Model.AbilityAnimationByAssignmentId.TryGetValue(assignment.Id, out var mappedAnimation);
|
|
var resolvedAnimation = hasMappedAnimation
|
|
? mappedAnimation
|
|
: (!string.IsNullOrWhiteSpace(ability?.AnimationKey) ? ability!.AnimationKey : "attack");
|
|
<tr class="hover:bg-gray-800/50">
|
|
<td class="py-3 text-white font-medium">@ability?.Name</td>
|
|
<td class="py-3 text-gray-300">@ability?.AbilityType</td>
|
|
<td class="py-3 text-gray-300">
|
|
@resolvedAnimation
|
|
@if (hasMappedAnimation)
|
|
{
|
|
<span class="ml-1 text-xs text-cyan-400">(override)</span>
|
|
}
|
|
</td>
|
|
<td class="py-3 text-gray-300">@ability?.BaseDamage</td>
|
|
<td class="py-3 text-gray-300">@ability?.Range</td>
|
|
<td class="py-3 text-gray-300">@ability?.Cooldown.ToString("0.#")s</td>
|
|
<td class="py-3 text-gray-300">@(assignment.Phase == 0 ? "All" : $"Phase {assignment.Phase}")</td>
|
|
<td class="py-3">
|
|
@if (assignment.IsEnabled)
|
|
{
|
|
<span class="text-green-400 text-xs">Active</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-gray-500 text-xs">Disabled</span>
|
|
}
|
|
</td>
|
|
<td class="py-3 text-right">
|
|
<div class="flex justify-end gap-1">
|
|
<form method="post" asp-page-handler="ToggleAbility" class="inline">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-gray-400" title="Toggle">
|
|
@if (assignment.IsEnabled)
|
|
{
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636"/></svg>
|
|
}
|
|
else
|
|
{
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
|
|
}
|
|
</button>
|
|
</form>
|
|
<form method="post" asp-page-handler="RemoveAbility" class="inline" onsubmit="return confirm('Remove this ability?')">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-red-400" title="Remove">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-gray-400 text-center py-4">No abilities assigned. This mob will use a basic attack.</p>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Ability Modal -->
|
|
<div id="addAbilityModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center">
|
|
<div class="bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-md mx-4 border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-4">Add Ability</h3>
|
|
<form method="post" asp-page-handler="AddAbility">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label class="label">Ability</label>
|
|
<select name="abilityId" class="input" required>
|
|
<option value="">Select an ability...</option>
|
|
@foreach (var ability in Model.AllAbilities)
|
|
{
|
|
<option value="@ability.Id">@ability.Name (@ability.AbilityType)</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="label">Priority Override (0 = use default)</label>
|
|
<input type="number" name="priority" value="0" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Animation (optional override)</label>
|
|
<select name="animationKey" class="input">
|
|
<option value="">Use ability default</option>
|
|
@foreach (var key in Model.AvailableAbilityAnimationKeys)
|
|
{
|
|
<option value="@key">@key</option>
|
|
}
|
|
</select>
|
|
@if (!Model.AvailableAbilityAnimationKeys.Any())
|
|
{
|
|
<p class="text-xs text-amber-400 mt-1">No mob animations assigned yet. Add animations first.</p>
|
|
}
|
|
</div>
|
|
<div>
|
|
<label class="label">Phase (0 = all phases)</label>
|
|
<input type="number" name="phase" value="0" class="input" min="0" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-3 pt-4">
|
|
<button type="button" onclick="closeAddAbilityModal()" class="btn btn-secondary">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Assign</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<!-- Animations Section -->
|
|
@if (!Model.IsNew)
|
|
{
|
|
<div id="animations-section" class="card">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<h2 class="text-lg font-semibold text-white">Animations (@Model.MobAnimations.Count)</h2>
|
|
<div class="flex gap-2">
|
|
<a href="/admin/spritesheets" class="btn btn-sm btn-secondary" target="_blank">Manage Sheets</a>
|
|
<button type="button" onclick="showAddAnimationModal()" class="btn btn-sm btn-primary">+ Add Animation</button>
|
|
</div>
|
|
</div>
|
|
<div class="p-4">
|
|
@if (Model.MobAnimations.Count > 0)
|
|
{
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr class="border-b border-gray-700">
|
|
<th class="py-2 text-left text-gray-400">Key</th>
|
|
<th class="py-2 text-left text-gray-400">Sheet</th>
|
|
<th class="py-2 text-left text-gray-400">Frames</th>
|
|
<th class="py-2 text-left text-gray-400">FPS</th>
|
|
<th class="py-2 text-left text-gray-400">Options</th>
|
|
<th class="py-2 text-left text-gray-400">Override Key</th>
|
|
<th class="py-2 text-left text-gray-400">Status</th>
|
|
<th class="py-2 text-right text-gray-400">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700/50">
|
|
@foreach (var assignment in Model.MobAnimations)
|
|
{
|
|
var anim = assignment.AnimationDefinition;
|
|
var sheet = anim?.SpriteSheet;
|
|
<tr class="hover:bg-gray-800/50">
|
|
<td class="py-3 text-white font-mono">@anim?.Key</td>
|
|
<td class="py-3 text-gray-300 text-xs">@sheet?.Name</td>
|
|
<td class="py-3 text-gray-300 font-mono text-xs">@anim?.FrameSequence</td>
|
|
<td class="py-3 text-gray-300">@anim?.Fps</td>
|
|
<td class="py-3 text-gray-400 text-xs">
|
|
@if (anim?.Loop == true) { <span class="mr-1">Loop</span> }
|
|
@if (anim?.FlipX == true) { <span class="mr-1">FlipX</span> }
|
|
@if (anim?.FlipY == true) { <span>FlipY</span> }
|
|
</td>
|
|
<td class="py-3 text-gray-300 font-mono text-xs">@(assignment.OverrideKey ?? "-")</td>
|
|
<td class="py-3">
|
|
@if (assignment.IsEnabled)
|
|
{
|
|
<span class="text-green-400 text-xs">Active</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-gray-500 text-xs">Disabled</span>
|
|
}
|
|
</td>
|
|
<td class="py-3 text-right">
|
|
<div class="flex justify-end gap-1">
|
|
<form method="post" asp-page-handler="ToggleAnimation" class="inline">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-gray-400" title="Toggle">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
|
|
</button>
|
|
</form>
|
|
<form method="post" asp-page-handler="RemoveAnimation" class="inline" onsubmit="return confirm('Remove this animation?')">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-red-400" title="Remove">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-gray-400 text-center py-4">No animations assigned. <a href="/admin/spritesheets" class="text-indigo-400 hover:underline">Create sprite sheets</a> first, then add animations here.</p>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Animation Modal -->
|
|
<div id="addAnimationModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center">
|
|
<div class="bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-md mx-4 border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-4">Add Animation</h3>
|
|
<form method="post" asp-page-handler="AddAnimation">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label class="label">Animation</label>
|
|
<input type="text" id="animationSearch" class="input mb-2" placeholder="Type to search animations..." oninput="filterAnimations()" autocomplete="off" />
|
|
<select name="animationId" id="animationSelect" class="input" required size="10" style="height: auto;">
|
|
<option value="">Select an animation...</option>
|
|
@foreach (var anim in Model.AllAnimations)
|
|
{
|
|
<option value="@anim.Id" data-search-text="[@(anim.SpriteSheet?.Name ?? "?")] @anim.Key - @anim.FrameSequence (@anim.Fps fps)">[@(anim.SpriteSheet?.Name ?? "?")] @anim.Key - @anim.FrameSequence (@anim.Fps fps)</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="label">Override Key (optional)</label>
|
|
<input type="text" name="overrideKey" class="input" placeholder="e.g., walk_down" />
|
|
<p class="text-xs text-gray-500 mt-1">Use if you want to map this animation to a different key for this mob</p>
|
|
</div>
|
|
<div>
|
|
<label class="label">Priority</label>
|
|
<input type="number" name="priority" value="0" class="input" />
|
|
<p class="text-xs text-gray-500 mt-1">Higher priority used when multiple match</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-3 pt-4">
|
|
<button type="button" onclick="closeAddAnimationModal()" class="btn btn-secondary">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Assign</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<!-- Loot Tables Section -->
|
|
@if (!Model.IsNew)
|
|
{
|
|
<div class="card">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<h2 class="text-lg font-semibold text-white">Loot Tables (@Model.MobLootTables.Count)</h2>
|
|
<button type="button" onclick="showAddLootModal()" class="btn btn-primary text-sm">+ Assign Loot Table</button>
|
|
</div>
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-900/50">
|
|
<tr>
|
|
<th class="table-header">Loot Table</th>
|
|
<th class="table-header w-24">Priority</th>
|
|
<th class="table-header w-24">Roll %</th>
|
|
<th class="table-header w-24">Entries</th>
|
|
<th class="table-header w-20">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700">
|
|
@foreach (var mlt in Model.MobLootTables)
|
|
{
|
|
<tr class="hover:bg-gray-700/30">
|
|
<td class="table-cell">
|
|
<a href="/admin/loottables/edit?id=@mlt.LootTableId" class="text-indigo-400 hover:underline">
|
|
@mlt.LootTable?.Name
|
|
</a>
|
|
<span class="text-xs text-gray-500 ml-2">(ID: @mlt.LootTableId)</span>
|
|
</td>
|
|
<td class="table-cell text-gray-400">@mlt.Priority</td>
|
|
<td class="table-cell">
|
|
<span class="@(mlt.RollChance >= 0.5 ? "text-green-400" : "text-yellow-400")">
|
|
@((mlt.RollChance * 100).ToString("0"))%
|
|
</span>
|
|
</td>
|
|
<td class="table-cell">
|
|
<span class="badge badge-common">@(mlt.LootTable?.Entries?.Count ?? 0)</span>
|
|
</td>
|
|
<td class="table-cell">
|
|
<form method="post" asp-page-handler="RemoveLoot" class="inline">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="mappingId" value="@mlt.Id" />
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-red-400" title="Remove" onclick="return confirm('Remove this loot table?')">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
}
|
|
@if (!Model.MobLootTables.Any())
|
|
{
|
|
<tr>
|
|
<td colspan="5" class="table-cell text-center text-gray-500 py-8">
|
|
No loot tables assigned. This mob won't drop items.
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Loot Table Modal -->
|
|
<div id="addLootModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50">
|
|
<div class="bg-gray-800 rounded-xl p-6 max-w-lg w-full mx-4 border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-4">Assign Loot Table</h3>
|
|
<form method="post" asp-page-handler="AddLoot" class="space-y-4">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
|
|
|
<div>
|
|
<label class="label">Loot Table *</label>
|
|
<select name="lootTableId" class="input" required>
|
|
<option value="">Select a loot table...</option>
|
|
@foreach (var lt in Model.AllLootTables)
|
|
{
|
|
<option value="@lt.Id">@lt.Name (Tier @lt.MinTier-@lt.MaxTier)</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="label">Priority (lower = first)</label>
|
|
<input type="number" name="priority" value="0" class="input" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="label">Roll Chance (0-1)</label>
|
|
<input type="number" name="rollChance" value="1.0" class="input" min="0" max="1" step="0.1" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-3 pt-4">
|
|
<button type="button" onclick="closeAddLootModal()" class="btn btn-secondary">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Assign</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
function showAddLootModal() {
|
|
document.getElementById('addLootModal').classList.remove('hidden');
|
|
document.getElementById('addLootModal').classList.add('flex');
|
|
}
|
|
function closeAddLootModal() {
|
|
document.getElementById('addLootModal').classList.add('hidden');
|
|
document.getElementById('addLootModal').classList.remove('flex');
|
|
}
|
|
function showAddAbilityModal() {
|
|
document.getElementById('addAbilityModal').classList.remove('hidden');
|
|
document.getElementById('addAbilityModal').classList.add('flex');
|
|
}
|
|
function closeAddAbilityModal() {
|
|
document.getElementById('addAbilityModal').classList.add('hidden');
|
|
document.getElementById('addAbilityModal').classList.remove('flex');
|
|
}
|
|
function showAddAnimationModal() {
|
|
document.getElementById('addAnimationModal').classList.remove('hidden');
|
|
document.getElementById('addAnimationModal').classList.add('flex');
|
|
}
|
|
function closeAddAnimationModal() {
|
|
document.getElementById('addAnimationModal').classList.add('hidden');
|
|
document.getElementById('addAnimationModal').classList.remove('flex');
|
|
}
|
|
document.addEventListener('keydown', e => {
|
|
if (e.key === 'Escape') {
|
|
closeAddLootModal();
|
|
closeAddAbilityModal();
|
|
closeAddAnimationModal();
|
|
}
|
|
});
|
|
|
|
// Animation search filter
|
|
function filterAnimations() {
|
|
const searchInput = document.getElementById('animationSearch');
|
|
const select = document.getElementById('animationSelect');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
for (let i = 0; i < select.options.length; i++) {
|
|
const option = select.options[i];
|
|
const searchText = option.getAttribute('data-search-text') || option.text;
|
|
|
|
if (searchTerm === '' || searchText.toLowerCase().includes(searchTerm)) {
|
|
option.style.display = '';
|
|
} else {
|
|
option.style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Resistance type options for dynamic rows
|
|
const resistanceOptions = `@Html.Raw(string.Join("", Model.ResistanceTypes.Select(rt => $"<option value=\"{rt.Key}\">{rt.DisplayName}</option>")))`;
|
|
|
|
function addResistance() {
|
|
const typeSelect = document.getElementById('newResistType');
|
|
const valueInput = document.getElementById('newResistValue');
|
|
|
|
const key = typeSelect.value;
|
|
if (!key) {
|
|
alert('Please select a resistance type');
|
|
return;
|
|
}
|
|
|
|
const percent = parseInt(valueInput.value) || 0;
|
|
const value = percent / 100;
|
|
|
|
const bgColor = value < 0 ? 'bg-red-900/30 border-red-700' :
|
|
value > 0 ? 'bg-green-900/30 border-green-700' :
|
|
'bg-gray-800 border-gray-700';
|
|
|
|
const html = `
|
|
<div class="${bgColor} border rounded-lg p-3 flex items-center gap-4 resistance-row">
|
|
<select name="resist_name[]" class="input w-40">${resistanceOptions.replace('value="'+key+'"', 'value="'+key+'" selected')}</select>
|
|
<div class="flex items-center gap-2 flex-1">
|
|
<input type="range" name="resist_value[]" value="${value}" min="-1" max="1" step="0.05" class="flex-1"
|
|
oninput="this.nextElementSibling.value = Math.round(this.value * 100)" />
|
|
<div class="flex items-center gap-1">
|
|
<input type="number" value="${percent}" min="-100" max="100" step="5"
|
|
class="input w-20 text-center text-sm"
|
|
oninput="this.parentElement.previousElementSibling.value = this.value / 100" />
|
|
<span class="text-gray-400">%</span>
|
|
</div>
|
|
</div>
|
|
<button type="button" onclick="this.closest('.resistance-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
`;
|
|
|
|
document.getElementById('resistancesList').insertAdjacentHTML('beforeend', html);
|
|
typeSelect.value = '';
|
|
valueInput.value = '50';
|
|
}
|
|
|
|
function addSprite() {
|
|
const html = `
|
|
<div class="bg-gray-800 border border-gray-700 rounded-lg p-3 flex items-center gap-3 sprite-row">
|
|
<select name="sprite_key[]" class="input w-36">
|
|
<option value="idle_front">idle_front</option>
|
|
<option value="idle_back">idle_back</option>
|
|
<option value="idle_left">idle_left</option>
|
|
<option value="idle_right">idle_right</option>
|
|
<option value="run_front">run_front</option>
|
|
<option value="run_back">run_back</option>
|
|
<option value="run_left">run_left</option>
|
|
<option value="run_right">run_right</option>
|
|
<option value="attack_front">attack_front</option>
|
|
<option value="attack_back">attack_back</option>
|
|
<option value="death">death</option>
|
|
</select>
|
|
<input type="text" name="sprite_path[]" value="" class="input flex-1" placeholder="textures/mobs/skeleton_idle_front.png" />
|
|
<input type="number" name="sprite_frames[]" value="8" class="input w-20" min="1" placeholder="Frames" title="Frame count" />
|
|
<label class="flex items-center gap-1 text-sm text-gray-400">
|
|
<input type="checkbox" name="sprite_loop[]" value="new" checked class="rounded border-gray-600 bg-gray-800" />
|
|
Loop
|
|
</label>
|
|
<button type="button" onclick="this.closest('.sprite-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
`;
|
|
document.getElementById('spritesList').insertAdjacentHTML('beforeend', html);
|
|
}
|
|
</script>
|
|
}
|