1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
use Smr\Admin\UniGenLocationCategories; |
4
|
|
|
|
5
|
|
|
$template = Smr\Template::getInstance(); |
6
|
|
|
$session = Smr\Session::getInstance(); |
7
|
|
|
$var = $session->getCurrentVar(); |
8
|
|
|
|
9
|
|
|
$session->getRequestVarInt('gal_on'); |
10
|
|
|
$template->assign('Galaxies', SmrGalaxy::getGameGalaxies($var['game_id'])); |
11
|
|
|
|
12
|
|
|
$container = Page::create('admin/unigen/universe_create_locations.php'); |
13
|
|
|
$container->addVar('game_id'); |
14
|
|
|
$template->assign('JumpGalaxyHREF', $container->href()); |
15
|
|
|
|
16
|
|
|
$locations = SmrLocation::getAllLocations(); |
17
|
|
|
|
18
|
|
|
// Initialize all location counts to zero |
19
|
|
|
$totalLocs = []; |
20
|
|
|
foreach ($locations as $location) { |
21
|
|
|
$totalLocs[$location->getTypeID()] = 0; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']); |
25
|
|
|
$template->assign('Galaxy', $galaxy); |
26
|
|
|
|
27
|
|
|
// Determine the current amount of each location |
28
|
|
|
foreach ($galaxy->getSectors() as $galSector) { |
29
|
|
|
foreach ($galSector->getLocations() as $sectorLocation) { |
30
|
|
|
$totalLocs[$sectorLocation->getTypeID()]++; |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
$template->assign('TotalLocs', $totalLocs); |
34
|
|
|
|
35
|
|
|
// Remove any linked locations, as they will be added automatically |
36
|
|
|
// with any corresponding HQs. |
37
|
|
|
foreach ($locations as $location) { |
38
|
|
|
foreach ($location->getLinkedLocations() as $linkedLoc) { |
39
|
|
|
unset($locations[$linkedLoc->getTypeID()]); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
// Set any extra information to be displayed with each location |
44
|
|
|
$locText = []; |
45
|
|
|
$categories = new UniGenLocationCategories(); |
46
|
|
|
foreach ($locations as $location) { |
47
|
|
|
$extra = '<span class="small"><br />'; |
48
|
|
|
if ($location->isWeaponSold()) { |
49
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Weapons'); |
50
|
|
|
foreach ($location->getWeaponsSold() as $weapon) { |
51
|
|
|
$extra .= $weapon->getName() . ' (' . $weapon->getShieldDamage() . '/' . $weapon->getArmourDamage() . '/' . $weapon->getBaseAccuracy() . ')<br />'; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
if ($location->isShipSold()) { |
55
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Ships'); |
56
|
|
|
foreach ($location->getShipsSold() as $shipSold) { |
57
|
|
|
$extra .= $shipSold->getName() . '<br />'; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
if ($location->isHardwareSold()) { |
61
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Hardware'); |
62
|
|
|
foreach ($location->getHardwareSold() as $hardware) { |
63
|
|
|
$extra .= $hardware['Name'] . '<br />'; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
if ($location->isBar()) { |
67
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Bars'); |
68
|
|
|
} |
69
|
|
|
if ($location->isBank()) { |
70
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Banks'); |
71
|
|
|
} |
72
|
|
|
if ($location->isHQ() || $location->isUG() || $location->isFed()) { |
73
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Headquarters'); |
74
|
|
|
foreach ($location->getLinkedLocations() as $linkedLoc) { |
75
|
|
|
$extra .= $linkedLoc->getName() . '<br />'; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
if (!$categories->added($location->getTypeID())) { |
79
|
|
|
// Anything that doesn't fit the other categories |
80
|
|
|
$extra .= $categories->addLoc($location->getTypeID(), 'Miscellaneous'); |
81
|
|
|
} |
82
|
|
|
$extra .= '</span>'; |
83
|
|
|
|
84
|
|
|
$locText[$location->getTypeID()] = $location->getName() . $extra; |
85
|
|
|
} |
86
|
|
|
$template->assign('LocText', $locText); |
87
|
|
|
$template->assign('LocTypes', $categories->locTypes); |
88
|
|
|
|
89
|
|
|
// Form to make location changes |
90
|
|
|
$container = Page::create('admin/unigen/universe_create_save_processing.php', $var); |
91
|
|
|
$container['forward_to'] = 'admin/unigen/universe_create_sectors.php'; |
92
|
|
|
$template->assign('CreateLocationsFormHREF', $container->href()); |
93
|
|
|
|
94
|
|
|
// HREF to cancel and return to the previous page |
95
|
|
|
$container = Page::create('admin/unigen/universe_create_sectors.php', $var); |
96
|
|
|
$template->assign('CancelHREF', $container->href()); |
97
|
|
|
|