creatures.php

main 71 lines · 2.4 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/**
3 * Creature library.
4 *
5 * Prepared by creatures.php: $creatures, $creatureRaces, $creatureSearch,
6 * $creatureRace, $creatureError. Nothing is read from disk here.
7 */
8?>
9<div class="znx-acct">
10
11<div class="znx-acct-head"><?= t('creatures.title') ?></div>
12
13<?php if ($creatureError !== ''): ?>
14
15 <div class="znx-empty-box"><?= htmlspecialchars($creatureError, ENT_QUOTES, 'UTF-8') ?></div>
16
17<?php else: ?>
18
19 <form action="" method="get" class="znx-acct-toolbar">
20 <div class="znx-acct-toolbar__field">
21 <input type="text" name="search" placeholder="<?= t('creatures.placeholder') ?>" class="znx-acct-select"
22 value="<?= htmlspecialchars($creatureSearch, ENT_QUOTES, 'UTF-8') ?>">
23 </div>
24 <div class="znx-acct-toolbar__field">
25 <select name="race" class="znx-acct-select">
26 <option value=""><?= t('creatures.all_races') ?></option>
27 <?php foreach ($creatureRaces as $race): ?>
28 <option value="<?= htmlspecialchars($race, ENT_QUOTES, 'UTF-8') ?>"
29 <?= $race === $creatureRace ? 'selected' : '' ?>>
30 <?= htmlspecialchars(ucfirst($race), ENT_QUOTES, 'UTF-8') ?>
31 </option>
32 <?php endforeach; ?>
33 </select>
34 </div>
35 <div class="znx-acct-toolbar__submit"><button type="submit" class="znx-acct-btn"><?= t('common.search') ?></button></div>
36 <?php if ($creatureSearch !== '' || $creatureRace !== ''): ?>
37 <div class="znx-acct-toolbar__submit"><a href="creatures.php" class="znx-acct-edit-btn"><?= t('common.clear') ?></a></div>
38 <?php endif; ?>
39 </form>
40
41 <div class="znx-acct-info"><?= count($creatures) ?> creature<?= count($creatures) === 1 ? '' : 's' ?>.</div>
42
43 <?php if ($creatures): ?>
44 <div class="znx-acct-table-wrap">
45 <table class="znx-acct-table">
46 <tr class="yellow">
47 <td>Name</td>
48 <td>Race</td>
49 <td>Health</td>
50 <td><?= t('creatures.experience') ?></td>
51 <td>Speed</td>
52 </tr>
53 <?php foreach ($creatures as $creature): ?>
54 <tr>
55 <td><?= htmlspecialchars($creature['name'], ENT_QUOTES, 'UTF-8') ?></td>
56 <td><?= htmlspecialchars(ucfirst($creature['race']), ENT_QUOTES, 'UTF-8') ?></td>
57 <td><?= number_format($creature['health']) ?></td>
58 <td><?= number_format($creature['experience']) ?></td>
59 <td><?= number_format($creature['speed']) ?></td>
60 </tr>
61 <?php endforeach; ?>
62 </table>
63 </div>
64 <?php else: ?>
65 <div class="znx-empty-box"><?= t('creatures.no_match') ?></div>
66 <?php endif; ?>
67
68<?php endif; ?>
69
70</div><!-- .znx-acct -->
71
Top