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;
}
Example #3
0
if ($replay) {
    $unpacked = sn_ube_simulator_decode_replay($replay);
    $sym_defender = $unpacked['D'];
    $sym_attacker = $unpacked['A'];
} else {
    $sym_defender = array(0 => $sym_defender);
    $sym_attacker = array(1 => $sym_attacker);
}
if ($_POST['submit'] || $execute) {
    $replay = sn_ube_simulator_encode_replay($sym_defender, 'D');
    $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A');
    $combat_data = sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender);
    $combat_data[UBE_OPTIONS][UBE_METHOD] = $config->game_ube_method ? $config->game_ube_method : 0;
    sn_ube_combat($combat_data);
    if (!sys_get_param_int('simulator') || sys_get_param_str('reload')) {
        sn_ube_report_save($combat_data);
    }
    if (sys_get_param_str('reload')) {
        $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
    }
    //debug($combat_data);
    // Рендерим их в темплейт
    sn_ube_report_generate($combat_data, $template_result);
    $template_result['MICROTIME'] = $combat_data[UBE_TIME_SPENT];
    $template = gettemplate('ube_combat_report', true);
    $template->assign_recursive($template_result);
    display($template, '', false, '', false, false, true);
} else {
    $template = gettemplate('simulator', true);
    $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL);
    foreach ($techs_and_officers as $tech_id) {