/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->getObjects(); $reslist = parent::$objects->getObjectsList(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $count = parent::$db->queryFetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `actcnt`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . (int) $this->_current_user['user_id'] . "') AS max_fleet,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . (int) $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15') AS max_expeditions"); // LOAD TEMPLATES REQUIRED $inputs_template = parent::$page->get_template('fleet/fleet1_inputs'); $ships_row_template = parent::$page->get_template('fleet/fleet1_row_ships'); // LANGUAGE $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; $MaxFlyingFleets = $count['max_fleet']; $MaxExpedition = $this->_current_user[$resource[124]]; if ($MaxExpedition >= 1) { $ExpeditionEnCours = $count['max_expeditions']; $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } $MaxFlottes = FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']); $missiontype = FleetsLib::get_missions(); $galaxy = isset($_GET['galaxy']) ? (int) $_GET['galaxy'] : $this->_current_planet['planet_galaxy']; $system = isset($_GET['system']) ? (int) $_GET['system'] : $this->_current_planet['planet_system']; $planet = isset($_GET['planet']) ? (int) $_GET['planet'] : $this->_current_planet['planet_planet']; $planettype = isset($_GET['planettype']) ? (int) $_GET['planettype'] : $this->_current_planet['planet_type']; $target_mission = isset($_GET['target_mission']) ? (int) $_GET['target_mission'] : FALSE; $parse['flyingfleets'] = $MaxFlyingFleets; $parse['maxfleets'] = $MaxFlottes; $parse['currentexpeditions'] = $ExpeditionEnCours; $parse['maxexpeditions'] = $EnvoiMaxExpedition; $parse['message_nofreeslot'] = $MaxFlottes == $MaxFlyingFleets ? parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_noslots_row'), $parse) : ''; $ships = $this->_lang; $ShipData = ''; $ship_inputs = ''; $ships_row = ''; foreach ($reslist['fleet'] as $n => $i) { if ($this->_current_planet[$resource[$i]] > 0) { if ($i == 212) { $ships['fleet_max_speed'] = '-'; } else { $ships['fleet_max_speed'] = FleetsLib::fleet_max_speed("", $i, $this->_current_user); } $ships['ship'] = $this->_lang['tech'][$i]; $ships['amount'] = FormatLib::pretty_number($this->_current_planet[$resource[$i]]); $inputs['i'] = $i; $inputs['maxship'] = $this->_current_planet[$resource[$i]]; $inputs['consumption'] = FleetsLib::ship_consumption($i, $this->_current_user); $inputs['speed'] = FleetsLib::fleet_max_speed("", $i, $this->_current_user); $inputs['capacity'] = isset($pricelist[$i]['capacity']) ? $pricelist[$i]['capacity'] : 0; if ($i == 212) { $ships['max_ships'] = ''; $ships['set_ships'] = ''; } else { $ships['max_ships'] = "<a href=\"javascript:maxShip('ship" . $i . "'); shortInfo();\">" . $this->_lang['fl_max'] . "</a>"; $ships['set_ships'] = "<input name=\"ship" . $i . "\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"" . $this->_lang['tech'][$i] . $this->_current_planet[$resource[$i]] . "\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" />"; } $ship_inputs .= parent::$page->parse_template($inputs_template, $inputs); $ships_row .= parent::$page->parse_template($ships_row_template, $ships); } $have_ships = TRUE; } if (!$have_ships) { $parse['noships_row'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_noships_row'), $this->_lang); } else { if ($MaxFlottes > $MaxFlyingFleets) { $parse['none_max_selector'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet_selectors'), $this->_lang); $parse['continue_button'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_button'), $this->_lang); } } $parse['body'] = $ships_row; $parse['shipdata'] = $ship_inputs; $parse['galaxy'] = $galaxy; $parse['system'] = $system; $parse['planet'] = $planet; $parse['planettype'] = $planettype; $parse['target_mission'] = $target_mission; $parse['envoimaxexpedition'] = $EnvoiMaxExpedition; $parse['expeditionencours'] = $ExpeditionEnCours; $parse['target_mission'] = $target_mission; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_table'), $parse)); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->getObjects(); $pricelist = parent::$objects->getPrice(); $reslist = parent::$objects->getObjectsList(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $getCurrentAcs = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ACS_FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE acs_fleet_members = '" . $this->_current_user['user_id'] . "'"); // ARRAYS $speed_values = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10); $planet_type = array('fl_planet', 'fl_debris', 'fl_moon'); // LOAD TEMPLATES REQUIRED $inputs_template = parent::$page->get_template('fleet/fleet2_inputs'); $options_template = parent::$page->get_template('fleet/fleet_options'); $shortcut_template = parent::$page->get_template('fleet/fleet2_shortcuts'); $shortcut_row_template = parent::$page->get_template('fleet/fleet2_shortcuts_row'); $shortcut_noshortcuts = parent::$page->get_template('fleet/fleet2_shortcuts_noshortcuts_row'); $shortcut_acs_row = parent::$page->get_template('fleet/fleet2_shortcut_acs_row'); // LANGUAGE $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; // COORDS $g = $_POST['galaxy'] == '' ? $this->_current_planet['planet_galaxy'] : $_POST['galaxy']; $s = $_POST['system'] == '' ? $this->_current_planet['planet_system'] : $_POST['system']; $p = $_POST['planet'] == '' ? $this->_current_planet['planet_planet'] : $_POST['planet']; $t = $_POST['planet_type'] == '' ? $this->_current_planet['planet_type'] : $_POST['planet_type']; // OTHER VALUES $value = 0; $FleetHiddenBlock = ''; ##################################################################################################### // END DEFAULT VALUES ##################################################################################################### ##################################################################################################### // LOAD SHIPS INPUTS ##################################################################################################### $fleet['fleetlist'] = ''; $fleet['amount'] = 0; $fleet['consumption'] = 0; foreach ($reslist['fleet'] as $n => $i) { if (isset($_POST["ship{$i}"]) && $i >= 201 && $i <= 215 && $_POST["ship{$i}"] > "0") { if ($_POST["ship{$i}"] > $this->_current_planet[$resource[$i]] or !ctype_digit($_POST["ship{$i}"])) { FunctionsLib::redirect('game.php?page=fleet1'); } else { $fleet['fleetarray'][$i] = $_POST["ship{$i}"]; $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";"; $fleet['amount'] += $_POST["ship{$i}"]; $fleet['i'] = $i; $fleet['consumption'] += FleetsLib::ship_consumption($i, $this->_current_user); $fleet['speed'] = FleetsLib::fleet_max_speed('', $i, $this->_current_user); $fleet['capacity'] = $pricelist[$i]['capacity']; $fleet['ship'] = $_POST["ship{$i}"]; $speedalls[$i] = FleetsLib::fleet_max_speed('', $i, $this->_current_user); $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet); } } } if (!$fleet['fleetlist']) { FunctionsLib::redirect('game.php?page=fleet1'); } else { $speedallsmin = min($speedalls); } ##################################################################################################### // LOAD PLANET TYPES OPTIONS ##################################################################################################### $parse['options_planettype'] = ''; foreach ($planet_type as $type) { $value++; $options['value'] = $value; if ($value == $t) { $options['selected'] = 'SELECTED'; } else { $options['selected'] = ''; } $options['title'] = $this->_lang[$type]; $parse['options_planettype'] .= parent::$page->parse_template($options_template, $options); } ##################################################################################################### // LOAD SPEED OPTIONS ##################################################################################################### $parse['options'] = ''; foreach ($speed_values as $value => $porcentage) { $speed_porcentage['value'] = $value; $speed_porcentage['selected'] = ''; $speed_porcentage['title'] = $porcentage; $parse['options'] .= parent::$page->parse_template($options_template, $speed_porcentage); } ##################################################################################################### // PARSE THE REST OF THE OPTIONS ##################################################################################################### $parse['fleetblock'] = $FleetHiddenBlock; $parse['speedallsmin'] = $speedallsmin; $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray']))); $parse['galaxy'] = $this->_current_planet['planet_galaxy']; $parse['system'] = $this->_current_planet['planet_system']; $parse['planet'] = $this->_current_planet['planet_planet']; $parse['galaxy_post'] = (int) $_POST['galaxy']; $parse['system_post'] = (int) $_POST['system']; $parse['planet_post'] = (int) $_POST['planet']; $parse['speedfactor'] = FunctionsLib::fleet_speed_factor(); $parse['planet_type'] = $this->_current_planet['planet_type']; $parse['metal'] = floor($this->_current_planet['planet_metal']); $parse['crystal'] = floor($this->_current_planet['planet_crystal']); $parse['deuterium'] = floor($this->_current_planet['planet_deuterium']); $parse['g'] = $g; $parse['s'] = $s; $parse['p'] = $p; ##################################################################################################### // LOAD FLEET SHORTCUTS ##################################################################################################### if (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander'])) { if ($this->_current_user['user_fleet_shortcuts']) { $scarray = explode(";", $this->_current_user['user_fleet_shortcuts']); foreach ($scarray as $a => $b) { if ($b != "") { $c = explode(',', $b); $shortcut['description'] = $c[0] . " " . $c[1] . ":" . $c[2] . ":" . $c[3] . " "; switch ($c[4]) { case 1: $shortcut['description'] .= $this->_lang['fl_planet_shortcut']; break; case 2: $shortcut['description'] .= $this->_lang['fl_debris_shortcut']; break; case 3: $shortcut['description'] .= $this->_lang['fl_moon_shortcut']; break; default: $shortcut['description'] .= ''; break; } $shortcut['select'] = 'shortcuts'; $shortcut['selected'] = ''; $shortcut['value'] = $c['1'] . ';' . $c['2'] . ';' . $c['3'] . ';' . $c['4']; $shortcut['title'] = $shortcut['description']; $shortcut['shortcut_options'] .= parent::$page->parse_template($options_template, $shortcut); } } $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_row_template, $shortcut); $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse); } else { $parse['fl_shorcut_message'] = $this->_lang['fl_no_shortcuts']; $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_noshortcuts, $parse); $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse); } } ##################################################################################################### // LOAD COLONY SHORTCUTS ##################################################################################################### $colony['select'] = 'colonies'; $colony['shortcut_options'] = FunctionsLib::build_planet_list($this->_current_user, $this->_current_planet['planet_id']); $parse['colonylist'] = parent::$page->parse_template($shortcut_row_template, $colony); if ($colony['shortcut_options'] === FALSE) { $parse['fl_shorcut_message'] = $this->_lang['fl_no_colony']; $parse['colonylist'] = parent::$page->parse_template($shortcut_noshortcuts, $parse); } ##################################################################################################### // LOAD SAC SHORTCUTS ##################################################################################################### $acs_fleets = ''; while ($row = parent::$db->fetchArray($getCurrentAcs)) { $members = explode(",", $row['acs_fleet_invited']); foreach ($members as $a => $b) { if ($b == $this->_current_user['user_id']) { $acs['galaxy'] = $row['acs_fleet_galaxy']; $acs['system'] = $row['acs_fleet_system']; $acs['planet'] = $row['acs_fleet_planet']; $acs['planet_type'] = $row['acs_fleet_planet_type']; $acs['id'] = $row['acs_fleet_id']; $acs['name'] = $row['acs_fleet_name']; $acs_fleets .= parent::$page->parse_template($shortcut_acs_row, $acs); } } } $parse['asc'] = $acs_fleets; $parse['maxepedition'] = $_POST['maxepedition']; $parse['curepedition'] = $_POST['curepedition']; $parse['target_mission'] = $_POST['target_mission']; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet2_table'), $parse)); }
/** * buildPage * * @return void */ private function buildPage() { if (!isset($_POST) or empty($_POST)) { FunctionsLib::redirect('game.php?page=fleet1'); } $pricelist = parent::$objects->getPrice(); $reslist = parent::$objects->getObjectsList(); $lang = $this->langs; ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // ARRAYS $exp_values = array(1, 2, 3, 4, 5); $hold_values = array(0, 1, 2, 4, 8, 16, 32); // LANG $this->langs['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->langs; // LOAD TEMPLATES REQUIRED $mission_row_template = parent::$page->get_template('fleet/fleet3_mission_row'); $input_template = parent::$page->get_template('fleet/fleet3_inputs'); $stay_template = parent::$page->get_template('fleet/fleet3_stay_row'); $options_template = parent::$page->get_template('fleet/fleet_options'); // OTHER VALUES $galaxy = (int) $_POST['galaxy']; $system = (int) $_POST['system']; $planet = (int) $_POST['planet']; $planettype = (int) $_POST['planettype']; $fleet_acs = (int) $_POST['fleet_group']; $YourPlanet = false; $UsedPlanet = false; $MissionSelector = ''; $available_ships = $this->getAvailableShips($_POST); // QUERYS $select = parent::$db->queryFetch("SELECT `planet_user_id`\n FROM `" . PLANETS . "`\n WHERE `planet_galaxy` = '" . $galaxy . "'\n AND `planet_system` = '" . $system . "'\n AND `planet_planet` = '" . $planet . "'\n AND `planet_type` = '" . $planettype . "';"); if ($select) { if ($select['planet_user_id'] == $this->current_user['user_id']) { $YourPlanet = true; $UsedPlanet = true; } else { $UsedPlanet = true; } } if ($planettype == 2) { if ($available_ships['ship209'] >= 1) { $missiontype[8] = $this->langs['type_mission'][8]; } else { $missiontype = array(); } } elseif ($planettype == 1 or $planettype == 3) { if ($available_ships['ship208'] >= 1 && !$UsedPlanet) { $missiontype[7] = $this->langs['type_mission'][7]; } elseif ($available_ships['ship210'] >= 1 && !$YourPlanet) { $missiontype[6] = $this->langs['type_mission'][6]; } if ($available_ships['ship202'] >= 1 or $available_ships['ship203'] >= 1 or $available_ships['ship204'] >= 1 or $available_ships['ship205'] >= 1 or $available_ships['ship206'] >= 1 or $available_ships['ship207'] >= 1 or $available_ships['ship210'] >= 1 or $available_ships['ship211'] >= 1 or $available_ships['ship213'] >= 1 or $available_ships['ship214'] >= 1 or $available_ships['ship215'] >= 1) { if (!$YourPlanet) { $missiontype[1] = $this->langs['type_mission'][1]; } $missiontype[3] = $this->langs['type_mission'][3]; $missiontype[5] = $this->langs['type_mission'][5]; } } elseif ($available_ships['ship209'] >= 1 or $available_ships['ship208']) { $missiontype[3] = $this->langs['type_mission'][3]; } if ($YourPlanet) { $missiontype[4] = $this->langs['type_mission'][4]; } if ($planettype == 3 || $planettype == 1 && $fleet_acs > 0 && $UsedPlanet) { if ($this->acsExists($fleet_acs, $galaxy, $system, $planet, $planettype)) { $missiontype[2] = $this->langs['type_mission'][2]; } } if ($planettype == 3 && $available_ships['ship214'] >= 1 && !$YourPlanet && $UsedPlanet) { $missiontype[9] = $this->langs['type_mission'][9]; } $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet']))); $mission = $_POST['target_mission']; $SpeedFactor = $_POST['speedfactor']; $AllFleetSpeed = FleetsLib::fleet_max_speed($fleetarray, 0, $this->current_user); $GenFleetSpeed = $_POST['speed']; $MaxFleetSpeed = min($AllFleetSpeed); $distance = FleetsLib::target_distance($_POST['thisgalaxy'], $galaxy, $_POST['thissystem'], $system, $_POST['thisplanet'], $planet); $duration = FleetsLib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = FleetsLib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->current_user); ##################################################################################################### // INPUTS DATA ##################################################################################################### $parse['metal'] = floor($this->current_planet['planet_metal']); $parse['crystal'] = floor($this->current_planet['planet_crystal']); $parse['deuterium'] = floor($this->current_planet['planet_deuterium']); $parse['consumption'] = $consumption; $parse['distance'] = $distance; $parse['speedfactor'] = $_POST['speedfactor']; $parse['thisgalaxy'] = $_POST['thisgalaxy']; $parse['thissystem'] = $_POST['thissystem']; $parse['thisplanet'] = $_POST['thisplanet']; $parse['galaxy'] = $galaxy; $parse['system'] = $system; $parse['planet'] = $planet; $parse['thisplanettype'] = $_POST['thisplanettype']; $parse['planettype'] = $planettype; $parse['speedallsmin'] = $_POST['speedallsmin']; $parse['speed'] = $_POST['speed']; $parse['speedfactor'] = $_POST['speedfactor']; $parse['usedfleet'] = $_POST['usedfleet']; $parse['maxepedition'] = $_POST['maxepedition']; $parse['curepedition'] = $_POST['curepedition']; $parse['fleet_group'] = $_POST['fleet_group']; $parse['acs_target_mr'] = $_POST['acs_target_mr']; ##################################################################################################### // EXTRA INPUTS ##################################################################################################### $input_extra = ''; foreach ($fleetarray as $Ship => $Count) { $input_parse['ship'] = $Ship; $input_parse['amount'] = $Count; $input_parse['capacity'] = $pricelist[$Ship]['capacity']; $input_parse['consumption'] = FleetsLib::ship_consumption($Ship, $this->current_user); $input_parse['speed'] = FleetsLib::fleet_max_speed('', $Ship, $this->current_user); $input_extra .= parent::$page->parse_template($input_template, $input_parse); } ##################################################################################################### // TOP TABLE TITLE ##################################################################################################### $parse['title'] = $_POST['thisgalaxy'] . ':' . $_POST['thissystem'] . ':' . $_POST['thisplanet'] . ' - '; if ($_POST['thisplanettype'] == 1) { $parse['title'] .= $this->langs['fl_planet']; } elseif ($_POST['thisplanettype'] == 3) { $parse['title'] .= $this->langs['fl_moon']; } ##################################################################################################### // MISSION TYPES ##################################################################################################### if (count($missiontype) > 0) { if ($planet == 16) { $parse_mission['value'] = 15; $parse_mission['mission'] = $this->langs['type_mission'][15]; $parse_mission['expedition_message'] = $this->langs['fl_expedition_alert_message']; $parse_mission['id'] = ' '; $parse_mission['checked'] = ' checked="checked"'; $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission); } else { $i = 0; foreach ($missiontype as $a => $b) { $parse_mission['value'] = $a; $parse_mission['mission'] = $b; $parse_mission['expedition_message'] = ''; $parse_mission['id'] = ' id="inpuT_' . $i . '" '; $parse_mission['checked'] = $mission == $a ? ' checked="checked"' : ''; $i++; $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission); } } } else { FunctionsLib::redirect('game.php?page=fleet1'); } ##################################################################################################### // STAY / EXPEDITION BLOCKS ##################################################################################################### $stay_row['options'] = ''; $StayBlock = ''; if ($planet == 16) { $stay_row['stay_type'] = 'expeditiontime'; foreach ($exp_values as $value) { $stay['value'] = $value; $stay['selected'] = ''; $stay['title'] = $value; $stay_row['options'] .= parent::$page->parse_template($options_template, $stay); } $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->langs)); } elseif (isset($missiontype[5])) { $stay_row['stay_type'] = 'holdingtime'; foreach ($hold_values as $value) { $stay['value'] = $value; $stay['selected'] = $value == 1 ? ' selected' : ''; $stay['title'] = $value; $stay_row['options'] .= parent::$page->parse_template($options_template, $stay); } $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->langs)); } $parse['input_extra'] = $input_extra; $parse['missionselector'] = $MissionSelector; $parse['stayblock'] = $StayBlock; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet3_table'), $parse)); }