Resistances + Dmg Types
This commit is contained in:
+2011
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SystemRevivalServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ResistancedmgType : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "DamageTypeKey",
|
||||
table: "dungeon_mob_definitions",
|
||||
type: "varchar(32)",
|
||||
maxLength: 32,
|
||||
nullable: false,
|
||||
defaultValue: "")
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "BuffDuration",
|
||||
table: "dungeon_item_definitions",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BuffResistancesJson",
|
||||
table: "dungeon_item_definitions",
|
||||
type: "varchar(1024)",
|
||||
maxLength: 1024,
|
||||
nullable: false,
|
||||
defaultValue: "")
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DamageTypeKey",
|
||||
table: "dungeon_mob_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BuffDuration",
|
||||
table: "dungeon_item_definitions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BuffResistancesJson",
|
||||
table: "dungeon_item_definitions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,6 +737,14 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Property<int>("BonusWisdom")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuffDuration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuffResistancesJson")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)");
|
||||
|
||||
b.Property<int>("DamageType")
|
||||
.HasColumnType("int");
|
||||
|
||||
@@ -1003,6 +1011,11 @@ namespace SystemRevivalServer.Migrations
|
||||
b.Property<float>("DamagePerTier")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("DamageTypeKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
|
||||
@@ -239,29 +239,142 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Resistances (Equipment) -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700">
|
||||
<h2 class="text-lg font-semibold text-white">Resistance Bonuses (When Equipped)</h2>
|
||||
<p class="text-sm text-gray-400 mt-1">Permanent resistances granted while this item is equipped</p>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div id="resistancesList" class="space-y-2 mb-4">
|
||||
@foreach (var resist in Model.ItemResistances)
|
||||
{
|
||||
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="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<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="10" min="-100" max="100" step="5" />
|
||||
<span class="text-gray-400">%</span>
|
||||
<button type="button" onclick="addResistance()" class="btn btn-secondary">Add</button>
|
||||
<a href="/admin/resistances" class="text-sm text-indigo-400 hover:underline ml-auto">Manage Types →</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Consumable Effects -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700">
|
||||
<h2 class="text-lg font-semibold text-white">Consumable Effects</h2>
|
||||
</div>
|
||||
<div class="p-6 grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<label class="label">Heal Amount</label>
|
||||
<input type="number" name="Item.HealAmount" value="@Model.Item.HealAmount" class="input" min="0" />
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-2 md:grid-cols-5 gap-4 mb-6">
|
||||
<div>
|
||||
<label class="label">Heal Amount</label>
|
||||
<input type="number" name="Item.HealAmount" value="@Model.Item.HealAmount" class="input" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Mana Restore</label>
|
||||
<input type="number" name="Item.ManaRestore" value="@Model.Item.ManaRestore" class="input" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Stamina Restore</label>
|
||||
<input type="number" name="Item.StaminaRestore" value="@Model.Item.StaminaRestore" class="input" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Buff Duration (sec)</label>
|
||||
<input type="number" name="Item.BuffDuration" value="@Model.Item.BuffDuration" class="input" min="0" />
|
||||
<p class="text-xs text-gray-500 mt-1">0 = instant only</p>
|
||||
</div>
|
||||
<div class="flex items-center pt-6">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" name="Item.IsTeleportScroll" value="true" checked="@Model.Item.IsTeleportScroll" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
|
||||
<span class="text-gray-300">Teleport Scroll</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Mana Restore</label>
|
||||
<input type="number" name="Item.ManaRestore" value="@Model.Item.ManaRestore" class="input" min="0" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Stamina Restore</label>
|
||||
<input type="number" name="Item.StaminaRestore" value="@Model.Item.StaminaRestore" class="input" min="0" />
|
||||
</div>
|
||||
<div class="flex items-center pt-6">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" name="Item.IsTeleportScroll" value="true" checked="@Model.Item.IsTeleportScroll" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
|
||||
<span class="text-gray-300">Teleport Scroll</span>
|
||||
</label>
|
||||
|
||||
<!-- Buff Resistances -->
|
||||
<div class="pt-4 border-t border-gray-700">
|
||||
<h3 class="text-md font-medium text-white mb-3">Temporary Buff Resistances</h3>
|
||||
<p class="text-sm text-gray-400 mb-4">Resistances applied for BuffDuration seconds when consumed</p>
|
||||
|
||||
<div id="buffResistancesList" class="space-y-2 mb-4">
|
||||
@foreach (var resist in Model.BuffResistances)
|
||||
{
|
||||
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 buff-resistance-row">
|
||||
<select name="buff_resist_name[]" class="input w-40">
|
||||
@foreach (var rt in Model.ResistanceTypes)
|
||||
{
|
||||
<option value="@rt.Key" selected="@(resist.Key == rt.Key)">@rt.DisplayName</option>
|
||||
}
|
||||
</select>
|
||||
<div class="flex items-center gap-2 flex-1">
|
||||
<input type="range" name="buff_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('.buff-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="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<select id="newBuffResistType" class="input w-40">
|
||||
<option value="">Select type...</option>
|
||||
@foreach (var rt in Model.ResistanceTypes)
|
||||
{
|
||||
<option value="@rt.Key">@rt.DisplayName</option>
|
||||
}
|
||||
</select>
|
||||
<input type="number" id="newBuffResistValue" class="input w-24" value="25" min="-100" max="100" step="5" />
|
||||
<span class="text-gray-400">%</span>
|
||||
<button type="button" onclick="addBuffResistance()" class="btn btn-secondary">Add Buff</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -318,5 +431,68 @@
|
||||
updatePreview();
|
||||
toggleMaxStack();
|
||||
});
|
||||
|
||||
// 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('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="M6 18L18 6M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>`;
|
||||
document.getElementById('resistancesList').insertAdjacentHTML('beforeend', html);
|
||||
typeSelect.value = '';
|
||||
valueInput.value = '10';
|
||||
}
|
||||
|
||||
function addBuffResistance() {
|
||||
const typeSelect = document.getElementById('newBuffResistType');
|
||||
const valueInput = document.getElementById('newBuffResistValue');
|
||||
|
||||
const key = typeSelect.value;
|
||||
if (!key) { alert('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 buff-resistance-row">
|
||||
<select name="buff_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="buff_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('.buff-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="M6 18L18 6M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>`;
|
||||
document.getElementById('buffResistancesList').insertAdjacentHTML('beforeend', html);
|
||||
typeSelect.value = '';
|
||||
valueInput.value = '25';
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using DataServer.Data.Enums;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Server.Services.Admin.Pages.Items;
|
||||
|
||||
@@ -17,6 +19,10 @@ public class EditModel : AdminPageModel
|
||||
[BindProperty]
|
||||
public DungeonItemDefinition Item { get; set; } = new();
|
||||
|
||||
public List<DamageResistanceType> ResistanceTypes { get; set; } = new();
|
||||
public Dictionary<string, float> ItemResistances => Item.Resistances;
|
||||
public Dictionary<string, float> BuffResistances => Item.BuffResistances;
|
||||
|
||||
public bool IsNew => Item.Id == 0;
|
||||
public string? Message { get; set; }
|
||||
public bool IsError { get; set; }
|
||||
@@ -27,6 +33,11 @@ public class EditModel : AdminPageModel
|
||||
var cdnUrl = Environment.GetEnvironmentVariable("CDN_BASE_URL");
|
||||
if (!string.IsNullOrEmpty(cdnUrl)) CdnBaseUrl = cdnUrl;
|
||||
|
||||
ResistanceTypes = await _db.DamageResistanceTypes
|
||||
.Where(r => r.IsEnabled)
|
||||
.OrderBy(r => r.SortOrder)
|
||||
.ToListAsync();
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
var item = await _db.DungeonItemDefinitions.FindAsync(id.Value);
|
||||
@@ -46,6 +57,11 @@ public class EditModel : AdminPageModel
|
||||
var cdnUrl = Environment.GetEnvironmentVariable("CDN_BASE_URL");
|
||||
if (!string.IsNullOrEmpty(cdnUrl)) CdnBaseUrl = cdnUrl;
|
||||
|
||||
ResistanceTypes = await _db.DamageResistanceTypes
|
||||
.Where(r => r.IsEnabled)
|
||||
.OrderBy(r => r.SortOrder)
|
||||
.ToListAsync();
|
||||
|
||||
// Handle checkbox binding (unchecked = not sent)
|
||||
Item.IsEnabled = Request.Form.ContainsKey("Item.IsEnabled");
|
||||
Item.Stackable = Request.Form.ContainsKey("Item.Stackable");
|
||||
@@ -55,6 +71,34 @@ public class EditModel : AdminPageModel
|
||||
Item.Description ??= "";
|
||||
Item.SpritePath ??= "";
|
||||
Item.TintColor ??= "#ffffff";
|
||||
|
||||
// Parse equipment resistances
|
||||
var resistances = new Dictionary<string, float>();
|
||||
var resistNames = Request.Form["resist_name[]"].ToArray();
|
||||
var resistValues = Request.Form["resist_value[]"].ToArray();
|
||||
for (int i = 0; i < resistNames.Length && i < resistValues.Length; i++)
|
||||
{
|
||||
var name = resistNames[i]?.Trim().ToLower();
|
||||
if (!string.IsNullOrEmpty(name) && float.TryParse(resistValues[i], out var value))
|
||||
{
|
||||
resistances[name] = value;
|
||||
}
|
||||
}
|
||||
Item.ResistancesJson = JsonSerializer.Serialize(resistances);
|
||||
|
||||
// Parse buff resistances
|
||||
var buffResistances = new Dictionary<string, float>();
|
||||
var buffResistNames = Request.Form["buff_resist_name[]"].ToArray();
|
||||
var buffResistValues = Request.Form["buff_resist_value[]"].ToArray();
|
||||
for (int i = 0; i < buffResistNames.Length && i < buffResistValues.Length; i++)
|
||||
{
|
||||
var name = buffResistNames[i]?.Trim().ToLower();
|
||||
if (!string.IsNullOrEmpty(name) && float.TryParse(buffResistValues[i], out var value))
|
||||
{
|
||||
buffResistances[name] = value;
|
||||
}
|
||||
}
|
||||
Item.BuffResistancesJson = JsonSerializer.Serialize(buffResistances);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Item.Name))
|
||||
{
|
||||
@@ -95,11 +139,14 @@ public class EditModel : AdminPageModel
|
||||
HealAmount = Item.HealAmount,
|
||||
ManaRestore = Item.ManaRestore,
|
||||
StaminaRestore = Item.StaminaRestore,
|
||||
BuffDuration = Item.BuffDuration,
|
||||
IsTeleportScroll = Item.IsTeleportScroll,
|
||||
Stackable = Item.Stackable,
|
||||
MaxStack = Item.MaxStack,
|
||||
SpritePath = Item.SpritePath,
|
||||
TintColor = Item.TintColor,
|
||||
ResistancesJson = Item.ResistancesJson,
|
||||
BuffResistancesJson = Item.BuffResistancesJson,
|
||||
IsEnabled = Item.IsEnabled
|
||||
};
|
||||
_db.DungeonItemDefinitions.Add(newItem);
|
||||
@@ -152,11 +199,14 @@ public class EditModel : AdminPageModel
|
||||
existing.HealAmount = Item.HealAmount;
|
||||
existing.ManaRestore = Item.ManaRestore;
|
||||
existing.StaminaRestore = Item.StaminaRestore;
|
||||
existing.BuffDuration = Item.BuffDuration;
|
||||
existing.IsTeleportScroll = Item.IsTeleportScroll;
|
||||
existing.Stackable = Item.Stackable;
|
||||
existing.MaxStack = Item.MaxStack;
|
||||
existing.SpritePath = Item.SpritePath;
|
||||
existing.TintColor = Item.TintColor;
|
||||
existing.ResistancesJson = Item.ResistancesJson;
|
||||
existing.BuffResistancesJson = Item.BuffResistancesJson;
|
||||
existing.IsEnabled = Item.IsEnabled;
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class EditModel : AdminPageModel
|
||||
|
||||
public List<DungeonMobLootTable> MobLootTables { get; set; } = new();
|
||||
public List<DungeonLootTable> AllLootTables { get; set; } = new();
|
||||
public List<DamageResistanceType> ResistanceTypes { get; set; } = new();
|
||||
|
||||
public bool IsNew => Mob.Id == 0;
|
||||
public string? Message { get; set; }
|
||||
@@ -86,6 +87,11 @@ public class EditModel : AdminPageModel
|
||||
.Where(t => t.IsEnabled)
|
||||
.OrderBy(t => t.Name)
|
||||
.ToListAsync();
|
||||
|
||||
ResistanceTypes = await _db.DamageResistanceTypes
|
||||
.Where(r => r.IsEnabled)
|
||||
.OrderBy(r => r.SortOrder)
|
||||
.ToListAsync();
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
@@ -109,6 +115,7 @@ public class EditModel : AdminPageModel
|
||||
Mob.MaxTier = 99;
|
||||
Mob.BaseHealth = 50;
|
||||
Mob.BasePhysicalDamage = 5;
|
||||
Mob.DamageTypeKey = "physical";
|
||||
Mob.MoveSpeed = 60f;
|
||||
Mob.AttackRange = 40f;
|
||||
Mob.AttackSpeed = 1.0f;
|
||||
|
||||
@@ -56,6 +56,34 @@ public class DungeonItemDefinition
|
||||
public int ManaRestore { get; set; } = 0;
|
||||
public int StaminaRestore { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Duration in seconds for consumable buff effects (resistances, stat boosts)
|
||||
/// 0 = instant effect only, no buff
|
||||
/// </summary>
|
||||
public int BuffDuration { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for temporary resistance buffs when consumed
|
||||
/// Example: {"fire": 0.25, "poison": 0.5}
|
||||
/// Only applies if BuffDuration > 0
|
||||
/// </summary>
|
||||
[MaxLength(1024)]
|
||||
public string BuffResistancesJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>
|
||||
/// Helper to get/set buff resistances dictionary
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public Dictionary<string, float> BuffResistances
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<Dictionary<string, float>>(BuffResistancesJson) ?? new(); }
|
||||
catch { return new(); }
|
||||
}
|
||||
set { BuffResistancesJson = JsonSerializer.Serialize(value); }
|
||||
}
|
||||
|
||||
// Special
|
||||
public bool IsTeleportScroll { get; set; } = false;
|
||||
public int? TeachesSpellId { get; set; } // For spell tomes
|
||||
|
||||
@@ -35,6 +35,13 @@ public class DungeonMobDefinition
|
||||
public int BaseArmor { get; set; } = 0;
|
||||
public int BaseMagicResist { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Primary damage type key (references DamageResistanceType.Key)
|
||||
/// e.g., "physical", "fire", "poison"
|
||||
/// </summary>
|
||||
[MaxLength(32)]
|
||||
public string DamageTypeKey { get; set; } = "physical";
|
||||
|
||||
// Movement & Combat
|
||||
public float MoveSpeed { get; set; } = 60f;
|
||||
public float AttackRange { get; set; } = 40f; // Melee range ~40, ranged 150+
|
||||
|
||||
Reference in New Issue
Block a user