135 lines
5.5 KiB
Plaintext
135 lines
5.5 KiB
Plaintext
@page "/admin/roomtemplates"
|
||
@model RoomTemplates.IndexModel
|
||
@using DataServer.Data.Entities
|
||
@{
|
||
ViewData["Title"] = "Room Templates";
|
||
}
|
||
|
||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 md:mb-6">
|
||
<div>
|
||
<h1 class="text-xl md:text-2xl font-bold text-white">Room Templates</h1>
|
||
<p class="text-gray-400 text-sm">Create and manage room layouts for dungeon generation</p>
|
||
</div>
|
||
<a href="/admin/roomtemplates/edit" class="btn btn-primary text-sm">+ New Room</a>
|
||
</div>
|
||
|
||
<!-- Room Type Filters -->
|
||
<div class="flex flex-wrap gap-2 mb-4">
|
||
<span class="text-gray-400 text-sm py-1">Filter:</span>
|
||
@foreach (var type in Enum.GetValues<RoomType>().Take(10))
|
||
{
|
||
var count = Model.Rooms.Count(r => r.Type == type);
|
||
if (count > 0)
|
||
{
|
||
<span class="px-2 py-1 text-xs rounded bg-gray-700 text-gray-300">@type (@count)</span>
|
||
}
|
||
}
|
||
</div>
|
||
|
||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 md:gap-4">
|
||
@foreach (var room in Model.Rooms)
|
||
{
|
||
<div class="card p-4">
|
||
<div class="flex justify-between items-start mb-3">
|
||
<div class="min-w-0 flex-1">
|
||
<h3 class="text-base md:text-lg font-semibold text-white truncate">@room.Name</h3>
|
||
<p class="text-xs text-gray-400">@room.Width×@room.Height tiles</p>
|
||
</div>
|
||
<div class="flex flex-col items-end gap-1 ml-2">
|
||
<span class="px-2 py-0.5 text-xs rounded @GetRoomTypeColor(room.Type)">@room.Type</span>
|
||
<span class="px-2 py-0.5 text-xs rounded @(room.IsEnabled ? "bg-green-900 text-green-300" : "bg-red-900 text-red-300")">
|
||
@(room.IsEnabled ? "On" : "Off")
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
@if (!string.IsNullOrEmpty(room.Description))
|
||
{
|
||
<p class="text-sm text-gray-400 mb-3 line-clamp-2">@room.Description</p>
|
||
}
|
||
|
||
<div class="grid grid-cols-2 gap-1 text-xs mb-3">
|
||
<div>
|
||
<span class="text-gray-500">Tier:</span>
|
||
<span class="text-gray-300">@room.MinTier - @(room.MaxTier == 0 ? "∞" : room.MaxTier.ToString())</span>
|
||
</div>
|
||
<div>
|
||
<span class="text-gray-500">Weight:</span>
|
||
<span class="text-gray-300">@room.Weight</span>
|
||
</div>
|
||
</div>
|
||
|
||
@if (!string.IsNullOrEmpty(room.Tags))
|
||
{
|
||
<div class="flex flex-wrap gap-1 mb-3">
|
||
@foreach (var tag in room.Tags.Split(',', StringSplitOptions.RemoveEmptyEntries).Take(4))
|
||
{
|
||
<span class="px-1.5 py-0.5 bg-blue-900/50 text-blue-300 text-xs rounded">@tag.Trim()</span>
|
||
}
|
||
</div>
|
||
}
|
||
|
||
<!-- Mini Preview -->
|
||
<div class="bg-gray-900 rounded p-2 mb-3 h-20 flex items-center justify-center">
|
||
@if (!string.IsNullOrEmpty(room.TileDataJson))
|
||
{
|
||
<span class="text-xs text-gray-500">@(CountTiles(room.TileDataJson)) tiles placed</span>
|
||
}
|
||
else
|
||
{
|
||
<span class="text-xs text-gray-500">No tiles placed</span>
|
||
}
|
||
</div>
|
||
|
||
<div class="flex gap-2">
|
||
<a href="/admin/roomtemplates/edit?id=@room.Id" class="btn btn-secondary flex-1 text-center text-sm py-1.5">Edit</a>
|
||
<form method="post" asp-page-handler="Duplicate" class="flex-shrink-0">
|
||
<input type="hidden" name="id" value="@room.Id" />
|
||
<button type="submit" class="btn btn-secondary text-sm py-1.5 px-2" title="Duplicate">📋</button>
|
||
</form>
|
||
<form method="post" asp-page-handler="Delete" class="flex-shrink-0">
|
||
<input type="hidden" name="id" value="@room.Id" />
|
||
<button type="submit" class="btn bg-red-600 hover:bg-red-700 text-sm py-1.5 px-2"
|
||
onclick="return confirm('Delete this room template?')" title="Delete">🗑️</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
}
|
||
</div>
|
||
|
||
@if (Model.Rooms.Count == 0)
|
||
{
|
||
<div class="card p-8 md:p-12 text-center">
|
||
<p class="text-gray-400 mb-4">No room templates yet. Create rooms to use in dungeon generation.</p>
|
||
<a href="/admin/roomtemplates/edit" class="btn btn-primary">Create Your First Room</a>
|
||
</div>
|
||
}
|
||
|
||
@functions {
|
||
string GetRoomTypeColor(RoomType type)
|
||
{
|
||
return type switch
|
||
{
|
||
RoomType.Entrance => "bg-green-900 text-green-300",
|
||
RoomType.Exit => "bg-blue-900 text-blue-300",
|
||
RoomType.Boss => "bg-red-900 text-red-300",
|
||
RoomType.Treasure => "bg-yellow-900 text-yellow-300",
|
||
RoomType.Secret => "bg-purple-900 text-purple-300",
|
||
RoomType.Shop => "bg-cyan-900 text-cyan-300",
|
||
RoomType.Hallway => "bg-gray-700 text-gray-300",
|
||
_ => "bg-gray-600 text-gray-300"
|
||
};
|
||
}
|
||
|
||
int CountTiles(string? json)
|
||
{
|
||
if (string.IsNullOrEmpty(json)) return 0;
|
||
try
|
||
{
|
||
var tiles = System.Text.Json.JsonSerializer.Deserialize<List<TilePlacement>>(json);
|
||
return tiles?.Count ?? 0;
|
||
}
|
||
catch { return 0; }
|
||
}
|
||
}
|