spells.php

main 196 lines · 6.2 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/**
3 * Spell list.
4 *
5 * Prepared by spells.php - see the docblock there for the variables.
6 */
7?>
8<?php
9
10if ($spells) {
11 // Preparing data
12 $configVoc = $config['vocations'];
13 $types = array_keys($spells);
14 $itemImg = static function($id){ return function_exists('znote_item_image_url') ? htmlspecialchars(znote_item_image_url((int)$id, 'gif'), ENT_QUOTES) : ''; };
15
16 // Filter spells by vocation
17 $getVoc = (isset($_GET['vocation'])) ? getValue($_GET['vocation'] ?? null) : 'all';
18 if ($getVoc !== 'all') {
19 $getVoc = (int)$getVoc;
20 foreach ($types as $type)
21 foreach ($spells[$type] as $name => $spell)
22 if (!empty($spell['vocations']))
23 if (!in_array($getVoc, $spell['vocations']))
24 unset($spells[$type][$name]);
25 }
26
27 // Render HTML
28 ?>
29
30 <div class="znx-acct">
31
32 <div class="znx-acct-head" id="spells"><?= t('spells.title') ?><?php if ($getVoc !== 'all') echo ' ('.$configVoc[$getVoc]['name'].')';?></div>
33
34 <form action="#spells" class="znx-acct-toolbar filter_spells">
35 <div class="znx-acct-toolbar__field">
36 <label for="vocation"><?= t('spells.filter_voc') ?></label>
37 <select id="vocation" name="vocation" class="znx-acct-select">
38 <option value="all"><?= t('spells.all') ?></option>
39 <?php foreach ($config['vocations'] as $id => $vocation): ?>
40 <option value="<?php echo $id; ?>" <?php if ($getVoc === $id) echo "selected"; ?>><?php echo $vocation['name']; ?></option>
41 <?php endforeach; ?>
42 </select>
43 </div>
44 <div class="znx-acct-toolbar__submit"><button type="submit" class="znx-acct-btn"><?= t('common.search') ?></button></div>
45 </form>
46
47 <div class="znx-acct-head"><?= t('spells.types') ?></div>
48 <div class="znx-pill-nav">
49 <?php foreach ($types as $type): ?>
50 <a href="#spell_<?php echo $type; ?>"><?php echo ucfirst($type); ?></a>
51 <?php endforeach; ?>
52 </div>
53
54 <div class="znx-acct-head" id="spell_instant"><?= t('spells.instant') ?></div>
55 <div class="znx-jump-top"><a href="#spells"><?= t('spells.jump_top') ?></a></div>
56 <div class="znx-acct-table-wrap">
57 <table class="znx-acct-table">
58 <tbody>
59 <tr class="yellow">
60 <td><?= t('common.name') ?></td>
61 <td><?= t('spells.words') ?></td>
62 <td><?= t('common.level') ?></td>
63 <td><?= t('spells.mana') ?></td>
64 <td><?= t('spells.vocations') ?></td>
65 </tr>
66 <?php foreach ($spells['instant'] as $spell): ?>
67 <tr>
68 <td><?php echo $spell['name']; ?></td>
69 <td><?php echo $spell['words']; ?></td>
70 <td><?php echo $spell['lvl']; ?></td>
71 <td><?php echo $spell['mana']; ?></td>
72 <td><?php
73 if (!empty($spell['vocations'])) {
74 if ($getVoc !== 'all') {
75 echo $configVoc[$getVoc]['name'];
76 } else {
77 $names = array();
78 foreach ($spell['vocations'] as $id) {
79 if (isset($configVoc[$id]))
80 $names[] = $configVoc[$id]['name'];
81 }
82 echo implode(',<br>', $names);
83 }
84 }
85 ?></td>
86 </tr>
87 <?php endforeach; ?>
88 </tbody>
89 </table>
90 </div>
91
92 <div class="znx-acct-head" id="spell_rune"><?= t('spells.runes') ?></div>
93 <div class="znx-jump-top"><a href="#spells"><?= t('spells.jump_top') ?></a></div>
94 <div class="znx-acct-table-wrap">
95 <table class="znx-acct-table">
96 <tbody>
97 <tr class="yellow">
98 <td><?= t('common.name') ?></td>
99 <td><?= t('common.level') ?></td>
100 <td><?= t('spells.magic_level') ?></td>
101 <td><?= t('spells.image') ?></td>
102 <td><?= t('spells.vocations') ?></td>
103 </tr>
104 <?php foreach ($spells['rune'] as $spell): ?>
105 <tr>
106 <td><?php echo $spell['name']; ?></td>
107 <td><?php echo $spell['lvl']; ?></td>
108 <td><?php echo $spell['maglv']; ?></td>
109 <td><img src="<?php echo $itemImg($spell['id']); ?>" alt="<?= h(t('spells.rune_image')) ?>"></td>
110 <td><?php
111 if (!empty($spell['vocations'])) {
112 if ($getVoc !== 'all') {
113 echo $configVoc[$getVoc]['name'];
114 } else {
115 $names = array();
116 foreach ($spell['vocations'] as $id) {
117 if (isset($configVoc[$id]))
118 $names[] = $configVoc[$id]['name'];
119 }
120 echo implode(',<br>', $names);
121 }
122 }
123 ?></td>
124 </tr>
125 <?php endforeach; ?>
126 </tbody>
127 </table>
128 </div>
129
130 <?php if (isset($spells['conjure'])): ?>
131 <div class="znx-acct-head" id="spell_conjure"><?= t('spells.conjure') ?></div>
132 <div class="znx-jump-top"><a href="#spells"><?= t('spells.jump_top') ?></a></div>
133 <div class="znx-acct-table-wrap">
134 <table class="znx-acct-table">
135 <tbody>
136 <tr class="yellow">
137 <td><?= t('common.name') ?></td>
138 <td><?= t('spells.words') ?></td>
139 <td><?= t('common.level') ?></td>
140 <td><?= t('spells.mana') ?></td>
141 <td><?= t('spells.soul') ?></td>
142 <td><?= t('spells.charges') ?></td>
143 <td><?= t('spells.image') ?></td>
144 <td><?= t('spells.vocations') ?></td>
145 </tr>
146 <?php foreach ($spells['conjure'] as $spell): ?>
147 <tr>
148 <td><?php echo $spell['name']; ?></td>
149 <td><?php echo $spell['words']; ?></td>
150 <td><?php echo $spell['lvl']; ?></td>
151 <td><?php echo $spell['mana']; ?></td>
152 <td><?php echo $spell['soul']; ?></td>
153 <td><?php echo $spell['conjureCount']; ?></td>
154 <td><img src="<?php echo $itemImg($spell['conjureId']); ?>" alt="<?= h(t('spells.rune_image')) ?>"></td>
155 <td><?php
156 if (!empty($spell['vocations'])) {
157 if ($getVoc !== 'all') {
158 echo $configVoc[$getVoc]['name'];
159 } else {
160 $names = array();
161 foreach ($spell['vocations'] as $id) {
162 if (isset($configVoc[$id]))
163 $names[] = $configVoc[$id]['name'];
164 }
165 echo implode(',<br>', $names);
166 }
167 }
168 ?></td>
169 </tr>
170 <?php endforeach; ?>
171 </tbody>
172 </table>
173 </div>
174 <div class="znx-jump-top"><a href="#spells"><?= t('spells.jump_top') ?></a></div>
175 <?php endif; ?>
176
177 </div><!-- .znx-acct -->
178 <?php
179} else {
180 ?>
181 <div class="znx-acct">
182 <div class="znx-acct-head"><?= t('spells.title') ?></div>
183 <div class="znx-empty-box"><?= h(t('spells.not_loaded')) ?></div>
184 </div>
185 <?php
186}
187
188/* Debug tests
189foreach ($spells as $type => $spells) {
190 data_dump($spells, false, "Type: $type");
191}
192
193// All spell attributes?
194'group', 'words', 'lvl', 'level', 'maglv', 'magiclevel', 'charges', 'allowfaruse', 'blocktype', 'mana', 'soul', 'prem', 'aggressive', 'range', 'selftarget', 'needtarget', 'blockwalls', 'needweapon', 'exhaustion', 'groupcooldown', 'needlearn', 'casterTargetOrDirection', 'direction', 'params', 'playernameparam', 'conjureId', 'reagentId', 'conjureCount', 'vocations'
195*/
196
Top