Beispiel #1
0
 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] = Production_Lib::production_amount($metal_prod, $geologe_boost);
     $Prod[2] = Production_Lib::production_amount($crystal_prod, $geologe_boost);
     $Prod[3] = Production_Lib::production_amount($deuterium_prod, $geologe_boost);
     if ($this->_element_id >= 4) {
         $Prod[4] = Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE);
         $ActualProd = floor($Prod[4]);
     } else {
         $Prod[4] = Production_Lib::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] = Production_Lib::production_amount($metal_prod, $geologe_boost);
             $Prod[2] = Production_Lib::production_amount($crystal_prod, $geologe_boost);
             $Prod[3] = Production_Lib::production_amount($deuterium_prod, $geologe_boost);
             if ($this->_element_id >= 4) {
                 $Prod[4] = Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $Prod[4] = Production_Lib::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;
 }
 public static function update_resource(&$current_user, &$current_planet, $UpdateTime, $Simul = FALSE)
 {
     $resource = parent::$objects->get_objects();
     $ProdGrid = parent::$objects->get_production();
     $reslist = parent::$objects->get_objects_list();
     $game_resource_multiplier = Functions_Lib::read_config('resource_multiplier');
     $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');
     $CurrentPlanet['planet_metal_max'] = Production_Lib::max_storable($current_planet[$resource[22]]);
     $current_planet['planet_crystal_max'] = Production_Lib::max_storable($current_planet[$resource[23]]);
     $current_planet['planet_deuterium_max'] = Production_Lib::max_storable($current_planet[$resource[24]]);
     $MaxMetalStorage = $current_planet['planet_metal_max'];
     $MaxCristalStorage = $current_planet['planet_crystal_max'];
     $MaxDeuteriumStorage = $current_planet['planet_deuterium_max'];
     $Caps = array();
     $BuildTemp = $current_planet['planet_temp_max'];
     $sub_query = '';
     $parse['production_level'] = 100;
     $post_porcent = Production_Lib::max_production($current_planet['planet_energy_max'], $current_planet['planet_energy_used']);
     $Caps['planet_metal_perhour'] = 0;
     $Caps['planet_crystal_perhour'] = 0;
     $Caps['planet_deuterium_perhour'] = 0;
     $Caps['planet_energy_max'] = 0;
     $Caps['planet_energy_used'] = 0;
     foreach ($ProdGrid as $ProdID => $formula) {
         $BuildLevelFactor = $current_planet['planet_' . $resource[$ProdID] . '_porcent'];
         $BuildLevel = $current_planet[$resource[$ProdID]];
         $BuildEnergy = $current_user['research_energy_technology'];
         // BOOST
         $geologe_boost = 1 + 1 * (Officiers_Lib::is_officier_active($current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
         $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
         // PRODUCTION FORMULAS
         $metal_prod = eval($ProdGrid[$ProdID]['formule']['metal']);
         $crystal_prod = eval($ProdGrid[$ProdID]['formule']['crystal']);
         $deuterium_prod = eval($ProdGrid[$ProdID]['formule']['deuterium']);
         $energy_prod = eval($ProdGrid[$ProdID]['formule']['energy']);
         // PRODUCTION
         $Caps['planet_metal_perhour'] += Production_Lib::current_production(Production_Lib::production_amount($metal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_crystal_perhour'] += Production_Lib::current_production(Production_Lib::production_amount($crystal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_deuterium_perhour'] += Production_Lib::current_production(Production_Lib::production_amount($deuterium_prod, $geologe_boost), $post_porcent);
         if ($ProdID >= 4) {
             if ($ProdID == 12 && $current_planet['planet_deuterium'] == 0) {
                 continue;
             }
             $Caps['planet_energy_max'] += Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE);
         } else {
             $Caps['planet_energy_used'] += Production_Lib::production_amount($energy_prod, 1, TRUE);
         }
     }
     if ($current_planet['planet_type'] == 3) {
         $game_metal_basic_income = 0;
         $game_crystal_basic_income = 0;
         $game_deuterium_basic_income = 0;
         $current_planet['planet_metal_perhour'] = 0;
         $current_planet['planet_crystal_perhour'] = 0;
         $current_planet['planet_deuterium_perhour'] = 0;
         $current_planet['planet_energy_used'] = 0;
         $current_planet['planet_energy_max'] = 0;
     } else {
         $current_planet['planet_metal_perhour'] = $Caps['planet_metal_perhour'];
         $current_planet['planet_crystal_perhour'] = $Caps['planet_crystal_perhour'];
         $current_planet['planet_deuterium_perhour'] = $Caps['planet_deuterium_perhour'];
         $current_planet['planet_energy_used'] = $Caps['planet_energy_used'];
         $current_planet['planet_energy_max'] = $Caps['planet_energy_max'];
     }
     $ProductionTime = $UpdateTime - $current_planet['planet_last_update'];
     $current_planet['planet_last_update'] = $UpdateTime;
     if ($current_planet['planet_energy_max'] == 0) {
         $current_planet['planet_metal_perhour'] = $game_metal_basic_income;
         $current_planet['planet_crystal_perhour'] = $game_crystal_basic_income;
         $current_planet['planet_deuterium_perhour'] = $game_deuterium_basic_income;
         $production_level = 100;
     } elseif ($current_planet['planet_energy_max'] >= $current_planet['planet_energy_used']) {
         $production_level = 100;
     } else {
         $production_level = floor($current_planet['planet_energy_max'] / $current_planet['planet_energy_used'] * 100);
     }
     if ($production_level > 100) {
         $production_level = 100;
     } elseif ($production_level < 0) {
         $production_level = 0;
     }
     if ($current_planet['planet_metal'] <= $MaxMetalStorage) {
         $MetalProduction = $ProductionTime * ($current_planet['planet_metal_perhour'] / 3600) * (0.01 * $production_level);
         $MetalBaseProduc = $ProductionTime * ($game_metal_basic_income / 3600);
         $MetalTheorical = $current_planet['planet_metal'] + $MetalProduction + $MetalBaseProduc;
         if ($MetalTheorical <= $MaxMetalStorage) {
             $current_planet['planet_metal'] = $MetalTheorical;
         } else {
             $current_planet['planet_metal'] = $MaxMetalStorage;
         }
     }
     if ($current_planet['planet_crystal'] <= $MaxCristalStorage) {
         $CristalProduction = $ProductionTime * ($current_planet['planet_crystal_perhour'] / 3600) * (0.01 * $production_level);
         $CristalBaseProduc = $ProductionTime * ($game_crystal_basic_income / 3600);
         $CristalTheorical = $current_planet['planet_crystal'] + $CristalProduction + $CristalBaseProduc;
         if ($CristalTheorical <= $MaxCristalStorage) {
             $current_planet['planet_crystal'] = $CristalTheorical;
         } else {
             $current_planet['planet_crystal'] = $MaxCristalStorage;
         }
     }
     if ($current_planet['planet_deuterium'] <= $MaxDeuteriumStorage) {
         $DeuteriumProduction = $ProductionTime * ($current_planet['planet_deuterium_perhour'] / 3600) * (0.01 * $production_level);
         $DeuteriumBaseProduc = $ProductionTime * ($game_deuterium_basic_income / 3600);
         $DeuteriumTheorical = $current_planet['planet_deuterium'] + $DeuteriumProduction + $DeuteriumBaseProduc;
         if ($DeuteriumTheorical <= $MaxDeuteriumStorage) {
             $current_planet['planet_deuterium'] = $DeuteriumTheorical;
         } else {
             $current_planet['planet_deuterium'] = $MaxDeuteriumStorage;
         }
     }
     if ($current_planet['planet_metal'] < 0) {
         $current_planet['planet_metal'] = 0;
     }
     if ($current_planet['planet_crystal'] < 0) {
         $current_planet['planet_crystal'] = 0;
     }
     if ($current_planet['planet_deuterium'] < 0) {
         $current_planet['planet_deuterium'] = 0;
     }
     if ($Simul == FALSE) {
         // SHIPS AND DEFENSES UPDATE
         $builded = self::building_queue($current_user, $current_planet, $ProductionTime);
         $ship_points = 0;
         $defense_points = 0;
         if ($builded != '') {
             foreach ($builded as $element => $count) {
                 if ($element != '') {
                     // POINTS
                     switch ($element) {
                         case $element >= 202 && $element <= 215:
                             $ship_points += Statistics_Lib::calculate_points($element, $count) * $count;
                             break;
                         case $element >= 401 && $element <= 503:
                             $defense_points += Statistics_Lib::calculate_points($element, $count) * $count;
                             break;
                         default:
                             break;
                     }
                     $sub_query .= "`" . $resource[$element] . "` = '" . $current_planet[$resource[$element]] . "', ";
                 }
             }
         }
         // RESEARCH UPDATE
         if ($current_planet['planet_b_tech'] <= time() && $current_planet['planet_b_tech_id'] != 0) {
             $current_user['research_points'] = Statistics_Lib::calculate_points($current_planet['planet_b_tech_id'], $current_user[$resource[$current_planet['planet_b_tech_id']]], 'tech');
             $current_user[$resource[$current_planet['planet_b_tech_id']]]++;
             $tech_query = "`planet_b_tech` = '0',";
             $tech_query .= "`planet_b_tech_id` = '0',";
             $tech_query .= "`" . $resource[$current_planet['planet_b_tech_id']] . "` = '" . $current_user[$resource[$current_planet['planet_b_tech_id']]] . "',";
             $tech_query .= "`user_statistic_technology_points` = `user_statistic_technology_points` + '" . $current_user['research_points'] . "',";
             $tech_query .= "`research_current_research` = '0',";
         } else {
             $tech_query = "";
         }
         parent::$db->query("UPDATE " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS_STATISTICS . " AS us ON us.user_statistic_user_id = p.planet_user_id\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id SET\r\n\t\t\t\t\t\t\t\t\t`planet_metal` = '" . $current_planet['planet_metal'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_crystal` = '" . $current_planet['planet_crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_deuterium` = '" . $current_planet['planet_deuterium'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_last_update` = '" . $current_planet['planet_last_update'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_b_hangar_id` = '" . $current_planet['planet_b_hangar_id'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_metal_perhour` = '" . $current_planet['planet_metal_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_crystal_perhour` = '" . $current_planet['planet_crystal_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour` = '" . $current_planet['planet_deuterium_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_energy_used` = '" . $current_planet['planet_energy_used'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_energy_max` = '" . $current_planet['planet_energy_max'] . "',\r\n\t\t\t\t\t\t\t\t\t`user_statistic_ships_points` = `user_statistic_ships_points` + '" . $ship_points . "',\r\n\t\t\t\t\t\t\t\t\t`user_statistic_defenses_points` = `user_statistic_defenses_points`  + '" . $defense_points . "',\r\n\t\t\t\t\t\t\t\t\t{$sub_query}\r\n\t\t\t\t\t\t\t\t\t{$tech_query}\r\n\t\t\t\t\t\t\t\t\t`planet_b_hangar` = '" . $current_planet['planet_b_hangar'] . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
     }
 }
Beispiel #3
0
 /**
  * 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));
 }
 /**
  * method check_storage
  * param $amount
  * param $force
  * return amount of resource production
  */
 public function check_storage($amount, $force = NULL)
 {
     if (!is_array($amount)) {
         throw new Exception("Must be array", 1);
     }
     $hangar = array('metal' => 22, 'crystal' => 23, 'deuterium' => 24);
     $check = array();
     foreach ($hangar as $k => $v) {
         if ($amount[$k] == 0) {
             unset($amount[$k]);
         }
         if (array_key_exists($k, $amount)) {
             if ($this->_current_planet[$k] + $amount[$k] >= Production_Lib::max_storable($this->_current_planet[$this->_resource[$v]])) {
                 $check[$k] = FALSE;
             } else {
                 $check[$k] = TRUE;
             }
         } else {
             $check[$k] = TRUE;
         }
     }
     if ($check['metal'] === true && $check['crystal'] === true && $check['deuterium'] === true) {
         return FALSE;
     } else {
         if (is_null($force)) {
             foreach ($hangar as $k => $v) {
                 if ($check[$k] === false) {
                     return sprintf($this->_lang['tr_full_storage'], strtolower($this->_lang['info'][$v]['name']));
                 } else {
                     continue;
                 }
             }
         } else {
             return $check;
         }
     }
 }