Пример #1
0
function sn_imperium_view($template = null)
{
    global $user, $lang;
    $planets = array();
    $ques = array();
    $sn_group_factories = sn_get_groups('factories');
    $planet_density = sn_get_groups('planet_density');
    if (sys_get_param('save_production')) {
        $production = sys_get_param('percent');
        if (is_array($production) && !empty($production)) {
            // sn_db_transaction_start();
            $query = array();
            $planet_row_list = db_planet_list_sorted($user, false, '*');
            // while($planet = db_fetch($planet_row_list))
            foreach ($planet_row_list as $planet) {
                foreach ($sn_group_factories as $factory_unit_id) {
                    $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id);
                    if (get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) && isset($production[$factory_unit_id][$planet['id']]) && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 && $actual_porcent <= 10 && $actual_porcent != $planet[$unit_db_name_porcent]) {
                        $query[$planet['id']][] = "{$unit_db_name_porcent} = {$actual_porcent}";
                    }
                }
            }
            foreach ($query as $planet_id => $query_data) {
                db_planet_set_by_id($planet_id, implode(',', $query_data));
            }
            // sn_db_transaction_commit();
        }
    }
    $planet_row_list = db_planet_list_sorted($user);
    // while ($planet = db_fetch($planet_row_list))
    foreach ($planet_row_list as $planet) {
        sn_db_transaction_start();
        $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true);
        $planets[$planet['id']] = $global_data['planet'];
        // $ques[$planet['id']] = que_get($user['id'], $planet['id'], false);
        $ques[$planet['id']] = $global_data['que'];
        sn_db_transaction_commit();
    }
    $template = gettemplate('imperium', $template);
    $template->assign_var('amount', count($planets) + 2);
    for ($i = 100; $i >= 0; $i -= 10) {
        $template->assign_block_vars('percent', array('PERCENT' => $i));
    }
    $fleet_id = 1;
    $fleets = array();
    $total['temp_min'] = 1000;
    $total['temp_max'] = -999;
    foreach ($planets as $planet_index => &$planet) {
        $list_planet_que = $ques[$planet_index];
        $planet_template = tpl_parse_planet($planet);
        $planet_fleet_id = 0;
        $fleet_list = $planet_template['fleet_list'];
        //flt_get_fleets_to_planet($planet);
        if ($fleet_list['own']['count']) {
            $planet_fleet_id = "p{$fleet_id}";
            $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
            $fleet_id++;
        }
        $template->assign_block_vars('planet', array_merge($planet_template, array('PLANET_FLEET_ID' => $planet_fleet_id, 'METAL_CUR' => pretty_number($planet['metal'], true, $planet['caps']['total_storage'][RES_METAL]), 'METAL_PROD' => pretty_number($planet['caps']['total'][RES_METAL]), 'CRYSTAL_CUR' => pretty_number($planet['crystal'], true, $planet['caps']['total_storage'][RES_CRYSTAL]), 'CRYSTAL_PROD' => pretty_number($planet['caps']['total'][RES_CRYSTAL]), 'DEUTERIUM_CUR' => pretty_number($planet['deuterium'], true, $planet['caps']['total_storage'][RES_DEUTERIUM]), 'DEUTERIUM_PROD' => pretty_number($planet['caps']['total'][RES_DEUTERIUM]), 'ENERGY_CUR' => pretty_number($planet['caps'][RES_ENERGY][BUILD_CREATE] - $planet['caps'][RES_ENERGY][BUILD_DESTROY], true, true), 'ENERGY_MAX' => pretty_number($planet['caps'][RES_ENERGY][BUILD_CREATE]), 'TEMP_MIN' => $planet['temp_min'], 'TEMP_MAX' => $planet['temp_max'], 'DENSITY_CLASS' => $planet['density_index'], 'DENSITY_RICHNESS' => $planet_density[$planet['density_index']][UNIT_PLANET_DENSITY_RICHNESS], 'DENSITY_CLASS_TEXT' => $lang['uni_planet_density_types'][$planet['density_index']])));
        $planet['fleet_list'] = $planet_template['fleet_list'];
        $planet['BUILDING_ID'] = $planet_template['BUILDING_ID'];
        $planet['hangar_que'] = $planet_template['hangar_que'];
        $planet['full_que'] = $list_planet_que;
        $total['fields'] += $planet['field_current'];
        $total['metal'] += $planet['metal'];
        $total['crystal'] += $planet['crystal'];
        $total['deuterium'] += $planet['deuterium'];
        $total['energy'] += $planet['energy_max'] - $planet['energy_used'];
        $total['fields_max'] += eco_planet_fields_max($planet);
        $total['metal_perhour'] += $planet['caps']['total'][RES_METAL];
        $total['crystal_perhour'] += $planet['caps']['total'][RES_CRYSTAL];
        $total['deuterium_perhour'] += $planet['caps']['total'][RES_DEUTERIUM];
        $total['energy_max'] += $planet['caps'][RES_ENERGY][BUILD_CREATE];
        $total['temp_min'] = min($planet['temp_min'], $total['temp_min']);
        $total['temp_max'] = max($planet['temp_max'], $total['temp_max']);
    }
    tpl_assign_fleet($template, $fleets);
    unset($planet);
    $show_groups = array(UNIT_STRUCTURES => 'structures', UNIT_STRUCTURES_SPECIAL => 'structures', UNIT_SHIPS => 'fleet', UNIT_DEFENCE => 'defense');
    foreach ($show_groups as $unit_group_id => $mode) {
        $template->assign_block_vars('prods', array('NAME' => $lang['tech'][$unit_group_id]));
        $unit_group = get_unit_param('techtree', $unit_group_id);
        foreach ($unit_group as $unit_id) {
            $unit_count = $unit_count_abs = 0;
            $block_vars = array();
            $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED);
            // $unit_db_name = pname_resource_name($unit_id);
            foreach ($planets as $planet) {
                $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true);
                $level_plus['FACTORY'] = $unit_is_factory;
                $level_plus['LEVEL_PLUS_YELLOW'] = 0;
                $level_plus['LEVEL_PLUS_GREEN'] = 0;
                $level_plus['PERCENT'] = $unit_is_factory ? $unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1 : -1;
                switch ($mode) {
                    /*
                    case 'structures':
                      $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id];
                      if($level_plus_build)
                      {
                        $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}";
                        $total['units'][$unit_id]['LEVEL_PLUS_GREEN'] += $level_plus['LEVEL_PLUS_GREEN'];
                      }
                    break;
                    */
                    /** @noinspection PhpMissingBreakStatementInspection */
                    case 'fleet':
                        $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}";
                        $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW'];
                    case 'structures':
                    case 'defense':
                        $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id];
                        if ($level_plus_build) {
                            $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}";
                            // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}";
                            $total['units'][$unit_id]['LEVEL_PLUS_GREEN'] += $level_plus['LEVEL_PLUS_GREEN'];
                        }
                        break;
                    default:
                        break;
                }
                $block_vars[] = array_merge($level_plus, array('ID' => $planet['id'], 'TYPE' => $planet['planet_type'], 'LEVEL' => $unit_level_plain == 0 && !$level_plus['LEVEL_PLUS_YELLOW'] && !$level_plus['LEVEL_PLUS_GREEN'] ? '-' : $unit_level_plain));
                $unit_count += $unit_level_plain;
                $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']);
            }
            if ($unit_count_abs) {
                $template->assign_block_vars('prods', array('ID' => $unit_id, 'FIELD' => 'unit_' . $unit_id, 'NAME' => $lang['tech'][$unit_id], 'MODE' => $mode));
                foreach ($block_vars as $block_var) {
                    $template->assign_block_vars('prods.planet', $block_var);
                }
                $unit_green = $total['units'][$unit_id]['LEVEL_PLUS_GREEN'];
                $unit_yellow = $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'];
                $template->assign_block_vars('prods.planet', array('ID' => 0, 'LEVEL' => $unit_count, 'LEVEL_PLUS_GREEN' => $unit_green == 0 ? '' : ($unit_green > 0 ? "+{$unit_green}" : $unit_green), 'LEVEL_PLUS_YELLOW' => $unit_yellow == 0 ? '' : ($unit_yellow > 0 ? "+{$unit_yellow}" : $unit_yellow), 'PERCENT' => $unit_is_factory ? '' : -1, 'FACTORY' => $unit_is_factory));
            }
        }
    }
    $template->assign_block_vars('planet', array_merge(array('ID' => 0, 'NAME' => $lang['sys_total'], 'FIELDS_CUR' => $total['fields'], 'FIELDS_MAX' => $total['fields_max'], 'METAL_CUR' => pretty_number($total['metal']), 'METAL_PROD' => pretty_number($total['metal_perhour']), 'CRYSTAL_CUR' => pretty_number($total['crystal']), 'CRYSTAL_PROD' => pretty_number($total['crystal_perhour']), 'DEUTERIUM_CUR' => pretty_number($total['deuterium']), 'DEUTERIUM_PROD' => pretty_number($total['deuterium_perhour']), 'ENERGY_CUR' => pretty_number($total['energy']), 'ENERGY_MAX' => pretty_number($total['energy_max']), 'TEMP_MIN' => $total['temp_min'], 'TEMP_MAX' => $total['temp_max'])));
    $template->assign_vars(array('COLONIES_CURRENT' => get_player_current_colonies($user), 'COLONIES_MAX' => get_player_max_colonies($user), 'EXPEDITIONS_CURRENT' => get_player_current_expeditions($user), 'EXPEDITIONS_MAX' => get_player_max_expeditons($user), 'PLANET_DENSITY_RICHNESS_NORMAL' => PLANET_DENSITY_RICHNESS_NORMAL, 'PLANET_DENSITY_RICHNESS_AVERAGE' => PLANET_DENSITY_RICHNESS_AVERAGE, 'PLANET_DENSITY_RICHNESS_GOOD' => PLANET_DENSITY_RICHNESS_GOOD, 'PLANET_DENSITY_RICHNESS_PERFECT' => PLANET_DENSITY_RICHNESS_PERFECT));
    //$template->assign_recursive($template_result);
    return $template;
}
Пример #2
0
    }
    //  $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);
