DK2/templates/pages/chars/list.php

43 lines
1.5 KiB
PHP
Raw Normal View History

<section>
2024-10-23 17:39:48 -05:00
<h1>Characters <span class="badge"><?= count($chars) . '/' . user()->char_slots ?></span></h1>
<?php
if (($f = flash('alert_character_list_1')) !== false) echo c_alert($f[0], $f[1]);
2024-10-05 14:23:32 -05:00
if (count($chars) > 0):
?>
<form action="/characters" method="post">
<input type="hidden" name="csrf" value="<?= csrf() ?>">
2024-10-05 14:23:32 -05:00
<div class="my-2 character-select">
<?php foreach ($chars as $id => $char) echo c_char_select_box($id, $char); ?>
2024-10-05 14:23:32 -05:00
<div class="mt-4 buttons">
<button type="submit" class="ui button primary" name="action" value="select">Select</button>
<button type="submit" class="ui button danger" name="action" value="delete">Delete</button>
</div>
</div>
</form>
<?php else: ?>
<!-- Should never see this particular message. If you have, there's a bug. -->
<p>You have no characters.</p>
<?php endif; ?>
</section>
2024-10-23 17:39:48 -05:00
<?php if (user()->char_slots > count($chars)): ?>
<section>
<h2>Create a new character</h2>
2024-10-23 17:39:48 -05:00
<?php $num_slots_left = user()->char_slots - count($chars); ?>
<p>You have <b><?= $num_slots_left ?> <?= $num_slots_left === 1 ? 'slot' : 'slots' ?></b> left.</p>
<form action="/character/create" method="post">
<input type="hidden" name="csrf" value="<?= csrf() ?>">
<div class="my-4">
2024-10-05 14:23:32 -05:00
<?= c_form_errors('create-character') ?>
<?= c_form_field('text', 'n', 'Character Name', formId: 'create-character') ?>
</div>
<button type="submit" class="ui button secondary">Create</button>
</form>
</section>
2024-10-05 14:23:32 -05:00
<?php endif; ?>