Exemplo n.º 1
0
function tpl_parse_fleet_db($fleet, $index, $user_data = false)
{
    global $lang, $time_now, $user, $sn_data;
    if (!$user_data) {
        $user_data = $user;
    }
    if ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == 2) {
        $aks = doquery("SELECT * FROM {{aks}} WHERE id={$fleet['fleet_group']} LIMIT 1;", '', true);
    }
    $spy_level = $user['id'] == $fleet['fleet_owner'] ? 100 : $user[$sn_data[TECH_SPY]['name']] + $user[$sn_data[MRC_SPY]['name']];
    $return['fleet'] = array('NUMBER' => $index, 'ID' => $fleet['fleet_id'], 'OWNER' => $fleet['fleet_owner'], 'TARGET_OWNER' => $fleet['fleet_target_owner'], 'MESSAGE' => $fleet['fleet_mess'], 'MISSION' => $fleet['fleet_mission'], 'MISSION_NAME' => $lang['type_mission'][$fleet['fleet_mission']], 'ACS' => $aks['name'], 'AMOUNT' => $spy_level >= 4 ? pretty_number($fleet['fleet_amount']) . ($fleet['fleet_resource_metal'] + $fleet['fleet_resource_crystal'] + $fleet['fleet_resource_deuterium'] ? '+' : '') : '?', 'METAL' => $spy_level >= 8 ? $fleet['fleet_resource_metal'] : 0, 'CRYSTAL' => $spy_level >= 8 ? $fleet['fleet_resource_crystal'] : 0, 'DEUTERIUM' => $spy_level >= 8 ? $fleet['fleet_resource_deuterium'] : 0, 'START_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$fleet['fleet_start_type']], 'START_COORDS' => "[{$fleet['fleet_start_galaxy']}:{$fleet['fleet_start_system']}:{$fleet['fleet_start_planet']}]", 'START_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['fleet_end_time']), 'START_LEFT' => floor($fleet['fleet_end_time'] + 1 - $time_now), 'START_URL' => uni_render_coordinates_href($fleet, 'fleet_start_', 3), 'START_NAME' => $fleet['fleet_start_name'], 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$fleet['fleet_end_type']], 'END_COORDS' => "[{$fleet['fleet_end_galaxy']}:{$fleet['fleet_end_system']}:{$fleet['fleet_end_planet']}]", 'END_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['fleet_start_time']), 'END_LEFT' => floor($fleet['fleet_start_time'] + 1 - $time_now), 'END_URL' => uni_render_coordinates_href($fleet, 'fleet_end_', 3), 'END_NAME' => $fleet['fleet_end_name'], 'STAY_TIME' => date(FMT_DATE_TIME, $fleet['fleet_end_stay']), 'STAY_LEFT' => floor($fleet['fleet_end_stay'] + 1 - $time_now), 'OV_LABEL' => $fleet['ov_label'], 'OV_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['ov_time']), 'OV_LEFT' => floor($fleet['ov_time'] + 1 - $time_now), 'OV_THIS_PLANET' => $fleet['ov_this_planet']);
    $ship_list = explode(';', $fleet['fleet_array']);
    if ($spy_level >= 6) {
        foreach ($ship_list as $ship_record) {
            if ($ship_record) {
                $ship_data = explode(',', $ship_record);
                if ($spy_level >= 10) {
                    $return['ships'][$ship_data[0]] = array('ID' => $ship_data[0], 'NAME' => $lang['tech'][$ship_data[0]], 'AMOUNT' => $ship_data[1], 'CONSUMPTION' => GetShipConsumption($ship_data[0], $user_data), 'SPEED' => get_ship_speed($ship_data[0], $user_data), 'CAPACITY' => $sn_data[$ship_data[0]]['capacity']);
                } else {
                    $return['ships'][$ship_data[0]] = array('ID' => $ship_id++, 'NAME' => $lang['tech'][SHIP_FLEET], 'AMOUNT' => $ship_data[1], 'CONSUMPTION' => 0, 'SPEED' => 0, 'CAPACITY' => 0);
                }
            }
        }
    }
    return $return;
}
Exemplo n.º 2
0
function GetFleetConsumption($FleetArray, $SpeedFactor, $MissionDuration, $MissionDistance, $FleetMaxSpeed, $Player, $speed_percent = 10)
{
    $consumption = 0;
    if (empty($FleetArray) || !$FleetMaxSpeed) {
        return 0;
    }
    $MissionDuration = $MissionDuration < 1 ? 1 : $MissionDuration;
    $MissionDistance = $MissionDistance < 1 ? 1 : $MissionDistance;
    $SpeedFactor = $SpeedFactor == 10 ? 11 : $SpeedFactor;
    $spd = $speed_percent * sqrt($FleetMaxSpeed);
    foreach ($FleetArray as $Ship => $Count) {
        if (!$Ship || !$Count) {
            continue;
        }
        $ShipSpeed = get_ship_speed($Ship, $Player);
        $ShipSpeed = $ShipSpeed < 1 ? 1 : $ShipSpeed;
        $ShipConsumption = GetShipConsumption($Ship, $Player);
        $consumption += $ShipConsumption * $Count * pow($spd / sqrt($ShipSpeed) / 10 + 1, 2);
    }
    $consumption = round($MissionDistance * $consumption / 35000) + 1;
    return $consumption;
}