Example #1
0
if (empty($target_row)) {
    $target_row = array('galaxy' => $target_coord['galaxy'], 'system' => $target_coord['system'], 'planet' => $target_coord['planet'], 'planet_type' => $target_planet_check, 'id_owner' => 0);
}
$fleet_array = array();
switch ($target_mission) {
    case MT_SPY:
        $fleet_array[SHIP_SPY] = min(mrc_get_level($user, $planetrow, SHIP_SPY), abs($user['spio_anz']));
        $unit_group = 'flt_spies';
        break;
    case MT_RECYCLE:
        foreach (sn_get_groups('flt_recyclers') as $unit_id) {
            if ($unit_count = mrc_get_level($user, $planetrow, $unit_id)) {
                $fleet_array[$unit_id] = $unit_count;
            }
        }
        $transport_data = flt_calculate_fleet_to_transport($fleet_array, $target_row['debris_metal'] + $target_row['debris_crystal'], $planetrow, $target_row);
        $fleet_array = $transport_data['fleet'];
        $unit_group = 'flt_recyclers';
        break;
    case MT_MISSILE:
        $fleet_array[UNIT_DEF_MISSILE_INTERPLANET] = min(mrc_get_level($user, $planetrow, UNIT_DEF_MISSILE_INTERPLANET), abs(sys_get_param_float('missiles')));
        $unit_group = 'missile';
        break;
}
$options = array('target_structure' => $target_structure = sys_get_param_int('structures'));
$cant_attack = flt_can_attack($planetrow, $target_row, $fleet_array, $target_mission, $options);
if ($cant_attack != ATTACK_ALLOWED) {
    die($lang['fl_attack_error'][$cant_attack]);
}
$FleetDBArray = array();
$db_changeset = array();
Example #2
0
    if ($uni_galaxyRowPlanet['debris']) {
        if ($fleet_list[$Planet][PT_DEBRIS]) {
            foreach ($fleet_list[$Planet][PT_DEBRIS] as $fleet_row) {
                if ($fleet_row['fleet_owner'] == $user['id']) {
                    $fleet_data = sys_unit_str2arr($fleet_row['fleet_array']);
                    foreach ($recycler_info as $recycler_id => $recycler_data) {
                        $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
                    }
                }
            }
        }
        $uni_galaxyRowPlanet['debris_reserved'] = $recyclers_incoming_capacity;
        $uni_galaxyRowPlanet['debris_reserved_percent'] = min(100, floor($uni_galaxyRowPlanet['debris_reserved'] / $uni_galaxyRowPlanet['debris'] * 100));
        $uni_galaxyRowPlanet['debris_to_gather'] = max(0, $uni_galaxyRowPlanet['debris'] - $recyclers_incoming_capacity);
        $uni_galaxyRowPlanet['debris_to_gather_percent'] = 100 - $uni_galaxyRowPlanet['debris_reserved_percent'];
        $recyclers_fleet_data = flt_calculate_fleet_to_transport($recyclers_fleet, $uni_galaxyRowPlanet['debris_to_gather'], $planetrow, $uni_galaxyRowPlanet);
        $uni_galaxyRowPlanet['debris_will_gather'] = max(0, min($recyclers_fleet_data['capacity'], $uni_galaxyRowPlanet['debris_to_gather']));
        $uni_galaxyRowPlanet['debris_will_gather_percent'] = $uni_galaxyRowPlanet['debris_to_gather'] ? floor($uni_galaxyRowPlanet['debris_will_gather'] / $uni_galaxyRowPlanet['debris_to_gather'] * $uni_galaxyRowPlanet['debris_to_gather_percent']) : 0;
        $uni_galaxyRowPlanet['debris_gather_total'] = max(0, $uni_galaxyRowPlanet['debris_will_gather'] + $uni_galaxyRowPlanet['debris_reserved']);
        $uni_galaxyRowPlanet['debris_gather_total_percent'] = min(100, floor($uni_galaxyRowPlanet['debris_gather_total'] / $uni_galaxyRowPlanet['debris'] * 100));
    }
    $RowUserPoints = $uni_galaxyRowUser['total_points'];
    $birthday_array = $uni_galaxyRowUser['user_birthday'] ? date_parse($uni_galaxyRowUser['user_birthday']) : array();
    $user_activity = floor((SN_TIME_NOW - $uni_galaxyRowUser['onlinetime']) / (60 * 60 * 24));
    $template->assign_block_vars('galaxyrow', array('PLANET_ID' => $uni_galaxyRowPlanet['id'], 'PLANET_NUM' => $Planet, 'PLANET_NAME' => $uni_galaxyRowPlanet['name'], 'PLANET_NAME_JS' => js_safe_string($uni_galaxyRowPlanet['name']), 'PLANET_DESTROYED' => $uni_galaxyRowPlanet["destruyed"], 'PLANET_TYPE' => $uni_galaxyRowPlanet["planet_type"], 'PLANET_ACTIVITY' => floor((SN_TIME_NOW - $uni_galaxyRowPlanet['last_update']) / 60), 'PLANET_IMAGE' => $uni_galaxyRowPlanet['image'], 'PLANET_FLEET_ID' => $planet_fleet_id, 'PLANET_DIAMETER' => number_format($uni_galaxyRowPlanet['diameter'], 0, '', '.'), 'MOON_NAME_JS' => js_safe_string($uni_galaxyRowMoon['name']), 'MOON_IMAGE' => $uni_galaxyRowMoon['image'], 'MOON_DIAMETER' => number_format($uni_galaxyRowMoon['diameter'], 0, '', '.'), 'MOON_TEMP' => number_format($uni_galaxyRowMoon['temp_min'], 0, '', '.'), 'MOON_FLEET_ID' => $moon_fleet_id, 'DEBRIS' => $uni_galaxyRowPlanet['debris'], 'DEBRIS_METAL' => $uni_galaxyRowPlanet['debris_metal'], 'DEBRIS_CRYSTAL' => $uni_galaxyRowPlanet['debris_crystal'], 'DEBRIS_REST_PERCENT' => $uni_galaxyRowPlanet["debris_rest_percent"], 'DEBRIS_RESERVED' => $uni_galaxyRowPlanet['debris_reserved'], 'DEBRIS_RESERVED_PERCENT' => $uni_galaxyRowPlanet['debris_reserved_percent'], 'DEBRIS_WILL_GATHER' => $uni_galaxyRowPlanet['debris_will_gather'], 'DEBRIS_WILL_GATHER_PERCENT' => $uni_galaxyRowPlanet['debris_will_gather_percent'], 'DEBRIS_GATHER_TOTAL' => $uni_galaxyRowPlanet['debris_gather_total'], 'DEBRIS_GATHER_TOTAL_PERCENT' => $uni_galaxyRowPlanet['debris_gather_total_percent'], 'USER_ID' => $uni_galaxyRowUser['id'], 'USER_NAME' => player_nick_render_to_html($uni_galaxyRowUser), 'USER_NAME_JS' => js_safe_string(player_nick_render_to_html($uni_galaxyRowUser)), 'USER_RANK' => in_array($uni_galaxyRowUser['id'], $user_skip_list) ? '-' : $uni_galaxyRowUser['total_rank'], 'USER_BANNED' => $uni_galaxyRowUser['banaday'], 'USER_VACATION' => $uni_galaxyRowUser['vacation'], 'USER_ACTIVITY' => $user_activity, 'USER_ATTACKABLE' => $user_activity >= 7, 'USER_INACTIVE' => $user_activity >= 28, 'USER_PROTECTED' => $RowUserPoints <= $config->game_noob_points, 'USER_NOOB' => $RowUserPoints * $config->game_noob_factor < $CurrentPoints && $config->game_noob_factor, 'USER_STRONG' => $CurrentPoints * $config->game_noob_factor < $RowUserPoints && $config->game_noob_factor, 'USER_AUTH' => $uni_galaxyRowUser['authlevel'], 'USER_ADMIN' => $lang['user_level_shortcut'][$uni_galaxyRowUser['authlevel']], 'USER_BIRTHDAY' => $birthday_array['month'] == $time_now_parsed['mon'] && $birthday_array['day'] == $time_now_parsed['mday'] ? date(FMT_DATE, SN_TIME_NOW) : 0, 'ALLY_ID' => $uni_galaxyRowUser['ally_id'], 'ALLY_TAG' => $uni_galaxyRowUser['ally_tag']));
}
tpl_assign_fleet($template, $fleets);
foreach (sn_get_groups('defense_active') as $unit_id) {
    $template->assign_block_vars('defense_active', array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id]));
}
foreach ($cached['users'] as $PlanetUser) {