$template->assign_vars(array('PLANET_NAME' => $planetrow['name'], 'PLANET_TYPE' => $planetrow['planet_type'], 'PLANET_DENSITY_INDEX' => $planet_density_index, 'PLANET_CORE_TEXT' => $lang['uni_planet_density_types'][$planet_density_index], 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), 'PAGE_HINT' => $lang['res_hint']));
display($template, $lang['res_planet_production']);
Пример #3
0
function eco_get_planet_caps(&$user, &$planet_row, $production_time = 0)
{
    // TODO Считать $production_time для термоядерной электростанции
    global $config;
    static $sn_group_modifiers, $config_resource_multiplier, $config_eco_scale_storage;
    if (!$sn_group_modifiers) {
        $sn_group_modifiers = sn_get_groups('modifiers');
        // $config_resource_multiplier = $config->resource_multiplier;
        $config_resource_multiplier = game_resource_multiplier();
        $config_eco_scale_storage = $config->eco_scale_storage ? $config_resource_multiplier : 1;
    }
    $caps = array();
    foreach (sn_get_groups('storages') as $unit_id) {
        foreach (get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) {
            $caps['storage'][$resource_id][$unit_id] = floor($config_eco_scale_storage * mrc_modify_value($user, $planet_row, $sn_group_modifiers[MODIFIER_RESOURCE_CAPACITY], $function(mrc_get_level($user, $planet_row, $unit_id))));
        }
    }
    if ($planet_row['planet_type'] == PT_MOON) {
        return $caps;
    }
    $sn_group_planet_density = sn_get_groups('planet_density');
    $planet_density = $sn_group_planet_density[$planet_row['density_index']][UNIT_RESOURCES];
    $caps['production_full'][RES_METAL][0] = floor($config->metal_basic_income * $config_resource_multiplier * (isset($planet_density[RES_METAL]) ? $planet_density[RES_METAL] : 1));
    $caps['production_full'][RES_CRYSTAL][0] = floor($config->crystal_basic_income * $config_resource_multiplier * (isset($planet_density[RES_CRYSTAL]) ? $planet_density[RES_CRYSTAL] : 1));
    $caps['production_full'][RES_DEUTERIUM][0] = floor($config->deuterium_basic_income * $config_resource_multiplier * (isset($planet_density[RES_DEUTERIUM]) ? $planet_density[RES_DEUTERIUM] : 1));
    $caps['production_full'][RES_ENERGY][0] = floor($config->energy_basic_income * $config_resource_multiplier * (isset($planet_density[RES_ENERGY]) ? $planet_density[RES_ENERGY] : 1));
    foreach (sn_get_groups('factories') as $unit_id) {
        $unit_data = get_unit_param($unit_id);
        $unit_level = mrc_get_level($user, $planet_row, $unit_id);
        $unit_load = $planet_row[pname_factory_production_field_name($unit_id)];
        foreach ($unit_data['production'] as $resource_id => $function) {
            $caps['production_full'][$resource_id][$unit_id] = $function($unit_level, $unit_load, $user, $planet_row) * $config_resource_multiplier * (isset($planet_density[$resource_id]) ? $planet_density[$resource_id] : 1);
        }
    }
    array_walk_recursive($caps['production_full'], 'eco_get_planet_caps_modify_production', array('user' => $user, 'planet' => $planet_row));
    foreach ($caps['production_full'] as $resource_id => $resource_data) {
        $caps['total_production_full'][$resource_id] = array_sum($resource_data);
    }
    $caps['production'] = $caps['production_full'];
    if ($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) {
        $deuterium_balance = array_sum($caps['production'][RES_DEUTERIUM]);
        $energy_balance = array_sum($caps['production'][RES_ENERGY]);
        if ($deuterium_balance < 0 || $energy_balance < 0) {
            $caps['production'][RES_DEUTERIUM][STRUC_MINE_FUSION] = $caps['production'][RES_ENERGY][STRUC_MINE_FUSION] = 0;
        }
    }
    foreach ($caps['production'][RES_ENERGY] as $energy) {
        $caps[RES_ENERGY][$energy >= 0 ? BUILD_CREATE : BUILD_DESTROY] += $energy;
    }
    $caps[RES_ENERGY][BUILD_DESTROY] = -$caps[RES_ENERGY][BUILD_DESTROY];
    $caps['efficiency'] = $caps[RES_ENERGY][BUILD_DESTROY] > $caps[RES_ENERGY][BUILD_CREATE] ? $caps[RES_ENERGY][BUILD_CREATE] / $caps[RES_ENERGY][BUILD_DESTROY] : 1;
    foreach ($caps['production'] as $resource_id => &$resource_data) {
        if ($caps['efficiency'] != 1) {
            foreach ($resource_data as $unit_id => &$resource_production) {
                if (!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) {
                    $resource_production = $resource_production * $caps['efficiency'];
                }
            }
        }
        $caps['total'][$resource_id] = array_sum($resource_data);
        $caps['total'][$resource_id] = $caps['total'][$resource_id] >= 0 ? floor($caps['total'][$resource_id]) : ceil($caps['total'][$resource_id]);
    }
    foreach ($caps['storage'] as $resource_id => &$resource_data) {
        $caps['total_storage'][$resource_id] = array_sum($resource_data);
    }
    $planet_row['caps'] = $caps;
    $planet_row['metal_max'] = $caps['total_storage'][RES_METAL];
    $planet_row['crystal_max'] = $caps['total_storage'][RES_CRYSTAL];
    $planet_row['deuterium_max'] = $caps['total_storage'][RES_DEUTERIUM];
    $planet_row['energy_max'] = $caps[RES_ENERGY][BUILD_CREATE];
    $planet_row['energy_used'] = $caps[RES_ENERGY][BUILD_DESTROY];
    return $caps;
}
Пример #4
0
function ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $Template)
{
    global $config;
    $unit_data = get_unit_param($BuildID);
    $config_resource_multiplier = game_resource_multiplier();
    $BuildLevelFactor = $CurrentPlanet[pname_factory_production_field_name($BuildID)];
    $BuildTemp = $CurrentPlanet['temp_max'];
    $BuildEnergyTech = $CurrentUser['energy_tech'];
    $CurrentBuildtLvl = mrc_get_level($CurrentUser, $CurrentPlanet, $BuildID);
    $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
    $modifiers = sn_get_groups('modifiers');
    $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
    $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
    $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
    $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
    $ActualProd = floor($Prod[$BuildID]);
    if ($BuildID != STRUC_MINE_FUSION) {
        $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]);
    } else {
        $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]);
    }
    $BuildStartLvl = $CurrentBuildtLvl - 2;
    if ($BuildStartLvl < 1) {
        $BuildStartLvl = 1;
    }
    $Table = '';
    $ProdFirst = 0;
    for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) {
        if ($BuildID != STRUC_MOON_PHALANX) {
            $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
            $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
            $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
            $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value($CurrentUser, $CurrentPlanet, $modifiers[MODIFIER_RESOURCE_PRODUCTION], $config_resource_multiplier * $unit_data['production'][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)));
            $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
            if ($ProdFirst > 0) {
                if ($BuildID != STRUC_MINE_FUSION) {
                    $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>";
                } else {
                    $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>";
                }
            } else {
                $bloc['build_gain'] = '';
            }
            if ($BuildID != STRUC_MINE_FUSION) {
                $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID]));
                $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true);
                $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true);
                $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualNeed), true, true);
            } else {
                $bloc['build_prod'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]));
                $bloc['build_prod_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualProd), true, true);
                $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true);
                $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true);
            }
            if ($ProdFirst == 0) {
                if ($BuildID != STRUC_MINE_FUSION) {
                    $ProdFirst = floor($Prod[$BuildID]);
                } else {
                    $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]);
                }
            }
        } else {
            // Cas particulier de la phalange
            $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
            $bloc['build_range'] = $BuildLevel * $BuildLevel - 1;
        }
        $Table .= parsetemplate($Template, $bloc);
    }
    return $Table;
}