예제 #1
0
foreach ($fleet_array as $unit_id => $unit_count) {
    $FleetDBArray[] = "{$unit_id},{$unit_count}";
    // $db_changeset[]  = "`{$unit_db_name}` = `{$unit_db_name}` - {$unit_count}";
    $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$unit_count, $user, $planetrow);
}
$FleetDBArray = implode(';', $FleetDBArray);
// $db_changeset  = implode(',', $db_changeset);
$fleet_ship_count = array_sum($fleet_array);
if ($target_mission == MT_MISSILE) {
    $distance = abs($target_coord['system'] - $planetrow['system']);
    $duration = round((30 + 60 * $distance) / flt_server_flight_speed_multiplier());
    $arrival = SN_TIME_NOW + $duration;
    $travel_data['consumption'] = 0;
    doquery("INSERT INTO `{{iraks}}` SET\n     `fleet_target_owner` = '{$target_row['id_owner']}', `fleet_end_galaxy` = '{$target_coord['galaxy']}', `fleet_end_system` = '{$target_coord['system']}', `fleet_end_planet` = '{$target_coord['planet']}',\n     `fleet_owner` = '{$user['id']}', `fleet_start_galaxy` = '{$planetrow['galaxy']}', `fleet_start_system` = '{$planetrow['system']}', `fleet_start_planet` = '{$planetrow['planet']}',\n     `fleet_end_time` = '{$arrival}', `fleet_amount` = '{$fleet_ship_count}', `primaer` = '{$target_structure}';");
} else {
    $travel_data = flt_travel_data($user, $planetrow, $target_coord, $fleet_array, 10);
    if ($planetrow['deuterium'] < $travel_data['consumption']) {
        die($lang['gs_c13']);
    }
    $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
    $fleet_end_time = $fleet_start_time + $travel_data['duration'];
    $QryInsertFleet = "INSERT INTO {{fleets}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '{$user['id']}', ";
    $QryInsertFleet .= "`fleet_mission` = '{$target_mission}', ";
    $QryInsertFleet .= "`fleet_amount` = '{$fleet_ship_count}', ";
    $QryInsertFleet .= "`fleet_array` = '{$FleetDBArray}', ";
    $QryInsertFleet .= "`fleet_start_time` = '{$fleet_start_time}', ";
    if ($planetrow['id']) {
        $QryInsertFleet .= "`fleet_start_planet_id` = '{$planetrow['id']}', ";
    }
    $QryInsertFleet .= "`fleet_start_galaxy` = '{$planetrow['galaxy']}', `fleet_start_system` = '{$planetrow['system']}', `fleet_start_planet` = '{$planetrow['planet']}', `fleet_start_type`   = '{$planetrow['planet_type']}', ";
예제 #2
0
function flt_calculate_fleet_to_transport($ship_list, $resource_amount, $from, $to)
{
    global $user;
    $ship_data = array();
    $fleet_array = array();
    foreach ($ship_list as $transport_id => $cork) {
        $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10);
    }
    uasort($ship_data, flt_calculate_ship_to_transport_sort);
    $fleet_hold = 0;
    $fleet_capacity = 0;
    $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM);
    foreach ($ship_data as $transport_id => &$ship_info) {
        $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption']));
        if ($ship_loaded) {
            $fleet_array[$transport_id] = $ship_loaded;
            $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded);
            $fuel_left -= $ship_info['consumption'] * $ship_loaded;
            $fleet_capacity += $ship_info['capacity'] * $ship_loaded;
        }
    }
    return array('fleet' => $fleet_array, 'ship_data' => $ship_data, 'capacity' => $fleet_capacity, 'consumption' => $fuel_total - $fuel_left);
}
예제 #3
0
                 }
             }
         }
     }
     if (!$target_mission && is_array($missiontype)) {
         $target_mission = MT_ATTACK;
     }
     //    $sn_group_missions = sn_get_groups('missions');
     //    foreach($sn_group_missions as $mission_id => $cork) {
     //      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
     //    }
     //
     //
     ksort($missiontype);
     $speed_percent = sys_get_param_int('speed', 10);
     $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
     //    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
     $fleet_speed = $travel_data['fleet_speed'];
     $distance = $travel_data['distance'];
     $duration = $travel_data['duration'];
     $consumption = $travel_data['consumption'];
     // No Break
 // No Break
 case 1:
     if ($galaxy && $system && $planet) {
         $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
         $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type);
     }
 case 0:
     $template_result += array('thisgalaxy' => $planetrow['galaxy'], 'thissystem' => $planetrow['system'], 'thisplanet' => $planetrow['planet'], 'thisplanet_type' => $planetrow['planet_type']);
     // no break