Ejemplo n.º 1
0
 /**
  * method make_stats
  * param
  * return builds the statistics
  */
 public static function make_stats()
 {
     // INITIAL TIME
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     self::$time = time();
     // INITIAL MEMORY
     $result['initial_memory'] = array(round(memory_get_usage() / 1024, 1), round(memory_get_usage(1) / 1024, 1));
     // MAKE STATISTICS FOR USERS
     self::make_user_rank();
     // MAKE STATISTICS FOR ALLIANCE
     self::make_ally_rank();
     // END STATISTICS BUILD
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $endtime = $mtime;
     $result['stats_time'] = self::$time;
     $result['totaltime'] = $endtime - $starttime;
     $result['memory_peak'] = array(round(memory_get_peak_usage() / 1024, 1), round(memory_get_peak_usage(1) / 1024, 1));
     $result['end_memory'] = array(round(memory_get_usage() / 1024, 1), round(memory_get_usage(1) / 1024, 1));
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     // RUN STATISTICS SCRIPT AND THE SET THE RESULT
     $result = Statistics_Lib::make_stats();
     // PREPARE DATA TO PARSE
     $parse = $this->_lang;
     $parse['memory_p'] = str_replace(array("%p", "%m"), $result['memory_peak'], $this->_lang['sb_top_memory']);
     $parse['memory_e'] = str_replace(array("%e", "%m"), $result['end_memory'], $this->_lang['sb_final_memory']);
     $parse['memory_i'] = str_replace(array("%i", "%m"), $result['initial_memory'], $this->_lang['sb_start_memory']);
     $parse['alert'] = Administration_Lib::save_message('ok', str_replace("%t", $result['totaltime'], $this->_lang['sb_stats_update']));
     // UPDATE STATISTICS LAST UPDATE
     Functions_Lib::update_config('stat_last_update', $result['stats_time']);
     // SHOW TEMPLATE
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('adm/buildstats_view'), $parse));
 }
Ejemplo n.º 3
0
 /**
  * method colonize_mission
  * param $fleet_row
  * return the colonization result
  */
 public function colonize_mission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == 0) {
         $colonization_check = parent::$db->query_fetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc1.`planet_user_id` = '" . $fleet_row['fleet_owner'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_type` = '1' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_destroyed` = '0') AS planet_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc2.`planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_planet` = '" . $fleet_row['fleet_end_planet'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc2.`planet_type` = 1') AS galaxy_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT `research_astrophysics`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . RESEARCH . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `research_user_id` = '" . $fleet_row['fleet_owner'] . "') AS astro_level");
         // SOME REQUIRED VALUES
         $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']);
         $max_colonies = Fleets_Lib::get_max_colonies($colonization_check['astro_level']);
         $planet_count = $colonization_check['planet_count'] - 1;
         // THE TOTAL AMOUNT OF PLANETS MINUS 1 (BECAUSE THE MAIN PLANET IT'S NOT CONSIDERED)
         // DIFFERENT TYPES OF MESSAGES
         $message[1] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_maxcolo'] . ($max_colonies + 1) . $this->_lang['sys_colo_planet'];
         $message[2] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_allisok'];
         $message[3] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_notfree'];
         $message[4] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_astro_level'];
         if ($colonization_check['galaxy_count'] == 0) {
             if ($planet_count >= $max_colonies) {
                 $this->colonize_message($fleet_row['fleet_owner'], $message[1], $fleet_row['fleet_start_time']);
                 parent::return_fleet($fleet_row['fleet_id']);
             } elseif (!$this->position_allowed($fleet_row['fleet_end_planet'], $colonization_check['astro_level'])) {
                 $this->colonize_message($fleet_row['fleet_owner'], $message[4], $fleet_row['fleet_start_time']);
                 parent::return_fleet($fleet_row['fleet_id']);
             } else {
                 if ($this->start_creation($fleet_row)) {
                     $this->colonize_message($fleet_row['fleet_owner'], $message[2], $fleet_row['fleet_start_time']);
                     if ($fleet_row['fleet_amount'] == 1) {
                         parent::$db->query("UPDATE " . USERS_STATISTICS . " AS us SET\n\t\t\t\t\t\t\t\t\t\t\t\t\tus.`user_statistic_ships_points` = us.`user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE us.`user_statistic_user_id` = (SELECT p.planet_user_id FROM " . PLANETS . " AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.planet_galaxy = '" . $fleet_row['fleet_start_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_system = '" . $fleet_row['fleet_start_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_planet = '" . $fleet_row['fleet_start_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_type = '" . $fleet_row['fleet_start_type'] . "');");
                         parent::store_resources($fleet_row);
                         parent::remove_fleet($fleet_row['fleet_id']);
                     } else {
                         parent::store_resources($fleet_row);
                         parent::$db->query("UPDATE " . FLEETS . ", " . USERS_STATISTICS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_array` = '" . $this->build_new_fleet($fleet_row['fleet_array']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_amount` = `fleet_amount` - 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_deuterium` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_ships_points` = `user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_id` = '" . $fleet_row['fleet_id'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_user_id` = (SELECT planet_user_id FROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE planet_galaxy = '" . $fleet_row['fleet_start_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = '" . $fleet_row['fleet_start_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . $fleet_row['fleet_start_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = '" . $fleet_row['fleet_start_type'] . "');");
                     }
                 } else {
                     $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']);
                     parent::return_fleet($fleet_row['fleet_id']);
                 }
             }
         } else {
             $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']);
             parent::return_fleet($fleet_row['fleet_id']);
         }
     }
     if ($fleet_row['fleet_end_time'] < time()) {
         parent::restore_fleet($fleet_row, TRUE);
         parent::remove_fleet($fleet_row['fleet_id']);
     }
 }
Ejemplo n.º 4
0
 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'] . "';");
     }
 }
