/** * method stay_mission * param $fleet_row * return the stay result */ public function stay_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0) { if ($fleet_row['fleet_start_time'] <= time()) { $transport_check = parent::$db->query_fetch("SELECT pc1.`planet_user_id` AS start_id,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_name` AS start_name,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_user_id` AS target_id,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_name` AS target_name\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc1, " . PLANETS . " AS pc2\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc1.planet_ = '" . $fleet_row['fleet_start_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_system` = '" . $fleet_row['fleet_start_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_planet` = '" . $fleet_row['fleet_start_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_type` = '" . $fleet_row['fleet_start_type'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_type` = '" . $fleet_row['fleet_end_type'] . "'"); // SOME REQUIRED VALUES $start_name = $transport_check['start_id']; $start_owner_id = $transport_check['start_name']; $target_name = $transport_check['target_id']; $target_owner_id = $transport_check['target_name']; // DIFFERENT TYPES OF MESSAGES $message[1] = sprintf($this->_lang['sys_tran_mess_owner'], $target_name, Fleets_Lib::target_link($fleet_row, ''), $fleet_row['fleet_resource_metal'], $this->_lang['Metal'], $fleet_row['fleet_resource_crystal'], $this->_lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $this->_lang['Deuterium']); $message[2] = sprintf($this->_lang['sys_tran_mess_user'], $start_name, Fleets_Lib::start_link($fleet_row, ''), $target_name, Fleets_Lib::target_link($fleet_row, ''), $fleet_row['fleet_resource_metal'], $this->_lang['Metal'], $fleet_row['fleet_resource_crystal'], $this->_lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $this->_lang['Deuterium']); $message[3] = sprintf($this->_lang['sys_tran_mess_back'], $start_name, Fleets_Lib::start_link($fleet_row, '')); $this->stay_message($start_owner_id, $message[1], $fleet_row['fleet_start_time'], $this->_lang['sys_mess_transport']); $this->stay_message($target_owner_id, $message[2], $fleet_row['fleet_start_time'], $this->_lang['sys_mess_transport']); $this->start_stay($fleet_row['fleet_id']); } if ($fleet_row['fleet_end_stay'] <= time()) { parent::return_fleet($fleet_row['fleet_id']); } } if ($fleet_row['fleet_end_time'] < time()) { $this->stay_message($start_owner_id, $message, $fleet_row['fleet_end_time'], $this->_lang['sys_mess_fleetback']); parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method recycle_mission * param $fleet_row * return the recycle result */ public function recycle_mission($fleet_row) { if ($fleet_row['fleet_mess'] == '0') { if ($fleet_row['fleet_start_time'] <= time()) { $recycled_resources = $this->calculate_capacity($fleet_row); parent::$db->query("UPDATE " . PLANETS . ", " . FLEETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`planet_debris_metal` = `planet_debris_metal` - '" . $recycled_resources['metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` - '" . $recycled_resources['crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = `fleet_resource_metal` + '" . $recycled_resources['metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = `fleet_resource_crystal` + '" . $recycled_resources['crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1 AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`fleet_id` = '" . (int) $fleet_row['fleet_id'] . "'"); $message = sprintf($this->_lang['sys_recy_gotten'], Format_Lib::pretty_number($recycled_resources['metal']), $this->_lang['Metal'], Format_Lib::pretty_number($recycled_resources['crystal']), $this->_lang['Crystal']); $this->recycle_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_start_time'], $this->_lang['sys_recy_report']); } } elseif ($fleet_row['fleet_end_time'] <= time()) { $message = sprintf($this->_lang['sys_tran_mess_owner'], $TargetName, Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']); $this->recycle_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_end_time'], $this->_lang['sys_mess_fleetback']); parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method colonize_mission * param $fleet_row * return the colonization result */ public function colonize_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0) { $colonization_check = parent::$db->query_fetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc1.`planet_user_id` = '" . $fleet_row['fleet_owner'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_type` = '1' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_destroyed` = '0') AS planet_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc2.`planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_planet` = '" . $fleet_row['fleet_end_planet'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_type` = 1') AS galaxy_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT `research_astrophysics`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . RESEARCH . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `research_user_id` = '" . $fleet_row['fleet_owner'] . "') AS astro_level"); // SOME REQUIRED VALUES $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); $max_colonies = Fleets_Lib::get_max_colonies($colonization_check['astro_level']); $planet_count = $colonization_check['planet_count'] - 1; // THE TOTAL AMOUNT OF PLANETS MINUS 1 (BECAUSE THE MAIN PLANET IT'S NOT CONSIDERED) // DIFFERENT TYPES OF MESSAGES $message[1] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_maxcolo'] . ($max_colonies + 1) . $this->_lang['sys_colo_planet']; $message[2] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_allisok']; $message[3] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_notfree']; $message[4] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_astro_level']; if ($colonization_check['galaxy_count'] == 0) { if ($planet_count >= $max_colonies) { $this->colonize_message($fleet_row['fleet_owner'], $message[1], $fleet_row['fleet_start_time']); parent::return_fleet($fleet_row['fleet_id']); } elseif (!$this->position_allowed($fleet_row['fleet_end_planet'], $colonization_check['astro_level'])) { $this->colonize_message($fleet_row['fleet_owner'], $message[4], $fleet_row['fleet_start_time']); parent::return_fleet($fleet_row['fleet_id']); } else { if ($this->start_creation($fleet_row)) { $this->colonize_message($fleet_row['fleet_owner'], $message[2], $fleet_row['fleet_start_time']); if ($fleet_row['fleet_amount'] == 1) { parent::$db->query("UPDATE " . USERS_STATISTICS . " AS us SET\n\t\t\t\t\t\t\t\t\t\t\t\t\tus.`user_statistic_ships_points` = us.`user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE us.`user_statistic_user_id` = (SELECT p.planet_user_id FROM " . PLANETS . " AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.planet_galaxy = '" . $fleet_row['fleet_start_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_system = '" . $fleet_row['fleet_start_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_planet = '" . $fleet_row['fleet_start_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_type = '" . $fleet_row['fleet_start_type'] . "');"); parent::store_resources($fleet_row); parent::remove_fleet($fleet_row['fleet_id']); } else { parent::store_resources($fleet_row); parent::$db->query("UPDATE " . FLEETS . ", " . USERS_STATISTICS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_array` = '" . $this->build_new_fleet($fleet_row['fleet_array']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_amount` = `fleet_amount` - 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_deuterium` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_ships_points` = `user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_id` = '" . $fleet_row['fleet_id'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_user_id` = (SELECT planet_user_id FROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE planet_galaxy = '" . $fleet_row['fleet_start_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = '" . $fleet_row['fleet_start_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . $fleet_row['fleet_start_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = '" . $fleet_row['fleet_start_type'] . "');"); } } else { $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']); parent::return_fleet($fleet_row['fleet_id']); } } } else { $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']); parent::return_fleet($fleet_row['fleet_id']); } } if ($fleet_row['fleet_end_time'] < time()) { parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method flying_fleets_table * param * return the fleets table */ private function flying_fleets_table() { $table = ''; $i = 0; while ($fleet = parent::$db->fetch_array($this->_flying_fleets)) { $block['num'] = ++$i; $block['mission'] = $this->resources_pop_up($this->_lang['ff_type_mission'][$fleet['fleet_mission']] . ' ' . (Fleets_Lib::is_fleet_returning($fleet) ? $this->_lang['ff_r'] : $this->_lang['ff_a']), $fleet); $block['amount'] = $this->ships_pop_up($this->_lang['ff_ships'], $fleet); $block['beginning'] = Format_Lib::pretty_coords($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet']); $block['departure'] = date(Functions_Lib::read_config('date_format_extended'), $fleet['fleet_creation']); $block['objective'] = Format_Lib::pretty_coords($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet']); $block['arrival'] = date(Functions_Lib::read_config('date_format_extended'), $fleet['fleet_start_time']); $block['return'] = date(Functions_Lib::read_config('date_format_extended'), $fleet['fleet_end_time']); $table .= parent::$page->parse_template(parent::$page->get_template('adm/fleet_rows_view'), $block); } return $table; }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->get_objects(); $pricelist = parent::$objects->get_price(); $reslist = parent::$objects->get_objects_list(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $getCurrentAcs = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ACS_FLEETS . "\r\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}"])) { Functions_Lib::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'] += Fleets_Lib::ship_consumption($i, $this->_current_user); $fleet['speed'] = Fleets_Lib::fleet_max_speed('', $i, $this->_current_user); $fleet['capacity'] = $pricelist[$i]['capacity']; $fleet['ship'] = $_POST["ship{$i}"]; $speedalls[$i] = Fleets_Lib::fleet_max_speed('', $i, $this->_current_user); $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet); } } } if (!$fleet['fleetlist']) { Functions_Lib::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'] = Functions_Lib::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 (Officiers_Lib::is_officier_active($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'] = Functions_Lib::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->fetch_array($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)); }
/** * method astrophysics_table * param * return builds the astrophysics table */ private function astrophysics_table($template) { $CurrentBuildtLvl = $this->_current_user[$this->_resource[$this->_element_id]]; $BuildStartLvl = max(1, $CurrentBuildtLvl - 2); $Table = ""; for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; ++$BuildLevel) { $bloc['tech_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; $bloc['tech_colonies'] = Format_Lib::pretty_number(Fleets_Lib::get_max_colonies($BuildLevel)); $bloc['tech_expeditions'] = Format_Lib::pretty_number(Fleets_Lib::get_max_expeditions($BuildLevel)); $Table .= parent::$page->parse_template($template, $bloc); } return $Table; }
/** * method get_fleet_movements * param * return fleets movements rows */ private function get_fleet_movements() { $fleet = ''; $fleet_row = ''; $record = 0; $record1 = 0; $record2 = 2000; $own_fleets = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . (int) $this->_current_user['user_id'] . "' OR\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $this->_current_user['user_id'] . "';"); while ($fleets = parent::$db->fetch_array($own_fleets)) { ###################################### # # own fleets # ###################################### $start_time = $fleets['fleet_start_time']; $stay_time = $fleets['fleet_end_stay']; $end_time = $fleets['fleet_end_time']; $target_galaxy = $fleets['fleet_end_galaxy']; $target_system = $fleets['fleet_end_system']; $target_planet = $fleets['fleet_end_planet']; $fleet_status = $fleets['fleet_mess']; $fleet_group = $fleets['fleet_group']; $id = $fleets['fleet_id']; if ($fleets['fleet_owner'] == $this->_current_user['user_id']) { $record++; $label = 'fs'; if ($start_time > time()) { $fleet_row[$start_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 0, TRUE, $label, $record, $this->_current_user); } if ($fleets['fleet_mission'] != 4 && $fleets['fleet_mission'] != 10) { $label = 'ft'; if ($stay_time > time()) { $fleet_row[$stay_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 1, TRUE, $label, $record, $this->_current_user); } $label = 'fe'; if ($end_time > time()) { $fleet_row[$end_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 2, TRUE, $label, $record, $this->_current_user); } } if ($fleets['fleet_mission'] == 4 && $start_time < time() && $end_time > time()) { $fleet_row[$end_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 2, TRUE, 'none', $record, $this->_current_user); } } ###################################### # # incoming fleets # ###################################### if ($fleets['fleet_owner'] != $this->_current_user['user_id']) { if ($fleets['fleet_mission'] == 2) { $record1++; $start_time = $fleet_status > 0 ? '' : $fleets['fleet_start_time']; if ($start_time > time()) { $fleet_row[$start_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 0, FALSE, 'ofs', $record1, $this->_current_user); } } if ($fleets['fleet_mission'] == 1 && $fleet_group > 0) { $record++; if ($fleet_status > 0) { $start_time = ''; } else { $start_time = $fleets['fleet_start_time']; } if ($start_time > time()) { $fleet_row[$start_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 0, FALSE, 'ofs', $record, $this->_current_user); } } } ###################################### # # other fleets # ###################################### if ($fleets['fleet_owner'] != $this->_current_user['user_id']) { if ($fleets['fleet_mission'] != 8) { $record2++; $start_time = $fleets['fleet_start_time']; $stay_time = $fleets['fleet_end_stay']; $id = $fleets['fleet_id']; if ($start_time > time()) { $fleet_row[$start_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 0, FALSE, 'ofs', $record, $this->_current_user); } if ($fleets['fleet_mission'] == 5) { if ($stay_time > time()) { $fleet_row[$stay_time . $id] = Fleets_Lib::flying_fleets_table($fleets, 1, FALSE, 'oft', $record, $this->_current_user); } } } } } parent::$db->free_result($own_fleets); if (count($fleet_row) > 0 && $fleet_row != '') { ksort($fleet_row); foreach ($fleet_row as $time => $content) { $fleet .= $content . "\n"; } } return $fleet; }
/** * method attack_mission * param $fleet_row * return the attack result */ public function attack_mission($fleet_row) { $targetPlanet = parent::$db->query_fetch("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = " . (int) $fleet_row['fleet_end_galaxy'] . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = " . (int) $fleet_row['fleet_end_system'] . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = " . (int) $fleet_row['fleet_end_type'] . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = " . (int) $fleet_row['fleet_end_planet'] . ";"); if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) { if ($fleet_row['fleet_group'] > 0) { parent::$db->query("DELETE FROM " . ACS_FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\tWHERE acs_fleet_id =" . intval($fleet_row['fleet_group'])); parent::$db->query("UPDATE `" . FLEETS . "` SET\r\n\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = " . $fleet_row['fleet_group']); } else { parent::return_fleet($fleet_row['fleet_id']); } $targetUser = parent::$db->query_fetch('SELECT u.*, r.research_energy_technology, pr.premium_officier_geologist, pr.premium_officier_engineer FROM ' . USERS . ' AS u INNER JOIN ' . RESEARCH . ' AS r ON r.research_user_id = u.user_id INNER JOIN ' . PREMIUM . ' AS pr ON pr.premium_user_id = u.user_id WHERE u.user_id = ' . intval($targetPlanet['planet_user_id'])); UpdateResources_Lib::update_resource($targetUser, $targetPlanet, time()); $targetGalaxy = parent::$db->query_fetch('SELECT `planet_id` FROM ' . PLANETS . ' WHERE `planet_galaxy` = ' . intval($fleet_row['fleet_end_galaxy']) . ' AND `planet_system` = ' . intval($fleet_row['fleet_end_system']) . ' AND `planet_planet` = ' . intval($fleet_row['fleet_end_planet']) . ' AND `planet_type` = 3;'); $targetUser = parent::$db->query_fetch('SELECT u.*, r.research_weapons_technology, r.research_shielding_technology, r.research_armour_technology, pr.premium_officier_technocrat FROM ' . USERS . ' AS u INNER JOIN ' . RESEARCH . ' AS r ON r.research_user_id = u.user_id INNER JOIN ' . PREMIUM . ' AS pr ON pr.premium_user_id = u.user_id WHERE u.user_id = ' . intval($targetPlanet['planet_user_id'])); $TargetUserID = $targetUser['user_id']; $attackFleets = array(); if ($fleet_row['fleet_group'] != 0) { $fleets = parent::$db->query('SELECT * FROM ' . FLEETS . ' WHERE fleet_group=' . $fleet_row['fleet_group']); if ($fleets != NULL) { while ($fleet = parent::$db->fetch_assoc($fleets)) { $attackFleets[$fleet['fleet_id']]['fleet'] = $fleet; $attackFleets[$fleet['fleet_id']]['user'] = parent::$db->query_fetch('SELECT u.*, r.research_weapons_technology, r.research_shielding_technology, r.research_armour_technology FROM ' . USERS . ' AS u INNER JOIN ' . RESEARCH . ' AS r ON r.research_user_id = u.user_id WHERE user_id=' . intval($fleet_row['fleet_owner'])); $attackFleets[$fleet['fleet_id']]['detail'] = array(); $temp = explode(';', $fleet['fleet_array']); foreach ($temp as $temp2) { $temp2 = explode(',', $temp2); if ($temp2[0] < 100) { continue; } if (!isset($attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]])) { $attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] = 0; } $attackFleets[$fleet['fleet_id']]['detail'][$temp2[0]] += $temp2[1]; } } } } else { $attackFleets[$fleet_row['fleet_id']]['fleet'] = $fleet_row; $attackFleets[$fleet_row['fleet_id']]['user'] = parent::$db->query_fetch('SELECT u.*, r.research_weapons_technology, r.research_shielding_technology, r.research_armour_technology FROM ' . USERS . ' AS u INNER JOIN ' . RESEARCH . ' AS r ON r.research_user_id = u.user_id WHERE user_id=' . intval($fleet_row['fleet_owner'])); $attackFleets[$fleet_row['fleet_id']]['detail'] = array(); $temp = explode(';', $fleet_row['fleet_array']); foreach ($temp as $temp2) { $temp2 = explode(',', $temp2); if ($temp2[0] < 100) { continue; } if (!isset($attackFleets[$fleet_row['fleet_id']]['detail'][$temp2[0]])) { $attackFleets[$fleet_row['fleet_id']]['detail'][$temp2[0]] = 0; } $attackFleets[$fleet_row['fleet_id']]['detail'][$temp2[0]] += $temp2[1]; } } $defense = array(); $def = parent::$db->query_fetch('SELECT * FROM ' . FLEETS . ' WHERE `fleet_end_galaxy` = ' . intval($fleet_row['fleet_end_galaxy']) . ' AND `fleet_end_system` = ' . intval($fleet_row['fleet_end_system']) . ' AND `fleet_end_type` = ' . intval($fleet_row['fleet_end_type']) . ' AND `fleet_end_planet` = ' . intval($fleet_row['fleet_end_planet']) . ' AND fleet_start_time<' . time() . ' AND fleet_end_stay>=' . time()); if ($def != NULL) { while ($defRow = parent::$db->fetch_assoc($def)) { $defRowDef = explode(';', $defRow['fleet_array']); foreach ($defRowDef as $Element) { $Element = explode(',', $Element); if ($Element[0] < 100) { continue; } if (!isset($defense[$defRow['fleet_id']]['def'][$Element[0]])) { $defense[$defRow['fleet_id']][$Element[0]] = 0; } $defense[$defRow['fleet_id']]['def'][$Element[0]] += $Element[1]; $defense[$defRow['fleet_id']]['user'] = parent::$db->query_fetch('SELECT * FROM ' . USERS . ' WHERE user_id = ' . intval($defRow['fleet_owner'])); } } } $defense[0]['def'] = array(); $defense[0]['user'] = $targetUser; for ($i = 200; $i < 500; $i++) { if (isset($this->_resource[$i]) && isset($targetPlanet[$this->_resource[$i]])) { $defense[0]['def'][$i] = $targetPlanet[$this->_resource[$i]]; } } $start = microtime(TRUE); $result = $this->acs_attack($attackFleets, $defense); $totaltime = microtime(TRUE) - $start; parent::$db->query("UPDATE " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t`planet_invisible_start_time` = '" . time() . "',\r\n\t\t\t\t\t\t\t\t\t`planet_debris_metal` = `planet_debris_metal` +'" . ($result['debree']['att'][0] + $result['debree']['def'][0]) . "',\r\n\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` + '" . ($result['debree']['att'][1] + $result['debree']['def'][1]) . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1\r\n\t\t\t\t\t\t\t\t\tLIMIT 1;"); $totalDebree = $result['debree']['def'][0] + $result['debree']['def'][1] + $result['debree']['att'][0] + $result['debree']['att'][1]; $steal = array('metal' => 0, 'crystal' => 0, 'deuterium' => 0); if ($result['won'] == "a") { $steal = $this->acs_steal($attackFleets, $targetPlanet); } foreach ($attackFleets as $fleetID => $attacker) { $fleetArray = ''; $totalCount = 0; foreach ($attacker['detail'] as $element => $amount) { if ($amount) { $fleetArray .= $element . ',' . $amount . ';'; } $totalCount += $amount; } if ($totalCount <= 0) { parent::remove_fleet($fleetID); } else { parent::$db->query('UPDATE ' . FLEETS . ' SET fleet_array="' . substr($fleetArray, 0, -1) . '", fleet_amount=' . $totalCount . ', fleet_mess=1 WHERE fleet_id=' . intval($fleetID)); } } foreach ($defense as $fleetID => $defender) { if ($fleetID != 0) { $fleetArray = ''; $totalCount = 0; foreach ($defender['def'] as $element => $amount) { if ($amount) { $fleetArray .= $element . ',' . $amount . ';'; } $totalCount += $amount; } if ($totalCount <= 0) { parent::remove_fleet($fleetID); } else { parent::$db->query("UPDATE " . FLEETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\tfleet_array='{$fleetArray}',\r\n\t\t\t\t\t\t\t\t\t\t\t\tfleet_amount='{$totalCount}'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE fleet_id='{$fleetID}'"); } } else { $fleetArray = ''; $totalCount = 0; foreach ($defender['def'] as $element => $amount) { $fleetArray .= '`' . $this->_resource[$element] . '`=' . $amount . ', '; } parent::$db->query("UPDATE " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id` SET\r\n\t\t\t\t\t\t\t\t\t\t\t{$fleetArray}\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - '" . $steal['metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - '" . $steal['crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - '" . $steal['deuterium'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $fleet_row['fleet_end_type'] . "';"); } } $FleetDebris = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1]; $StrAttackerUnits = sprintf($this->_lang['sys_attacker_lostunits'], $result['lost']['att']); $StrDefenderUnits = sprintf($this->_lang['sys_defender_lostunits'], $result['lost']['def']); $StrRuins = sprintf($this->_lang['sys_gcdrunits'], $result['debree']['def'][0] + $result['debree']['att'][0], $this->_lang['Metal'], $result['debree']['def'][1] + $result['debree']['att'][1], $this->_lang['Crystal']); $DebrisField = $StrAttackerUnits . "<br />" . $StrDefenderUnits . "<br />" . $StrRuins; $MoonChance = $FleetDebris / 100000; if ($FleetDebris > 2000000) { $MoonChance = 20; $UserChance = mt_rand(1, 100); $ChanceMoon = sprintf($this->_lang['sys_moonproba'], $MoonChance); } elseif ($FleetDebris < 100000) { $UserChance = 0; $ChanceMoon = sprintf($this->_lang['sys_moonproba'], $MoonChance); } elseif ($FleetDebris >= 100000) { $UserChance = mt_rand(1, 100); $ChanceMoon = sprintf($this->_lang['sys_moonproba'], $MoonChance); } if ($UserChance > 0 && $UserChance <= $MoonChance && $targetGalaxy['id'] == 0) { include_once XGP_ROOT . 'application/libraries/Creator_Lib.php'; $creator = new Creator_Lib(); $TargetPlanetName = $creator->create_moon($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $TargetUserID, $fleet_row['fleet_start_time'], '', $MoonChance); $GottenMoon = sprintf($this->_lang['sys_moonbuilt'], $TargetPlanetName, $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); $GottenMoon .= "<br />"; } elseif ($UserChance = 0 or $UserChance > $MoonChance) { $GottenMoon = ""; } $formatted_cr = $this->build_report($result, $steal, $MoonChance, $GottenMoon, $totaltime); $raport = $formatted_cr['html']; $rid = md5($raport); $QryInsertRapport = 'INSERT INTO ' . REPORTS . ' SET '; $QryInsertRapport .= '`report_time` = UNIX_TIMESTAMP(), '; foreach ($attackFleets as $fleetID => $attacker) { $users2[$attacker['user']['user_id']] = $attacker['user']['user_id']; } foreach ($defense as $fleetID => $defender) { $users2[$defender['user']['user_id']] = $defender['user']['user_id']; } $QryInsertRapport .= '`report_owners` = "' . implode(',', $users2) . '", '; $QryInsertRapport .= '`report_rid` = "' . $rid . '", '; $QryInsertRapport .= '`report_destroyed` = "' . $formatted_cr['destroyed'] . '", '; $QryInsertRapport .= '`report_content` = "' . parent::$db->escape_value($raport) . '"'; parent::$db->query($QryInsertRapport); if ($result['won'] == "a") { $style = "green"; } elseif ($result['won'] == "w") { $style = "orange"; } elseif ($result['won'] == "r") { $style = "red"; } $raport = "<a href=\"#\" style=\"color:" . $style . ";\" OnClick=\\'f(\"game.php?page=CombatReport&report=" . $rid . "\", \"\");\\' >" . $this->_lang['sys_mess_attack_report'] . " [" . $fleet_row['fleet_end_galaxy'] . ":" . $fleet_row['fleet_end_system'] . ":" . $fleet_row['fleet_end_planet'] . "]</a>"; Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], 1, $this->_lang['sys_mess_tower'], $raport, ''); if ($result['won'] == "a") { $style = "red"; } elseif ($result['won'] == "w") { $style = "orange"; } elseif ($result['won'] == "r") { $style = "lime"; } $raport2 = "<a href=\"#\" style=\"color:" . $style . ";\" OnClick=\\'f(\"game.php?page=CombatReport&report=" . $rid . "\", \"\");\\' >" . $this->_lang['sys_mess_attack_report'] . " [" . $fleet_row['fleet_end_galaxy'] . ":" . $fleet_row['fleet_end_system'] . ":" . $fleet_row['fleet_end_planet'] . "]</a>"; foreach ($users2 as $id) { if ($id != $fleet_row['fleet_owner'] && $id != 0) { Functions_Lib::send_message($id, '', $fleet_row['fleet_start_time'], 1, $this->_lang['sys_mess_tower'], $raport2, ''); } } } elseif ($fleet_row['fleet_end_time'] <= time()) { $Message = sprintf($this->_lang['sys_fleet_won'], $targetPlanet['planet_name'], Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']); Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 1, $this->_lang['sys_mess_tower'], $this->_lang['sys_mess_fleetback'], $Message); parent::restore_fleet($fleet_row); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->get_objects(); $reslist = parent::$objects->get_objects_list(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $count = parent::$db->query_fetch("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 = Fleets_Lib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } $MaxFlottes = Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']); $missiontype = Fleets_Lib::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'] = Fleets_Lib::fleet_max_speed("", $i, $this->_current_user); } $ships['ship'] = $this->_lang['tech'][$i]; $ships['amount'] = Format_Lib::pretty_number($this->_current_planet[$resource[$i]]); $inputs['i'] = $i; $inputs['maxship'] = $this->_current_planet[$resource[$i]]; $inputs['consumption'] = Fleets_Lib::ship_consumption($i, $this->_current_user); $inputs['speed'] = Fleets_Lib::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 attack_mission * param $fleet_row * return the attack result */ public function attack_mission($fleet_row) { // null == use default handlers $errorHandler = null; $exceptionHandler = null; if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) { $base = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR; require $base . 'utils' . DIRECTORY_SEPARATOR . 'includer.php'; $target_planet = parent::$db->query_fetch("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = " . (int) $fleet_row['fleet_end_galaxy'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = " . (int) $fleet_row['fleet_end_system'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = " . (int) $fleet_row['fleet_end_type'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = " . (int) $fleet_row['fleet_end_planet'] . ";"); if ($fleet_row['fleet_group'] > 0) { parent::$db->query("DELETE FROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $fleet_row['fleet_group'] . "'"); parent::$db->query("UPDATE `" . FLEETS . "` SET\n\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_row['fleet_group'] . "'"); } else { parent::return_fleet($fleet_row['fleet_id']); } $target_user = doquery('SELECT * FROM {{table}} WHERE id=' . $target_planet['id_owner'], 'users', true); $target_userID = $target_user['id']; PlanetResourceUpdate($target_user, $target_planet, time()); // attackers fleet sum $attackers = new PlayerGroup(); if ($fleet_row['fleet_group'] != 0) { $fleets = doquery('SELECT * FROM {{table}} WHERE fleet_group=' . $fleet_row['fleet_group'], 'fleets'); $attackers = get_player_group_from_query($fleets); } else { $attackers = get_player_group($fleet_row); } //defenders fleet sum $def = doquery('SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = ' . $fleet_row['fleet_end_galaxy'] . ' AND `fleet_end_system` = ' . $fleet_row['fleet_end_system'] . ' AND `fleet_end_type` = ' . $fleet_row['fleet_end_type'] . ' AND `fleet_end_planet` = ' . $fleet_row['fleet_end_planet'] . ' AND fleet_start_time<' . time() . ' AND fleet_end_stay>=' . time(), 'fleets'); $defenders = get_player_group_from_query($def, true, $target_user); //defenses sum $homeFleet = new HomeFleet(0); for ($i = self::DEFENSE_MIN_ID; $i < self::DEFENSE_MAX_ID; $i++) { if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) { if ($target_planet[$this->_resource[$i]] != 0) { $homeFleet->add(get_ship_type($i, $target_planet[$this->_resource[$i]])); } } } for ($i = self::SHIP_MIN_ID; $i < self::SHIP_MAX_ID; $i++) { if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) { if ($target_planet[$this->_resource[$i]] != 0) { $homeFleet->add(get_ship_type($i, $target_planet[$this->_resource[$i]])); } } } if (!$defenders->existPlayer($target_userID)) { $player = new Player($target_userID, array($homeFleet)); $player->setTech($target_user['military_tech'], $target_user['shield_tech'], $target_user['defence_tech']); $defenders->addPlayer($player); } else { $defenders->getPlayer($target_userID)->addDefense($homeFleet); } //start of battle $battle = new Battle($attackers, $defenders); $startBattle = DebugManager::runDebugged(array($battle, 'startBattle'), $errorHandler, $exceptionHandler); $startBattle(); //end of battle $report = $battle->getReport(); $steal = $this->update_attackers($report->getPresentationAttackersFleetOnRound('START'), $report->getAfterBattleAttackers(), $target_planet); $this->update_defenders($report->getPresentationDefendersFleetOnRound('START'), $report->getAfterBattleDefenders(), $target_planet, $steal); $this->updateDebris($fleet_row, $report); $this->update_moon($fleet_row, $report, '', $target_userID, $target_planet); $this->send_message($fleet_row, $report); } elseif ($fleet_row['fleet_end_time'] <= time()) { $message = sprintf($this->_lang['sys_fleet_won'], $target_planet['planet_name'], Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']); Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 1, $this->_lang['sys_mess_tower'], $this->_lang['sys_mess_fleetback'], $message); parent::restore_fleet($fleet_row); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $parse = $this->_lang; /* range */ $radar_limit_inf = $this->_current_planet['planet_system'] - $this->_formula->phalanx_range($this->_current_planet['building_phalanx']); $radar_limit_sup = $this->_current_planet['planet_system'] + $this->_formula->phalanx_range($this->_current_planet['building_phalanx']); $radar_limit_inf = max($radar_limit_inf, 1); $radar_limit_sup = min($radar_limit_sup, MAX_SYSTEM_IN_GALAXY); /* input validation */ $Galaxy = (int) $_GET['galaxy']; $System = (int) $_GET['system']; $Planet = (int) $_GET['planet']; $PlType = (int) $_GET['planettype']; /* cheater detection */ if ($System < $radar_limit_inf or $System > $radar_limit_sup or $Galaxy != $this->_current_planet['planet_galaxy'] or $PlType != 1 or $this->_current_planet['planet_type'] != 3) { Functions_Lib::redirect('game.php?page=galaxy'); } /* main page */ if ($this->_current_planet['planet_deuterium'] > 10000) { parent::$db->query("UPDATE " . PLANETS . " SET\n \t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - '10000'\n \t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_user['user_current_planet'] . "';"); $TargetInfo = parent::$db->query_fetch("SELECT `planet_name`, `planet_user_id`\n \t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n \t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $Galaxy . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $System . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $Planet . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1"); $TargetID = $TargetInfo['planet_user_id']; $TargetName = $TargetInfo['planet_name']; $TargetInfo = parent::$db->query_fetch("SELECT `planet_destroyed`\n \t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n \t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $Galaxy . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $System . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $Planet . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 3 "); //if there isn't a moon, if ($TargetInfo === false) { $TargetMoonIsDestroyed = true; } else { $TargetMoonIsDestroyed = $TargetInfo['planet_destroyed'] !== 0; } $FleetToTarget = parent::$db->query("SELECT *\n \t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n \t\t\t\t\t\t\t\t\t\tWHERE ( ( `fleet_start_galaxy` = '" . $Galaxy . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_start_system` = '" . $System . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_start_planet` = '" . $Planet . "' ) OR\n \t\t\t\t\t\t\t\t\t\t\t\t( `fleet_end_galaxy` = '" . $Galaxy . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_system` = '" . $System . "' AND\n \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_planet` = '" . $Planet . "' )\n \t\t\t\t\t\t\t\t\t\t\t ) ;"); $Record = 0; $fpage = array(); while ($FleetRow = parent::$db->fetch_array($FleetToTarget)) { $Record++; $ArrivetoTargetTime = $FleetRow['fleet_start_time']; $EndStayTime = $FleetRow['fleet_end_stay']; $ReturnTime = $FleetRow['fleet_end_time']; $Mission = $FleetRow['fleet_mission']; $myFleet = $FleetRow['fleet_owner'] == $TargetID ? true : false; $FleetRow['fleet_resource_metal'] = 0; $FleetRow['fleet_resource_crystal'] = 0; $FleetRow['fleet_resource_deuterium'] = 0; $isStartedfromThis = $FleetRow['fleet_start_galaxy'] == $Galaxy && $FleetRow['fleet_start_system'] == $System && $FleetRow['fleet_start_planet'] == $Planet; $isTheTarget = $FleetRow['fleet_end_galaxy'] == $Galaxy && $FleetRow['fleet_end_system'] == $System && $FleetRow['fleet_end_planet'] == $Planet; /* 1)the arrive to target fleet table event * you can see start-fleet event only if this is a planet(or destroyed moon) * and if the fleet mission started from this planet is different from hold * or if it's a enemy mission. */ if ($ArrivetoTargetTime > time()) { //scannig of fleet started planet if ($isStartedfromThis && ($FleetRow['fleet_start_type'] == 1 || $FleetRow['fleet_start_type'] == 3 && $TargetMoonIsDestroyed)) { if ($Mission != 4) { $Label = "fs"; $fpage[$ArrivetoTargetTime] .= "\n" . Fleets_Lib::flying_fleets_table($FleetRow, 0, $myFleet, $Label, $Record, $this->_current_user); } } elseif (!$isStartedfromThis && ($FleetRow['fleet_end_type'] == 1 || $FleetRow['fleet_end_type'] == 3 && $TargetMoonIsDestroyed)) { $Label = "fs"; $fpage[$ArrivetoTargetTime] .= "\n" . Fleets_Lib::flying_fleets_table($FleetRow, 0, $myFleet, $Label, $Record, $this->_current_user); } } /* 2)the stay fleet table event * you can see stay-fleet event only if the target is a planet(or destroyed moon) and is the targetPlanet */ if ($EndStayTime > time() && $Mission == 5 && ($FleetRow['fleet_end_type'] == 1 || $FleetRow['fleet_end_type'] == 3 && $TargetMoonIsDestroyed) && $isTheTarget) { $Label = "ft"; $fpage[$EndStayTime] .= "\n" . Fleets_Lib::flying_fleets_table($FleetRow, 1, $myFleet, $Label, $Record, $this->_current_user); } /* 3)the return fleet table event * you can see the return fleet if this is the started planet(or destroyed moon) * but no if it is a hold mission or mip */ if ($ReturnTime > time() && $Mission != 4 && $Mission != 10 && $isStartedfromThis && ($FleetRow['fleet_start_type'] == 1 || $FleetRow['fleet_start_type'] == 3 && $TargetMoonIsDestroyed)) { $Label = "fe"; $fpage[$ReturnTime] .= "\n" . Fleets_Lib::flying_fleets_table($FleetRow, 2, $myFleet, $Label, $Record, $this->_current_user); } } ksort($fpage); foreach ($fpage as $FleetTime => $FleetContent) { $Fleets .= $FleetContent . "\n"; } $parse['phl_fleets_table'] = $Fleets; $parse['phl_er_deuter'] = ""; } else { $parse['phl_er_deuter'] = $this->_lang['px_no_deuterium']; } $parse['phl_pl_galaxy'] = $Galaxy; $parse['phl_pl_system'] = $System; $parse['phl_pl_place'] = $Planet; $parse['phl_pl_name'] = $TargetName; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('galaxy/phalanx_body'), $parse), FALSE, '', FALSE); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->get_objects(); $pricelist = parent::$objects->get_price(); $reslist = parent::$objects->get_objects_list(); $parse = $this->_lang; if (parent::$users->is_on_vacations($this->_current_user)) { exit(Functions_Lib::message($this->_lang['fl_vacation_mode_active'], "game.php?page=overview", 2)); } $fleet_group_mr = 0; if ($_POST['fleet_group'] > 0) { if ($_POST['mission'] == 2) { $target = 'g' . (int) $_POST['galaxy'] . 's' . (int) $_POST['system'] . 'p' . (int) $_POST['planet'] . 't' . (int) $_POST['planettype']; if ($_POST['acs_target_mr'] == $target) { $aks_count_mr = parent::$db->query("SELECT COUNT(`acs_fleet_id`)\n\t\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\t\tWHERE `acs_fleet_id` = '" . (int) $_POST['fleet_group'] . "'"); if ($aks_count_mr > 0) { $fleet_group_mr = $_POST['fleet_group']; } } } } if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) { $_POST['mission'] = 1; } $TargetPlanet = parent::$db->query_fetch("SELECT `planet_user_id`,`planet_destroyed`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `planet_galaxy` = '" . (int) $_POST['galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_system` = '" . (int) $_POST['system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_planet` = '" . (int) $_POST['planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_type` = '" . (int) $_POST['planettype'] . "';"); $MyDBRec = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = '" . $this->_current_user['user_id'] . "';"); $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet']))); if ($TargetPlanet['planet_destroyed'] != 0) { Functions_Lib::redirect('game.php?page=movement'); } if (!is_array($fleetarray)) { Functions_Lib::redirect('game.php?page=movement'); } foreach ($fleetarray as $Ship => $Count) { $Count = intval($Count); if ($Count > $this->_current_planet[$resource[$Ship]]) { Functions_Lib::redirect('game.php?page=movement'); } } $error = 0; $galaxy = (int) $_POST['galaxy']; $system = (int) $_POST['system']; $planet = (int) $_POST['planet']; $planettype = (int) $_POST['planettype']; $fleetmission = (int) $_POST['mission']; //fix by jstar if ($fleetmission == 7 && !isset($fleetarray[208])) { Functions_Lib::redirect('game.php?page=movement'); } if ($planettype != 1 && $planettype != 2 && $planettype != 3) { Functions_Lib::redirect('game.php?page=movement'); } //fix invisible debris like ogame by jstar if ($fleetmission == 8) { $YourPlanet = FALSE; $UsedPlanet = FALSE; $select = parent::$db->query_fetch("SELECT COUNT(*) AS count, p.*\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1;"); if ($select['planet_debris_metal'] == 0 && $select['planet_debris_crystal'] == 0 && time() > $select['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) { Functions_Lib::redirect('game.php?page=movement'); } } else { $YourPlanet = FALSE; $UsedPlanet = FALSE; $select = parent::$db->query_fetch("SELECT COUNT(*) AS count, p.`planet_user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planettype . "'"); } if ($this->_current_planet['planet_galaxy'] == $galaxy && $this->_current_planet['planet_system'] == $system && $this->_current_planet['planet_planet'] == $planet && $this->_current_planet['planet_type'] == $planettype) { Functions_Lib::redirect('game.php?page=movement'); } if ($_POST['mission'] != 15) { if ($select['count'] < 1 && $fleetmission != 7) { Functions_Lib::redirect('game.php?page=movement'); } elseif ($fleetmission == 9 && $select['count'] < 1) { Functions_Lib::redirect('game.php?page=movement'); } } else { $MaxExpedition = $this->_current_user[$resource[124]]; if ($MaxExpedition >= 1) { $maxexpde = parent::$db->query_fetch("SELECT COUNT(fleet_owner) AS `expedi`\n\t\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\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15';"); $ExpeditionEnCours = $maxexpde['expedi']; $EnvoiMaxExpedition = Fleets_Lib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } if ($EnvoiMaxExpedition == 0) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2); } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_fleets_limit'] . "</b></font>", "game.php?page=movement", 2); } } if ($select['planet_user_id'] == $this->_current_user['user_id']) { $YourPlanet = TRUE; $UsedPlanet = TRUE; } elseif (!empty($select['planet_user_id'])) { $YourPlanet = FALSE; $UsedPlanet = TRUE; } else { $YourPlanet = FALSE; $UsedPlanet = FALSE; } //fix by jstar if ($fleetmission == 9) { $countfleettype = count($fleetarray); if ($YourPlanet or !$UsedPlanet or $planettype != 3) { Functions_Lib::redirect('game.php?page=movement'); } elseif ($countfleettype == 1 && !isset($fleetarray[214])) { Functions_Lib::redirect('game.php?page=movement'); } elseif ($countfleettype == 2 && !isset($fleetarray[214])) { Functions_Lib::redirect('game.php?page=movement'); } elseif ($countfleettype > 2) { Functions_Lib::redirect('game.php?page=movement'); } } if (empty($fleetmission)) { Functions_Lib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] == '') { $HeDBRec = $MyDBRec; } elseif ($TargetPlanet['planet_user_id'] != '') { $HeDBRec = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $TargetPlanet['planet_user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` ='" . $TargetPlanet['planet_user_id'] . "';"); } $user_points = $this->_noob->return_points($MyDBRec['user_id'], $HeDBRec['user_id']); $MyGameLevel = $user_points['user_points']; $HeGameLevel = $user_points['target_points']; if ($HeDBRec['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) { if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) { Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_week_player'] . "</b></font>", "game.php?page=movement", 2); } if ($this->_noob->is_strong($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_strong_player'] . "</b></font>", "game.php?page=movement", 2); } } if ($HeDBRec['setting_vacations_status'] && $_POST['mission'] != 8) { Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2); } $FlyingFleets = parent::$db->query_fetch("SELECT COUNT(fleet_id) as Number\n\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\tWHERE `fleet_owner`='" . $this->_current_user['user_id'] . "'"); $ActualFleets = $FlyingFleets['Number']; if (Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) { Functions_Lib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1); } if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) { Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_empty_transport'] . "</b></font>", "game.php?page=movement", 1); } if ($_POST['mission'] != 15) { if ($TargetPlanet['planet_user_id'] == '' && $_POST['mission'] < 7) { Functions_Lib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_planet_populed'] . "</b></font>", "game.php?page=movement", 2); } if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $_POST['mission'] == 4) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2); } if ($TargetPlanet['planet_user_id'] == $this->_current_planet['planet_user_id'] && ($_POST['mission'] == 1 or $_POST['mission'] == 6)) { Functions_Lib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_deploy_only_your_planets'] . "</b></font>", "game.php?page=movement", 2); } if ($_POST['mission'] == 5) { $buddy = parent::$db->query_fetch("SELECT COUNT( * ) AS buddys\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . BUDDY . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_status =1"); if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $buddy['buddys'] < 1) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2); } } } $missiontype = Fleets_Lib::get_missions(); $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); $AllFleetSpeed = Fleets_Lib::fleet_max_speed($fleetarray, 0, $this->_current_user); $GenFleetSpeed = $_POST['speed']; $SpeedFactor = Functions_Lib::fleet_speed_factor(); $MaxFleetSpeed = min($AllFleetSpeed); if (!in_array($GenFleetSpeed, $speed_possible)) { Functions_Lib::redirect('game.php?page=movement'); } if ($MaxFleetSpeed != $_POST['speedallsmin']) { Functions_Lib::redirect('game.php?page=movement'); } if (!$_POST['planettype']) { Functions_Lib::redirect('game.php?page=movement'); } if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) { Functions_Lib::redirect('game.php?page=movement'); } if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) { Functions_Lib::redirect('game.php?page=movement'); } if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) { Functions_Lib::redirect('game.php?page=movement'); } if ($_POST['thisgalaxy'] != $this->_current_planet['planet_galaxy'] | $_POST['thissystem'] != $this->_current_planet['planet_system'] | $_POST['thisplanet'] != $this->_current_planet['planet_planet'] | $_POST['thisplanettype'] != $this->_current_planet['planet_type']) { Functions_Lib::redirect('game.php?page=movement'); } if (!isset($fleetarray)) { Functions_Lib::redirect('game.php?page=movement'); } $distance = Fleets_Lib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = Fleets_Lib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = Fleets_Lib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user); $fleet['start_time'] = $duration + time(); // START CODE BY JSTAR if ($_POST['mission'] == 15) { $StayDuration = floor($_POST['expeditiontime']); if ($StayDuration > 0) { $StayDuration = $StayDuration * 3600; $StayTime = $fleet['start_time'] + $StayDuration; } else { Functions_Lib::redirect('game.php?page=movement'); } } elseif ($_POST['mission'] == 5) { $StayDuration = $_POST['holdingtime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + time(); $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; //fix by jstar $haveSpyProbos = FALSE; foreach ($fleetarray as $Ship => $Count) { $Count = intval($Count); if ($Ship == 210) { $haveSpyProbos = TRUE; } $FleetStorage += $pricelist[$Ship]['capacity'] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", "; } if (!$haveSpyProbos && $_POST['mission'] == 6) { Functions_Lib::redirect('game.php?page=movement'); } $FleetStorage -= $consumption; $StorageNeeded = 0; $_POST['resource1'] = max(0, (int) trim($_POST['resource1'])); $_POST['resource2'] = max(0, (int) trim($_POST['resource2'])); $_POST['resource3'] = max(0, (int) trim($_POST['resource3'])); if ($_POST['resource1'] < 1) { $TransMetal = 0; } else { $TransMetal = $_POST['resource1']; $StorageNeeded += $TransMetal; } if ($_POST['resource2'] < 1) { $TransCrystal = 0; } else { $TransCrystal = $_POST['resource2']; $StorageNeeded += $TransCrystal; } if ($_POST['resource3'] < 1) { $TransDeuterium = 0; } else { $TransDeuterium = $_POST['resource3']; $StorageNeeded += $TransDeuterium; } $StockMetal = $this->_current_planet['planet_metal']; $StockCrystal = $this->_current_planet['planet_crystal']; $StockDeuterium = $this->_current_planet['planet_deuterium']; $StockDeuterium -= $consumption; $StockOk = FALSE; if ($StockMetal >= $TransMetal) { if ($StockCrystal >= $TransCrystal) { if ($StockDeuterium >= $TransDeuterium) { $StockOk = TRUE; } } } if (!$StockOk) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . Format_Lib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2); } if ($StorageNeeded > $FleetStorage) { Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . Format_Lib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2); } if (Functions_Lib::read_config('adm_attack') != 0) { Functions_Lib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2); } if ($fleet_group_mr != 0) { $AksStartTime = parent::$db->query_fetch("SELECT MAX(`fleet_start_time`) AS Start\n\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\tWHERE `fleet_group` = '" . $fleet_group_mr . "';"); if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t\t\t`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';"); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t`fleet_mission` = '" . (int) $_POST['mission'] . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . (int) $FleetShipCount . "',\n\t\t\t\t\t\t\t`fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . (int) $_POST['thisgalaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . (int) $_POST['thissystem'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . (int) $_POST['thisplanet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . (int) $_POST['thisplanettype'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . (int) $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . (int) $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . (int) $_POST['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . (int) $_POST['system'] . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . (int) $_POST['planet'] . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . (int) $_POST['planettype'] . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . $TransMetal . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . $TransCrystal . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . $TransDeuterium . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $TargetPlanet['planet_user_id'] . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . (int) $fleet_group_mr . "',\n\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';"); parent::$db->query("UPDATE `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . $TransMetal . ",\n\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . $TransCrystal . ",\n\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . ($TransDeuterium + $consumption) . "\n\t\t\t\t\t\t\t\tWHERE `planet_id` = " . $this->_current_planet['planet_id'] . ";"); Functions_Lib::redirect('game.php?page=movement'); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // ELEMENTS $resource = parent::$objects->get_objects(); // QUERYS $count = parent::$db->query_fetch("SELECT\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `actcnt`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "') AS max_fleet,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `expedi`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15') AS max_expeditions"); // 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 = Fleets_Lib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } $MaxFlottes = Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']); $missiontype = Fleets_Lib::get_missions(); $ShipData = ''; $parse['flyingfleets'] = $MaxFlyingFleets; $parse['maxfleets'] = $MaxFlottes; $parse['currentexpeditions'] = $ExpeditionEnCours; $parse['maxexpeditions'] = $EnvoiMaxExpedition; $i = 0; $flying_fleets = ''; if ($count['max_fleet'] != 0 or $MaxExpedition != 0) { $fq = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\tWHERE fleet_owner = '" . $this->_current_user['user_id'] . "'"); while ($f = parent::$db->fetch_array($fq)) { $i++; $parse['num'] = $i; $parse['fleet_mission'] = $missiontype[$f['fleet_mission']]; if (Fleets_Lib::is_fleet_returning($f)) { $parse['tooltip'] = $this->_lang['fl_returning']; $parse['title'] = $this->_lang['fl_r']; } else { $parse['tooltip'] = $this->_lang['fl_onway']; $parse['title'] = $this->_lang['fl_a']; } $fleet = explode(";", $f['fleet_array']); $e = 0; $parse['fleet'] = ''; foreach ($fleet as $a => $b) { if ($b != '') { $e++; $a = explode(",", $b); $parse['fleet'] .= $this->_lang['tech'][$a[0]] . ":" . $a[1] . "\n"; if ($e > 1) { $parse['fleet'] .= "\t"; } } } $parse['fleet_amount'] = Format_Lib::pretty_number($f['fleet_amount']); $parse['fleet_start'] = Format_Lib::pretty_coords($f['fleet_start_galaxy'], $f['fleet_start_system'], $f['fleet_start_planet']); $parse['fleet_start_time'] = date(Functions_Lib::read_config('date_format_extended'), $f['fleet_creation']); $parse['fleet_end'] = Format_Lib::pretty_coords($f['fleet_end_galaxy'], $f['fleet_end_system'], $f['fleet_end_planet']); $parse['fleet_end_time'] = date(Functions_Lib::read_config('date_format_extended'), $f['fleet_start_time']); $parse['fleet_arrival'] = date(Functions_Lib::read_config('date_format_extended'), $f['fleet_end_time']); //now we can view the call back button for ships in maintaing position (2) if ($f['fleet_mess'] == 0 or $f['fleet_mess'] == 2) { $parse['inputs'] = '<form action="game.php?page=movement&action=return" method="post">'; $parse['inputs'] .= '<input name="fleetid\\" value="' . $f['fleet_id'] . '" type="hidden">'; $parse['inputs'] .= '<input value="' . $this->_lang['fl_send_back'] . '" type="submit" name="send">'; $parse['inputs'] .= '</form>'; if ($f['fleet_mission'] == 1) { $parse['inputs'] .= '<a href="#" onClick="f(\'game.php?page=federationlayer&union=' . $f['fleet_group'] . '&fleet=' . $f['fleet_id'] . '\', \'\')">'; $parse['inputs'] .= '<input value="' . $this->_lang['fl_acs'] . '" type="button">'; $parse['inputs'] .= '</a>'; } } else { $parse['inputs'] = ' - '; } $flying_fleets .= parent::$page->parse_template(parent::$page->get_template('movement/fleet_row_fleets'), $parse); } } if ($i == 0) { $parse['num'] = '-'; $parse['fleet_mission'] = '-'; $parse['title'] = ''; $parse['fleet_amount'] = '-'; $parse['fleet_start'] = '-'; $parse['fleet_start_time'] = '-'; $parse['fleet_end'] = '-'; $parse['fleet_end_time'] = '-'; $parse['fleet_arrival'] = '-'; $parse['inputs'] = '-'; $flying_fleets .= parent::$page->parse_template(parent::$page->get_template('movement/fleet_row_fleets'), $parse); } $parse['fleetpagerow'] = $flying_fleets; $parse['envoimaxexpedition'] = $EnvoiMaxExpedition; $parse['expeditionencours'] = $ExpeditionEnCours; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('movement/fleet_table'), $parse)); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { if (!isset($_POST) or empty($_POST)) { Functions_Lib::redirect('game.php?page=fleet1'); } $resource = parent::$objects->get_objects(); $pricelist = parent::$objects->get_price(); $reslist = parent::$objects->get_objects_list(); $lang = $this->_lang; ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // ARRAYS $exp_values = array(1, 2, 3, 4, 5); $hold_values = array(0, 1, 2, 4, 8, 16, 32); // LANG $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; // 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 = ''; // QUERYS $select = parent::$db->query_fetch("SELECT `planet_user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_system` = '" . $system . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_planet` = '" . $planet . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_type` = '" . $planettype . "';"); if ($select) { if ($select['planet_user_id'] == $this->_current_user['user_id']) { $YourPlanet = TRUE; $UsedPlanet = TRUE; } else { $UsedPlanet = TRUE; } } if ($_POST['planettype'] == 2) { if ($_POST['ship209'] >= 1) { $missiontype = array(8 => $this->_lang['type_mission'][8]); } else { $missiontype = array(); } } elseif ($_POST['planettype'] == 1 or $_POST['planettype'] == 3) { if ($_POST['ship208'] >= 1 && !$UsedPlanet) { $missiontype = array(7 => $this->_lang['type_mission'][7]); } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) { $missiontype = array(6 => $this->_lang['type_mission'][6]); } if ($_POST['ship202'] >= 1 or $_POST['ship203'] >= 1 or $_POST['ship204'] >= 1 or $_POST['ship205'] >= 1 or $_POST['ship206'] >= 1 or $_POST['ship207'] >= 1 or $_POST['ship210'] >= 1 or $_POST['ship211'] >= 1 or $_POST['ship213'] >= 1 or $_POST['ship214'] >= 1 or $_POST['ship215'] >= 1) { if (!$YourPlanet) { $missiontype[1] = $this->_lang['type_mission'][1]; } $missiontype[3] = $this->_lang['type_mission'][3]; $missiontype[5] = $this->_lang['type_mission'][5]; } } elseif ($_POST['ship209'] >= 1 or $_POST['ship208']) { $missiontype[3] = $this->_lang['type_mission'][3]; } if ($YourPlanet) { $missiontype[4] = $this->_lang['type_mission'][4]; } if ($_POST['planettype'] == 3 || $_POST['planettype'] == 1 && $fleet_acs > 0 && $UsedPlanet) { $acs = parent::$db->query_fetch("SELECT `acs_fleet_galaxy`, `acs_fleet_planet``, `acs_fleet_system`, `acs_fleet_planet_type`\r\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . $fleet_acs . "';"); if ($acs['acs_fleet_galaxy'] == $galaxy && $acs['acs_fleet_planet'] == $planet && $acs['acs_fleet_system'] == $system && $acs['acs_fleet_planet_type'] == $planettype) { $missiontype[2] = $this->_lang['type_mission'][2]; } } if ($_POST['planettype'] == 3 && $_POST['ship214'] >= 1 && !$YourPlanet && $UsedPlanet) { $missiontype[9] = $this->_lang['type_mission'][9]; } $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet']))); $mission = $_POST['target_mission']; $SpeedFactor = $_POST['speedfactor']; $AllFleetSpeed = Fleets_Lib::fleet_max_speed($fleetarray, 0, $this->_current_user); $GenFleetSpeed = $_POST['speed']; $MaxFleetSpeed = min($AllFleetSpeed); $distance = Fleets_Lib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = Fleets_Lib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = Fleets_Lib::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'] = $_POST['galaxy']; $parse['system'] = $_POST['system']; $parse['planet'] = $_POST['planet']; $parse['thisplanettype'] = $_POST['thisplanettype']; $parse['planettype'] = $_POST['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'] = Fleets_Lib::ship_consumption($Ship, $this->_current_user); $input_parse['speed'] = Fleets_Lib::fleet_max_speed("", $Ship, $this->_current_user); $input_extra .= parent::$page->parse_template($input_template, $input_parse); } ##################################################################################################### // TOP TABLE TITLE ##################################################################################################### if ($_POST['thisplanettype'] == 1) { $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $this->_lang['fl_planet'] . ""; } elseif ($_POST['thisplanettype'] == 3) { $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $this->_lang['fl_moon'] . ""; } ##################################################################################################### // MISSION TYPES ##################################################################################################### if (count($missiontype) > 0) { if ($planet == 16) { $parse_mission['value'] = 15; $parse_mission['mission'] = $this->_lang['type_mission'][15]; $parse_mission['expedition_message'] = $this->_lang['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 { Functions_Lib::redirect('game.php?page=fleet1'); } ##################################################################################################### // STAY / EXPEDITION BLOCKS ##################################################################################################### $stay_row['options'] = ''; 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->_lang)); } elseif ($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->_lang)); } $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)); }
/** * method send_fleet * param * return send fleet routine */ private function send_fleet() { $max_spy_probes = $this->_current_user['setting_probes_amount']; $UserSpyProbes = $this->_current_planet['ship_espionage_probe']; $UserRecycles = $this->_current_planet['ship_recycler']; $UserDeuterium = $this->_current_planet['planet_deuterium']; $UserMissiles = $this->_current_planet['defense_interplanetary_missile']; $fleet = array(); $speedalls = array(); $PartialFleet = FALSE; $PartialCount = 0; $order = isset($_POST['order']) ? $_POST['order'] : NULL; $ResultMessage = ''; $fleet['fleetlist'] = ''; $fleet['amount'] = ''; switch ($order) { case 6: $_POST['ship210'] = $_POST['shipcount']; break; case 7: $_POST['ship208'] = $_POST['shipcount']; break; case 8: $_POST['ship209'] = $_POST['shipcount']; break; } foreach ($this->_reslist['fleet'] as $Node => $ShipID) { $TName = "ship" . $ShipID; if (isset($_POST[$TName]) && $ShipID > 200 && $ShipID < 300 && $_POST[$TName] > 0) { if ($_POST[$TName] > $this->_current_planet[$this->_resource[$ShipID]]) { $fleet['fleetarray'][$ShipID] = $this->_current_planet[$this->_resource[$ShipID]]; $fleet['fleetlist'] .= $ShipID . "," . $this->_current_planet[$this->_resource[$ShipID]] . ";"; $fleet['amount'] += $this->_current_planet[$this->_resource[$ShipID]]; $PartialCount += $this->_current_planet[$this->_resource[$ShipID]]; $PartialFleet = TRUE; } else { $fleet['fleetarray'][$ShipID] = $_POST[$TName]; $fleet['fleetlist'] .= $ShipID . "," . $_POST[$TName] . ";"; $fleet['amount'] += $_POST[$TName]; $speedalls[$ShipID] = $_POST[$TName]; } } } $errors_types = array(600 => $this->_lang['gl_success'], 601 => $this->_lang['gl_error'], 602 => $this->_lang['gl_no_moon'], 603 => $this->_lang['gl_noob_protection'], 604 => $this->_lang['gl_too_strong'], 605 => $this->_lang['gl_vacation_mode'], 610 => $this->_lang['gl_only_amount_ships'], 611 => $this->_lang['gl_no_ships'], 612 => $this->_lang['gl_no_slots'], 613 => $this->_lang['gl_no_deuterium'], 614 => $this->_lang['gl_no_planet'], 615 => $this->_lang['gl_not_enough_storage'], 616 => $this->_lang['gl_multi_alarm']); if ($PartialFleet == TRUE) { if ($PartialCount < 1) { die("611 "); } } $galaxy = isset($_POST['galaxy']) ? (int) $_POST['galaxy'] : 0; $system = isset($_POST['system']) ? (int) $_POST['system'] : 0; $planet = isset($_POST['planet']) ? (int) $_POST['planet'] : 0; $FleetArray = isset($fleet['fleetarray']) ? $fleet['fleetarray'] : NULL; if ($galaxy > MAX_GALAXY_IN_WORLD or $galaxy < 1 or ($system > MAX_SYSTEM_IN_GALAXY or $system < 1) or ($planet > MAX_PLANET_IN_SYSTEM or $planet < 1) or is_null($FleetArray)) { die("614 "); } $CurrentFlyingFleets = parent::$db->query_fetch("SELECT COUNT(fleet_id) AS `Nbre`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "';"); $CurrentFlyingFleets = $CurrentFlyingFleets['Nbre']; $TargetRow = parent::$db->query_fetch("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . parent::$db->escape_value($_POST['galaxy']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . parent::$db->escape_value($_POST['system']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . parent::$db->escape_value($_POST['planet']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . parent::$db->escape_value($_POST['planettype']) . "';"); if ($TargetRow['planet_user_id'] == '') { $TargetUser = $this->_current_user; } elseif ($TargetRow['planet_user_id'] != '') { $TargetUser = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_authlevel`, s.`setting_vacations_status`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS s ON s.setting_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $TargetRow['planet_user_id'] . "';"); } // invisible debris by jstar if ($order == 8) { $TargetGPlanet = parent::$db->query_fetch("SELECT planet_invisible_start_time, planet_debris_metal, planet_debris_crystal\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE planet_galaxy = '" . parent::$db->escape_value($_POST['galaxy']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = '" . parent::$db->escape_value($_POST['system']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . parent::$db->escape_value($_POST['planet']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = 1;"); if ($TargetGPlanet['planet_debris_metal'] == 0 && $TargetGPlanet['planet_debris_crystal'] == 0 && time() > $TargetGPlanet['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) { die; } } $user_points = $this->_noob->return_points($this->_current_user['user_id'], $TargetUser['user_id']); $CurrentPoints = $user_points['user_points']; $TargetPoints = $user_points['target_points']; $TargetVacat = $TargetUser['setting_vacations_status']; if (Fleets_Lib::get_max_fleets($this->_current_user[$this->_resource[108]], $this->_current_user['premium_officier_admiral']) <= $CurrentFlyingFleets) { die("612 "); } if (!is_array($FleetArray)) { die("611 "); } if (!($order == 6 or $order == 8)) { die("601 "); } if ($TargetVacat && $order != 8 or $this->_current_user['setting_vacations_status']) { die("605 "); } if ($TargetUser['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) { if ($this->_noob->is_weak($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) { die("603 "); } if ($this->_noob->is_strong($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) { die("604 "); } } if ($TargetRow['planet_user_id'] == '' && $order != 8) { die("601 "); } if ($TargetRow['planet_user_id'] == $this->_current_planet['planet_user_id'] && $order == 6) { die("601 "); } $Distance = Fleets_Lib::target_distance($this->_current_planet['planet_galaxy'], $_POST['galaxy'], $this->_current_planet['planet_system'], $_POST['system'], $this->_current_planet['planet_planet'], $_POST['planet']); $speedall = Fleets_Lib::fleet_max_speed($FleetArray, 0, $this->_current_user); $SpeedAllMin = min($speedall); $Duration = Fleets_Lib::mission_duration(10, $SpeedAllMin, $Distance, Functions_Lib::fleet_speed_factor()); $fleet['fly_time'] = $Duration; $fleet['start_time'] = $Duration + time(); $fleet['end_time'] = $Duration * 2 + time(); $FleetShipCount = 0; $FleetDBArray = ""; $FleetSubQRY = ""; $consumption = 0; $SpeedFactor = Functions_Lib::fleet_speed_factor(); foreach ($FleetArray as $Ship => $Count) { if ($Ship != '') { $ShipSpeed = $this->_pricelist[$Ship]['speed']; $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed); $basicConsumption = $this->_pricelist[$Ship]['consumption'] * $Count; $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1); $FleetShipCount += $Count; $FleetDBArray .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $this->_resource[$Ship] . "` = `" . $this->_resource[$Ship] . "` - " . $Count . " , "; } } $consumption = round($consumption) + 1; if ($UserDeuterium < $consumption) { die("613 "); } if (Functions_Lib::read_config('adm_attack') == 1 && $TargetUser['user_authlevel'] > 0) { die("601 "); } parent::$db->query("INSERT INTO " . FLEETS . " SET\r\n\t\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_mission` = '" . intval($order) . "',\r\n\t\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\r\n\t\t\t\t\t\t\t\t`fleet_array` = '" . $FleetDBArray . "',\r\n\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $this->_current_planet['planet_galaxy'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_start_system` = '" . $this->_current_planet['planet_system'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_start_planet` = '" . $this->_current_planet['planet_planet'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_start_type` = '" . $this->_current_planet['planet_type'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "',\r\n\t\t\t\t\t\t\t\t`fleet_end_system` = '" . intval($_POST['system']) . "',\r\n\t\t\t\t\t\t\t\t`fleet_end_planet` = '" . intval($_POST['planet']) . "',\r\n\t\t\t\t\t\t\t\t`fleet_end_type` = '" . intval($_POST['planettype']) . "',\r\n\t\t\t\t\t\t\t\t`fleet_target_owner` = '" . $TargetRow['planet_user_id'] . "',\r\n\t\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';"); $UserDeuterium -= $consumption; parent::$db->query("UPDATE " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\r\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\r\n\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . ($UserDeuterium < 1 ? 0 : $UserDeuterium) . "'\r\n\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';"); $CurrentFlyingFleets++; foreach ($FleetArray as $Ships => $Count) { if ($max_spy_probes > $this->_current_planet[$this->_resource[$Ships]]) { $ResultMessage = "610 " . $FleetShipCount; } } if ($ResultMessage == '') { $ResultMessage = "600 " . $Ships; } die($ResultMessage); }
/** * method flying_fleets_table * param $fleet_row * param $Status * param $Owner * param $Label * param $Record * param $current_user * return the fleet table for the overview and phalanx */ public static function flying_fleets_table($fleet_row, $Status, $Owner, $Label, $Record, $current_user) { $FleetStyle = array(1 => 'attack', 2 => 'federation', 3 => 'transport', 4 => 'deploy', 5 => 'hold', 6 => 'espionage', 7 => 'colony', 8 => 'harvest', 9 => 'destroy', 10 => 'missile', 15 => 'transport'); $FleetStatus = array(0 => 'flight', 1 => 'holding', 2 => 'return'); $FleetPrefix = $Owner ? 'own' : ''; $RowsTPL = parent::$page->get_template('overview/overview_fleet_event'); $MissionType = $fleet_row['fleet_mission']; $FleetContent = self::fleet_ships_popup($fleet_row, parent::$lang['cff_flotte'], $FleetPrefix . $FleetStyle[$MissionType], $current_user); $FleetCapacity = self::fleet_resources_popup($fleet_row, parent::$lang['type_mission'][$MissionType], $FleetPrefix . $FleetStyle[$MissionType]); $planet_name = parent::$db->query_fetch("SELECT\t(SELECT `planet_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . intval($fleet_row['fleet_start_galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . intval($fleet_row['fleet_start_system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . intval($fleet_row['fleet_start_planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . intval($fleet_row['fleet_start_type']) . "') AS start_planet_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT `planet_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . intval($fleet_row['fleet_end_galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . intval($fleet_row['fleet_end_system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . intval($fleet_row['fleet_end_planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . intval($fleet_row['fleet_end_type']) . "') AS target_planet_name"); $StartType = $fleet_row['fleet_start_type']; $TargetType = $fleet_row['fleet_end_type']; if ($Status != 2) { if ($StartType == 1) { $StartID = parent::$lang['cff_from_the_planet']; } elseif ($StartType == 3) { $StartID = parent::$lang['cff_from_the_moon']; } $StartID .= $planet_name['start_planet_name'] . " "; $StartID .= Fleets_Lib::start_link($fleet_row, $FleetPrefix . $FleetStyle[$MissionType]); if ($MissionType != 15) { switch ($TargetType) { case 1: $TargetID = parent::$lang['cff_the_planet']; break; case 2: $TargetID = parent::$lang['cff_debris_field']; break; case 3: $TargetID = parent::$lang['cff_to_the_moon']; break; } } else { $TargetID = parent::$lang['cff_the_position']; } $TargetID .= $planet_name['target_planet_name'] . " "; $TargetID .= Fleets_Lib::target_link($fleet_row, $FleetPrefix . $FleetStyle[$MissionType]); } else { if ($StartType == 1) { $StartID = parent::$lang['cff_to_the_planet']; } elseif ($StartType == 3) { $StartID = parent::$lang['cff_the_moon']; } $StartID .= $planet_name['start_planet_name'] . " "; $StartID .= Fleets_Lib::start_link($fleet_row, $FleetPrefix . $FleetStyle[$MissionType]); if ($MissionType != 15) { switch ($TargetType) { case 1: $TargetID = parent::$lang['cff_from_planet']; break; case 2: $TargetID = parent::$lang['cff_from_debris_field']; break; case 3: $TargetID = parent::$lang['cff_from_the_moon']; break; } } else { $TargetID = parent::$lang['cff_from_position']; } $TargetID .= $planet_name['target_planet_name'] . " "; $TargetID .= Fleets_Lib::target_link($fleet_row, $FleetPrefix . $FleetStyle[$MissionType]); } if ($MissionType == 10) { $EventString = parent::$lang['cff_missile_attack'] . " ( " . preg_replace("(503,)i", "", $fleet_row['fleet_array']) . " ) "; $Time = $fleet_row['fleet_start_time']; $Rest = $Time - time(); $EventString .= $StartID; $EventString .= parent::$lang['cff_to']; $EventString .= $TargetID; $EventString .= "."; } else { if ($Owner == TRUE) { $EventString = parent::$lang['cff_one_of_your']; $EventString .= $FleetContent; } else { $EventString = parent::$lang['cff_a']; $EventString .= $FleetContent; $EventString .= parent::$lang['cff_of']; $EventString .= self::enemy_link($fleet_row); } switch ($Status) { case 0: $Time = $fleet_row['fleet_start_time']; $Rest = $Time - time(); $EventString .= parent::$lang['cff_goes']; $EventString .= $StartID; $EventString .= parent::$lang['cff_toward']; $EventString .= $TargetID; $EventString .= parent::$lang['cff_with_the_mission_of']; break; case 1: $Time = $fleet_row['fleet_end_stay']; $Rest = $Time - time(); $EventString .= parent::$lang['cff_goes']; $EventString .= $StartID; $EventString .= parent::$lang['cff_to_explore']; $EventString .= $TargetID; $EventString .= parent::$lang['cff_with_the_mission_of']; break; case 2: $Time = $fleet_row['fleet_end_time']; $Rest = $Time - time(); $EventString .= parent::$lang['cff_comming_back']; $EventString .= $TargetID; $EventString .= $StartID; $EventString .= parent::$lang['cff_with_the_mission_of']; break; } $EventString .= $FleetCapacity; } $bloc['fleet_status'] = $FleetStatus[$Status]; $bloc['fleet_prefix'] = $FleetPrefix; $bloc['fleet_style'] = $FleetStyle[$MissionType]; $bloc['fleet_javai'] = Functions_Lib::chrono_applet($Label, $Record, $Rest, TRUE); $bloc['fleet_order'] = $Label . $Record; $bloc['fleet_descr'] = $EventString; $bloc['fleet_javas'] = Functions_Lib::chrono_applet($Label, $Record, $Rest, FALSE); return parent::$page->parse_template($RowsTPL, $bloc); }
/** * attackMission * * @param array $fleet_row Fleet row * * @return void */ public function attackMission($fleet_row) { // null == use default handlers $errorHandler = null; $exceptionHandler = null; $target_planet = parent::$db->query_fetch("SELECT *\n FROM " . PLANETS . " AS p\n INNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\n INNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\n INNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\n WHERE `planet_galaxy` = " . (int) $fleet_row['fleet_end_galaxy'] . " AND\n `planet_system` = " . (int) $fleet_row['fleet_end_system'] . " AND\n `planet_type` = " . (int) $fleet_row['fleet_end_type'] . " AND\n `planet_planet` = " . (int) $fleet_row['fleet_end_planet'] . ";"); if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) { $base = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR; // require several stuff require $base . 'libraries' . DIRECTORY_SEPARATOR . 'battle_engine' . DIRECTORY_SEPARATOR . 'utils' . DIRECTORY_SEPARATOR . 'includer.php'; // require language implementation require $base . 'libraries' . DIRECTORY_SEPARATOR . 'missions' . DIRECTORY_SEPARATOR . 'attackLang.php'; // set language for the reports LangManager::getInstance()->setImplementation(new AttackLang($this->_lang)); if ($fleet_row['fleet_group'] > 0) { parent::$db->query("DELETE FROM `" . ACS_FLEETS . "`\n WHERE `acs_fleet_id` = '" . (int) $fleet_row['fleet_group'] . "'"); parent::$db->query("UPDATE `" . FLEETS . "` SET\n `fleet_mess` = '1'\n WHERE `fleet_group` = '" . $fleet_row['fleet_group'] . "'"); } else { parent::return_fleet($fleet_row['fleet_id']); } $targetUser = parent::$db->query_fetch("SELECT u.*,\n r.*,\n pr.*\n FROM " . USERS . " AS u\n INNER JOIN " . RESEARCH . " AS r ON r.research_user_id = u.user_id\n INNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = u.user_id\n WHERE u.user_id = '" . intval($target_planet['planet_user_id']) . "';"); $target_userID = $targetUser['user_id']; UpdateResourcesLib::updateResource($targetUser, $target_planet, time()); //----------------------- prepare players for battle ---------------------- // attackers fleet sum $attackers = new PlayerGroup(); // If we have a ACS attack if ($fleet_row['fleet_group'] != 0) { $fleets = parent::$db->query_fetch("SELECT * FROM `" . FLEETS . "` WHERE `fleet_group` = '" . $fleet_row['fleet_group'] . "';"); $attackers = $this->getPlayerGroupFromQuery($fleets); } else { $attackers = $this->getPlayerGroup($fleet_row); } // defenders fleet sum $def = parent::$db->query("SELECT * FROM `" . FLEETS . "` \n WHERE `fleet_end_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND \n `fleet_end_system` = '" . $fleet_row['fleet_end_system'] . "' AND \n `fleet_end_type` = '" . $fleet_row['fleet_end_type'] . "' AND \n `fleet_end_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\n `fleet_start_time` < '" . time() . "' AND \n `fleet_end_stay` >= '" . time() . "';"); $defenders = $this->getPlayerGroupFromQuery($def, $targetUser); //defenses sum $homeFleet = new HomeFleet(0); for ($i = self::DEFENSE_MIN_ID; $i < self::DEFENSE_MAX_ID; $i++) { if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) { if ($target_planet[$this->_resource[$i]] != 0) { $homeFleet->addShipType($this->getShipType($i, $target_planet[$this->_resource[$i]])); } } } for ($i = self::SHIP_MIN_ID; $i < self::SHIP_MAX_ID; $i++) { if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) { if ($target_planet[$this->_resource[$i]] != 0) { $homeFleet->addShipType($this->getShipType($i, $target_planet[$this->_resource[$i]])); } } } if (!$defenders->existPlayer($target_userID)) { $player = new Player($target_userID, array($homeFleet)); $player->setTech($targetUser['research_weapons_technology'], $targetUser['research_shielding_technology'], $targetUser['research_armour_technology']); $player->setName($targetUser['user_name']); $defenders->addPlayer($player); } else { $defenders->getPlayer($target_userID)->addDefense($homeFleet); } //------------------------------------------------------------------------- //------------------------------ battle ----------------------------------- $battle = new Battle($attackers, $defenders); $startBattle = DebugManager::runDebugged(array($battle, 'startBattle'), $errorHandler, $exceptionHandler); $startBattle(); //------------------------------------------------------------------------- //-------------------------- after battle stuff --------------------------- $report = $battle->getReport(); $steal = $this->updateAttackers($report->getPresentationAttackersFleetOnRound('START'), $report->getAfterBattleAttackers(), $target_planet); $report->setSteal($steal); $this->updateDefenders($report->getPresentationDefendersFleetOnRound('START'), $report->getAfterBattleDefenders(), $target_planet, $steal); $this->updateDebris($fleet_row, $report); $this->updateMoon($fleet_row, $report, '', $target_userID, $target_planet); $this->sendMessage($fleet_row, $report); } elseif ($fleet_row['fleet_end_time'] <= time()) { $message = sprintf($this->_lang['sys_fleet_won'], $target_planet['planet_name'], Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']); Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 1, $this->_lang['sys_mess_tower'], $this->_lang['sys_mess_fleetback'], $message); parent::restore_fleet($fleet_row); parent::remove_fleet($fleet_row['fleet_id']); } }