-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathspells.php
More file actions
123 lines (96 loc) · 2.23 KB
/
spells.php
File metadata and controls
123 lines (96 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
$pagetitle = 'Spell Database';
$NEEDPUB = true;
require 'common.php';
$sections = array(
'Heal Spells' => array(
'types' => array(0)
),
'Damage Spells' => array(
'types' => array(1)
),
'Other Spells' => array(
'types' => array(2)
),
);
if (isset($_GET['section']))
{
$spells = array();
if (!isset($sections[$_GET['section']]))
{
$tpl->message = "Invalid section";
$tpl->Execute(null);
exit;
}
$section = $sections[$_GET['section']];
foreach ($eoserv_spells->Data() as $esfitem)
{
if ($esfitem->id == 0)
continue;
$insec = false;
foreach ($section['types'] as $type)
{
if ($type == $esfitem->type)
{
$insec = true;
break;
}
}
if (!$insec)
continue;
$image = 'spellimage/gif/' . (100 + $esfitem->icon) . '.gif';
if (!file_exists($image)) $image = null;
$spell = array(
'id' => $esfitem->id,
'name' => $esfitem->name,
'image' => $image
);
$data = '';
switch ($_GET['section'])
{
case 'Damage Spells':
$data .= "<b>TP:</b> {$esfitem->tp}<br>";
$data .= "<b>SP:</b> {$esfitem->sp}<br>";
$data .= "<b>Damage:</b> {$esfitem->mindam} - {$esfitem->maxdam}";
break;
case 'Heal Spells':
$data .= "<b>TP:</b> {$esfitem->tp}<br>";
$data .= "<b>SP:</b> {$esfitem->sp}<br>";
$data .= "<b>HP:</b> +{$esfitem->hp}";
break;
}
$spell['data'] = $data;
$spells[] = $spell;
}
usort($spells, function($a, $b)
{
return $b['name'] < $a['name'];
});
$perpage = $imgperpage;
$count = count($spells);
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pages = ceil($count / $perpage);
if ($page < 1 || $page > $pages)
{
$page = max(min($page, $pages), 1);
}
$start = ($page-1) * $perpage;
$pagination = generate_pagination($pages, $page, '?section=' . $_GET['section']);
$spells = array_slice($spells, $start, $perpage);
$tpl->page = $page;
$tpl->pages = $pages;
$tpl->pagination = $pagination;
$tpl->perpage = $perpage;
$tpl->showing = count($spells);
$tpl->start = $start+1;
$tpl->end = min($start+$perpage, $count);
$tpl->count = $count;
$tpl->section = $_GET['section'];
$tpl->spells = $spells;
$tpl->Execute('spells');
}
else
{
$tpl->sections = array_keys($sections);
$tpl->Execute('spells_index');
}