Ejemplo n.º 1
0
 /**
  * method do_command
  * param $have_fields
  * param $full_queue
  * param $building
  * param $queue
  * return (string) $action
  */
 private function set_action_button($have_fields, $full_queue, $building, $queue)
 {
     // all field occupied
     $action = FormatLib::color_red($this->_lang['bd_no_more_fields']);
     // with fields
     if ($have_fields && !$full_queue) {
         if ($queue['lenght'] == 0) {
             if (DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $building, TRUE, FALSE) && !parent::$users->is_on_vacations($this->_current_user)) {
                 $action = FunctionsLib::set_url('game.php?page=' . $this->_current_page . '&cmd=insert&building=' . $building, '', FormatLib::color_green($this->_lang['bd_build']));
             } else {
                 $action = FormatLib::color_red($this->_lang['bd_build']);
             }
         } else {
             $action = FunctionsLib::set_url('game.php?page=' . $this->_current_page . '&cmd=insert&building=' . $building, '', FormatLib::color_green($this->_lang['bd_add_to_list']));
         }
     }
     if ($have_fields && $full_queue) {
         $action = FormatLib::color_red($this->_lang['bd_build']);
     }
     if ($building == 31 && DevelopmentsLib::is_lab_working($this->_current_user) or ($building == 21 or $building == 14 or $building == 15) && DevelopmentsLib::is_shipyard_working($this->_current_planet)) {
         $action = FormatLib::color_red($this->_lang['bd_working']);
     }
     return $action;
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
0
 /**
  * method resource_color
  * param1 $current_amount
  * param2 $max_amount
  * return color depending on the current storage capacity
  */
 private function resource_color($current_amount, $max_amount)
 {
     if ($max_amount < $current_amount) {
         return FormatLib::color_red(FormatLib::pretty_number($max_amount / 1000) . 'k');
     } else {
         return FormatLib::color_green(FormatLib::pretty_number($max_amount / 1000) . 'k');
     }
 }
Ejemplo n.º 4
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $page = '';
     $header_template = parent::$page->get_template('techtree/techtree_head');
     $row_template = parent::$page->get_template('techtree/techtree_row');
     foreach ($this->_lang['tech'] as $element => $element_name) {
         if ($element < 600) {
             $parse['tt_name'] = $element_name;
             if (!isset($this->_resource[$element])) {
                 $parse['Requirements'] = $this->_lang['tt_requirements'];
                 $page .= parent::$page->parse_template($header_template, $parse);
             } else {
                 if (isset($this->_requeriments[$element])) {
                     $list = '';
                     foreach ($this->_requeriments[$element] as $requirement => $level) {
                         if (isset($this->_current_user[$this->_resource[$requirement]]) && $this->_current_user[$this->_resource[$requirement]] >= $level) {
                             $list .= FormatLib::color_green($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         } elseif (isset($this->_current_planet[$this->_resource[$requirement]]) && $this->_current_planet[$this->_resource[$requirement]] >= $level) {
                             $list .= FormatLib::color_green($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         } else {
                             $list .= FormatLib::color_red($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         }
                         $list .= '<br/>';
                     }
                     $parse['required_list'] = $list;
                 } else {
                     $parse['required_list'] = '';
                     $parse['tt_detail'] = '';
                 }
                 $parse['tt_info'] = $element;
                 $page .= parent::$page->parse_template($row_template, $parse);
             }
         }
     }
     $parse['techtree_list'] = $page;
     return parent::$page->display(parent::$page->parse_template(parent::$page->get_template('techtree/techtree_body'), $parse));
 }