Example #1
0
 public function build_page()
 {
     $parse = $this->_lang;
     if (isset($_POST['fmenge'])) {
         $AddedInQueue = FALSE;
         $totalCount = 0;
         foreach ($_POST['fmenge'] as $Element => $Count) {
             if ($Element < 200 or $Element > 300) {
                 continue;
             }
             $Element = (int) $Element;
             $Count = (int) $Count;
             $totalCount += $Count;
             if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                 $Count = MAX_FLEET_OR_DEFS_PER_ROW;
             }
             if ($Count != 0) {
                 if (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                     $MaxElements = $this->GetMaxConstructibleElements($Element, $this->_current_planet);
                     if ($Count > $MaxElements) {
                         $Count = $MaxElements;
                     }
                     $Ressource = $this->GetElementRessources($Element, $Count);
                     if ($Count >= 1) {
                         $this->_current_planet['planet_metal'] -= $Ressource['metal'];
                         $this->_current_planet['planet_crystal'] -= $Ressource['crystal'];
                         $this->_current_planet['planet_deuterium'] -= $Ressource['deuterium'];
                         $this->_current_planet['planet_b_hangar_id'] .= '' . $Element . ',' . $Count . ';';
                     }
                 }
             }
         }
         if ($totalCount > 0) {
             parent::$db->query("UPDATE " . PLANETS . " AS p SET\n                                                                            p.`planet_b_hangar_id` = '" . $this->_current_planet['planet_b_hangar_id'] . "',\n                                                                            p.`planet_metal` = '" . $this->_current_planet['planet_metal'] . "',\n                                                                            p.`planet_crystal` = '" . $this->_current_planet['planet_crystal'] . "',\n                                                                            p.`planet_deuterium` = '" . $this->_current_planet['planet_deuterium'] . "'\n                                                                            WHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         }
         FunctionsLib::redirect('game.php?page=shipyard');
     }
     if ($this->_current_planet[$this->_resource[21]] == 0) {
         FunctionsLib::message($this->_lang['bd_shipyard_required'], '', '', TRUE);
     }
     $NotBuilding = TRUE;
     if ($this->_current_planet['planet_b_building_id'] != 0) {
         $CurrentQueue = $this->_current_planet['planet_b_building_id'];
         if (strpos($CurrentQueue, ";")) {
             // FIX BY LUCKY - IF THE SHIPYARD IS IN QUEUE THE USER CANT RESEARCH ANYTHING...
             $QueueArray = explode(";", $CurrentQueue);
             for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) {
                 $ListIDArray = explode(",", $QueueArray[$i]);
                 $Element = $ListIDArray[0];
                 if ($Element == 21 or $Element == 14 or $Element == 15) {
                     break;
                 }
             }
             // END - FIX
         } else {
             $CurrentBuilding = $CurrentQueue;
         }
         if ($CurrentBuilding == 21 or $CurrentBuilding == 14 or $CurrentBuilding == 15 or ($Element == 21 or $Element == 14 or $Element == 15)) {
             $parse['message'] = "<font color=\"red\">" . $this->_lang['bd_building_shipyard'] . "</font>";
             $NotBuilding = FALSE;
         }
     }
     $TabIndex = 0;
     $PageTable = '';
     $BuildQueue = '';
     foreach ($this->_lang['tech'] as $Element => $ElementName) {
         if ($Element > 201 && $Element <= 399) {
             if (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                 $CanBuildOne = DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $BuildOneElementTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $Element);
                 $ElementCount = $this->_current_planet[$this->_resource[$Element]];
                 $ElementNbre = $ElementCount == 0 ? "" : " (" . $this->_lang['bd_available'] . FormatLib::pretty_number($ElementCount) . ")";
                 $parse['dpath'] = DPATH;
                 $parse['add_element'] = '';
                 $parse['element'] = $Element;
                 $parse['element_name'] = $ElementName;
                 $parse['element_description'] = $this->_lang['res']['descriptions'][$Element];
                 $parse['element_price'] = DevelopmentsLib::formated_development_price($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $parse['building_time'] = DevelopmentsLib::formated_development_time($BuildOneElementTime);
                 $parse['element_nbre'] = $ElementNbre;
                 if ($CanBuildOne && $NotBuilding && !parent::$users->is_on_vacations($this->_current_user)) {
                     $TabIndex++;
                     $parse['add_element'] = '<input type=text name=fmenge[' . $Element . '] alt="' . $this->_lang['tech'][$Element] . '" size=6 maxlength=6 value=0 tabindex=' . $TabIndex . '>';
                 }
                 if ($NotBuilding) {
                     $parse['build_fleet'] = '<tr><td class="c" colspan="2" align="center"><input type="submit" value="' . $this->_lang['bd_build_ships'] . '"></td></tr>';
                 }
                 $PageTable .= parent::$page->parse_template(parent::$page->get_template('buildings/buildings_fleet_row'), $parse);
             }
         }
     }
     if ($this->_current_planet['planet_b_hangar_id'] != '') {
         $BuildQueue .= $this->ElementBuildListBox('shipyard');
     }
     $parse['buildlist'] = $PageTable;
     $parse['buildinglist'] = $BuildQueue;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_fleet'), $parse));
 }
