Пример #1
0
            continue;
        }
    }
    //  $SubQry = substr($SubQry, 0, -1);
    //  if($SubQry) {
    //    db_planet_set_by_id($planetrow['id'], $SubQry);
    //  }
    !empty($SubQry) ? db_planet_set_by_id($planetrow['id'], implode(',', $SubQry)) : false;
}
// -------------------------------------------------------------------------------------------------------
// $BuildTemp                   = $planetrow[ 'temp_max' ];
// $BuildEnergyTech             = $user['energy_tech'];
for ($Option = 10; $Option >= 0; $Option--) {
    $template->assign_block_vars('option', array('VALUE' => $Option * 10));
}
$caps_real = eco_get_planet_caps($user, $planetrow, 3600);
$template->assign_block_vars('production', array('TYPE' => $lang['res_basic_income'], 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][0], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][0], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][0], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][0], true, true)));
foreach ($sn_group_factories as $unit_id) {
    if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) {
        $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
        $template->assign_block_vars('production', array('ID' => $unit_id, 'PERCENT' => $planetrow[pname_factory_production_field_name($unit_id)] * 10, 'TYPE' => $lang['tech'][$unit_id], 'LEVEL' => $level_plain, 'LEVEL_BONUS' => mrc_get_level($user, $planetrow, $unit_id) - $level_plain, 'LEVEL_TYPE' => $unit_id > 200 ? $lang['quantity'] : $lang['level'], 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][$unit_id], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][$unit_id], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][$unit_id], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][$unit_id], true, true), 'METAL_FULL' => pretty_number($caps_real['production_full'][RES_METAL][$unit_id], true, true), 'CRYSTAL_FULL' => pretty_number($caps_real['production_full'][RES_CRYSTAL][$unit_id], true, true), 'DEUTERIUM_FULL' => pretty_number($caps_real['production_full'][RES_DEUTERIUM][$unit_id], true, true), 'ENERGY_FULL' => pretty_number($caps_real['production_full'][RES_ENERGY][$unit_id], true, true), 'SELECT' => $row_select, 'P_MINING_IS_MANAGED' => get_unit_param($unit_id, P_MINING_IS_MANAGED)));
    }
}
$user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER);
$planet_density_index = $planetrow['density_index'];
$density_price_chart = planet_density_price_chart($planetrow);
tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
$template->assign_block_vars('production', array('TYPE' => $lang['res_total'], 'METAL_TYPE' => pretty_number($caps_real['total'][RES_METAL], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['total'][RES_CRYSTAL], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['total'][RES_DEUTERIUM], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['total'][RES_ENERGY], true, true), 'METAL_FULL' => pretty_number($caps_real['total_production_full'][RES_METAL], true, true), 'CRYSTAL_FULL' => pretty_number($caps_real['total_production_full'][RES_CRYSTAL], true, true), 'DEUTERIUM_FULL' => pretty_number($caps_real['total_production_full'][RES_DEUTERIUM], true, true), 'ENERGY_FULL' => pretty_number($caps_real['total_production_full'][RES_ENERGY], true, true)));
int_calc_storage_bar(RES_METAL);
int_calc_storage_bar(RES_CRYSTAL);
int_calc_storage_bar(RES_DEUTERIUM);
Пример #2
0
function sys_o_get_updated($user, $planet, $UpdateTime, $simulation = false, $no_user_update = false)
{
    sn_db_transaction_check(true);
    $no_data = array('user' => false, 'planet' => false, 'que' => false);
    if (!$planet) {
        return $no_data;
    }
    if (!$no_user_update) {
        $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user);
        if (!$user) {
            // TODO - Убрать позже
            print '<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>';
            $backtrace = debug_backtrace();
            array_shift($backtrace);
            pdump($backtrace);
            die;
        }
        $user = db_user_by_id($user, !$simulation, '*', true);
    }
    if (empty($user['id'])) {
        return $no_data;
    }
    if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
        $planet = db_planet_by_vector($planet, '', !$simulation);
    } else {
        $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet);
        $planet = db_planet_by_id($planet, !$simulation);
    }
    if (!is_array($planet) || !isset($planet['id'])) {
        return $no_data;
    }
    $que = que_process($user, $planet, $UpdateTime);
    $ProductionTime = max(0, $UpdateTime - $planet['last_update']);
    $planet['prev_update'] = $planet['last_update'];
    $planet['last_update'] += $ProductionTime;
    /*
    $que = eco_que_process($user, $planet, $ProductionTime);
    $hangar_built = $ProductionTime && !$simulation ? eco_bld_que_hangar($user, $planet, $ProductionTime) : array();
    */
    // TODO ЭТО НАДО ДЕЛАТЬ ТОЛЬКО ПРИ СПЕЦУСЛОВИЯХ
    $caps_real = eco_get_planet_caps($user, $planet, $ProductionTime);
    $resources_increase = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0);
    switch ($planet['planet_type']) {
        case PT_PLANET:
            foreach ($resources_increase as $resource_id => &$increment) {
                $resource_name = pname_resource_name($resource_id);
                $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600;
                $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name];
                $increment = min($increment, max(0, $store_free));
                if ($planet[$resource_name] + $increment < 0 && !$simulation) {
                    global $debug;
                    $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501);
                }
                $planet[$resource_name] += $increment;
                $planet[$resource_name . '_perhour'] = $caps_real['total'][$resource_id];
            }
            break;
        case PT_MOON:
        default:
            $planet['metal_perhour'] = 0;
            $planet['crystal_perhour'] = 0;
            $planet['deuterium_perhour'] = 0;
            $planet['energy_used'] = 0;
            $planet['energy_max'] = 0;
            break;
    }
    // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора
    $planet['field_current'] = 0;
    $sn_group_build_allow = sn_get_groups('build_allow');
    if (is_array($sn_group_build_allow[$planet['planet_type']])) {
        foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) {
            $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true);
        }
    }
    if ($simulation) {
        return array('user' => $user, 'planet' => $planet, 'que' => $que);
    }
    db_planet_set_by_id($planet['id'], "`last_update` = '{$planet['last_update']}', `field_current` = {$planet['field_current']},\n    `metal` = `metal` + '{$resources_increase[RES_METAL]}', `crystal` = `crystal` + '{$resources_increase[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$resources_increase[RES_DEUTERIUM]}',\n    `metal_perhour` = '{$planet['metal_perhour']}', `crystal_perhour` = '{$planet['crystal_perhour']}', `deuterium_perhour` = '{$planet['deuterium_perhour']}',\n    `energy_used` = '{$planet['energy_used']}', `energy_max` = '{$planet['energy_max']}'");
    return array('user' => $user, 'planet' => $planet, 'que' => $que);
}