Stash and player management fix

This commit is contained in:
dingo
2025-12-26 20:23:10 -05:00
parent 28b816553d
commit 7d3514ede7
6 changed files with 195 additions and 22 deletions
+119 -1
View File
@@ -148,6 +148,47 @@
</div>
</div>
<!-- Stash Grid (VIP Feature) -->
<div class="card p-4">
<h2 class="text-md font-semibold text-white mb-3">🔐 Stash (@Model.StashItems.Count/50)</h2>
<div class="grid grid-cols-10 gap-1">
@for (int i = 0; i < 50; i++)
{
var item = Model.StashItems.FirstOrDefault(s => s.SlotIndex == i);
var rarityBorder = item?.Definition?.Rarity switch
{
ItemRarity.Uncommon => "border-green-500",
ItemRarity.Rare => "border-blue-500",
ItemRarity.Epic => "border-purple-500",
ItemRarity.Legendary => "border-orange-500",
_ => "border-gray-700"
};
<div class="w-10 h-10 bg-gray-900 rounded border @rarityBorder flex items-center justify-center relative group cursor-pointer"
@if (item != null) { <text>onclick="showStashModal(@item.Id, @item.Quantity, @item.SlotIndex)"</text> }>
@if (item?.Definition != null)
{
@if (!string.IsNullOrEmpty(item.Definition.SpritePath))
{
<img src="@Model.CdnBaseUrl/downloads/@item.Definition.SpritePath" class="w-8 h-8 object-contain" />
}
else
{
<span class="text-xs text-gray-400">@item.Definition.Name.Substring(0, Math.Min(2, item.Definition.Name.Length))</span>
}
@if (item.Quantity > 1)
{
<span class="absolute bottom-0 right-0 bg-black/80 text-white text-[10px] px-0.5 rounded-tl">@item.Quantity</span>
}
<div class="absolute left-full ml-1 top-0 z-50 hidden group-hover:block">
@await Html.PartialAsync("_ItemTooltip", item.Definition)
</div>
}
</div>
}
</div>
</div>
<!-- Lifetime Stats -->
<div class="card p-4">
<h2 class="text-md font-semibold text-white mb-3">Lifetime Stats</h2>
@@ -251,9 +292,51 @@
<input type="hidden" name="itemId" id="deleteItemId" />
</form>
<!-- Stash Edit Modal -->
<div id="stashModal" class="fixed inset-0 bg-black/70 hidden items-center justify-center z-50">
<div class="bg-gray-800 rounded-xl p-4 max-w-xs w-full mx-4 border border-gray-700">
<h3 class="text-md font-semibold text-white mb-3">🔐 Edit Stash Item</h3>
<div class="space-y-3 mb-4">
<div>
<label class="label text-xs">Quantity</label>
<input type="number" id="stashModalQuantity" class="input text-sm py-1" min="1" />
</div>
<div>
<label class="label text-xs">Slot (0-49)</label>
<input type="number" id="stashModalSlotIndex" class="input text-sm py-1" min="0" max="49" />
</div>
</div>
<div class="flex justify-between gap-2 pt-3 border-t border-gray-700">
<button type="button" onclick="deleteStashItem()" class="btn bg-red-700 hover:bg-red-600 text-white btn-sm">Delete</button>
<div class="flex gap-2">
<button type="button" onclick="closeStashModal()" class="btn btn-secondary btn-sm">Cancel</button>
<button type="button" onclick="saveStashItem()" class="btn btn-primary btn-sm">Save</button>
</div>
</div>
</div>
</div>
<!-- Hidden stash forms -->
<form id="updateStashItemForm" method="post" asp-page-handler="UpdateStashItem" style="display:none">
@Html.AntiForgeryToken()
<input type="hidden" name="characterId" value="@Model.Character.Id" />
<input type="hidden" name="stashItemId" id="updateStashItemId" />
<input type="hidden" name="quantity" id="updateStashQuantity" />
<input type="hidden" name="slotIndex" id="updateStashSlotIndex" />
</form>
<form id="deleteStashItemForm" method="post" asp-page-handler="DeleteStashItem" style="display:none">
@Html.AntiForgeryToken()
<input type="hidden" name="characterId" value="@Model.Character.Id" />
<input type="hidden" name="stashItemId" id="deleteStashItemId" />
</form>
@section Scripts {
<script>
let currentItemId = null;
let currentStashItemId = null;
function showItemModal(itemId, quantity, slotIndex) {
currentItemId = itemId;
@@ -284,6 +367,41 @@
document.getElementById('deleteItemForm').submit();
}
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeItemModal(); });
// Stash functions
function showStashModal(stashItemId, quantity, slotIndex) {
currentStashItemId = stashItemId;
document.getElementById('stashModalQuantity').value = quantity;
document.getElementById('stashModalSlotIndex').value = slotIndex;
document.getElementById('stashModal').classList.remove('hidden');
document.getElementById('stashModal').classList.add('flex');
}
function closeStashModal() {
document.getElementById('stashModal').classList.add('hidden');
document.getElementById('stashModal').classList.remove('flex');
currentStashItemId = null;
}
function saveStashItem() {
if (!currentStashItemId) return;
document.getElementById('updateStashItemId').value = currentStashItemId;
document.getElementById('updateStashQuantity').value = document.getElementById('stashModalQuantity').value;
document.getElementById('updateStashSlotIndex').value = document.getElementById('stashModalSlotIndex').value;
document.getElementById('updateStashItemForm').submit();
}
function deleteStashItem() {
if (!currentStashItemId) return;
if (!confirm('Delete this stash item permanently?')) return;
document.getElementById('deleteStashItemId').value = currentStashItemId;
document.getElementById('deleteStashItemForm').submit();
}
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
closeItemModal();
closeStashModal();
}
});
</script>
}