Example #2
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = $this->_objects->getObjects();
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $page = '';
     $max_fields = DevelopmentsLib::max_fields($this->_current_planet);
     // time to do something
     $this->do_command();
     DevelopmentsLib::set_first_element($this->_current_planet, $this->_current_user);
     $Sprice = array();
     $queue = $this->show_queue($Sprice);
     $this->start_building();
     $full_queue = $queue['lenght'] < MAX_BUILDING_QUEUE_SIZE ? FALSE : TRUE;
     foreach ($this->_lang['tech'] as $building => $building_name) {
         if (in_array($building, $this->_allowed[$this->_current_planet['planet_type']])) {
             $queue['to_destroy'] = isset($queue['to_destroy']) ? $queue['to_destroy'] : 0;
             if ($this->_current_planet['planet_field_current'] < $max_fields - $queue['to_destroy']) {
                 $have_fields = TRUE;
             } else {
                 $have_fields = FALSE;
             }
             if (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $building)) {
                 $building_level = $this->_current_planet[$resource[$building]];
                 $building_time = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building, $building_level);
                 $parse['i'] = $building;
                 $parse['nivel'] = DevelopmentsLib::set_level_format($building_level);
                 $parse['n'] = $building_name;
                 $parse['descriptions'] = $this->_lang['res']['descriptions'][$building];
                 $parse['price'] = DevelopmentsLib::formated_development_price($this->_current_user, $this->_current_planet, $building, TRUE, $building_level);
                 $parse['time'] = DevelopmentsLib::formated_development_time($building_time);
                 $parse['click'] = $this->set_action_button($have_fields, $full_queue, $building, $queue);
                 $page .= parent::$page->parse_template(parent::$page->get_template('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($queue['lenght'] > 0) {
         $parse['BuildListScript'] = DevelopmentsLib::current_building($this->_current_page);
         $parse['BuildList'] = $queue['buildlist'];
     } else {
         $parse['BuildListScript'] = '';
         $parse['BuildList'] = '';
     }
     $parse['BuildingsList'] = $page;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_builds'), $parse));
 }
Example #3
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $tech_row_template = parent::$page->get_template('buildings/buildings_research_row');
     $tech_script_template = parent::$page->get_template('buildings/buildings_research_script');
     $technology_list = '';
     // time to do something
     $this->do_command();
     // build the page
     foreach ($this->_lang['tech'] as $tech => $tech_name) {
         if ($tech > 105 && $tech <= 199) {
             if (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $tech)) {
                 $RowParse['dpath'] = DPATH;
                 $RowParse['tech_id'] = $tech;
                 $building_level = $this->_current_user[$this->_resource[$tech]];
                 $RowParse['tech_level'] = DevelopmentsLib::set_level_format($building_level, $tech, $this->_current_user);
                 $RowParse['tech_name'] = $tech_name;
                 $RowParse['tech_descr'] = $this->_lang['res']['descriptions'][$tech];
                 $RowParse['tech_price'] = DevelopmentsLib::formated_development_price($this->_current_user, $this->_current_planet, $tech);
                 $SearchTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $tech, FALSE, $this->_lab_level);
                 $RowParse['search_time'] = DevelopmentsLib::formated_development_time($SearchTime);
                 if (!$this->_is_working['is_working']) {
                     if (DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $tech) && !parent::$users->is_on_vacations($this->_current_user)) {
                         if (!$this->is_laboratory_in_queue()) {
                             $action_link = FormatLib::color_red($this->_lang['bd_research']);
                         } else {
                             $action_link = FunctionsLib::set_url('game.php?page=research&cmd=search&tech=' . $tech, '', FormatLib::color_green($this->_lang['bd_research']));
                         }
                     } else {
                         $action_link = FormatLib::color_red($this->_lang['bd_research']);
                     }
                 } else {
                     if ($this->_is_working['working_on']['planet_b_tech_id'] == $tech) {
                         $bloc = $this->_lang;
                         if ($this->_is_working['working_on']['id'] != $this->_current_planet['planet_id']) {
                             $bloc['tech_time'] = $this->_is_working['working_on']['planet_b_tech'] - time();
                             $bloc['tech_name'] = $this->_lang['bd_from'] . $this->_is_working['working_on']['planet_name'] . '<br /> ' . FormatLib::pretty_coords($this->_is_working['working_on']['planet_galaxy'], $this->_is_working['working_on']['planet_system'], $this->_is_working['working_on']['planet_planet']);
                             $bloc['tech_home'] = $this->_is_working['working_on']['id'];
                             $bloc['tech_id'] = $this->_is_working['working_on']['planet_b_tech_id'];
                         } else {
                             $bloc['tech_time'] = $this->_current_planet['planet_b_tech'] - time();
                             $bloc['tech_name'] = '';
                             $bloc['tech_home'] = $this->_current_planet['planet_id'];
                             $bloc['tech_id'] = $this->_current_planet['planet_b_tech_id'];
                         }
                         $action_link = parent::$page->parse_template($tech_script_template, $bloc);
                     } else {
                         $action_link = "<center>-</center>";
                     }
                 }
                 $RowParse['tech_link'] = $action_link;
                 $technology_list .= parent::$page->parse_template($tech_row_template, $RowParse);
             }
         }
     }
     $parse['noresearch'] = !$this->is_laboratory_in_queue() ? $this->_lang['bd_building_lab'] : '';
     $parse['technolist'] = $technology_list;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_research'), $parse));
 }