Resistances + Dmg Types
This commit is contained in:
@@ -105,6 +105,15 @@
|
||||
<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" />
|
||||
@@ -181,6 +190,7 @@
|
||||
<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 -->
|
||||
@@ -191,7 +201,12 @@
|
||||
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">
|
||||
<input type="text" name="resist_name[]" value="@resist.Key" class="input w-40" placeholder="Type name" />
|
||||
<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[]"
|
||||
@@ -224,15 +239,13 @@
|
||||
|
||||
<!-- Add New Resistance -->
|
||||
<div class="flex items-center gap-4 pt-4 border-t border-gray-700">
|
||||
<select id="newResistType" class="input w-40" onchange="toggleCustomInput(this)">
|
||||
<select id="newResistType" class="input w-40">
|
||||
<option value="">Select type...</option>
|
||||
@foreach (var dt in Enum.GetValues<DamageType>())
|
||||
@foreach (var rt in Model.ResistanceTypes)
|
||||
{
|
||||
<option value="@dt.ToString().ToLower()">@dt</option>
|
||||
<option value="@rt.Key" data-color="@rt.Color">@rt.DisplayName</option>
|
||||
}
|
||||
<option value="custom">Custom...</option>
|
||||
</select>
|
||||
<input type="text" id="newResistCustom" class="input w-40 hidden" placeholder="Custom name" />
|
||||
<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>
|
||||
@@ -453,48 +466,34 @@
|
||||
}
|
||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeAddLootModal(); });
|
||||
|
||||
function toggleCustomInput(select) {
|
||||
const customInput = document.getElementById('newResistCustom');
|
||||
if (select.value === 'custom') {
|
||||
customInput.classList.remove('hidden');
|
||||
customInput.focus();
|
||||
} else {
|
||||
customInput.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
// 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 customInput = document.getElementById('newResistCustom');
|
||||
const valueInput = document.getElementById('newResistValue');
|
||||
|
||||
let name = typeSelect.value === 'custom' ? customInput.value.trim().toLowerCase() : typeSelect.value;
|
||||
const percent = parseInt(valueInput.value) || 0;
|
||||
const value = percent / 100;
|
||||
|
||||
if (!name) {
|
||||
alert('Please select or enter a resistance type');
|
||||
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">
|
||||
<input type="text" name="resist_name[]" value="${name}" class="input w-40" placeholder="Type name" />
|
||||
<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"
|
||||
<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"
|
||||
<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>
|
||||
@@ -509,11 +508,7 @@
|
||||
`;
|
||||
|
||||
document.getElementById('resistancesList').insertAdjacentHTML('beforeend', html);
|
||||
|
||||
// Reset inputs
|
||||
typeSelect.value = '';
|
||||
customInput.value = '';
|
||||
customInput.classList.add('hidden');
|
||||
valueInput.value = '50';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user