/** * flt_mission_transport.php * * @version 2.0 return cacher result * @version 1 * @copyright 2008 By Chlorel for XNova */ function flt_mission_transport(&$mission_data) { $fleet_row =& $mission_data['fleet']; $source_planet =& $mission_data['src_planet']; $destination_planet =& $mission_data['dst_planet']; if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) { // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); flt_send_back($fleet_row); return CACHE_FLEET; } global $lang; $Message = sprintf($lang['sys_tran_mess_user'], $source_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']); msg_send_simple_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); if ($fleet_row['fleet_target_owner'] != $fleet_row['fleet_owner']) { msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); } /* $Message = sprintf( $lang['sys_tran_mess_owner'], $TargetName, uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium'] ); msg_send_simple_message ( $StartOwner, '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); */ return RestoreFleetToPlanet($fleet_row, false, true); }
function flt_mission_hold(&$mission_data) { if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) { flt_send_back($mission_data['fleet']); // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"); return CACHE_FLEET; } return CACHE_NOTHING; }
function flt_mission_destroy($mission_data) { $fleet_row = $mission_data['fleet']; $destination_planet = $mission_data['dst_planet']; if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { flt_send_back($fleet_row); return CACHE_FLEET; } $combat_data = flt_mission_attack($mission_data); return $combat_data; /* $combat_data = flt_mission_attack($mission_data, false); if(empty($combat_data) || $combat_data[UBE_OUTCOME][UBE_COMBAT_RESULT] != UBE_COMBAT_RESULT_WIN) { return $combat_data; } $fleet_row = $mission_data['fleet']; $destination_planet = $mission_data['dst_planet']; if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); return $combat_data; } // sn_ube_combat_analyze_moon_destroy($combat_data); sn_ube_report_save($combat_data); $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); sn_db_transaction_commit(); //debug($combat_data); sn_db_transaction_start(); ube_combat_result_apply($combat_data); sn_db_transaction_rollback(); sn_ube_message_send($combat_data); // $combat_data[UBE_OUTCOME][UBE_MOON] = UBE_MOON_DESTROY_SUCCESS; global $template_result; sn_ube_report_generate($combat_data, $template_result); $template = gettemplate('ube_combat_report', true); $template->assign_recursive($template_result); display($template, '', false, '', false, false, true); die(); // $combat_data[UBE_OUTCOME][UBE_MOON] = UBE_MOON_DESTROY_FAILED; // $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = UBE_MOON_REAPERS_NONE; // $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = UBE_MOON_REAPERS_DIED; // $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = UBE_MOON_REAPERS_RETURNED; // $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] = min(99, round((100 - sqrt($moon_size)) * sqrt($reapers))); // $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS_DIE_CHANCE] = round(sqrt($moon_size) / 2); // $combat_data[UBE_OUTCOME][UBE_PLANET][PLANET_SIZE] return $combat_data; */ }
function flt_mission_destroy($mission_data) { $fleet_row = $mission_data['fleet']; $destination_planet = $mission_data['dst_planet']; if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { flt_send_back($fleet_row); return CACHE_FLEET; } $combat_data = flt_mission_attack($mission_data); return $combat_data; }
/** * MissionCaseStay.php * * version 2.0 returns results for new fleet handler * @version 1.1 * @copyright 2008 by Chlorel for XNova */ function flt_mission_relocate($mission_data) { $fleet_row =& $mission_data['fleet']; $destination_planet =& $mission_data['dst_planet']; if (!$destination_planet || !is_array($destination_planet)) { // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); flt_send_back($mission_data['fleet']); return CACHE_FLEET; } global $lang; $Message = sprintf($lang['sys_tran_mess_user'], $mission_data['src_planet']['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']) . '<br />' . $lang['sys_relocate_mess_user']; foreach (sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) { $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; } msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_qg'], $lang['sys_stay_mess_stay'], $Message); return RestoreFleetToPlanet($fleet_row, false); }
function flt_mission_attack($mission_data, $save_report = true) { $fleet_row = $mission_data['fleet']; $destination_user = $mission_data['dst_user']; $destination_planet = $mission_data['dst_planet']; if (!$fleet_row) { return; } if (!$destination_user || !$destination_planet || !is_array($destination_user) || !is_array($destination_planet) || $fleet_row['fleet_mission'] == MT_DESTROY && $destination_planet['planet_type'] != PT_MOON) { // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); flt_send_back($fleet_row); return; } $combat_data = ube_attack_prepare($mission_data); sn_ube_combat($combat_data); sn_ube_report_save($combat_data); ube_combat_result_apply($combat_data); sn_ube_message_send($combat_data); return $combat_data; }
function flt_mission_attack($mission_data, $save_report = true) { $fleet_row = $mission_data['fleet']; $destination_user = $mission_data['dst_user']; $destination_planet = $mission_data['dst_planet']; if (!$fleet_row) { return null; } if (empty($destination_user) || empty($destination_planet) || !is_array($destination_user) || !is_array($destination_planet) || $fleet_row['fleet_mission'] == MT_DESTROY && $destination_planet['planet_type'] != PT_MOON) { // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); flt_send_back($fleet_row); return null; } $combat_data = ube_attack_prepare($mission_data); sn_ube_combat($combat_data); flt_planet_capture($fleet_row, $combat_data); sn_ube_report_save($combat_data); ube_combat_result_apply($combat_data); sn_ube_message_send($combat_data); // global $config;sn_db_transaction_rollback();$config->db_saveItem('fleet_update_lock', '');die(); return $combat_data; }
/** * MissionCaseRecycling.php * * @version 1.0 * @copyright 2008 By Chlorel for XNova */ function flt_mission_recycle(&$mission_data) { $fleet_row =& $mission_data['fleet']; $destination_planet =& $mission_data['dst_planet']; if (!$fleet_row) { return CACHE_NOTHING; } if (!isset($destination_planet['id'])) { // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); flt_send_back($mission_data['fleet']); return CACHE_FLEET; } global $lang; $RecyclerCapacity = 0; $OtherFleetCapacity = 0; $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); foreach ($fleet_array as $unit_id => $unit_count) { if (in_array($unit_id, sn_get_groups('fleet'))) { $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; if (in_array($unit_id, sn_get_groups('flt_recyclers'))) { $RecyclerCapacity += $capacity; } else { $OtherFleetCapacity += $capacity; } } } $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"]; if ($IncomingFleetGoods > $OtherFleetCapacity) { $RecyclerCapacity -= $IncomingFleetGoods - $OtherFleetCapacity; } if ($destination_planet["debris_metal"] + $destination_planet["debris_crystal"] <= $RecyclerCapacity) { $RecycledGoods["metal"] = $destination_planet["debris_metal"]; $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; } else { if ($destination_planet["debris_metal"] > $RecyclerCapacity / 2 and $destination_planet["debris_crystal"] > $RecyclerCapacity / 2) { $RecycledGoods["metal"] = $RecyclerCapacity / 2; $RecycledGoods["crystal"] = $RecyclerCapacity / 2; } else { if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; if ($destination_planet["debris_metal"] > $RecyclerCapacity - $RecycledGoods["crystal"]) { $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"]; } else { $RecycledGoods["metal"] = $destination_planet["debris_metal"]; } } else { $RecycledGoods["metal"] = $destination_planet["debris_metal"]; if ($destination_planet["debris_crystal"] > $RecyclerCapacity - $RecycledGoods["metal"]) { $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"]; } else { $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; } } } } $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; $NewCargo['Crystal'] = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"]; $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"]; db_planet_set_by_gspt($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], PT_PLANET, "`debris_metal` = `debris_metal` - '{$RecycledGoods['metal']}', `debris_crystal` = `debris_crystal` - '{$RecycledGoods['crystal']}'"); $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal']); msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); $QryUpdateFleet = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' "; $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"; doquery($QryUpdateFleet); return CACHE_FLEET | CACHE_PLANET_DST; }