コード例 #1
0
ファイル: infos.php プロジェクト: saiikup/XG-Proyect-v3.x.x
 /**
  * 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);
 }
コード例 #2
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->get_objects();
     $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 = Developments_Lib::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'] = Statistics_Lib::calculate_points($element, $current_planet[$resource[$element]]);
             parent::$db->query("\nUPDATE " . PLANETS . " AS p\nINNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = p.planet_user_id\nINNER 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'] . "'\nWHERE `planet_id` = '" . $current_planet['planet_id'] . "';\n");
             $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'] . "'\nWHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
         $ret_value = false;
     }
     return $ret_value;
 }
コード例 #3
0
ファイル: buildings.php プロジェクト: Gritch69/XG-Project
 /**
  * method cancel_current
  * param
  * return (bool) confirmation
  */
 private function cancel_current()
 {
     $CurrentQueue = $this->_current_planet['planet_b_building_id'];
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
         $CanceledIDArray = explode(",", $QueueArray[0]);
         $building = $CanceledIDArray[0];
         $BuildMode = $CanceledIDArray[4];
         if ($ActualCount > 1) {
             array_shift($QueueArray);
             $NewCount = count($QueueArray);
             $BuildEndTime = time();
             for ($ID = 0; $ID < $NewCount; $ID++) {
                 $ListIDArray = explode(",", $QueueArray[$ID]);
                 if ($ListIDArray[0] == $building) {
                     $ListIDArray[1] -= 1;
                 }
                 $current_build_time = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $ListIDArray[0]);
                 $BuildEndTime += $current_build_time;
                 $ListIDArray[2] = $current_build_time;
                 $ListIDArray[3] = $BuildEndTime;
                 $QueueArray[$ID] = implode(",", $ListIDArray);
             }
             $NewQueue = implode(";", $QueueArray);
             $ReturnValue = TRUE;
             $BuildEndTime = '0';
         } else {
             $NewQueue = '0';
             $ReturnValue = FALSE;
             $BuildEndTime = '0';
         }
         if ($BuildMode == 'destroy') {
             $ForDestroy = TRUE;
         } else {
             $ForDestroy = FALSE;
         }
         if ($building != FALSE) {
             $Needed = Developments_Lib::development_price($this->_current_user, $this->_current_planet, $building, TRUE, $ForDestroy);
             $this->_current_planet['planet_metal'] += $Needed['metal'];
             $this->_current_planet['planet_crystal'] += $Needed['crystal'];
             $this->_current_planet['planet_deuterium'] += $Needed['deuterium'];
         }
     } else {
         $NewQueue = '0';
         $BuildEndTime = '0';
         $ReturnValue = FALSE;
     }
     $this->_current_planet['planet_b_building_id'] = $NewQueue;
     $this->_current_planet['planet_b_building'] = $BuildEndTime;
     return $ReturnValue;
 }
コード例 #4
0
ファイル: research.php プロジェクト: Gritch69/XG-Project
 /**
  * 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');
     }
 }