feat: add battlefield, match stub, and upload result templates
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BattleForge\Http\Escape;
|
||||
|
||||
/**
|
||||
* @var string $csrf Provided by the front controller.
|
||||
* @var string $scenarioId Provided by the front controller from the URL.
|
||||
* @var int $width Battlefield width (8-16).
|
||||
* @var int $height Battlefield height (8-16).
|
||||
*/
|
||||
$e = static fn (string $v): string => Escape::html($v);
|
||||
$a = static fn (string $v): string => Escape::attr($v);
|
||||
$terrain = ['open', 'forest', 'rough', 'water', 'blocking'];
|
||||
?><?php
|
||||
render_layout(static function () use ($csrf, $e, $a, $scenarioId, $width, $height, $terrain): void {
|
||||
?>
|
||||
<h1>Battlefield editor</h1>
|
||||
<p>Scenario: <strong><?= $e($scenarioId) ?></strong></p>
|
||||
<form id="battlefield-form" method="post" action="<?= $a('/scenarios/' . $e($scenarioId) . '/edit/battlefield') ?>" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="_csrf" value="<?= $a($csrf) ?>">
|
||||
<fieldset>
|
||||
<legend>Battlefield</legend>
|
||||
<label>Width: <input type="number" name="battlefieldWidth" min="8" max="16" value="<?= $e((string) $width) ?>" required></label>
|
||||
<label>Height: <input type="number" name="battlefieldHeight" min="8" max="16" value="<?= $e((string) $height) ?>" required></label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Terrain palette</legend>
|
||||
<?php foreach ($terrain as $t) : ?>
|
||||
<button type="button" data-paint="<?= $a($t) ?>" class="bf-paint"><?= $e($t) ?></button>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Grid (<?= $e((string) $width) ?> × <?= $e((string) $height) ?>)</legend>
|
||||
<table class="bf-grid" id="bf-grid">
|
||||
<?php for ($y = 0; $y < $height; $y++) : ?>
|
||||
<tr>
|
||||
<?php for ($x = 0; $x < $width; $x++) : ?>
|
||||
<td><button type="button" class="bf-tile" data-x="<?= $e((string) $x) ?>" data-y="<?= $e((string) $y) ?>" data-paint="open">.</button></td>
|
||||
<?php endfor; ?>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Deployment zones</legend>
|
||||
<label><input type="radio" name="zoneMode" value="alpha" checked> Place team A zones</label>
|
||||
<label><input type="radio" name="zoneMode" value="bravo"> Place team B zones</label>
|
||||
<label><input type="radio" name="zoneMode" value="objective"> Place objective</label>
|
||||
</fieldset>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
<script type="module" src="<?= $a('/js/grid-editor.js') ?>"></script>
|
||||
<?php
|
||||
}, $csrf, 'Battlefield editor');
|
||||
Reference in New Issue
Block a user