Exemple #1
0
 /**
  * method add_to_queue
  * param $building
  * param $AddMode
  * return (int) the queue ID
  */
 private function add_to_queue($building, $AddMode = TRUE)
 {
     $resource = $this->_objects->getObjects();
     $CurrentQueue = $this->_current_planet['planet_b_building_id'];
     $queue = $this->show_queue();
     $max_fields = DevelopmentsLib::max_fields($this->_current_planet);
     if ($this->_current_planet['planet_field_current'] >= $max_fields - $queue['lenght']) {
         FunctionsLib::redirect('game.php?page=' . $this->_current_page);
     }
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
     } else {
         $QueueArray = "";
         $ActualCount = 0;
     }
     if ($AddMode == TRUE) {
         $BuildMode = 'build';
     } else {
         $BuildMode = 'destroy';
     }
     if ($ActualCount < MAX_BUILDING_QUEUE_SIZE) {
         $QueueID = $ActualCount + 1;
     } else {
         $QueueID = FALSE;
     }
     $continue = FALSE;
     if ($QueueID != FALSE && DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $building)) {
         if ($QueueID <= 1) {
             if (DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $building, TRUE, FALSE) && !parent::$users->is_on_vacations($this->_current_user)) {
                 $continue = TRUE;
             }
         } else {
             $continue = TRUE;
         }
         if ($continue) {
             if ($QueueID > 1) {
                 $InArray = 0;
                 for ($QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++) {
                     $QueueSubArray = explode(",", $QueueArray[$QueueElement]);
                     if ($QueueSubArray[0] == $building) {
                         $InArray++;
                     }
                 }
             } else {
                 $InArray = 0;
             }
             if ($InArray != 0) {
                 $ActualLevel = $this->_current_planet[$resource[$building]];
                 if ($AddMode == TRUE) {
                     $BuildLevel = $ActualLevel + 1 + $InArray;
                     $this->_current_planet[$resource[$building]] += $InArray;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building);
                     $this->_current_planet[$resource[$building]] -= $InArray;
                 } else {
                     $BuildLevel = $ActualLevel - 1 - $InArray;
                     $this->_current_planet[$resource[$building]] -= $InArray;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building) / 2;
                     $this->_current_planet[$resource[$building]] += $InArray;
                 }
             } else {
                 $ActualLevel = $this->_current_planet[$resource[$building]];
                 if ($AddMode == TRUE) {
                     $BuildLevel = $ActualLevel + 1;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building);
                 } else {
                     $BuildLevel = $ActualLevel - 1;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building) / 2;
                 }
             }
             if ($QueueID == 1) {
                 $BuildEndTime = time() + $BuildTime;
             } else {
                 $PrevBuild = explode(",", $QueueArray[$ActualCount - 1]);
                 $BuildEndTime = $PrevBuild[3] + $BuildTime;
             }
             $QueueArray[$ActualCount] = $building . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $BuildMode;
             $NewQueue = implode(";", $QueueArray);
             $this->_current_planet['planet_b_building_id'] = $NewQueue;
         }
     }
     return $QueueID;
 }
Exemple #2
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     // SOME DEFAULT VALUES
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     ######################################
     #
     # blocks
     #
     ######################################
     // MESSAGES BLOCK
     $block['messages'] = $this->get_messages();
     // FLEET MOVEMENTS BLOCK
     $block['fleet_movements'] = $this->get_fleet_movements();
     // MOON BLOCK
     $block['moon'] = $this->get_planet_moon();
     // PLANETS BLOCK
     $block['planets'] = $this->get_planets();
     ######################################
     #
     # parse information
     #
     ######################################
     // SHOW ALL THE INFORMATION, IN ORDER, ACCORDING TO THE TEMPLATE
     $parse['planet_name'] = $this->_current_planet['planet_name'];
     $parse['user_name'] = $this->_current_user['user_name'];
     $parse['date_time'] = date(FunctionsLib::read_config('date_format_extended'), time());
     $parse['Have_new_message'] = $block['messages'];
     $parse['fleet_list'] = $block['fleet_movements'];
     $parse['planet_image'] = $this->_current_planet['planet_image'];
     $parse['building'] = $this->get_current_work($this->_current_planet);
     $parse['moon_img'] = $block['moon']['moon_img'];
     $parse['moon'] = $block['moon']['moon'];
     $parse['anothers_planets'] = $block['planets'];
     $parse['planet_diameter'] = FormatLib::pretty_number($this->_current_planet['planet_diameter']);
     $parse['planet_field_current'] = $this->_current_planet['planet_field_current'];
     $parse['planet_field_max'] = DevelopmentsLib::max_fields($this->_current_planet);
     $parse['planet_temp_min'] = $this->_current_planet['planet_temp_min'];
     $parse['planet_temp_max'] = $this->_current_planet['planet_temp_max'];
     $parse['galaxy_galaxy'] = $this->_current_planet['planet_galaxy'];
     $parse['galaxy_system'] = $this->_current_planet['planet_system'];
     $parse['galaxy_planet'] = $this->_current_planet['planet_planet'];
     $parse['user_rank'] = $this->get_user_rank();
     // DISPLAY THE RESULT PAGE
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('overview/overview_body'), $parse));
 }