function GetBuildingTime($user, $planet, $Element, $for_building = BUILD_CREATE, $level = false) { global $config, $sn_data; $isDefense = in_array($Element, $sn_data['groups']['defense']); $isFleet = in_array($Element, $sn_data['groups']['fleet']); if ($level === false) { $unit_db_name = $sn_data[$Element]['name']; $level = $planet[$unit_db_name] ? $planet[$unit_db_name] : $user[$unit_db_name]; $level = ($level and !($isDefense or $isFleet)) ? $level : 1; } $time = ($sn_data[$Element]['metal'] + $sn_data[$Element]['crystal'] + $sn_data[$Element]['deuterium']) * pow($sn_data[$Element]['factor'], $level) / get_game_speed() / 2500; if (in_array($Element, $sn_data['groups']['structures'])) { // Pour un batiment ... $time = $time * (1 / ($planet[$sn_data['14']['name']] + 1)) * pow(0.5, $planet[$sn_data['15']['name']]); $time = floor(mrc_modify_value($user, $planet, MRC_ARCHITECT, $time * 60 * 60)); } elseif (in_array($Element, $sn_data['groups']['tech'])) { // Pour une recherche $intergal_lab = $user[$sn_data[TECH_RESEARCH]['name']]; if ($intergal_lab < 1) { $time = $time / (($planet[$sn_data['31']['name']] + 1) * 2) * pow(0.5, $planet[$sn_data['35']['name']]); } else { $lab_require = intval($sn_data[$Element]['require'][31]); $limite = $intergal_lab + 1; $inves = doquery("SELECT SUM(laboratory) AS laboratorio\r\n FROM\r\n (\r\n SELECT laboratory\r\n FROM {{planets}}\r\n WHERE id_owner='{$user['id']}' AND laboratory>={$lab_require}\r\n ORDER BY laboratory DESC\r\n LIMIT {$limite}\r\n ) AS subquery;", '', true); // $time = $time / (($inves['laboratorio'] + 1) * 2) * pow(0.5, $planet[$sn_data[35]['name']]); $inves = doquery("SELECT SUM(lab) AS laboratorio\r\n FROM\r\n (\r\n SELECT ({$sn_data[31]['name']} + 1) * 2 / pow(0.5, {$sn_data[35]['name']}) AS lab\r\n FROM {{planets}}\r\n WHERE id_owner='{$user['id']}' AND {$sn_data[31]['name']} >= {$lab_require}\r\n ORDER BY lab DESC\r\n LIMIT {$limite}\r\n ) AS subquery;", '', true); $time = $time / $inves['laboratorio']; } $time = floor(mrc_modify_value($user, $planet, MRC_ACADEMIC, $time * 60 * 60)); } elseif ($isDefense) { // Pour les defenses ou la flotte 'tarif fixe' durée adaptée a u niveau nanite et usine robot $time = $time * (1 / ($planet[$sn_data[21]['name']] + 1)) * pow(1 / 2, $planet[$sn_data[15]['name']]); $time = floor(mrc_modify_value($user, $planet, MRC_FORTIFIER, $time * 60 * 60)); } elseif ($isFleet) { $time = $time * (1 / ($planet[$sn_data[21]['name']] + 1)) * pow(1 / 2, $planet[$sn_data[15]['name']]); $time = floor(mrc_modify_value($user, $planet, MRC_CONSTRUCTOR, $time * 60 * 60)); } if ($for_building == BUILD_DESTROY) { $time = floor($time / 2); } return $time ? $time : 1; }
<?php $allow_anonymous = true; include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('admin'); $template = gettemplate('server_info', true); $template->assign_vars(array('game_speed' => get_game_speed(), 'fleet_speed' => get_fleet_speed(), 'game_build_and_research' => $config->BuildLabWhileRun, 'USER_VACATION_DISABLE' => $config->user_vacation_disable, 'ALLOW_BUFFING' => $config->allow_buffing, 'ALLY_HELP_WEAK' => $config->ally_help_weak, 'DB_VERSION' => DB_VERSION, 'SN_VERSION' => SN_VERSION, 'FLEET_BASHING_ATTACKS' => $config->fleet_bashing_attacks, 'fleet_bashing_interval' => sys_time_human($config->fleet_bashing_interval), 'fleet_bashing_scope' => sys_time_human($config->fleet_bashing_scope), 'fleet_bashing_war_delay' => sys_time_human($config->fleet_bashing_war_delay))); display(parsetemplate($template));
function eco_get_build_data(&$user, $planet, $unit_id, $unit_level = 0, $only_cost = false) { global $config; $rpg_exchange_deuterium = $config->rpg_exchange_deuterium; $unit_data = get_unit_param($unit_id); // $unit_db_name = &$unit_data[P_NAME]; $unit_factor = $unit_data[P_COST][P_FACTOR] ? $unit_data[P_COST][P_FACTOR] : 1; $price_increase = pow($unit_factor, $unit_level); $can_build = isset($unit_data[P_MAX_STACK]) && $unit_data[P_MAX_STACK] ? $unit_data[P_MAX_STACK] : 1000000000000.0; $can_destroy = 1000000000000.0; $time = 0; $only_dark_matter = 0; foreach ($unit_data[P_COST] as $resource_id => $resource_amount) { if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { continue; } $cost[BUILD_CREATE][$resource_id] = round($resource_cost); $cost[BUILD_DESTROY][$resource_id] = round($resource_cost / 2); $resource_db_name = pname_resource_name($resource_id); if (in_array($resource_id, sn_get_groups('resources_loot'))) { $time += $resource_cost * $config->__get("rpg_exchange_{$resource_db_name}") / $rpg_exchange_deuterium; $resource_got = mrc_get_level($user, $planet, $resource_id); } elseif ($resource_id == RES_DARK_MATTER) { $resource_got = mrc_get_level($user, null, $resource_id); } elseif ($resource_id == RES_ENERGY) { $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']); } else { $resource_got = 0; } $only_dark_matter = $only_dark_matter ? $only_dark_matter : $resource_id; $can_build = min($can_build, $resource_got / $cost[BUILD_CREATE][$resource_id]); $can_destroy = min($can_destroy, $resource_got / $cost[BUILD_DESTROY][$resource_id]); } $can_build = $can_build > 0 ? floor($can_build) : 0; $cost['CAN'][BUILD_CREATE] = $can_build; $can_destroy = $can_destroy > 0 ? floor($can_destroy) : 0; $cost['CAN'][BUILD_DESTROY] = $can_destroy; $cost[P_OPTIONS][P_ONLY_DARK_MATTER] = $only_dark_matter = $only_dark_matter == RES_DARK_MATTER; $cost[P_OPTIONS][P_TIME_RAW] = $time = $time * 60 * 60 / get_game_speed() / 2500; // TODO - Вынести в отдельную процедуру расчёт стоимости if ($only_cost) { return $cost; } $cost['RESULT'][BUILD_CREATE] = eco_can_build_unit($user, $planet, $unit_id); $cost['RESULT'][BUILD_CREATE] = $cost['RESULT'][BUILD_CREATE] == BUILD_ALLOWED ? $cost['CAN'][BUILD_CREATE] ? BUILD_ALLOWED : BUILD_NO_RESOURCES : $cost['RESULT'][BUILD_CREATE]; $mercenary = 0; $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE; if (in_array($unit_id, sn_get_groups('structures'))) { $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1); $mercenary = MRC_ENGINEER; $cost['RESULT'][BUILD_DESTROY] = mrc_get_level($user, $planet, $unit_id, false, true) ? $cost['CAN'][BUILD_DESTROY] ? $cost['RESULT'][BUILD_CREATE] == BUILD_UNIT_BUSY ? BUILD_UNIT_BUSY : BUILD_ALLOWED : BUILD_NO_RESOURCES : BUILD_NO_UNITS; } elseif (in_array($unit_id, sn_get_groups('tech'))) { $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data['require'][STRUC_LABORATORY])); $time = $time / $lab_level; $mercenary = MRC_ACADEMIC; } elseif (in_array($unit_id, sn_get_groups('defense'))) { $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); $mercenary = MRC_FORTIFIER; } elseif (in_array($unit_id, sn_get_groups('fleet'))) { $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); $mercenary = MRC_ENGINEER; } if ($mercenary) { $time = $time / mrc_modify_value($user, $planet, $mercenary, 1); } if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0; } else { $cost[RES_TIME][BUILD_CREATE] = round($time >= 1 ? $time : 1); $cost[RES_TIME][BUILD_DESTROY] = round($time / 2 <= 1 ? 1 : $time / 2); } return $cost; }
<?php $allow_anonymous = true; include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('admin'); $template = gettemplate('server_info', true); $template->assign_vars(array('game_build_and_research' => $config->BuildLabWhileRun, 'USER_VACATION_DISABLE' => $config->user_vacation_disable, 'ALLOW_BUFFING' => $config->allow_buffing, 'ALLY_HELP_WEAK' => $config->ally_help_weak, 'FLEET_BASHING_ATTACKS' => $config->fleet_bashing_attacks, 'fleet_bashing_interval' => sys_time_human($config->fleet_bashing_interval), 'fleet_bashing_scope' => sys_time_human($config->fleet_bashing_scope), 'fleet_bashing_war_delay' => sys_time_human($config->fleet_bashing_war_delay), 'EMPIRE_MERCENARY_TEMPORARY' => $config->empire_mercenary_temporary, 'ALI_BONUS_MEMBERS' => isset($sn_module['ali_ally_player']) ? $config->ali_bonus_members : 0, 'PLAYER_MAX_COLONIES' => $config->player_max_colonies, 'GAME_MULTIACCOUNT_ENABLED' => $config->game_multiaccount_enabled, 'GAME_SPEED' => get_game_speed(), 'GAME_SPEED_PLAIN' => get_game_speed(true), 'FLEET_SPEED' => flt_server_flight_speed_multiplier(), 'FLEET_SPEED_PLAIN' => flt_server_flight_speed_multiplier(true), 'RESOURCE_MULTIPLIER' => game_resource_multiplier(), 'RESOURCE_MULTIPLIER_PLAIN' => game_resource_multiplier(true))); display(parsetemplate($template));
/** * eco_get_build_data.php * * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws * @version 1.0 */ function eco_get_build_data($user, $planet, $unit_id, $unit_level = 0) { global $sn_data; $sn_groups = $sn_data['groups']; $unit_data = $sn_data[$unit_id]; $unit_db_name = $unit_data['name']; $unit_factor = $unit_data['factor'] ? $unit_data['factor'] : 1; $price_increase = pow($unit_factor, $unit_level); $can_build = 1000000000000; foreach ($unit_data['cost'] as $resource_id => $resource_amount) { $resource_cost = $resource_amount * $price_increase; $cost[BUILD_CREATE][$resource_id] = floor($resource_cost); $cost[BUILD_DESTROY][$resource_id] = floor($resource_cost / 2); if ($resource_id != RES_ENERGY && $resource_id != RES_DARK_MATTER) { if ($resource_cost != 0) { $can_build = min($can_build, $planet[$sn_data[$resource_id]['name']] / $resource_cost); } $time += $resource_cost; } } $cost['CAN'][BUILD_DESTROY] = floor($can_build * 2); $cost['CAN'][BUILD_CREATE] = floor($can_build); $time = $time * 60 * 60 / get_game_speed() / 2500; $mercenary = 0; if (in_array($unit_id, $sn_groups['structures'])) { $time = $time * pow(0.5, $planet[$sn_data[15]['name']]) / ($planet[$sn_data[14]['name']] + 1); $mercenary = MRC_ARCHITECT; } elseif (in_array($unit_id, $sn_groups['tech'])) { $tech_intergalactic = $user[$sn_data[TECH_RESEARCH]['name']]; if ($tech_intergalactic < 1) { $time = $time * pow(0.5, $planet[$sn_data[35]['name']]) / (($planet[$sn_data[31]['name']] + 1) * 2); } else { $lab_db_name = $sn_data[31]['name']; $lab_require = intval($unit_data['require'][31]); $tech_intergalactic = $tech_intergalactic + 1; /* $inves = doquery("SELECT SUM(`{$lab_db_name}`) AS `laboratorio` FROM ( SELECT `{$lab_db_name}` FROM `{{planets}}` WHERE `id_owner` = '{$user['id']}' AND `{$lab_db_name}` >= {$lab_require} ORDER BY `{$lab_db_name}` DESC LIMIT {$tech_intergalactic} ) AS subquery;", '', true); // $time = $time / (($inves['laboratorio'] + 1) * 2) * pow(0.5, $planet[$sn_data[35]['name']]); */ // TODO: Fix bug with counting building labs/nanolabs $inves = doquery("SELECT SUM(lab) AS effective_level\r\n FROM\r\n (\r\n SELECT ({$lab_db_name} + 1) * 2 / pow(0.5, {$sn_data[35]['name']}) AS lab\r\n FROM {{planets}}\r\n WHERE id_owner='{$user['id']}' AND {$lab_db_name} >= {$lab_require}\r\n ORDER BY lab DESC\r\n LIMIT {$tech_intergalactic}\r\n ) AS subquery;", '', true); $time = $time / $inves['effective_level']; } $mercenary = MRC_ACADEMIC; } elseif (in_array($unit_id, $sn_groups['defense'])) { $time = $time * pow(0.5, $planet[$sn_data[15]['name']]) / ($planet[$sn_data[21]['name']] + 1); $mercenary = MRC_FORTIFIER; } elseif (in_array($unit_id, $sn_groups['fleet'])) { $time = $time * pow(0.5, $planet[$sn_data[15]['name']]) / ($planet[$sn_data[21]['name']] + 1); $mercenary = MRC_CONSTRUCTOR; } if ($mercenary) { $time = mrc_modify_value($user, $planet, $mercenary, $time); } $time = $time >= 2 ? $time : 2; $cost[BUILD_CREATE][RES_TIME] = floor($time); $cost[BUILD_DESTROY][RES_TIME] = floor($time / 2); return $cost; }