/** * 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 (Developments_Lib::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'] = Developments_Lib::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'] = Developments_Lib::formated_development_price($this->_current_user, $this->_current_planet, $tech); $SearchTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $tech, FALSE, $this->_lab_level); $RowParse['search_time'] = Developments_Lib::formated_development_time($SearchTime); if (!$this->_is_working['is_working']) { if (Developments_Lib::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 = Format_Lib::color_red($this->_lang['bd_research']); } else { $action_link = Functions_Lib::set_url('game.php?page=research&cmd=search&tech=' . $tech, '', Format_Lib::color_green($this->_lang['bd_research'])); } } else { $action_link = Format_Lib::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 /> ' . Format_Lib::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)); }
public function build_page() { $parse = $this->_lang; if (isset($_POST['fmenge'])) { $Missiles[502] = $this->_current_planet[$this->_resource[502]]; $Missiles[503] = $this->_current_planet[$this->_resource[503]]; $SiloSize = $this->_current_planet[$this->_resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $this->_current_planet['planet_b_hangar_id']; $BuildArray = explode(";", $BuildQueue); $totalCount = 0; for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[0] == 502) { $Missiles[502] += $ElmentArray[1]; } elseif ($ElmentArray[0] == 503) { $Missiles[503] += $ElmentArray[1]; } } foreach ($_POST['fmenge'] as $Element => $Count) { if ($Element < 300 or $Element > 550) { 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 ($Element == 407 or $Element == 408) { if (!$this->is_shield_in_queue($BuildQueue, $Element)) { $Count = 1; } else { $Count = 0; } } if (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) { $MaxElements = $this->GetMaxConstructibleElements($Element, $this->_current_planet); if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { 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\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_b_hangar_id` = '" . $this->_current_planet['planet_b_hangar_id'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_metal` = '" . $this->_current_planet['planet_metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_crystal` = '" . $this->_current_planet['planet_crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . $this->_current_planet['planet_deuterium'] . "'\r\n\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';"); } Functions_Lib::redirect('game.php?page=defense'); } if ($this->_current_planet[$this->_resource[21]] == 0) { Functions_Lib::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 > 400 && $Element <= 599) { if (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) { $CanBuildOne = Developments_Lib::is_development_payable($this->_current_user, $this->_current_planet, $Element, FALSE); $BuildOneElementTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $Element); $ElementCount = $this->_current_planet[$this->_resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $this->_lang['bd_available'] . Format_Lib::pretty_number($ElementCount) . ")"; $parse['add_element'] = ''; $parse['dpath'] = DPATH; $parse['element'] = $Element; $parse['element_name'] = $ElementName; $parse['element_description'] = $this->_lang['res']['descriptions'][$Element]; $parse['element_price'] = Developments_Lib::formated_development_price($this->_current_user, $this->_current_planet, $Element, FALSE); $parse['building_time'] = Developments_Lib::formated_development_time($BuildOneElementTime); $parse['element_nbre'] = $ElementNbre; if ($CanBuildOne && !parent::$users->is_on_vacations($this->_current_user)) { $InQueue = strpos($this->_current_planet['planet_b_hangar_id'], $Element . ","); $IsBuildp = $this->_current_planet[$this->_resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $this->_current_planet[$this->_resource[408]] >= 1 ? TRUE : FALSE; $BuildIt = TRUE; if ($Element == 407 || $Element == 408) { $BuildIt = FALSE; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $BuildIt = TRUE; } } if (!$BuildIt) { $parse['add_element'] = '<font color="red">' . $this->_lang['bd_protection_shield_only_one'] . '</font>'; } elseif ($NotBuilding) { $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_defenses'] = '<tr><td class="c" colspan="2" align="center"><input type="submit" value="' . $this->_lang['bd_build_defenses'] . '"></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('defenses'); } $parse['buildlist'] = $PageTable; $parse['buildinglist'] = $BuildQueue; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_defense'), $parse)); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = $this->_objects->get_objects(); $parse = $this->_lang; $parse['dpath'] = DPATH; $page = ''; $max_fields = Developments_Lib::max_fields($this->_current_planet); // time to do something $this->do_command(); Developments_Lib::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 (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $building)) { $building_level = $this->_current_planet[$resource[$building]]; $building_time = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $building, $building_level); $parse['i'] = $building; $parse['nivel'] = Developments_Lib::set_level_format($building_level); $parse['n'] = $building_name; $parse['descriptions'] = $this->_lang['res']['descriptions'][$building]; $parse['price'] = Developments_Lib::formated_development_price($this->_current_user, $this->_current_planet, $building, TRUE, $building_level); $parse['time'] = Developments_Lib::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'] = Developments_Lib::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)); }