Dungeon Builder. CONT.

This commit is contained in:
dingo
2026-01-04 13:22:15 -05:00
parent b8af3545a8
commit 03353fa338
5 changed files with 72 additions and 10 deletions
@@ -130,7 +130,7 @@
</a>
<!-- Test Generator -->
<a href="/admin/dungeonbuilder/test" class="card p-6 hover:border-orange-500 transition-colors group">
<a href="/admin/dungeonbuilder/testgen" class="card p-6 hover:border-orange-500 transition-colors group">
<div class="flex items-start gap-4">
<div class="w-12 h-12 rounded-lg bg-orange-500/20 flex items-center justify-center text-orange-400 text-2xl">
🧪
@@ -28,8 +28,6 @@
z-index: 10;
}
.palette-item {
width: 36px;
height: 36px;
cursor: pointer;
border: 2px solid transparent;
border-radius: 4px;
@@ -38,6 +36,7 @@
align-items: center;
justify-content: center;
image-rendering: pixelated;
box-sizing: content-box;
}
.palette-item:hover { border-color: #60a5fa; }
.palette-item.active { border-color: #fbbf24; background: #374151; }
@@ -387,7 +386,7 @@ function loadTilePalette() {
for (let i = 0; i < total; i++) {
const col = i % sheet.cols, row = Math.floor(i / sheet.cols);
html += `<div class="palette-item" data-type="tile" data-sid="${sheet.id}" data-f="${i}" title="Frame ${i}"
style="background:url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat; background-size:${sheet.sw}px ${sheet.sh}px;"
style="width:${sheet.tw}px; height:${sheet.th}px; background:url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat; background-size:${sheet.sw}px ${sheet.sh}px;"
onclick="selectPaletteItem(this)"></div>`;
}
document.getElementById('tilePalette').innerHTML = html;
@@ -26,6 +26,7 @@
.dungeon-cell.player { background: #48bb78; }
.dungeon-cell.exit { background: #4299e1; }
.dungeon-cell.mob { background: #f56565; }
.dungeon-cell.boss { background: #dc2626; }
.dungeon-cell.chest { background: #ecc94b; }
.dungeon-cell.object { background: #9f7aea; }
.cell-icon {
@@ -145,6 +146,10 @@
<span class="text-gray-400">Mobs:</span>
<span class="text-white">@Model.GeneratedDungeon.MobCount</span>
</div>
<div class="flex justify-between">
<span class="text-gray-400">Bosses:</span>
<span class="text-white">@Model.GeneratedDungeon.BossCount</span>
</div>
<div class="flex justify-between">
<span class="text-gray-400">Chests:</span>
<span class="text-white">@Model.GeneratedDungeon.ChestCount</span>
@@ -163,6 +168,51 @@
</div>
</div>
</div>
@if (Model.GeneratedDungeon.FloorTemplatesUsed.Any() || Model.GeneratedDungeon.WallTemplatesUsed.Any() ||
Model.GeneratedDungeon.ObjectTemplatesUsed.Any() || Model.GeneratedDungeon.RoomTemplatesUsed.Any())
{
<div class="card p-4">
<h3 class="font-semibold text-white mb-3">Templates Used</h3>
<div class="space-y-2 text-xs">
@if (Model.GeneratedDungeon.FloorTemplatesUsed.Any())
{
<div>
<span class="text-blue-400">Floors:</span>
<span class="text-gray-300">@string.Join(", ", Model.GeneratedDungeon.FloorTemplatesUsed)</span>
</div>
}
@if (Model.GeneratedDungeon.WallTemplatesUsed.Any())
{
<div>
<span class="text-red-400">Walls:</span>
<span class="text-gray-300">@string.Join(", ", Model.GeneratedDungeon.WallTemplatesUsed)</span>
</div>
}
@if (Model.GeneratedDungeon.ObjectTemplatesUsed.Any())
{
<div>
<span class="text-purple-400">Objects:</span>
<span class="text-gray-300">@string.Join(", ", Model.GeneratedDungeon.ObjectTemplatesUsed)</span>
</div>
}
@if (Model.GeneratedDungeon.RoomTemplatesUsed.Any())
{
<div>
<span class="text-green-400">Rooms:</span>
<span class="text-gray-300">@string.Join(", ", Model.GeneratedDungeon.RoomTemplatesUsed)</span>
</div>
}
</div>
</div>
}
else
{
<div class="card p-4">
<h3 class="font-semibold text-white mb-2">Templates Used</h3>
<p class="text-xs text-gray-500">No custom templates - using procedural generation</p>
</div>
}
}
<div class="card p-4">
@@ -174,6 +224,7 @@
<div class="legend-item"><div class="legend-box bg-green-500"></div><span class="text-gray-300">Player Spawn</span></div>
<div class="legend-item"><div class="legend-box bg-blue-500"></div><span class="text-gray-300">Exit Portal</span></div>
<div class="legend-item"><div class="legend-box bg-red-500"></div><span class="text-gray-300">Mob Spawn</span></div>
<div class="legend-item"><div class="legend-box bg-red-700"></div><span class="text-gray-300">Boss Spawn</span></div>
<div class="legend-item"><div class="legend-box bg-yellow-500"></div><span class="text-gray-300">Chest</span></div>
<div class="legend-item"><div class="legend-box bg-purple-400"></div><span class="text-gray-300">Object</span></div>
</div>
@@ -217,7 +217,8 @@ public class TestGenModel : AdminPageModel
for (int i = 1; i < rooms.Count; i++)
{
var room = rooms[i];
int mobCount = room.Type == "Boss" ? 1 : rng.Next(1, 4);
bool isBossRoom = room.Type == "Boss";
int mobCount = isBossRoom ? 1 : rng.Next(1, 4);
for (int m = 0; m < mobCount; m++)
{
@@ -225,8 +226,9 @@ public class TestGenModel : AdminPageModel
int my = room.Y + rng.Next(1, room.Height - 1);
if (dungeon.Cells[mx, my].Type == CellType.Floor)
{
dungeon.Cells[mx, my] = new CellInfo { Type = CellType.Mob };
dungeon.MobCount++;
dungeon.Cells[mx, my] = new CellInfo { Type = isBossRoom ? CellType.Boss : CellType.Mob };
if (isBossRoom) dungeon.BossCount++;
else dungeon.MobCount++;
}
}
@@ -320,11 +322,18 @@ public class TestGenModel : AdminPageModel
public List<RoomInfo> Rooms { get; set; } = new();
public int RoomCount { get; set; }
public int MobCount { get; set; }
public int BossCount { get; set; }
public int ChestCount { get; set; }
public int ObjectCount { get; set; }
public int Seed { get; set; }
public long GenerationTimeMs { get; set; }
// Template usage tracking
public List<string> FloorTemplatesUsed { get; set; } = new();
public List<string> WallTemplatesUsed { get; set; } = new();
public List<string> ObjectTemplatesUsed { get; set; } = new();
public List<string> RoomTemplatesUsed { get; set; } = new();
public CellInfo GetCell(int x, int y)
{
if (x >= 0 && x < Width && y >= 0 && y < Height)
@@ -345,6 +354,7 @@ public class TestGenModel : AdminPageModel
CellType.PlayerSpawn => "player",
CellType.Exit => "exit",
CellType.Mob => "mob",
CellType.Boss => "boss",
CellType.Chest => "chest",
CellType.Object => "object",
_ => "wall"
@@ -355,6 +365,7 @@ public class TestGenModel : AdminPageModel
CellType.PlayerSpawn => "🧑",
CellType.Exit => "🌀",
CellType.Mob => "👾",
CellType.Boss => "💀",
CellType.Chest => "📦",
CellType.Object => "•",
_ => ""
@@ -369,6 +380,7 @@ public class TestGenModel : AdminPageModel
PlayerSpawn,
Exit,
Mob,
Boss,
Chest,
Object
}
@@ -28,12 +28,11 @@
outline-offset: -2px;
}
.palette-tile {
width: 34px;
height: 34px;
cursor: pointer;
border: 2px solid transparent;
border-radius: 2px;
image-rendering: pixelated;
box-sizing: content-box;
}
.palette-tile:hover { border-color: #60a5fa; }
.palette-tile.active { border-color: #fbbf24; }
@@ -381,7 +380,8 @@ function loadSheet() {
const col = i % sheet.cols;
const row = Math.floor(i / sheet.cols);
html += `<div class="palette-tile" data-frame="${i}" onclick="selectTile(${i})"
style="background: url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
style="width: ${sheet.tw}px; height: ${sheet.th}px;
background: url('${cdnBase}/${sheet.cdn}') ${-col * sheet.tw}px ${-row * sheet.th}px no-repeat;
background-size: ${sheet.sw}px ${sheet.sh}px;"></div>`;
}
document.getElementById('palette').innerHTML = html;