private function ShowProductionTable($Template) { $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$this->_element_id] . '_porcent']; $BuildTemp = $this->_current_planet['planet_temp_max']; $CurrentBuildtLvl = $this->_current_planet[$this->_resource[$this->_element_id]]; $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1; $BuildEnergy = $this->_current_user['research_energy_technology']; // BOOST $geologe_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0); $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0); // PRODUCTION FORMULAS $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']); $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']); $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']); $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']); // PRODUCTION $Prod[1] = ProductionLib::production_amount($metal_prod, $geologe_boost); $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost); $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost); if ($this->_element_id >= 4) { $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE); $ActualProd = floor($Prod[4]); } else { $Prod[4] = ProductionLib::production_amount($energy_prod, 1, TRUE); $ActualProd = floor($Prod[$this->_element_id]); } if ($this->_element_id != 12) { $ActualNeed = floor($Prod[4]); } else { $ActualNeed = floor($Prod[3]); } $BuildStartLvl = $CurrentBuildtLvl - 2; if ($BuildStartLvl < 1) { $BuildStartLvl = 1; } $Table = ""; $ProdFirst = 0; for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) { if ($this->_element_id != 42) { // PRODUCTION FORMULAS $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']); $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']); $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']); $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']); // PRODUCTION $Prod[1] = ProductionLib::production_amount($metal_prod, $geologe_boost); $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost); $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost); if ($this->_element_id >= 4) { $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE); } else { $Prod[4] = ProductionLib::production_amount($energy_prod, 1, TRUE); } $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; if ($ProdFirst > 0) { if ($this->_element_id != 12) { $bloc['build_gain'] = "<font color=\"lime\">(" . Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ProdFirst)) . ")</font>"; } else { $bloc['build_gain'] = "<font color=\"lime\">(" . Format_Lib::pretty_number(floor($Prod[4] - $ProdFirst)) . ")</font>"; } } else { $bloc['build_gain'] = ""; } if ($this->_element_id != 12) { $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[$this->_element_id])); $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ActualProd))); $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4]))); $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualNeed))); } else { $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[4])); $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualProd))); $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[3]))); $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[3] - $ActualNeed))); } if ($ProdFirst == 0) { if ($this->_element_id != 12) { $ProdFirst = floor($Prod[$this->_element_id]); } else { $ProdFirst = floor($Prod[4]); } } } else { $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; $bloc['build_range'] = $BuildLevel * $BuildLevel - 1; } $Table .= parent::$page->parse_template($Template, $bloc); } return $Table; }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $parse = $this->_lang; $game_metal_basic_income = Functions_Lib::read_config('metal_basic_income'); $game_crystal_basic_income = Functions_Lib::read_config('crystal_basic_income'); $game_deuterium_basic_income = Functions_Lib::read_config('deuterium_basic_income'); $game_energy_basic_income = Functions_Lib::read_config('energy_basic_income'); $game_resource_multiplier = Functions_Lib::read_config('resource_multiplier'); if ($this->_current_planet['planet_type'] == 3) { $game_metal_basic_income = 0; $game_crystal_basic_income = 0; $game_deuterium_basic_income = 0; } $this->_current_planet['planet_metal_max'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[22]]); $this->_current_planet['planet_crystal_max'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[23]]); $this->_current_planet['planet_deuterium_max'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[24]]); $parse['production_level'] = 100; $post_porcent = Production_Lib::max_production($this->_current_planet['planet_energy_max'], $this->_current_planet['planet_energy_used']); $parse['resource_row'] = ''; $this->_current_planet['planet_metal_perhour'] = 0; $this->_current_planet['planet_crystal_perhour'] = 0; $this->_current_planet['planet_deuterium_perhour'] = 0; $this->_current_planet['planet_energy_max'] = 0; $this->_current_planet['planet_energy_used'] = 0; $BuildTemp = $this->_current_planet['planet_temp_max']; $ResourcesRowTPL = parent::$page->get_template('resources/resources_row'); foreach ($this->_reslist['prod'] as $ProdID) { if ($this->_current_planet[$this->_resource[$ProdID]] > 0 && isset($this->_prod_grid[$ProdID])) { $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$ProdID] . '_porcent']; $BuildLevel = $this->_current_planet[$this->_resource[$ProdID]]; $BuildEnergy = $this->_current_user['research_energy_technology']; // BOOST $geologe_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0); $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0); // PRODUCTION FORMULAS $metal_prod = eval($this->_prod_grid[$ProdID]['formule']['metal']); $crystal_prod = eval($this->_prod_grid[$ProdID]['formule']['crystal']); $deuterium_prod = eval($this->_prod_grid[$ProdID]['formule']['deuterium']); $energy_prod = eval($this->_prod_grid[$ProdID]['formule']['energy']); // PRODUCTION $metal = Production_Lib::production_amount($metal_prod, $geologe_boost); $crystal = Production_Lib::production_amount($crystal_prod, $geologe_boost); $deuterium = Production_Lib::production_amount($deuterium_prod, $geologe_boost); if ($ProdID >= 4) { $energy = Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE); } else { $energy = Production_Lib::production_amount($energy_prod, 1, TRUE); } if ($energy > 0) { $this->_current_planet['planet_energy_max'] += $energy; } else { $this->_current_planet['planet_energy_used'] += $energy; } $this->_current_planet['planet_metal_perhour'] += $metal; $this->_current_planet['planet_crystal_perhour'] += $crystal; $this->_current_planet['planet_deuterium_perhour'] += $deuterium; $metal = Production_Lib::current_production($metal, $post_porcent); $crystal = Production_Lib::current_production($crystal, $post_porcent); $deuterium = Production_Lib::current_production($deuterium, $post_porcent); $energy = Production_Lib::current_production($energy, $post_porcent); $Field = 'planet_' . $this->_resource[$ProdID] . '_porcent'; $CurrRow = array(); $CurrRow['name'] = $this->_resource[$ProdID]; $CurrRow['porcent'] = $this->_current_planet[$Field]; $CurrRow['option'] = $this->build_options($CurrRow['porcent']); $CurrRow['type'] = $this->_lang['tech'][$ProdID]; $CurrRow['level'] = $ProdID > 200 ? $this->_lang['rs_amount'] : $this->_lang['rs_lvl']; $CurrRow['level_type'] = $this->_current_planet[$this->_resource[$ProdID]]; $CurrRow['metal_type'] = Format_Lib::pretty_number($metal); $CurrRow['crystal_type'] = Format_Lib::pretty_number($crystal); $CurrRow['deuterium_type'] = Format_Lib::pretty_number($deuterium); $CurrRow['energy_type'] = Format_Lib::pretty_number($energy); $CurrRow['metal_type'] = Format_Lib::color_number($CurrRow['metal_type']); $CurrRow['crystal_type'] = Format_Lib::color_number($CurrRow['crystal_type']); $CurrRow['deuterium_type'] = Format_Lib::color_number($CurrRow['deuterium_type']); $CurrRow['energy_type'] = Format_Lib::color_number($CurrRow['energy_type']); $parse['resource_row'] .= parent::$page->parse_template($ResourcesRowTPL, $CurrRow); } } $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $this->_current_planet['planet_name'], $this->_lang['rs_production_on_planet']); $parse['production_level'] = $this->prod_level($this->_current_planet['planet_energy_used'], $this->_current_planet['planet_energy_max']); $parse['metal_basic_income'] = $game_metal_basic_income; $parse['crystal_basic_income'] = $game_crystal_basic_income; $parse['deuterium_basic_income'] = $game_deuterium_basic_income; $parse['energy_basic_income'] = $game_energy_basic_income; $parse['planet_metal_max'] = $this->resource_color($this->_current_planet['planet_metal'], $this->_current_planet['planet_metal_max']); $parse['planet_crystal_max'] = $this->resource_color($this->_current_planet['planet_crystal'], $this->_current_planet['planet_crystal_max']); $parse['planet_deuterium_max'] = $this->resource_color($this->_current_planet['planet_deuterium'], $this->_current_planet['planet_deuterium_max']); $parse['metal_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income']))); $parse['crystal_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income']))); $parse['deuterium_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income']))); $parse['energy_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_energy_max'] + $parse['energy_basic_income'] + $this->_current_planet['planet_energy_used']))); $parse['daily_metal'] = $this->calculate_daily($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']); $parse['weekly_metal'] = $this->calculate_weekly($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']); $parse['daily_crystal'] = $this->calculate_daily($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']); $parse['weekly_crystal'] = $this->calculate_weekly($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']); $parse['daily_deuterium'] = $this->calculate_daily($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']); $parse['weekly_deuterium'] = $this->calculate_weekly($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']); $parse['daily_metal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_metal'])); $parse['weekly_metal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['weekly_metal'])); $parse['daily_crystal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_crystal'])); $parse['weekly_crystal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['weekly_crystal'])); $parse['daily_deuterium'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_deuterium'])); $parse['weekly_deuterium'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['weekly_deuterium'])); $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100); $SubQry = ''; if ($_POST && !parent::$users->is_on_vacations($this->_current_user)) { foreach ($_POST as $Field => $Value) { $FieldName = 'planet_' . $Field . '_porcent'; if (isset($this->_current_planet[$FieldName])) { if (!in_array($Value, $ValidList['percent'])) { Functions_Lib::redirect('game.php?page=resourceSettings'); } $Value = $Value / 10; $this->_current_planet[$FieldName] = $Value; $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'"; } } parent::$db->query("UPDATE " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t`planet_id` = '" . $this->_current_planet['planet_id'] . "'\r\n\t\t\t\t\t\t\t\t\t{$SubQry}\r\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';"); Functions_Lib::redirect('game.php?page=resourceSettings'); } parent::$page->display(parent::$page->parse_template(parent::$page->get_template('resources/resources'), $parse)); }