|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
try { |
|
3
|
|
|
require_once('config.inc'); |
|
4
|
|
|
|
|
5
|
|
|
$template = new Template(); |
|
6
|
|
|
|
|
7
|
|
|
$gameType = ''; // no game type here |
|
8
|
|
|
foreach (SmrShip::getAllBaseShips($gameType) as $ship) { |
|
9
|
|
|
$shipArray[] = buildShipStats($ship); |
|
10
|
|
|
} |
|
11
|
|
|
$template->assign('shipArray', $shipArray); |
|
12
|
|
|
|
|
13
|
|
|
$speeds = array_unique(array_column($shipArray, 'speed')); |
|
14
|
|
|
rsort($speeds); |
|
15
|
|
|
$template->assign('Speeds', $speeds); |
|
16
|
|
|
|
|
17
|
|
|
$hardpoints = array_unique(array_column($shipArray, 'hardpoint')); |
|
18
|
|
|
rsort($hardpoints); |
|
19
|
|
|
$template->assign('Hardpoints', $hardpoints); |
|
20
|
|
|
|
|
21
|
|
|
$booleanFields = ['Scanner', 'Cloak', 'Illusion', 'Jump', 'Scrambler']; |
|
22
|
|
|
$template->assign('BooleanFields', $booleanFields); |
|
23
|
|
|
|
|
24
|
|
|
$template->display('ship_list.php'); |
|
25
|
|
|
} catch (Throwable $e) { |
|
26
|
|
|
handleException($e); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function buildShipStats($ship) { |
|
30
|
|
|
//we want to put them all in an array so we dont have to have 15 td rows |
|
31
|
|
|
if ($ship['AlignRestriction'] == BUYER_RESTRICTION_GOOD) { |
|
32
|
|
|
$restriction = '<span class="dgreen">Good</span>'; |
|
33
|
|
|
} elseif ($ship['AlignRestriction'] == BUYER_RESTRICTION_EVIL) { |
|
34
|
|
|
$restriction = '<span class="red">Evil</span>'; |
|
35
|
|
|
} else { |
|
36
|
|
|
$restriction = ''; |
|
37
|
|
|
} |
|
38
|
|
|
// Array key is the td class (sort key), and array value is the data value |
|
39
|
|
|
$stat = [ |
|
40
|
|
|
'name' => $ship['Name'], |
|
41
|
|
|
'race race' . $ship['RaceID'] => Globals::getRaceName($ship['RaceID']), |
|
42
|
|
|
'class_' => Globals::getShipClass($ship['ShipClassID']), |
|
43
|
|
|
'cost' => number_format($ship['Cost']), |
|
44
|
|
|
'speed' => $ship['Speed'], |
|
45
|
|
|
'hardpoint' => $ship['Hardpoint'], |
|
46
|
|
|
'restriction' => $restriction, |
|
47
|
|
|
'shields' => $ship['MaxHardware'][HARDWARE_SHIELDS], |
|
48
|
|
|
'armour' => $ship['MaxHardware'][HARDWARE_ARMOUR], |
|
49
|
|
|
'cargo' => $ship['MaxHardware'][HARDWARE_CARGO], |
|
50
|
|
|
'cds' => $ship['MaxHardware'][HARDWARE_COMBAT], |
|
51
|
|
|
'scouts' => $ship['MaxHardware'][HARDWARE_SCOUT], |
|
52
|
|
|
'mines' => $ship['MaxHardware'][HARDWARE_MINE], |
|
53
|
|
|
'scanner' => $ship['MaxHardware'][HARDWARE_SCANNER] == 1 ? 'Yes' : '', |
|
54
|
|
|
'cloak' => $ship['MaxHardware'][HARDWARE_CLOAK] == 1 ? 'Yes' : '', |
|
55
|
|
|
'illusion' => $ship['MaxHardware'][HARDWARE_ILLUSION] == 1 ? 'Yes' : '', |
|
56
|
|
|
'jump' => $ship['MaxHardware'][HARDWARE_JUMP] == 1 ? 'Yes' : '', |
|
57
|
|
|
'scrambler' => $ship['MaxHardware'][HARDWARE_DCS] == 1 ? 'Yes' : '', |
|
58
|
|
|
]; |
|
59
|
|
|
return $stat; |
|
60
|
|
|
} |
|
61
|
|
|
|