private function ElementBuildListBox($current_page) { $ElementQueue = explode(';', $this->_current_planet['planet_b_hangar_id']); $NbrePerType = ''; $NamePerType = ''; $TimePerType = ''; $QueueTime = 0; foreach ($ElementQueue as $ElementLine => $Element) { if ($Element != '') { $Element = explode(',', $Element); $ElementTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $Element[0]); $QueueTime += $ElementTime * $Element[1]; $TimePerType .= "" . $ElementTime . ","; $NamePerType .= "'" . html_entity_decode($this->_lang['tech'][$Element[0]], ENT_COMPAT, "utf-8") . "',"; $NbrePerType .= "" . $Element[1] . ","; } } $parse = $this->_lang; $parse['a'] = $NbrePerType; $parse['b'] = $NamePerType; $parse['c'] = $TimePerType; $parse['b_hangar_id_plus'] = $this->_current_planet['planet_b_hangar']; $parse['current_page'] = $current_page; $parse['pretty_time_b_hangar'] = Format_Lib::pretty_time($QueueTime - $this->_current_planet['planet_b_hangar']); return parent::$page->parse_template(parent::$page->get_template('buildings/buildings_script'), $parse); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { if (!array_key_exists($this->_element_id, $this->_resource)) { Functions_Lib::redirect('game.php?page=techtree'); } $GateTPL = ''; $DestroyTPL = ''; $TableHeadTPL = ''; $TableFooterTPL = ''; $parse = $this->_lang; $parse['dpath'] = DPATH; $parse['name'] = $this->_lang['info'][$this->_element_id]['name']; $parse['image'] = $this->_element_id; $parse['description'] = $this->_lang['info'][$this->_element_id]['description']; if ($this->_element_id < 13 or $this->_element_id == 43 && $this->_current_planet[$this->_resource[43]] > 0) { $PageTPL = parent::$page->get_template('infos/info_buildings_table'); } elseif ($this->_element_id < 200) { $PageTPL = parent::$page->get_template('infos/info_buildings_general'); } elseif ($this->_element_id < 400) { $PageTPL = parent::$page->get_template('infos/info_buildings_fleet'); } elseif ($this->_element_id < 600) { $PageTPL = parent::$page->get_template('infos/info_buildings_defense'); } else { $PageTPL = parent::$page->get_template('infos/info_officiers_general'); } //S�lo hay destroy en <200 if ($this->_element_id < 200 && $this->_element_id != 33 && $this->_element_id != 41) { $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy'); } if ($this->_element_id >= 1 && $this->_element_id <= 3) { $PageTPL = parent::$page->get_template('infos/info_buildings_table'); $TableHeadTPL = parent::$page->get_template('infos/info_production_header'); $TableTPL = parent::$page->get_template('infos/info_production_body'); } elseif ($this->_element_id == 4) { $PageTPL = parent::$page->get_template('infos/info_buildings_table'); $TableHeadTPL = parent::$page->get_template('infos/info_production_simple_header'); $TableTPL = parent::$page->get_template('infos/info_production_simple_body'); } elseif ($this->_element_id >= 22 && $this->_element_id <= 24) { $PageTPL = parent::$page->get_template('infos/info_buildings_table'); $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy'); $TableHeadTPL = parent::$page->get_template('infos/info_storage_header'); $TableTPL = parent::$page->get_template('infos/info_storage_table'); } elseif ($this->_element_id == 12) { $TableHeadTPL = parent::$page->get_template('infos/info_energy_header'); $TableTPL = parent::$page->get_template('infos/info_energy_body'); } elseif ($this->_element_id == 42) { $TableHeadTPL = parent::$page->get_template('infos/info_range_header'); $TableTPL = parent::$page->get_template('infos/info_range_body'); } elseif ($this->_element_id == 43) { $GateTPL = parent::$page->get_template('infos/info_gate_table'); if ($_POST) { Functions_Lib::message($this->DoFleetJump(), "game.php?page=infos&gid=43", 2); } } elseif ($this->_element_id == 124) { $PageTPL = parent::$page->get_template('infos/info_buildings_table'); $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy'); $TableHeadTPL = parent::$page->get_template('infos/info_astrophysics_header'); $TableTPL = parent::$page->get_template('infos/info_astrophysics_table'); $TableFooterTPL = parent::$page->get_template('infos/info_astrophysics_footer'); } elseif ($this->_element_id >= 202 && $this->_element_id <= 250) { $PageTPL = parent::$page->get_template('infos/info_buildings_fleet'); $parse['element_typ'] = $this->_lang['tech'][200]; $parse['rf_info_to'] = $this->ShowRapidFireTo(); $parse['rf_info_fr'] = $this->ShowRapidFireFrom(); $parse['hull_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']); $parse['shield_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['shield']); $parse['attack_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['attack']); $parse['capacity_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['capacity']); $parse['base_speed'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed']); $parse['base_conso'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['consumption']); if ($this->_element_id == 202) { $parse['upd_speed'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>"; $parse['upd_conso'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['consumption2']) . ")</font>"; } elseif ($this->_element_id == 211) { $parse['upd_speed'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>"; } } elseif ($this->_element_id >= 401 && $this->_element_id <= 550) { $PageTPL = parent::$page->get_template('infos/info_buildings_defense'); $parse['element_typ'] = $this->_lang['tech'][400]; if ($this->_element_id < 500) { $parse['rf_info_to'] = $this->ShowRapidFireTo(); $parse['rf_info_fr'] = $this->ShowRapidFireFrom(); } $parse['hull_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']); $parse['shield_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['shield']); $parse['attack_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['attack']); } if ($TableHeadTPL != '') { $parse['table_head'] = parent::$page->parse_template($TableHeadTPL, $this->_lang); if ($this->_element_id >= 22 && $this->_element_id <= 24) { $parse['table_data'] = $this->storage_table($TableTPL); } elseif ($this->_element_id == 124) { $parse['table_data'] = $this->astrophysics_table($TableTPL); } else { $parse['table_data'] = $this->ShowProductionTable($TableTPL); } } if ($TableFooterTPL != '') { $parse['table_footer'] = parent::$page->parse_template($TableFooterTPL, $this->_lang); } $page = parent::$page->parse_template($PageTPL, $parse); if ($GateTPL != '') { if ($this->_current_planet[$this->_resource[$this->_element_id]] > 0) { $RestString = $this->GetNextJumpWaitTime($this->_current_planet); $parse['gate_start_link'] = $this->planet_link($this->_current_planet); if ($RestString['value'] != 0) { $parse['gate_time_script'] = Functions_Lib::chrono_applet("Gate", "1", $RestString['value'], TRUE); $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>"; $parse['gate_script_go'] = Functions_Lib::chrono_applet("Gate", "1", $RestString['value'], FALSE); } else { $parse['gate_time_script'] = ""; $parse['gate_wait_time'] = ""; $parse['gate_script_go'] = ""; } $parse['gate_dest_moons'] = $this->BuildJumpableMoonCombo($this->_current_user, $this->_current_planet); $parse['gate_fleet_rows'] = $this->BuildFleetListRows($this->_current_planet); $page .= parent::$page->parse_template($GateTPL, $parse); } } if ($DestroyTPL != '') { if (isset($this->_current_planet[$this->_resource[$this->_element_id]]) && $this->_current_planet[$this->_resource[$this->_element_id]] > 0) { $NeededRessources = Developments_Lib::development_price($this->_current_user, $this->_current_planet, $this->_element_id, TRUE, TRUE); $DestroyTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $this->_element_id) / 2; $parse['destroyurl'] = "game.php?page=" . Developments_Lib::set_building_page($this->_element_id) . "&cmd=destroy&building=" . $this->_element_id; $parse['levelvalue'] = $this->_current_planet[$this->_resource[$this->_element_id]]; $parse['nfo_metal'] = $this->_lang['Metal']; $parse['nfo_crysta'] = $this->_lang['Crystal']; $parse['nfo_deuter'] = $this->_lang['Deuterium']; $parse['metal'] = Format_Lib::pretty_number($NeededRessources['metal']); $parse['crystal'] = Format_Lib::pretty_number($NeededRessources['crystal']); $parse['deuterium'] = Format_Lib::pretty_number($NeededRessources['deuterium']); $parse['destroytime'] = Format_Lib::pretty_time($DestroyTime); $page .= parent::$page->parse_template($DestroyTPL, $parse); } } parent::$page->display($page); }
/** * method add_to_queue * param $building * param $AddMode * return (int) the queue ID */ private function add_to_queue($building, $AddMode = TRUE) { $resource = $this->_objects->get_objects(); $CurrentQueue = $this->_current_planet['planet_b_building_id']; $queue = $this->show_queue(); $max_fields = Developments_Lib::max_fields($this->_current_planet); if ($this->_current_planet['planet_field_current'] >= $max_fields - $queue['lenght']) { Functions_Lib::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 && Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $building)) { if ($QueueID <= 1) { if (Developments_Lib::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 = Developments_Lib::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 = Developments_Lib::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 = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $building); } else { $BuildLevel = $ActualLevel - 1; $BuildTime = Developments_Lib::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; }
private static function building_queue($current_user, &$current_planet, $ProductionTime) { $resource = parent::$objects->get_objects(); if ($current_planet['planet_b_hangar_id'] != 0) { $Builded = array(); $current_planet['planet_b_hangar'] += $ProductionTime; $BuildQueue = explode(';', $current_planet['planet_b_hangar_id']); $BuildArray = array(); foreach ($BuildQueue as $Node => $Array) { if ($Array != '') { $Item = explode(',', $Array); $AcumTime = Developments_Lib::development_time($current_user, $current_planet, $Item[0]); $BuildArray[$Node] = array($Item[0], $Item[1], $AcumTime); } } $current_planet['planet_b_hangar_id'] = ''; $UnFinished = FALSE; foreach ($BuildArray as $Node => $Item) { $Element = $Item[0]; $Count = $Item[1]; $BuildTime = $Item[2]; $Builded[$Element] = 0; if (!$UnFinished and $BuildTime > 0) { $AllTime = $BuildTime * $Count; if ($current_planet['planet_b_hangar'] >= $BuildTime) { $Done = min($Count, floor($current_planet['planet_b_hangar'] / $BuildTime)); if ($Count > $Done) { $current_planet['planet_b_hangar'] -= $BuildTime * $Done; $UnFinished = TRUE; $Count -= $Done; } else { $current_planet['planet_b_hangar'] -= $AllTime; $Count = 0; } $Builded[$Element] += $Done; $current_planet[$resource[$Element]] += $Done; } else { $UnFinished = TRUE; } } elseif (!$UnFinished) { $Builded[$Element] += $Count; $current_planet[$resource[$Element]] += $Count; $Count = 0; } if ($Count != 0) { $current_planet['planet_b_hangar_id'] .= $Element . "," . $Count . ";"; } } } else { $Builded = ''; $current_planet['planet_b_hangar'] = 0; } return $Builded; }
/** * method do_command * param * return void */ private function do_command() { $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : NULL; if (!is_null($cmd)) { $technology = (int) $_GET['tech']; if (in_array($technology, $this->_reslist['tech'])) { if (is_array($this->_is_working['working_on'])) { $working_planet = $this->_is_working['working_on']; } else { $working_planet = $this->_current_planet; } switch ($cmd) { // cancel a research case 'cancel': if ($this->_is_working['working_on']['planet_b_tech_id'] == $technology) { $costs = Developments_Lib::development_price($this->_current_user, $working_planet, $technology); $working_planet['planet_metal'] += $costs['metal']; $working_planet['planet_crystal'] += $costs['crystal']; $working_planet['planet_deuterium'] += $costs['deuterium']; $working_planet['planet_b_tech_id'] = 0; $working_planet['planet_b_tech'] = 0; $this->_current_user['research_current_research'] = 0; $update_data = TRUE; $this->_is_working['is_working'] = FALSE; } break; // start a research // start a research case 'search': if (Developments_Lib::is_development_allowed($this->_current_user, $working_planet, $technology) && Developments_Lib::is_development_payable($this->_current_user, $working_planet, $technology) && !parent::$users->is_on_vacations($this->_current_user)) { $costs = Developments_Lib::development_price($this->_current_user, $working_planet, $technology); $working_planet['planet_metal'] -= $costs['metal']; $working_planet['planet_crystal'] -= $costs['crystal']; $working_planet['planet_deuterium'] -= $costs['deuterium']; $working_planet['planet_b_tech_id'] = $technology; $working_planet['planet_b_tech'] = time() + Developments_Lib::development_time($this->_current_user, $working_planet, $technology, FALSE, $this->_lab_level); $this->_current_user['research_current_research'] = $working_planet['id']; $update_data = TRUE; $this->_is_working['is_working'] = TRUE; } break; } if ($update_data == TRUE) { parent::$db->query("UPDATE " . PLANETS . " AS p, " . RESEARCH . " AS r SET\r\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech_id` = '" . $working_planet['planet_b_tech_id'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech` = '" . $working_planet['planet_b_tech'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_metal` = '" . $working_planet['planet_metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_crystal` = '" . $working_planet['planet_crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . $working_planet['planet_deuterium'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\tr.`research_current_research` = '" . $this->_current_user['research_current_research'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $working_planet['planet_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND r.`research_user_id` = '" . $this->_current_user['user_id'] . "';"); } $this->_current_planet = $working_planet; if (is_array($this->_is_working['working_on'])) { $this->_is_working['working_on'] = $working_planet; } else { $this->_current_planet = $working_planet; if ($cmd == 'search') { $this->_is_working['working_on'] = $this->_current_planet; } } } Functions_Lib::redirect('game.php?page=research'); } }