feat: add match view server-rendered shell

This commit is contained in:
Keith Solomon
2026-07-26 00:13:40 -05:00
parent 51f57d309a
commit b444f98aa0
3 changed files with 106 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace BattleForge\Http\Handlers;
use BattleForge\Http\Request;
use BattleForge\Http\Response;
final class GetMatchView
{
/** @param array<string, string> $params */
public function handle(Request $request, array $params): Response
{
$csrf = $request->cookies['__csrf'] ?? '';
ob_start();
require_once __DIR__ . '/../../Views/layout.php';
require __DIR__ . '/../../Views/match.php';
$body = (string) ob_get_clean();
return Response::html(200, $body);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use BattleForge\Http\Escape;
/** @var string $csrf Provided by the front controller. */
?><?php
render_layout(static function (): void {
$a = static fn (string $v): string => Escape::attr($v);
?>
<header id="bf-match-header" data-bf-active-team="" data-bf-round="0">
<h1>Battle</h1>
<p>
Active team: <strong id="bf-active-team">&mdash;</strong>
&middot; Round: <strong id="bf-round">0</strong>
</p>
<p>
<button id="bf-end-turn" type="button">End Turn</button>
</p>
</header>
<main>
<div id="bf-grid" class="bf-grid" data-bf-width="0" data-bf-height="0"></div>
<aside id="bf-panel" class="bf-panel">
<p>Selected: <span id="bf-selected-unit">none</span></p>
<p>
<button id="bf-action-move" type="button" disabled>Move</button>
<button id="bf-action-attack" type="button" disabled>Attack</button>
<button id="bf-action-ability" type="button" disabled>Ability</button>
</p>
<div id="bf-ability-options"></div>
</aside>
</main>
<section id="bf-log" class="bf-log" aria-label="Action log"></section>
<section id="bf-result" class="bf-result" hidden>
<h2>Match over</h2>
<p>Winner: <strong id="bf-winner"></strong></p>
<p><a id="bf-return-home" href="/">Return to home</a></p>
</section>
<div id="bf-toast-host"></div>
<script type="module" src="<?= $a('/js/match.js') ?>"></script>
<?php
}, $csrf, 'Battle');