143 lines
5.6 KiB
Plaintext
143 lines
5.6 KiB
Plaintext
@page "/admin/dungeonbuilder/rooms"
|
||
@model DungeonBuilder.RoomsModel
|
||
@using DataServer.Data.Entities
|
||
@{
|
||
ViewData["Title"] = "Room Templates";
|
||
var roomTypes = Enum.GetValues<RoomType>();
|
||
}
|
||
|
||
<div class="mb-4">
|
||
<a href="/admin/dungeonbuilder" class="text-blue-400 hover:text-blue-300 text-sm">← Back to Dungeon Builder</a>
|
||
</div>
|
||
|
||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6">
|
||
<div>
|
||
<h1 class="text-2xl font-bold text-white">Room Templates</h1>
|
||
<p class="text-gray-400 text-sm mt-1">Pre-built rooms with tiles, objects, and spawns</p>
|
||
</div>
|
||
<a href="/admin/dungeonbuilder/rooms/edit" class="btn btn-primary">+ New Room</a>
|
||
</div>
|
||
|
||
@if (!string.IsNullOrEmpty(Model.Message))
|
||
{
|
||
<div class="mb-4 p-3 rounded @(Model.IsError ? "bg-red-900/50 text-red-300" : "bg-green-900/50 text-green-300")">
|
||
@Model.Message
|
||
</div>
|
||
}
|
||
|
||
<!-- Filters -->
|
||
<div class="card p-4 mb-4">
|
||
<form method="get" class="flex flex-wrap gap-3">
|
||
<div class="flex-1 min-w-[150px]">
|
||
<input type="text" name="search" value="@Model.Search"
|
||
class="input w-full text-sm" placeholder="Search by name..." />
|
||
</div>
|
||
<select name="type" class="input text-sm">
|
||
<option value="">All Types</option>
|
||
@foreach (var t in roomTypes)
|
||
{
|
||
<option value="@((int)t)" selected="@(Model.TypeFilter == (int)t)">@t</option>
|
||
}
|
||
</select>
|
||
<select name="biome" class="input text-sm">
|
||
<option value="">All Biomes</option>
|
||
@foreach (var b in Model.Biomes)
|
||
{
|
||
<option value="@b" selected="@(Model.BiomeFilter == b)">@b</option>
|
||
}
|
||
</select>
|
||
<button type="submit" class="btn btn-secondary text-sm">Filter</button>
|
||
<a href="/admin/dungeonbuilder/rooms" class="btn btn-ghost text-sm">Clear</a>
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Rooms Grid -->
|
||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||
@foreach (var room in Model.Rooms)
|
||
{
|
||
<div class="card p-4 hover:border-green-500/50 transition-colors">
|
||
<div class="flex items-start justify-between gap-3">
|
||
<div class="flex-1 min-w-0">
|
||
<h3 class="font-semibold text-white truncate">@room.Name</h3>
|
||
<div class="text-xs text-gray-400 mt-1">
|
||
<span class="@GetTypeColor(room.Type)">@room.Type</span>
|
||
<span class="ml-2">@(room.Width)×@(room.Height)</span>
|
||
@if (!string.IsNullOrEmpty(room.Biome))
|
||
{
|
||
<span class="ml-2 text-gray-500">@room.Biome</span>
|
||
}
|
||
</div>
|
||
|
||
<!-- Stats -->
|
||
<div class="flex flex-wrap gap-2 mt-3">
|
||
<span class="px-1.5 py-0.5 bg-gray-700 text-gray-300 rounded text-xs">
|
||
@(room.MinConnections)-@(room.MaxConnections) doors
|
||
</span>
|
||
@if (room.PlayerSpawnX.HasValue)
|
||
{
|
||
<span class="px-1.5 py-0.5 bg-yellow-500/20 text-yellow-400 rounded text-xs">Spawn</span>
|
||
}
|
||
@if (room.ExitPortalX.HasValue)
|
||
{
|
||
<span class="px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs">Exit</span>
|
||
}
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Mini Preview -->
|
||
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0 text-2xl">
|
||
@GetRoomIcon(room.Type)
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex items-center justify-between mt-3 pt-3 border-t border-gray-700">
|
||
<span class="text-xs text-gray-500">ID: @room.Id</span>
|
||
<div class="flex gap-2">
|
||
<a href="/admin/dungeonbuilder/rooms/edit?id=@room.Id" class="text-blue-400 hover:text-blue-300 text-sm">Edit</a>
|
||
<form method="post" asp-page-handler="Delete" class="inline" onsubmit="return confirm('Delete this room?');">
|
||
<input type="hidden" name="id" value="@room.Id" />
|
||
<button type="submit" class="text-red-400 hover:text-red-300 text-sm">Delete</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
@if (!Model.Rooms.Any())
|
||
{
|
||
<div class="col-span-full card p-8 text-center text-gray-500">
|
||
No room templates found. <a href="/admin/dungeonbuilder/rooms/edit" class="text-blue-400 hover:underline">Create one</a>!
|
||
</div>
|
||
}
|
||
</div>
|
||
|
||
@functions {
|
||
string GetTypeColor(RoomType type)
|
||
{
|
||
return type switch
|
||
{
|
||
RoomType.Entrance => "text-yellow-400",
|
||
RoomType.Exit => "text-blue-400",
|
||
RoomType.Boss => "text-red-400",
|
||
RoomType.Treasure => "text-amber-400",
|
||
RoomType.Secret => "text-purple-400",
|
||
RoomType.Shop => "text-emerald-400",
|
||
_ => "text-gray-400"
|
||
};
|
||
}
|
||
|
||
string GetRoomIcon(RoomType type)
|
||
{
|
||
return type switch
|
||
{
|
||
RoomType.Entrance => "🚪",
|
||
RoomType.Exit => "🌀",
|
||
RoomType.Boss => "💀",
|
||
RoomType.Treasure => "💎",
|
||
RoomType.Secret => "❓",
|
||
RoomType.Shop => "🛒",
|
||
_ => "🏠"
|
||
};
|
||
}
|
||
}
|