supernova-ws /
SuperNova
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Created by Gorlum 25.01.2018 7:50 |
||||
| 4 | */ |
||||
| 5 | |||||
| 6 | namespace Pages\Deprecated; |
||||
| 7 | |||||
| 8 | use DBAL\db_mysql; |
||||
| 9 | use Fleet\DbFleetStatic; |
||||
| 10 | use Planet\DBStaticPlanet; |
||||
| 11 | use SN; |
||||
| 12 | use HelperString; |
||||
| 13 | use Exception; |
||||
| 14 | use Planet\Planet; |
||||
| 15 | use SnTemplate; |
||||
| 16 | use template; |
||||
| 17 | |||||
| 18 | class PageOverview extends PageDeprecated { |
||||
| 19 | /** |
||||
| 20 | * @var \classConfig $config |
||||
| 21 | */ |
||||
| 22 | protected $config; |
||||
| 23 | /** |
||||
| 24 | * @var \core_auth $auth |
||||
| 25 | */ |
||||
| 26 | protected $auth; |
||||
| 27 | /** |
||||
| 28 | * @var \classLocale $lang |
||||
| 29 | */ |
||||
| 30 | protected $lang; |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * @var \Core\RepoV2 $repo |
||||
| 34 | */ |
||||
| 35 | protected $repo; |
||||
| 36 | |||||
| 37 | /** |
||||
| 38 | * @var Planet $planet |
||||
| 39 | */ |
||||
| 40 | protected $planet; |
||||
| 41 | |||||
| 42 | public function __construct() { |
||||
| 43 | parent::__construct(); |
||||
| 44 | |||||
| 45 | $this->lang = SN::$lang; |
||||
| 46 | $this->config = SN::$config; |
||||
| 47 | $this->auth = SN::$auth; |
||||
| 48 | $this->repo = SN::$gc->repoV2; |
||||
| 49 | |||||
| 50 | lng_include('overview'); |
||||
| 51 | lng_include('mrc_mercenary'); |
||||
| 52 | } |
||||
| 53 | |||||
| 54 | |||||
| 55 | public function setPlanetById($planetId) { |
||||
| 56 | /** @noinspection PhpUnhandledExceptionInspection */ |
||||
| 57 | return $this->planet = $this->repo->getPlanet($planetId); |
||||
| 58 | } |
||||
| 59 | |||||
| 60 | public function getPlanet() { |
||||
| 61 | if (empty($this->planet)) { |
||||
| 62 | throw new Exception('No planet in Overview'); |
||||
| 63 | } |
||||
| 64 | |||||
| 65 | return $this->planet; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | public function route() { |
||||
| 69 | global $user, $planetrow, $que, $user_option_list; |
||||
| 70 | |||||
| 71 | $this->setPlanetById($planetrow['id']); |
||||
| 72 | |||||
| 73 | switch ($mode = sys_get_param_str('mode')) { |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 74 | case 'manage': |
||||
| 75 | $this->manage($user, $planetrow); |
||||
| 76 | break; |
||||
| 77 | |||||
| 78 | default: |
||||
| 79 | $this->overview($user, $planetrow, $que, $user_option_list); |
||||
| 80 | break; |
||||
| 81 | } |
||||
| 82 | } |
||||
| 83 | |||||
| 84 | /** |
||||
| 85 | * @param $user |
||||
| 86 | * @param &$planetrow |
||||
| 87 | * @param $que |
||||
| 88 | * @param $user_option_list |
||||
| 89 | */ |
||||
| 90 | public function overview($user, &$planetrow, $que, $user_option_list) { |
||||
| 91 | $this->planet->sn_sys_sector_buy(); |
||||
|
0 ignored issues
–
show
The function
Planet\Planet::sn_sys_sector_buy() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 92 | |||||
| 93 | rpg_level_up($user, RPG_STRUCTURE); |
||||
| 94 | rpg_level_up($user, RPG_RAID); |
||||
| 95 | rpg_level_up($user, RPG_TECH); |
||||
| 96 | rpg_level_up($user, RPG_EXPLORE); |
||||
| 97 | |||||
| 98 | if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
||||
| 99 | $planetrow['name'] = $new_name; |
||||
| 100 | $new_name_safe = SN::$db->db_escape($new_name); |
||||
| 101 | DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name_safe}'"); |
||||
| 102 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
||||
| 103 | $this->planet->reload(); |
||||
| 104 | } |
||||
| 105 | |||||
| 106 | if (!empty($theResult = $this->planet->sn_sys_planet_core_transmute($user))) { |
||||
|
0 ignored issues
–
show
The function
Planet\Planet::sn_sys_planet_core_transmute() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 107 | $this->resultMessageList->add($theResult['MESSAGE'], $theResult['STATUS']); |
||||
| 108 | } |
||||
| 109 | |||||
| 110 | $template = SnTemplate::gettemplate('planet_overview', true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 111 | |||||
| 112 | $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER); |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type array expected by parameter $planet of mrc_get_level().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 113 | $template->assign_recursive($this->planet->tpl_planet_density_info($user_dark_matter)); |
||||
|
0 ignored issues
–
show
It seems like
$user_dark_matter can also be of type boolean and double; however, parameter $user_dark_matter of Planet\Planet::tpl_planet_density_info() does only seem to accept integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 114 | |||||
| 115 | $fleets_to_planet = []; |
||||
| 116 | $planet_count = 0; |
||||
| 117 | $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false); |
||||
| 118 | foreach ($planets_query as $an_id => $planetRecord) { |
||||
| 119 | $fleet_list = flt_get_fleets_to_planet($planetRecord); |
||||
| 120 | if (!empty($fleet_list['own']['count'])) { |
||||
| 121 | $fleets_to_planet[$an_id] = tpl_parse_fleet_sn($fleet_list['own']['total'], getUniqueFleetId($planetRecord)); |
||||
| 122 | } |
||||
| 123 | |||||
| 124 | if ($planetRecord['planet_type'] == PT_MOON) { |
||||
| 125 | continue; |
||||
| 126 | } |
||||
| 127 | |||||
| 128 | $planet_count++; |
||||
| 129 | |||||
| 130 | db_mysql::db_transaction_start(); |
||||
| 131 | $updatedData = sys_o_get_updated($user['id'], $planetRecord['id'], SN_TIME_NOW, false, true); |
||||
| 132 | db_mysql::db_transaction_commit(); |
||||
| 133 | |||||
| 134 | $templatizedPlanet = tpl_parse_planet($user, $updatedData['planet']); |
||||
| 135 | $templatizedPlanet += tpl_parse_planet_result_fleet($updatedData['planet'], $fleet_list); |
||||
| 136 | $templatizedPlanet += tpl_parse_planet_moon($planetRecord['id']); |
||||
| 137 | |||||
| 138 | $template->assign_block_vars('planet', $templatizedPlanet); |
||||
| 139 | } |
||||
| 140 | |||||
| 141 | $fleets = flt_parse_fleets_to_events(DbFleetStatic::fleet_and_missiles_list_incoming($user['id'])); |
||||
|
0 ignored issues
–
show
Are you sure the assignment to
$fleets is correct as flt_parse_fleets_to_even..._incoming($user['id'])) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||||
| 142 | tpl_assign_fleet($template, $fleets_to_planet); |
||||
|
0 ignored issues
–
show
The function
tpl_assign_fleet() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 143 | tpl_assign_fleet($template, $fleets); |
||||
|
0 ignored issues
–
show
The function
tpl_assign_fleet() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 144 | |||||
| 145 | $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']); |
||||
| 146 | if ($lune) { |
||||
| 147 | $template->assign_vars([ |
||||
| 148 | 'MOON_ID' => $lune['id'], |
||||
| 149 | 'MOON_IMG' => $lune['image'], |
||||
| 150 | 'MOON_NAME' => $lune['name'], |
||||
| 151 | ]); |
||||
| 152 | } |
||||
| 153 | |||||
| 154 | $template->assign_recursive($this->planet->int_planet_pretemplate($user)); |
||||
| 155 | |||||
| 156 | if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) { |
||||
|
0 ignored issues
–
show
|
|||||
| 157 | $this->templateQue($template, QUE_STRUCTURES, $que); |
||||
| 158 | } |
||||
| 159 | |||||
| 160 | $this->templateQue($template, SUBQUE_FLEET, $que); |
||||
| 161 | if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) { |
||||
|
0 ignored issues
–
show
|
|||||
| 162 | $this->templateQue($template, SUBQUE_DEFENSE, $que); |
||||
| 163 | } |
||||
| 164 | |||||
| 165 | $template->assign_vars($this->templateGridSizes($user, $user_option_list, $planet_count)); |
||||
| 166 | |||||
| 167 | $template->assign_vars($this->templateSector($user, $user_dark_matter)); |
||||
| 168 | |||||
| 169 | $planet_recyclers_orbiting = 0; |
||||
| 170 | foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
||||
| 171 | $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id); |
||||
| 172 | } |
||||
| 173 | $governor_level = $planetrow['PLANET_GOVERNOR_ID'] ? mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID'], false, true) : 0; |
||||
| 174 | $template->assign_vars([ |
||||
| 175 | 'USER_ID' => $user['id'], |
||||
| 176 | 'user_username' => $user['username'], |
||||
| 177 | 'USER_AUTHLEVEL' => $user['authlevel'], |
||||
| 178 | |||||
| 179 | 'NEW_MESSAGES' => $user['new_message'], |
||||
| 180 | // TODO |
||||
| 181 | // 'NEW_LEVEL_MINER' => $level_miner, |
||||
| 182 | // 'NEW_LEVEL_RAID' => $level_raid, |
||||
| 183 | |||||
| 184 | 'planet_diameter' => HelperString::numberFloorAndFormat($planetrow['diameter']), |
||||
| 185 | |||||
| 186 | 'metal_debris' => HelperString::numberFloorAndFormat($planetrow['debris_metal']), |
||||
| 187 | 'crystal_debris' => HelperString::numberFloorAndFormat($planetrow['debris_crystal']), |
||||
| 188 | 'PLANET_RECYCLERS' => $planet_recyclers_orbiting, |
||||
| 189 | 'planet_image' => $planetrow['image'], |
||||
| 190 | 'planet_temp_min' => $planetrow['temp_min'], |
||||
| 191 | 'planet_temp_avg' => round(($planetrow['temp_min'] + $planetrow['temp_max']) / 2), |
||||
| 192 | 'planet_temp_max' => $planetrow['temp_max'], |
||||
| 193 | 'planet_density' => $planetrow['density'], |
||||
| 194 | 'planet_density_index' => $planetrow['density_index'], |
||||
| 195 | 'planet_density_text' => $this->lang['uni_planet_density_types'][$planetrow['density_index']], |
||||
| 196 | |||||
| 197 | 'GATE_LEVEL' => mrc_get_level($user, $planetrow, STRUC_MOON_GATE), |
||||
| 198 | 'GATE_JUMP_REST_TIME' => uni_get_time_to_jump($planetrow), |
||||
| 199 | |||||
| 200 | 'ADMIN_EMAIL' => $this->config->game_adminEmail, |
||||
| 201 | |||||
| 202 | 'PLANET_GOVERNOR_ID' => $planetrow['PLANET_GOVERNOR_ID'], |
||||
| 203 | 'PLANET_GOVERNOR_LEVEL' => $governor_level, |
||||
| 204 | 'PLANET_GOVERNOR_LEVEL_PLUS' => mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID']) - $governor_level, |
||||
| 205 | 'PLANET_GOVERNOR_NAME' => $this->lang['tech'][$planetrow['PLANET_GOVERNOR_ID']], |
||||
| 206 | |||||
| 207 | 'IS_CAPITAL' => $planetrow['id'] == $user['id_planet'], |
||||
| 208 | 'IS_MOON' => $planetrow['planet_type'] == PT_MOON, |
||||
| 209 | |||||
| 210 | 'DARK_MATTER' => $user_dark_matter, |
||||
| 211 | |||||
| 212 | 'PAGE_HEADER' => $this->lang['ov_overview'] . " - " . $this->lang['sys_planet_type'][$planetrow['planet_type']] . " {$planetrow['name']} [{$planetrow['galaxy']}:{$planetrow['system']}:{$planetrow['planet']}]", |
||||
| 213 | ]); |
||||
| 214 | tpl_set_resource_info($template, $planetrow, $fleets_to_planet); |
||||
| 215 | |||||
| 216 | $this->resultMessageList->templateAdd($template); |
||||
| 217 | |||||
| 218 | SnTemplate::display($template); |
||||
| 219 | } |
||||
| 220 | |||||
| 221 | /** |
||||
| 222 | * @param $user |
||||
| 223 | * @param &$planetrow |
||||
| 224 | */ |
||||
| 225 | public function manage($user, &$planetrow) { |
||||
| 226 | $this->planet->sn_sys_sector_buy('overview.php?mode=manage'); |
||||
|
0 ignored issues
–
show
The function
Planet\Planet::sn_sys_sector_buy() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 227 | |||||
| 228 | $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER); |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type array expected by parameter $planet of mrc_get_level().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 229 | if (!empty($theResult = $this->planet->sn_sys_planet_core_transmute($user))) { |
||||
|
0 ignored issues
–
show
The function
Planet\Planet::sn_sys_planet_core_transmute() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 230 | $this->resultMessageList->add($theResult['MESSAGE'], $theResult['STATUS']); |
||||
| 231 | } |
||||
| 232 | |||||
| 233 | $template = SnTemplate::gettemplate('planet_manage', true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 234 | $planet_id = sys_get_param_id('planet_id'); |
||||
| 235 | |||||
| 236 | if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
||||
| 237 | $planetrow['name'] = $new_name; |
||||
| 238 | DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name}'"); |
||||
| 239 | } elseif (sys_get_param_str('action') == 'make_capital') { |
||||
| 240 | try { |
||||
| 241 | db_mysql::db_transaction_start(); |
||||
| 242 | $user = db_user_by_id($user['id'], true); |
||||
|
0 ignored issues
–
show
The function
db_user_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 243 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
||||
| 244 | |||||
| 245 | if ($planetrow['planet_type'] != PT_PLANET) { |
||||
| 246 | throw new exception($this->lang['ov_capital_err_not_a_planet'], ERR_ERROR); |
||||
| 247 | } |
||||
| 248 | |||||
| 249 | if ($planetrow['id'] == $user['id_planet']) { |
||||
| 250 | throw new exception($this->lang['ov_capital_err_capital_already'], ERR_ERROR); |
||||
| 251 | } |
||||
| 252 | |||||
| 253 | if ($user_dark_matter < $this->config->planet_capital_cost) { |
||||
| 254 | throw new exception($this->lang['ov_capital_err_no_dark_matter'], ERR_ERROR); |
||||
| 255 | } |
||||
| 256 | |||||
| 257 | rpg_points_change($user['id'], RPG_CAPITAL, -$this->config->planet_capital_cost, |
||||
| 258 | array('Planet %s ID %d at coordinates %s now become Empire Capital', $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow)) |
||||
| 259 | ); |
||||
| 260 | |||||
| 261 | db_user_set_by_id($user['id'], "id_planet = {$planetrow['id']}, galaxy = {$planetrow['galaxy']}, system = {$planetrow['system']}, planet = {$planetrow['planet']}"); |
||||
|
0 ignored issues
–
show
The function
db_user_set_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 262 | |||||
| 263 | $user['id_planet'] = $planetrow['id']; |
||||
| 264 | $this->resultMessageList->add($this->lang['ov_capital_err_none'], ERR_NONE); |
||||
| 265 | db_mysql::db_transaction_commit(); |
||||
| 266 | sys_redirect('overview.php?mode=manage'); |
||||
| 267 | } catch (exception $e) { |
||||
| 268 | db_mysql::db_transaction_rollback(); |
||||
| 269 | $this->resultMessageList->add($e->getMessage(), $e->getCode()); |
||||
| 270 | } |
||||
| 271 | } elseif (sys_get_param_str('action') == 'planet_teleport') { |
||||
| 272 | try { |
||||
| 273 | if (!uni_coordinates_valid($new_coordinates = array( |
||||
| 274 | 'galaxy' => sys_get_param_int('new_galaxy'), |
||||
| 275 | 'system' => sys_get_param_int('new_system'), |
||||
| 276 | 'planet' => sys_get_param_int('new_planet'))) |
||||
| 277 | ) { |
||||
| 278 | throw new exception($this->lang['ov_teleport_err_wrong_coordinates'], ERR_ERROR); |
||||
| 279 | } |
||||
| 280 | |||||
| 281 | db_mysql::db_transaction_start(); |
||||
| 282 | // При телепорте обновлять данные не надо - просто получить текущие данные и залочить их |
||||
| 283 | $user = db_user_by_id($user['id'], true); |
||||
|
0 ignored issues
–
show
The function
db_user_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 284 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
||||
| 285 | |||||
| 286 | $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates); |
||||
| 287 | if ($can_teleport['result'] != ERR_NONE) { |
||||
| 288 | throw new exception($can_teleport['message'], $can_teleport['result']); |
||||
| 289 | } |
||||
| 290 | |||||
| 291 | rpg_points_change($user['id'], RPG_TELEPORT, -$this->config->planet_teleport_cost, |
||||
| 292 | array($this->lang['ov_teleport_log_record'], $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow), uni_render_coordinates($new_coordinates)) |
||||
| 293 | ); |
||||
| 294 | $planet_teleport_next = SN_TIME_NOW + $this->config->planet_teleport_timeout; |
||||
| 295 | DBStaticPlanet::db_planet_set_by_gspt($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}, planet_teleport_next = {$planet_teleport_next}", |
||||
| 296 | PT_ALL); |
||||
| 297 | |||||
| 298 | if ($planetrow['id'] == $user['id_planet']) { |
||||
| 299 | db_user_set_by_id($user['id'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}"); |
||||
|
0 ignored issues
–
show
The function
db_user_set_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 300 | } |
||||
| 301 | db_mysql::db_transaction_commit(); |
||||
| 302 | |||||
| 303 | $user = db_user_by_id($user['id'], true); |
||||
|
0 ignored issues
–
show
The function
db_user_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 304 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
||||
| 305 | $this->resultMessageList->add($this->lang['ov_teleport_err_none'], ERR_NONE); |
||||
| 306 | sys_redirect('overview.php?mode=manage'); |
||||
| 307 | } catch (exception $e) { |
||||
| 308 | db_mysql::db_transaction_rollback(); |
||||
| 309 | $this->resultMessageList->add($e->getMessage(), $e->getCode()); |
||||
| 310 | } |
||||
| 311 | } elseif (sys_get_param_str('action') == 'planet_abandon') { |
||||
| 312 | if ($this->auth->password_check(sys_get_param('abandon_confirm'))) { |
||||
| 313 | if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { |
||||
| 314 | $destroyed = SN_TIME_NOW + 60 * 60 * 24; |
||||
| 315 | DBStaticPlanet::db_planet_set_by_id($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); |
||||
| 316 | DBStaticPlanet::db_planet_set_by_parent($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); |
||||
| 317 | db_user_set_by_id($user['id'], '`current_planet` = `id_planet`'); |
||||
|
0 ignored issues
–
show
The function
db_user_set_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 318 | SnTemplate::messageBox($this->lang['ov_delete_ok'], $this->lang['colony_abandon'], 'overview.php?mode=manage'); |
||||
| 319 | } else { |
||||
| 320 | SnTemplate::messageBox($this->lang['ov_delete_wrong_planet'], $this->lang['colony_abandon'], 'overview.php?mode=manage'); |
||||
| 321 | } |
||||
| 322 | } else { |
||||
| 323 | SnTemplate::messageBox($this->lang['ov_delete_wrong_pass'], $this->lang['colony_abandon'], 'overview.php?mode=manage'); |
||||
| 324 | } |
||||
| 325 | } elseif (($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))) { |
||||
| 326 | $this->planet->governorHire($hire); |
||||
| 327 | |||||
| 328 | sys_redirect('overview.php?mode=manage'); |
||||
| 329 | die(); |
||||
|
0 ignored issues
–
show
|
|||||
| 330 | } |
||||
| 331 | |||||
| 332 | // TODO - refresh planet by itself |
||||
| 333 | // $this->setPlanetById($planetrow['id']); |
||||
| 334 | $this->planet->dbLoadRecord($planetrow['id']); |
||||
| 335 | $template->assign_recursive($this->planet->int_planet_pretemplate($user)); |
||||
| 336 | |||||
| 337 | foreach (sn_get_groups('governors') as $governor_id) { |
||||
| 338 | if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) { |
||||
| 339 | continue; |
||||
| 340 | } |
||||
| 341 | |||||
| 342 | $governor_level = $planetrow['PLANET_GOVERNOR_ID'] == $governor_id ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0; |
||||
| 343 | $build_data = eco_get_build_data($user, $planetrow, $governor_id, $governor_level); |
||||
| 344 | $template->assign_block_vars('governors', array( |
||||
| 345 | 'ID' => $governor_id, |
||||
| 346 | 'NAME' => $this->lang['tech'][$governor_id], |
||||
| 347 | 'COST' => $build_data[BUILD_CREATE][RES_DARK_MATTER], |
||||
| 348 | 'MAX' => get_unit_param($governor_id, P_MAX_STACK), |
||||
| 349 | 'LEVEL' => $governor_level, |
||||
| 350 | 'LEVEL_PLUS' => mrc_get_level($user, $planetrow, $governor_id) - $governor_level, |
||||
| 351 | )); |
||||
| 352 | } |
||||
| 353 | |||||
| 354 | $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER); |
||||
| 355 | $template->assign_recursive($this->planet->tpl_planet_density_info($user_dark_matter)); |
||||
| 356 | |||||
| 357 | $template->assign_vars($this->templateSector($user, $user_dark_matter)); |
||||
| 358 | |||||
| 359 | $can_teleport = uni_planet_teleport_check($user, $planetrow); |
||||
| 360 | $template->assign_vars(array( |
||||
| 361 | 'DARK_MATTER' => $user_dark_matter, |
||||
| 362 | |||||
| 363 | 'CAN_TELEPORT' => $can_teleport['result'] == ERR_NONE, |
||||
| 364 | 'CAN_NOT_TELEPORT_MSG' => $can_teleport['message'], |
||||
| 365 | 'TELEPORT_COST_TEXT' => prettyNumberStyledCompare($this->config->planet_teleport_cost, $user_dark_matter), |
||||
| 366 | |||||
| 367 | 'IS_CAPITAL' => $planetrow['id'] == $user['id_planet'], |
||||
| 368 | 'CAN_CAPITAL' => $user_dark_matter >= $this->config->planet_capital_cost, |
||||
| 369 | 'CAPITAL_COST_TEXT' => prettyNumberStyledCompare($this->config->planet_capital_cost, $user_dark_matter), |
||||
| 370 | |||||
| 371 | 'PAGE_HINT' => $this->lang['ov_manage_page_hint'], |
||||
| 372 | )); |
||||
| 373 | |||||
| 374 | $this->resultMessageList->templateAdd($template); |
||||
| 375 | |||||
| 376 | SnTemplate::display($template, $this->lang['rename_and_abandon_planet']); |
||||
| 377 | } |
||||
| 378 | |||||
| 379 | /** |
||||
| 380 | * @param $user |
||||
| 381 | * @param $user_dark_matter |
||||
| 382 | * |
||||
| 383 | * @return array |
||||
| 384 | */ |
||||
| 385 | protected function templateSector($user, $user_dark_matter) { |
||||
| 386 | $sector_cost = eco_get_build_data($user, $this->planet->asArray(), UNIT_SECTOR, mrc_get_level($user, $this->planet->asArray(), UNIT_SECTOR), true); |
||||
| 387 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
||||
| 388 | $planet_fill = floor($this->planet->field_current / eco_planet_fields_max($this->planet->asArray()) * 100); |
||||
|
0 ignored issues
–
show
The property
field_current does not exist on Planet\Planet. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||
| 389 | $planet_fill = $planet_fill > 100 ? 100 : $planet_fill; |
||||
| 390 | $vararray = [ |
||||
| 391 | 'planet_field_current' => $this->planet->field_current, |
||||
| 392 | 'planet_field_max' => eco_planet_fields_max($this->planet->asArray()), |
||||
| 393 | 'PLANET_FILL' => floor($this->planet->field_current / eco_planet_fields_max($this->planet->asArray()) * 100), |
||||
| 394 | 'PLANET_FILL_BAR' => $planet_fill, |
||||
| 395 | 'SECTOR_CAN_BUY' => $sector_cost <= $user_dark_matter, |
||||
| 396 | 'SECTOR_COST' => $sector_cost, |
||||
| 397 | 'SECTOR_COST_TEXT' => HelperString::numberFloorAndFormat($sector_cost), |
||||
| 398 | ]; |
||||
| 399 | |||||
| 400 | return $vararray; |
||||
| 401 | } |
||||
| 402 | |||||
| 403 | |||||
| 404 | /** |
||||
| 405 | * @param template $template |
||||
| 406 | * @param int $que_type |
||||
| 407 | * @param $que |
||||
| 408 | */ |
||||
| 409 | protected function templateQue($template, $que_type, $que) { |
||||
| 410 | // $que = que_get($planet->id_owner, $planet->id, $que_type); |
||||
| 411 | $que = $que['ques'][$que_type][$this->planet->id_owner][$this->planet->id]; |
||||
| 412 | |||||
| 413 | $que_length = 0; |
||||
| 414 | if (!empty($que)) { |
||||
| 415 | foreach ($que as $que_item) { |
||||
| 416 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
||||
| 417 | } |
||||
| 418 | $que_length = count($que); |
||||
| 419 | } |
||||
| 420 | |||||
| 421 | $template->assign_block_vars('ques', [ |
||||
| 422 | 'ID' => $que_type, |
||||
| 423 | 'NAME' => $this->lang['sys_ques'][$que_type], |
||||
| 424 | 'LENGTH' => $que_length, |
||||
| 425 | ]); |
||||
| 426 | } |
||||
| 427 | |||||
| 428 | /** |
||||
| 429 | * Calculates planet grid sizes (horizontal and vertical) for Planet Overview |
||||
| 430 | * |
||||
| 431 | * @param $user |
||||
| 432 | * @param $user_option_list |
||||
| 433 | * @param $planet_count |
||||
| 434 | * |
||||
| 435 | * @return array |
||||
| 436 | */ |
||||
| 437 | protected function templateGridSizes($user, $user_option_list, $planet_count) { |
||||
| 438 | $overview_planet_rows = $user['opt_int_overview_planet_rows']; |
||||
| 439 | $overview_planet_columns = $user['opt_int_overview_planet_columns']; |
||||
| 440 | |||||
| 441 | if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { |
||||
| 442 | $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows']; |
||||
| 443 | $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns']; |
||||
| 444 | } |
||||
| 445 | |||||
| 446 | if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) { |
||||
| 447 | $overview_planet_columns = ceil($planet_count / $overview_planet_rows); |
||||
| 448 | } |
||||
| 449 | $vararray = [ |
||||
| 450 | 'LIST_ROW_COUNT' => $overview_planet_rows, |
||||
| 451 | 'LIST_COLUMN_COUNT' => $overview_planet_columns, |
||||
| 452 | ]; |
||||
| 453 | |||||
| 454 | return $vararray; |
||||
| 455 | } |
||||
| 456 | |||||
| 457 | } |
||||
| 458 |