/** * 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 acs_mission * param $fleet_row * return the acs result */ public function acs_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] > time()) { parent::return_fleet($fleet_row['fleet_id']); } if ($fleet_row['fleet_end_time'] <= time()) { parent::restore_fleet($fleet_row); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method missile_mission * param $fleet_row * return the missile result */ public function missile_mission($fleet_row) { if ($fleet_row['fleet_start_time'] <= time()) { if ($fleet_row['fleet_mess'] == 0) { $attacker_data = parent::$db->query_fetch("SELECT p.`planet_name`, r.`research_weapons_technology`\n\t\t\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\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\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`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`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`planet_type` = " . $fleet_row['fleet_start_type'] . ";"); $target_data = parent::$db->query_fetch("SELECT p.`planet_id`, p.`planet_name`, p.`planet_user_id`, d.*, r.`research_shielding_technology`\n\t\t\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\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\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `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`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`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`planet_type` = " . $fleet_row['fleet_end_type'] . ";"); if ($target_data['defense_anti-ballistic_missile'] >= $fleet_row['fleet_amount']) { $message = $this->_lang['ma_all_destroyed'] . '<br>'; $amount = $fleet_row['fleet_amount']; } else { $amount = 0; if ($target_data['defense_anti-ballistic_missile'] > 0) { $message = $target_data['defense_anti-ballistic_missile'] . $this->_lang['ma_some_destroyed'] . " <br>"; } $attack = floor(($fleet_row['fleet_amount'] - $target_data['defense_anti-ballistic_missile']) * ($this->_combat_caps[503]['attack'] * (1 + $attacker_data['research_weapons_technology'] / 10))); $attack_order = $this->set_attack_order($fleet_row['fleet_target_obj']); $destroyed_query = ''; // PROCESS THE MISSILE ATTACK for ($t = 0; $t < count($attack_order); $t++) { $n = $attack_order[$t]; if ($target_data[$this->_resource[$n]]) { $defense = ($this->_pricelist[$n]['metal'] + parent::$_pricelist[$n]['crystal']) / 10 * (1 + $target_data['research_shielding_technology'] / 10); if ($attack >= $defense * $target_data[$this->_resource[$n]]) { $destroyed = $target_data[$this->_resource[$n]]; } else { $destroyed = floor($attack / $defense); } $attack -= $destroyed * $defense; if ($destroyed != 0) { $message .= $this->_lang['tech'][$n] . " (-" . $destroyed . ")<br>"; $destroyed_query .= "`" . $this->_resource[$n] . "` = `" . $this->_resource[$n] . "` - " . $destroyed . ","; } } } if ($destroyed_query != '') { parent::$db->query("UPDATE " . DEFENSES . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t{$destroyed_query}\n\t\t\t\t\t\t\t\t\t\t\t\t`defense_anti-ballistic_missile` = '" . $amount . "'\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE defense_planet_id = " . $target_data['id']); } } $search = array('%1%', '%2%', '%3%'); $replace = array($fleet_row['fleet_amount'], $attacker_data['planet_name'] . ' [' . $fleet_row['fleet_start_galaxy'] . ':' . $fleet_row['fleet_start_system'] . ':' . $fleet_row['fleet_start_planet'] . '] ', $target_data['name'] . ' [' . $fleet_row['fleet_end_galaxy'] . ':' . $fleet_row['fleet_end_system'] . ':' . $fleet_row['fleet_end_planet'] . '] '); $message_vorlage = str_replace($search, $replace, $this->_lang['ma_missile_string']); if (empty($message) or $message == '') { $message = $this->_lang['ma_planet_without_defens']; } Functions_Lib::send_message($target_data['planet_user_id'], '', $fleet_row['fleet_end_time'], 5, $this->_lang['sys_mess_tower'], $this->_lang['gl_missile_attack'], $message_vorlage . $message); 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 deploy_mission * param $fleet_row * return the deploy result */ public function deploy_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0) { if ($fleet_row['fleet_start_time'] <= time()) { $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); $target_resources = sprintf($this->_lang['sys_stay_mess_goods'], $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Deuterium'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium'])); $target_message = $this->_lang['sys_stay_mess_start'] . "<a href=\"game.php?page=galaxy&mode=3&galaxy=" . $fleet_row['fleet_end_galaxy'] . "&system=" . $fleet_row['fleet_end_system'] . "\">"; $target_message .= $target_coords . "</a>" . $this->_lang['sys_stay_mess_end'] . "<br />" . $target_resources; Functions_Lib::send_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], 5, $this->_lang['sys_mess_qg'], $this->_lang['sys_stay_mess_stay'], $target_message); parent::restore_fleet($fleet_row, FALSE); parent::remove_fleet($fleet_row['fleet_id']); } } else { if ($fleet_row['fleet_end_time'] <= time()) { $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_start_galaxy'], $fleet_row['fleet_start_system'], $fleet_row['fleet_start_planet']); $target_resources = sprintf($this->_lang['sys_stay_mess_goods'], $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Deuterium'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium'])); $target_message = $this->_lang['sys_stay_mess_back'] . "<a href=\"game.php?page=galaxy&mode=3&galaxy=" . $fleet_row['fleet_start_galaxy'] . "&system=" . $fleet_row['fleet_start_system'] . "\">"; $target_message .= $target_coords . "</a>" . $this->_lang['sys_stay_mess_bend'] . "<br />" . $target_resources; Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 5, $this->_lang['sys_mess_qg'], $this->_lang['sys_mess_fleetback'], $target_message); parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } } }
/** * method destroy_mission * param $fleet_row * return the transport result */ public function destroy_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) { $current_data = parent::$db->query_fetch("SELECT p.planet_name, r.research_weapons_technology, r.research_shielding_technology, r.research_armour_technology, u.user_name, u.user_id\n\t\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\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\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\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\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\tp.`planet_type` = " . $fleet_row['fleet_start_type'] . ";"); $target_data = parent::$db->query_fetch("SELECT s.*, d.*, p.`planet_id`, p.planet_diameter, p.planet_user_id, u.user_name, u.user_current_planet, r.research_weapons_technology, r.research_shielding_technology, r.research_armour_technology\n\t\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\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\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\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`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\tp.`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\tp.`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\tp.`planet_type` = '" . $fleet_row['fleet_end_type'] . "';"); for ($SetItem = 200; $SetItem < 500; $SetItem++) { if ($target_data[$this->_resource[$SetItem]] > 0) { $target_ships[$SetItem]['count'] = $target_data[$this->_resource[$SetItem]]; } } $TheFleet = explode(";", $fleet_row['fleet_array']); foreach ($TheFleet as $a => $b) { if ($b != '') { $a = explode(",", $b); $current_ships[$a[0]]['count'] = $a[1]; } } $attack = $this->attack($current_ships, $target_ships, $current_data, $target_data); $current_ships = $attack['attacker']; $target_ships = $attack['enemy']; $FleetResult = $attack['win']; $dane_do_rw = $attack['data_for_rw']; $zlom = $attack['debris']; $FleetArray = ''; $FleetAmount = 0; $FleetStorage = 0; foreach ($current_ships as $Ship => $Count) { $FleetStorage += $this->_pricelist[$Ship]['capacity'] * $Count['count']; $FleetArray .= $Ship . "," . $Count['count'] . ";"; $FleetAmount += $Count['count']; } $TargetPlanetUpd = ""; if (!is_null($target_ships)) { foreach ($target_ships as $Ship => $Count) { $TargetPlanetUpd .= "`" . $this->_resource[$Ship] . "` = '" . $Count['count'] . "', "; } } if ($FleetResult == "a") { $destructionl1 = 100 - sqrt($target_data['planet_diameter']); $destructionl21 = $destructionl1 * sqrt($current_ships['214']['count']); $destructionl2 = $destructionl21 / 1; if ($destructionl2 > 100) { $chance = '100'; } else { $chance = round($destructionl2); } $tirage = mt_rand(0, 100); $probalune = sprintf($this->_lang['sys_destruc_lune'], $chance); if ($tirage <= $chance) { $resultat = '1'; $finmess = $this->_lang['sys_destruc_reussi']; parent::$db->query("UPDATE " . FLEETS . " AS f1 SET\n\t\t\t\t\t\t\t\t\t\t\tf1.`fleet_start_type` = '1'\n\t\t\t\t\t\t\t\t\t\t\tWHERE f1.`fleet_start_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tf1.`fleet_start_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tf1.`fleet_start_planet` = '" . $fleet_row['fleet_end_planet'] . "';"); parent::$db->query("UPDATE " . FLEETS . " AS f2 SET\n\t\t\t\t\t\t\t\t\t\t\tf2.`fleet_end_type` = '1'\n\t\t\t\t\t\t\t\t\t\t\tWHERE f2.`fleet_end_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tf2.`fleet_end_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\tf2.`fleet_end_planet` = '" . $fleet_row['fleet_end_planet'] . "';"); parent::$db->query("UPDATE " . PLANETS . " AS p SET\n\t\t\t\t\t\t\t\t\t\t\t`planet_destroyed` = '" . time() . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $target_data['id'] . "';"); if ($target_data['user_current_planet'] == $target_data['id']) { parent::$db->query("UPDATE " . USERS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t`user_current_planet` = (SELECT `planet_id`\n\t\t\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\t\tWHERE `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`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`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`planet_type` = '1')\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $target_data['planet_user_id'] . "';"); } } else { $resultat = '0'; } $destructionrip = sqrt($target_data['planet_diameter']) / 2; $chance2 = round($destructionrip); if ($resultat == 0) { $tirage2 = mt_rand(0, 100); $probarip = sprintf($this->_lang['sys_destruc_rip'], $chance2); if ($tirage2 <= $chance2) { $resultat2 = ' detruite 1'; $finmess = $this->_lang['sys_destruc_echec']; parent::remove_fleet($fleet_row['fleet_id']); } else { $resultat2 = 'sauvees 0'; $finmess = $this->_lang['sys_destruc_null']; } } } $introdestruc = sprintf($this->_lang['sys_destruc_mess'], $current_data['planet_name'], $fleet_row['fleet_start_galaxy'], $fleet_row['fleet_start_system'], $fleet_row['fleet_start_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); parent::$db->query("UPDATE " . PLANETS . " AS p\n\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\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t\t{$TargetPlanetUpd}\n\t\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - '" . $Mining['metal'] . "',\n\t\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - '" . $Mining['crystal'] . "',\n\t\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - '" . $Mining['deuter'] . "',\n\t\t\t\t\t\t\t\t\t`planet_invisible_start_time` = '" . time() . "',\n\t\t\t\t\t\t\t\t\t`planet_debris_metal` = `planet_debris_metal` + '" . $zlom['metal'] . "',\n\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` + '" . $zlom['crystal'] . "'\n\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $fleet_row['fleet_end_type'] . "';"); $StrAttackerUnits = sprintf($this->_lang['sys_attacker_lostunits'], $zlom['attacker']); $StrDefenderUnits = sprintf($this->_lang['sys_defender_lostunits'], $zlom['enemy']); $StrRuins = sprintf($this->_lang['sys_gcdrunits'], $zlom['metal'], $this->_lang['Metal'], $zlom['crystal'], $this->_lang['Crystal']); $DebrisField = $StrAttackerUnits . "<br />" . $StrDefenderUnits . "<br />" . $StrRuins; $AttackDate = date("r", $fleet_row['fleet_start_time']); $title = sprintf($this->_lang['sys_destruc_title'], $AttackDate); $raport = "<center><table><tr><td>" . $title . "<br />"; $zniszczony = FALSE; $a_zestrzelona = 0; $AttackTechon['A'] = $current_data['research_weapons_technology'] * 10; $AttackTechon['B'] = $current_data['research_shielding_technology'] * 10; $AttackTechon['C'] = $current_data['research_armour_technology'] * 10; $AttackerData = sprintf($this->_lang['sys_attack_attacker_pos'], $current_data['user_name'], $fleet_row['fleet_start_galaxy'], $fleet_row['fleet_start_system'], $fleet_row['fleet_start_planet']); $AttackerTech = sprintf($this->_lang['sys_attack_techologies'], $AttackTechon['A'], $AttackTechon['B'], $AttackTechon['C']); $DefendTechon['A'] = $target_data['research_weapons_technology'] * 10; $DefendTechon['B'] = $target_data['research_shielding_technology'] * 10; $DefendTechon['C'] = $target_data['research_armour_technology'] * 10; $DefenderData = sprintf($this->_lang['sys_attack_defender_pos'], $target_data['user_name'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']); $DefenderTech = sprintf($this->_lang['sys_attack_techologies'], $DefendTechon['A'], $DefendTechon['B'], $DefendTechon['C']); foreach ($dane_do_rw as $a => $b) { $raport .= "<table border=1 width=100%><tr><th><br /><center>" . $AttackerData . "<br />" . $AttackerTech . "<table border=1>"; if ($b['attacker']['count'] > 0) { $raport1 = "<tr><th>" . $this->_lang['sys_ship_type'] . "</th>"; $raport2 = "<tr><th>" . $this->_lang['sys_ship_count'] . "</th>"; $raport3 = "<tr><th>" . $this->_lang['sys_ship_weapon'] . "</th>"; $raport4 = "<tr><th>" . $this->_lang['sys_ship_shield'] . "</th>"; $raport5 = "<tr><th>" . $this->_lang['sys_ship_armour'] . "</th>"; foreach ($b['attacker'] as $Ship => $Data) { if (is_numeric($Ship)) { if ($Data['count'] > 0) { $raport1 .= "<th>" . $this->_lang['tech_rc'][$Ship] . "</th>"; $raport2 .= "<th>" . $Data['count'] . "</th>"; $raport3 .= "<th>" . round($Data['attack'] / $Data['count']) . "</th>"; $raport4 .= "<th>" . round($Data['shield'] / $Data['count']) . "</th>"; $raport5 .= "<th>" . round($Data['defense'] / $Data['count']) . "</th>"; } } } $raport1 .= "</tr>"; $raport2 .= "</tr>"; $raport3 .= "</tr>"; $raport4 .= "</tr>"; $raport5 .= "</tr>"; $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; } else { if ($a == 2) { $a_zestrzelona = 1; } $zniszczony = TRUE; $raport .= "<br />" . $this->_lang['sys_destroyed']; } $raport .= "</table></center></th></tr></table>"; $raport .= "<table border=1 width=100%><tr><th><br /><center>" . $DefenderData . "<br />" . $DefenderTech . "<table border=1>"; if ($b['enemy']['count'] > 0) { $raport1 = "<tr><th>" . $this->_lang['sys_ship_type'] . "</th>"; $raport2 = "<tr><th>" . $this->_lang['sys_ship_count'] . "</th>"; $raport3 = "<tr><th>" . $this->_lang['sys_ship_weapon'] . "</th>"; $raport4 = "<tr><th>" . $this->_lang['sys_ship_shield'] . "</th>"; $raport5 = "<tr><th>" . $this->_lang['sys_ship_armour'] . "</th>"; foreach ($b['enemy'] as $Ship => $Data) { if (is_numeric($Ship)) { if ($Data['count'] > 0) { $raport1 .= "<th>" . $this->_lang['tech_rc'][$Ship] . "</th>"; $raport2 .= "<th>" . $Data['count'] . "</th>"; $raport3 .= "<th>" . round($Data['attack'] / $Data['count']) . "</th>"; $raport4 .= "<th>" . round($Data['shield'] / $Data['count']) . "</th>"; $raport5 .= "<th>" . round($Data['defense'] / $Data['count']) . "</th>"; } } } $raport1 .= "</tr>"; $raport2 .= "</tr>"; $raport3 .= "</tr>"; $raport4 .= "</tr>"; $raport5 .= "</tr>"; $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; } else { $zniszczony = TRUE; $raport .= "<br />" . $this->_lang['sys_destroyed']; } $raport .= "</table></center></th></tr></table>"; if ($zniszczony == FALSE && !($a == 8)) { $AttackWaveStat = sprintf($this->_lang['sys_attack_attack_wave'], floor($b['attacker']['attack']), floor($b['enemy']['shield'])); $DefendWavaStat = sprintf($this->_lang['sys_attack_defend_wave'], floor($b['enemy']['attack']), floor($b['attacker']['shield'])); $raport .= "<br /><center>" . $AttackWaveStat . "<br />" . $DefendWavaStat . "</center>"; } } switch ($FleetResult) { case "a": $raport .= $this->_lang['sys_attacker_won'] . "<br />"; $raport .= $DebrisField . "<br />"; $raport .= $introdestruc . "<br />"; $raport .= $this->_lang['sys_destruc_mess1']; $raport .= $finmess . "<br />"; $raport .= $probalune . "<br />"; $raport .= $probarip . "<br />"; break; case "r": $raport .= $this->_lang['sys_both_won'] . "<br />"; $raport .= $DebrisField . "<br />"; $raport .= $introdestruc . "<br />"; $raport .= $this->_lang['sys_destruc_stop'] . "<br />"; break; case "w": $raport .= $this->_lang['sys_defender_won'] . "<br />"; $raport .= $DebrisField . "<br />"; $raport .= $introdestruc . "<br />"; $raport .= $this->_lang['sys_destruc_stop'] . "<br />"; parent::remove_fleet($fleet_row['fleet_id']); break; } $raport .= "</table>"; $rid = md5($raport); $owners = $fleet_row['fleet_owner'] . "," . $target_data['planet_user_id']; parent::$db->query("INSERT INTO " . REPORTS . " SET\n\t\t\t\t\t\t\t\t\t`report_time` = UNIX_TIMESTAMP(),\n\t\t\t\t\t\t\t\t\t`report_owners` = '" . $owners . "',\n\t\t\t\t\t\t\t\t\t`report_rid` = '" . $rid . "',\n\t\t\t\t\t\t\t\t\t`report_destroyed` = '" . $a_zestrzelona . "',\n\t\t\t\t\t\t\t\t\t`report_content` = '" . addslashes($raport) . "';"); $raport = "<a href=\"#\" OnClick=\\'f(\"game.php?page=CombatReport&report=" . $rid . "\", \"\");\\' >"; $raport .= "<center>"; $raport .= $this->set_report_color($FleetResult); $raport .= $this->_lang['sys_mess_destruc_report'] . " [" . $fleet_row['fleet_end_galaxy'] . ":" . $fleet_row['fleet_end_system'] . ":" . $fleet_row['fleet_end_planet'] . "] </font></a><br /><br />"; $raport .= "<font color=\"red\">" . $this->_lang['sys_perte_attaquant'] . ": " . $zlom['attacker'] . "</font>"; $raport .= "<font color=\"green\"> " . $this->_lang['sys_perte_defenseur'] . ":" . $zlom['enemy'] . "</font><br />"; $raport .= $this->_lang['sys_debris'] . " " . $this->_lang['Metal'] . ":<font color=\"#adaead\">" . $zlom['metal'] . "</font> " . $this->_lang['Crystal'] . ":<font color=\"#ef51ef\">" . $zlom['crystal'] . "</font><br /></center>"; parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetAmount . "',\n\t\t\t\t\t\t\t\t\t`fleet_array` = '" . $FleetArray . "',\n\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\n\t\t\t\t\t\t\t\t\tWHERE fleet_id = '" . (int) $fleet_row['fleet_id'] . "';"); $this->destroy_message($current_data['id'], $raport, $fleet_row['fleet_start_time']); $raport2 = "<a href=\"#\" OnClick=\\'f(\"game.php?page=CombatReport&report=" . $rid . "\", \"\");\\' >"; $raport2 .= "<center>"; $raport2 .= $this->set_report_color($FleetResult, FALSE); $raport2 .= $this->_lang['sys_mess_destruc_report'] . " [" . $fleet_row['fleet_end_galaxy'] . ":" . $fleet_row['fleet_end_system'] . ":" . $fleet_row['fleet_end_planet'] . "] </font></a><br /><br />"; $this->destroy_message($target_data['planet_user_id'], $raport2, $fleet_row['fleet_start_time']); } elseif ($fleet_row['fleet_mess'] == 1 && $fleet_row['fleet_end_time'] <= time()) { parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * 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 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']); } }
public function getFileMission($language, $id) { if (!$this->setupLanguage($language)) { App::abort(404); } // Redirection de l'utilisateur s'il est pas connecté : if (!Auth::check()) { return Redirect::to(URL::to($language . '/home')); } try { $mission = Missions::where('_id', "=", $id)->firstOrFail(); return Response::download(app_path() . "/" . $mission->_file); } catch (Exception $e) { App::abort(404); } }
/** * 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']); } }
/** * method spy_mission * param $fleet_row * return the spy result */ public function spy_mission($fleet_row) { if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) { $current_data = parent::$db->query_fetch("SELECT p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, u.user_name, r.research_espionage_technology, pr.premium_officier_technocrat\n\t\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\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\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\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\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\tp.`planet_type` = " . $fleet_row['fleet_start_type'] . ";"); $target_data = parent::$db->query_fetch("SELECT p.`planet_id`, p.planet_user_id, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, p.planet_metal, p.planet_crystal, p.planet_deuterium, p.planet_energy_max, s.*, d.*, b.*, r.*, pr.premium_officier_technocrat\n\t\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\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\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\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\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`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\tp.`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\tp.`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\tp.`planet_type` = '" . $fleet_row['fleet_end_type'] . "';"); $CurrentSpyLvl = Officiers_Lib::get_max_espionage($current_data['research_espionage_technology'], $current_data['premium_officier_technocrat']); $TargetSpyLvl = Officiers_Lib::get_max_espionage($target_data['research_espionage_technology'], $target_data['premium_officier_technocrat']); $fleet = explode(';', $fleet_row['fleet_array']); $fquery = ''; parent::make_update($fleet_row, $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type']); foreach ($fleet as $a => $b) { if ($b != '') { $a = explode(",", $b); if ($a[0] == "210") { $LS = $a[1]; $SpyToolDebris = $LS * 300; $MaterialsInfo = $this->spy_target($target_data, 0, $this->_lang['sys_spy_maretials']); $Materials = $MaterialsInfo['String']; $PlanetFleetInfo = $this->spy_target($target_data, 1, $this->_lang['sys_spy_fleet']); $PlanetFleet = $Materials; $PlanetFleet .= $PlanetFleetInfo['String']; $PlanetDefenInfo = $this->spy_target($target_data, 2, $this->_lang['sys_spy_defenses']); $PlanetDefense = $PlanetFleet; $PlanetDefense .= $PlanetDefenInfo['String']; $PlanetBuildInfo = $this->spy_target($target_data, 3, $this->_lang['tech'][0]); $PlanetBuildings = $PlanetDefense; $PlanetBuildings .= $PlanetBuildInfo['String']; $TargetTechnInfo = $this->spy_target($target_data, 4, $this->_lang['tech'][100]); $TargetTechnos = $PlanetBuildings; $TargetTechnos .= $TargetTechnInfo['String']; $TargetForce = $PlanetFleetInfo['Count'] * $LS / 4; if ($TargetForce > 100) { $TargetForce = 100; } $TargetChances = mt_rand(0, $TargetForce); $SpyerChances = mt_rand(0, 100); if ($TargetChances >= $SpyerChances) { $DestProba = "<font color=\"red\">" . $this->_lang['sys_mess_spy_destroyed'] . "</font>"; } elseif ($TargetChances < $SpyerChances) { $DestProba = sprintf($this->_lang['sys_mess_spy_lostproba'], $TargetChances); } $AttackLink = "<center>"; $AttackLink .= "<a href=\"game.php?page=fleet1&galaxy=" . $fleet_row['fleet_end_galaxy'] . "&system=" . $fleet_row['fleet_end_system'] . ""; $AttackLink .= "&planet=" . $fleet_row['fleet_end_planet'] . "&planettype=" . $fleet_row['fleet_end_type'] . ""; $AttackLink .= "&target_mission=1"; $AttackLink .= " \">" . $this->_lang['type_mission'][1] . ""; $AttackLink .= "</a></center>"; $MessageEnd = "<center>" . $DestProba . "</center>"; $spionage_difference = abs($CurrentSpyLvl - $TargetSpyLvl); if ($TargetSpyLvl >= $CurrentSpyLvl) { $ST = pow($spionage_difference, 2); $resources = 1; $fleet = $ST + 2; $defense = $ST + 3; $buildings = $ST + 5; $tech = $ST + 7; } if ($CurrentSpyLvl > $TargetSpyLvl) { $ST = pow($spionage_difference, 2) * -1; $resources = 1; $fleet = $ST + 2; $defense = $ST + 3; $buildings = $ST + 5; $tech = $ST + 7; } if ($resources <= $LS) { $SpyMessage = $Materials . "<br />" . $AttackLink . $MessageEnd; } if ($fleet <= $LS) { $SpyMessage = $PlanetFleet . "<br />" . $AttackLink . $MessageEnd; } if ($defense <= $LS) { $SpyMessage = $PlanetDefense . "<br />" . $AttackLink . $MessageEnd; } if ($buildings <= $LS) { $SpyMessage = $PlanetBuildings . "<br />" . $AttackLink . $MessageEnd; } if ($tech <= $LS) { $SpyMessage = $TargetTechnos . "<br />" . $AttackLink . $MessageEnd; } Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], 0, $this->_lang['sys_mess_qg'], $this->_lang['sys_mess_spy_report'], $SpyMessage); $TargetMessage = $this->_lang['sys_mess_spy_ennemyfleet'] . " " . $current_data['planet_name']; $TargetMessage .= " <a href=\"game.php?page=galaxy&mode=3&galaxy=" . $current_data['planet_galaxy'] . "&system=" . $current_data['planet_system'] . "\">"; $TargetMessage .= "[" . $current_data['planet_galaxy'] . ":" . $current_data['planet_system'] . ":" . $current_data['planet_planet'] . "]</a> (" . $current_data['user_name'] . ") "; $TargetMessage .= $this->_lang['sys_mess_spy_seen_at'] . " " . $target_data['planet_name']; $TargetMessage .= " <a href=\"game.php?page=galaxy&mode=3&galaxy=" . $target_data['planet_galaxy'] . "&system=" . $target_data['planet_system'] . "\">"; $TargetMessage .= "[" . $target_data['planet_galaxy'] . ":" . $target_data['planet_system'] . ":" . $target_data['planet_planet'] . "]</a>."; Functions_Lib::send_message($target_data['planet_user_id'], '', $fleet_row['fleet_start_time'], 0, $this->_lang['sys_mess_spy_control'], $this->_lang['sys_mess_spy_activity'], $TargetMessage . ' ' . sprintf($this->_lang['sys_mess_spy_lostproba'], $TargetChances)); if ($TargetChances >= $SpyerChances) { parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_invisible_start_time` = '" . time() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` + '" . (0 + $SpyToolDebris) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $target_data['id'] . "';"); parent::remove_fleet($fleet_row['fleet_id']); } else { parent::return_fleet($fleet_row['fleet_id']); } } } } } elseif ($fleet_row['fleet_mess'] == 1 && $fleet_row['fleet_end_time'] <= time()) { parent::restore_fleet($fleet_row, TRUE); parent::remove_fleet($fleet_row['fleet_id']); } }
/** * method hazard_nothing * param $fleet_row * return the nothing hazard result */ private function hazard_nothing($fleet_row) { $this->expedition_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_end_stay'], $this->_lang['sys_expe_nothing_' . mt_rand(1, 2)]); parent::return_fleet($fleet_row['fleet_id']); }
public function getimageAction() { $this->_helper->layout->disableLayout(); $id = (int) $this->_request->getParam('id', 0); $missionTable = new Missions(); $brand = $missionTable->find($id)->current(); //Zend_Debug::dump($photo); header("Content-type:{$brand->logo_type}"); $this->view->image = base64_decode($brand->logo); }