Ejemplo n.º 5
0
 /**
  * checkBuildingQueue
  *
  * @param array $current_planet Current planet
  * @param array $current_user   Current user
  *
  * @return boolean
  */
 private static function checkBuildingQueue(&$current_planet, &$current_user)
 {
     $resource = parent::$objects->get_objects();
     $ret_value = false;
     if ($current_planet['planet_b_building_id'] != 0) {
         $current_queue = $current_planet['planet_b_building_id'];
         if ($current_queue != 0) {
             $queue_array = explode(";", $current_queue);
         }
         $build_array = explode(",", $queue_array[0]);
         $build_end_time = floor($build_array[3]);
         $build_mode = $build_array[4];
         $element = $build_array[0];
         array_shift($queue_array);
         if ($build_mode == 'destroy') {
             $for_destroy = true;
         } else {
             $for_destroy = false;
         }
         if ($build_end_time <= time()) {
             $needed = Developments_Lib::development_price($current_user, $current_planet, $element, true, $for_destroy);
             $units = $needed['metal'] + $needed['crystal'] + $needed['deuterium'];
             $current = (int) $current_planet['planet_field_current'];
             $max = (int) $current_planet['planet_field_max'];
             if ($current_planet['planet_type'] == 3) {
                 if ($element == 41) {
                     $current += 1;
                     $max += FIELDS_BY_MOONBASIS_LEVEL;
                     $current_planet[$resource[$element]]++;
                 } elseif ($element != 0) {
                     if ($for_destroy == false) {
                         $current += 1;
                         $current_planet[$resource[$element]]++;
                     } else {
                         $current -= 1;
                         $current_planet[$resource[$element]]--;
                     }
                 }
             } elseif ($current_planet['planet_type'] == 1) {
                 if ($for_destroy == false) {
                     $current += 1;
                     $current_planet[$resource[$element]]++;
                 } else {
                     $current -= 1;
                     $current_planet[$resource[$element]]--;
                 }
             }
             if (count($queue_array) == 0) {
                 $new_queue = 0;
             } else {
                 $new_queue = implode(';', $queue_array);
             }
             $current_planet['planet_b_building'] = 0;
             $current_planet['planet_b_building_id'] = $new_queue;
             $current_planet['planet_field_current'] = $current;
             $current_planet['planet_field_max'] = $max;
             $current_planet['building_points'] = Statistics_Lib::calculate_points($element, $current_planet[$resource[$element]]);
             parent::$db->query("\nUPDATE " . PLANETS . " AS p\nINNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = p.planet_user_id\nINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id` SET\n`" . $resource[$element] . "` = '" . $current_planet[$resource[$element]] . "',\n`user_statistic_buildings_points` = `user_statistic_buildings_points` + '" . $current_planet['building_points'] . "',\n`planet_b_building` = '" . $current_planet['planet_b_building'] . "',\n`planet_b_building_id` = '" . $current_planet['planet_b_building_id'] . "',\n`planet_field_current` = '" . $current_planet['planet_field_current'] . "',\n`planet_field_max` = '" . $current_planet['planet_field_max'] . "'\nWHERE `planet_id` = '" . $current_planet['planet_id'] . "';\n");
             $ret_value = true;
         } else {
             $ret_value = false;
         }
     } else {
         $current_planet['planet_b_building'] = 0;
         $current_planet['planet_b_building_id'] = 0;
         parent::$db->query("UPDATE " . PLANETS . " SET\n`planet_b_building` = '" . $current_planet['planet_b_building'] . "',\n`planet_b_building_id` = '" . $current_planet['planet_b_building_id'] . "'\nWHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
         $ret_value = false;
     }
     return $ret_value;
 }