Ejemplo n.º 1
0
 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 = DevelopmentsLib::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'] = FormatLib::pretty_time($QueueTime - $this->_current_planet['planet_b_hangar']);
     return parent::$page->parse_template(parent::$page->get_template('buildings/buildings_script'), $parse);
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 /**
  * 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 = DevelopmentsLib::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 (DevelopmentsLib::is_development_allowed($this->_current_user, $working_planet, $technology) && DevelopmentsLib::is_development_payable($this->_current_user, $working_planet, $technology) && !parent::$users->is_on_vacations($this->_current_user)) {
                         $costs = DevelopmentsLib::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() + DevelopmentsLib::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\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech_id` = '" . $working_planet['planet_b_tech_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech` = '" . $working_planet['planet_b_tech'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_metal` = '" . $working_planet['planet_metal'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_crystal` = '" . $working_planet['planet_crystal'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . $working_planet['planet_deuterium'] . "',\n\t\t\t\t\t\t\t\t\t\t\tr.`research_current_research` = '" . $this->_current_user['research_current_research'] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $working_planet['planet_id'] . "'\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;
                 }
             }
         }
         FunctionsLib::redirect('game.php?page=research');
     }
 }
Ejemplo n.º 4
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->getObjects();
     $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 = DevelopmentsLib::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'] = StatisticsLib::calculate_points($element, $current_planet[$resource[$element]]);
             parent::$db->query("UPDATE " . PLANETS . " AS p\n                    INNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = p.planet_user_id\n                    INNER 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'] . "'\n                    WHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
             $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'] . "'\n                WHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
         $ret_value = false;
     }
     return $ret_value;
 }
Ejemplo n.º 5
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $reslist = parent::$objects->getObjectsList();
     $planetsrow = parent::$db->query("SELECT `planet_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_name`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_galaxy`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_image`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_current`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_max`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_used`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_max`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_mine`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_mine`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_sintetizer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_solar_plant`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_fusion_reactor`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_robot_factory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_nano_factory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_hangar`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_store`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_store`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_tank`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_laboratory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_terraformer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_ally_deposit`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_missile_silo`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_mondbasis`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_phalanx`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_jump_gate`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_rocket_launcher`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_light_laser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_heavy_laser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_gauss_cannon`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_ion_cannon`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_plasma_turret`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_small_shield_dome`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_large_shield_dome`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_anti-ballistic_missile`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_interplanetary_missile`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_small_cargo_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_big_cargo_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_light_fighter`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_heavy_fighter`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_cruiser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battleship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_colony_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_recycler`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_espionage_probe`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_bomber`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_solar_satellite`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_destroyer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_deathstar`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battlecruiser`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_user_id` = '" . (int) $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_destroyed` = 0;");
     $parse = $this->_lang;
     $planet = array();
     $r = array();
     $EmpireRowTPL = parent::$page->get_template('empire/empire_row');
     $f = array('file_images', 'file_names', 'file_coordinates', 'file_fields', 'file_metal', 'file_crystal', 'file_deuterium', 'file_energy');
     $m = array('build', 'tech', 'fleet', 'defense');
     $n = array('building_row', 'technology_row', 'fleet_row', 'defense_row');
     while ($p = parent::$db->fetchArray($planetsrow)) {
         $planet[] = $p;
     }
     $parse['mount'] = count($planet) + 1;
     foreach ($planet as $p) {
         $datat = array('<a href="game.php?page=overview&cp=' . $p['planet_id'] . '&amp;re=0"><img src="' . DPATH . 'planets/small/s_' . $p['planet_image'] . '.jpg" border="0" height="80" width="80"></a>', $p['planet_name'], "[<a href=\"game.php?page=galaxy&mode=3&galaxy={$p['planet_galaxy']}&system={$p['planet_system']}\">{$p['planet_galaxy']}:{$p['planet_system']}:{$p['planet_planet']}</a>]", $p['planet_field_current'] . '/' . $p['planet_field_max'], '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . FormatLib::pretty_number($p['planet_metal']) . '</a> / ' . FormatLib::pretty_number($p['planet_metal_perhour'] + FunctionsLib::read_config('metal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . FormatLib::pretty_number($p['planet_crystal']) . '</a> / ' . FormatLib::pretty_number($p['planet_crystal_perhour'] + FunctionsLib::read_config('crystal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . FormatLib::pretty_number($p['planet_deuterium']) . '</a> / ' . FormatLib::pretty_number($p['planet_deuterium_perhour'] + FunctionsLib::read_config('deuterium_basic_income')), FormatLib::pretty_number($p['planet_energy_max'] - $p['planet_energy_used']) . ' / ' . FormatLib::pretty_number($p['planet_energy_max']));
         for ($k = 0; $k < 8; $k++) {
             $parse[$f[$k]] = isset($parse[$f[$k]]) ? $parse[$f[$k]] : '';
             $data['text'] = $datat[$k];
             $parse[$f[$k]] .= parent::$page->parse_template($EmpireRowTPL, $data);
         }
         foreach ($resource as $i => $res) {
             $r[$i] = isset($r[$i]) ? $r[$i] : '';
             $data['text'] = !isset($p[$resource[$i]]) && !isset($this->_current_user[$resource[$i]]) ? '0' : (in_array($i, $reslist['build']) ? "<a href=\"game.php?page=" . DevelopmentsLib::set_building_page($i) . "&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : (in_array($i, $reslist['tech']) ? "<a href=\"game.php?page=research&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$this->_current_user[$resource[$i]]}</a>" : (in_array($i, $reslist['fleet']) ? "<a href=\"game.php?page=shipyard&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : (in_array($i, $reslist['defense']) ? "<a href=\"game.php?page=defense&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : '0'))));
             $r[$i] .= parent::$page->parse_template($EmpireRowTPL, $data);
         }
     }
     for ($j = 0; $j < 4; $j++) {
         foreach ($reslist[$m[$j]] as $a => $i) {
             $parse[$n[$j]] = isset($parse[$n[$j]]) ? $parse[$n[$j]] : '';
             $data['text'] = $this->_lang['tech'][$i];
             $parse[$n[$j]] .= "<tr>" . parent::$page->parse_template($EmpireRowTPL, $data) . $r[$i] . "</tr>";
         }
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('empire/empire_table'), $parse), FALSE);
 }
Ejemplo n.º 6
0
 /**
  * buildingQueue
  *
  * @param array $current_user   Current user
  * @param array $current_planet Current planet
  * @param int   $ProductionTime Production time
  *
  * @return int
  */
 private static function buildingQueue($current_user, &$current_planet, $ProductionTime)
 {
     $resource = parent::$objects->getObjects();
     if ($current_planet['planet_b_hangar_id'] != 0) {
         $Builded = array();
         $BuildArray = array();
         $BuildQueue = explode(';', $current_planet['planet_b_hangar_id']);
         $current_planet['planet_b_hangar'] += $ProductionTime;
         foreach ($BuildQueue as $Node => $Array) {
             if ($Array != '') {
                 $Item = explode(',', $Array);
                 $AcumTime = DevelopmentsLib::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;
 }
Ejemplo n.º 7
0
 /**
  * method get_planets
  * param $user_planet
  * param $is_current_planet
  * return building in progress or free text
  */
 private function get_current_work($user_planet, $is_current_planet = TRUE)
 {
     // THE PLANET IS "FREE" BY DEFAULT
     $building_block = $this->_lang['ov_free'];
     if (!$is_current_planet) {
         // UPDATE THE PLANET INFORMATION FIRST, MAY BE SOMETHING HAS JUST FINISHED
         UpdateLib::updateBuildingsQueue($user_planet, $this->_current_user);
     }
     if ($user_planet['planet_b_building'] != 0) {
         if ($user_planet['planet_b_building'] != 0) {
             $queue = explode(';', $user_planet['planet_b_building_id']);
             // GET ALL
             $current_building = explode(',', $queue[0]);
             // GET ONLY THE FIRST ELEMENT
             $building = $current_building[0];
             // THE BUILDING
             $level = $current_building[1];
             // THE LEVEL
             $time_to_end = $current_building[3] - time();
             // THE TIME
             // THE BUILDING BLOCK
             if ($is_current_planet) {
                 $building_block = DevelopmentsLib::current_building("overview", $building);
                 $building_block .= $this->_lang['tech'][$building] . ' (' . $level . ')';
                 $building_block .= "<br /><div id=\"blc\" class=\"z\">" . FormatLib::pretty_time($time_to_end) . "</div>";
                 $building_block .= "\n<script language=\"JavaScript\">";
                 $building_block .= "\n\tpp = \"" . $time_to_end . "\";\n";
                 $building_block .= "\n\tpk = \"" . 1 . "\";\n";
                 $building_block .= "\n\tpm = \"cancel\";\n";
                 $building_block .= "\n\tpl = \"" . $this->_current_planet['planet_id'] . "\";\n";
                 $building_block .= "\n\tt();\n";
                 $building_block .= "\n</script>\n";
             } else {
                 $building_block = '' . $this->_lang['tech'][$building] . ' (' . $level . ')';
                 $building_block .= '<br><font color="#7f7f7f">(' . FormatLib::pretty_time($time_to_end) . ')</font>';
             }
         }
     }
     // BACK TO THE PLANET!
     return $building_block;
 }
Ejemplo n.º 8
0
 /**
  * method current_building
  * param $call_program
  * param $element_id
  * return if is possible develop a new building, research, ship or defense.
  */
 public static function current_building($call_program, $element_id = 0)
 {
     $parse = parent::$lang;
     $parse['call_program'] = $call_program;
     $parse['current_page'] = $element_id != 0 ? DevelopmentsLib::set_building_page($element_id) : $call_program;
     return parent::$page->parse_template(parent::$page->get_template('buildings/buildings_buildlist_script'), $parse);
 }
Ejemplo n.º 9
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if (!array_key_exists($this->_element_id, $this->_resource)) {
         FunctionsLib::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) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $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) {
             FunctionsLib::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'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['attack']);
         $parse['capacity_pt'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['capacity']);
         $parse['base_speed'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['speed']);
         $parse['base_conso'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['consumption']);
         if ($this->_element_id == 202) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . FormatLib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>";
             $parse['upd_conso'] = "<font color=\"yellow\">(" . FormatLib::pretty_number($this->_pricelist[$this->_element_id]['consumption2']) . ")</font>";
         } elseif ($this->_element_id == 211) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . FormatLib::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'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = FormatLib::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);
         } elseif ($this->_element_id == 42) {
             $parse['table_data'] = $this->phalanxRange($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'] = FunctionsLib::chrono_applet("Gate", "1", $RestString['value'], TRUE);
                 $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                 $parse['gate_script_go'] = FunctionsLib::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 = DevelopmentsLib::development_price($this->_current_user, $this->_current_planet, $this->_element_id, TRUE, TRUE);
             $DestroyTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $this->_element_id) / 2;
             $parse['destroyurl'] = "game.php?page=" . DevelopmentsLib::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'] = FormatLib::pretty_number($NeededRessources['metal']);
             $parse['crystal'] = FormatLib::pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = FormatLib::pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = FormatLib::pretty_time($DestroyTime);
             $page .= parent::$page->parse_template($DestroyTPL, $parse);
         }
     }
     parent::$page->display($page);
 }