Exemplo n.º 1
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->get_objects();
     $pricelist = parent::$objects->get_price();
     $reslist = parent::$objects->get_objects_list();
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // QUERYS
     $getCurrentAcs = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ACS_FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE acs_fleet_members = '" . $this->_current_user['user_id'] . "'");
     // ARRAYS
     $speed_values = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10);
     $planet_type = array('fl_planet', 'fl_debris', 'fl_moon');
     // LOAD TEMPLATES REQUIRED
     $inputs_template = parent::$page->get_template('fleet/fleet2_inputs');
     $options_template = parent::$page->get_template('fleet/fleet_options');
     $shortcut_template = parent::$page->get_template('fleet/fleet2_shortcuts');
     $shortcut_row_template = parent::$page->get_template('fleet/fleet2_shortcuts_row');
     $shortcut_noshortcuts = parent::$page->get_template('fleet/fleet2_shortcuts_noshortcuts_row');
     $shortcut_acs_row = parent::$page->get_template('fleet/fleet2_shortcut_acs_row');
     // LANGUAGE
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     // COORDS
     $g = $_POST['galaxy'] == '' ? $this->_current_planet['planet_galaxy'] : $_POST['galaxy'];
     $s = $_POST['system'] == '' ? $this->_current_planet['planet_system'] : $_POST['system'];
     $p = $_POST['planet'] == '' ? $this->_current_planet['planet_planet'] : $_POST['planet'];
     $t = $_POST['planet_type'] == '' ? $this->_current_planet['planet_type'] : $_POST['planet_type'];
     // OTHER VALUES
     $value = 0;
     $FleetHiddenBlock = '';
     #####################################################################################################
     // END DEFAULT VALUES
     #####################################################################################################
     #####################################################################################################
     // LOAD SHIPS INPUTS
     #####################################################################################################
     $fleet['fleetlist'] = '';
     $fleet['amount'] = 0;
     $fleet['consumption'] = 0;
     foreach ($reslist['fleet'] as $n => $i) {
         if (isset($_POST["ship{$i}"]) && $i >= 201 && $i <= 215 && $_POST["ship{$i}"] > "0") {
             if ($_POST["ship{$i}"] > $this->_current_planet[$resource[$i]] or !ctype_digit($_POST["ship{$i}"])) {
                 Functions_Lib::redirect('game.php?page=fleet1');
             } else {
                 $fleet['fleetarray'][$i] = $_POST["ship{$i}"];
                 $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";";
                 $fleet['amount'] += $_POST["ship{$i}"];
                 $fleet['i'] = $i;
                 $fleet['consumption'] += Fleets_Lib::ship_consumption($i, $this->_current_user);
                 $fleet['speed'] = Fleets_Lib::fleet_max_speed('', $i, $this->_current_user);
                 $fleet['capacity'] = $pricelist[$i]['capacity'];
                 $fleet['ship'] = $_POST["ship{$i}"];
                 $speedalls[$i] = Fleets_Lib::fleet_max_speed('', $i, $this->_current_user);
                 $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet);
             }
         }
     }
     if (!$fleet['fleetlist']) {
         Functions_Lib::redirect('game.php?page=fleet1');
     } else {
         $speedallsmin = min($speedalls);
     }
     #####################################################################################################
     // LOAD PLANET TYPES OPTIONS
     #####################################################################################################
     $parse['options_planettype'] = '';
     foreach ($planet_type as $type) {
         $value++;
         $options['value'] = $value;
         if ($value == $t) {
             $options['selected'] = 'SELECTED';
         } else {
             $options['selected'] = '';
         }
         $options['title'] = $this->_lang[$type];
         $parse['options_planettype'] .= parent::$page->parse_template($options_template, $options);
     }
     #####################################################################################################
     // LOAD SPEED OPTIONS
     #####################################################################################################
     $parse['options'] = '';
     foreach ($speed_values as $value => $porcentage) {
         $speed_porcentage['value'] = $value;
         $speed_porcentage['selected'] = '';
         $speed_porcentage['title'] = $porcentage;
         $parse['options'] .= parent::$page->parse_template($options_template, $speed_porcentage);
     }
     #####################################################################################################
     // PARSE THE REST OF THE OPTIONS
     #####################################################################################################
     $parse['fleetblock'] = $FleetHiddenBlock;
     $parse['speedallsmin'] = $speedallsmin;
     $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray'])));
     $parse['galaxy'] = $this->_current_planet['planet_galaxy'];
     $parse['system'] = $this->_current_planet['planet_system'];
     $parse['planet'] = $this->_current_planet['planet_planet'];
     $parse['galaxy_post'] = (int) $_POST['galaxy'];
     $parse['system_post'] = (int) $_POST['system'];
     $parse['planet_post'] = (int) $_POST['planet'];
     $parse['speedfactor'] = Functions_Lib::fleet_speed_factor();
     $parse['planet_type'] = $this->_current_planet['planet_type'];
     $parse['metal'] = floor($this->_current_planet['planet_metal']);
     $parse['crystal'] = floor($this->_current_planet['planet_crystal']);
     $parse['deuterium'] = floor($this->_current_planet['planet_deuterium']);
     $parse['g'] = $g;
     $parse['s'] = $s;
     $parse['p'] = $p;
     #####################################################################################################
     // LOAD FLEET SHORTCUTS
     #####################################################################################################
     if (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander'])) {
         if ($this->_current_user['user_fleet_shortcuts']) {
             $scarray = explode(";", $this->_current_user['user_fleet_shortcuts']);
             foreach ($scarray as $a => $b) {
                 if ($b != "") {
                     $c = explode(',', $b);
                     $shortcut['description'] = $c[0] . " " . $c[1] . ":" . $c[2] . ":" . $c[3] . " ";
                     switch ($c[4]) {
                         case 1:
                             $shortcut['description'] .= $this->_lang['fl_planet_shortcut'];
                             break;
                         case 2:
                             $shortcut['description'] .= $this->_lang['fl_debris_shortcut'];
                             break;
                         case 3:
                             $shortcut['description'] .= $this->_lang['fl_moon_shortcut'];
                             break;
                         default:
                             $shortcut['description'] .= '';
                             break;
                     }
                     $shortcut['select'] = 'shortcuts';
                     $shortcut['selected'] = '';
                     $shortcut['value'] = $c['1'] . ';' . $c['2'] . ';' . $c['3'] . ';' . $c['4'];
                     $shortcut['title'] = $shortcut['description'];
                     $shortcut['shortcut_options'] .= parent::$page->parse_template($options_template, $shortcut);
                 }
             }
             $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_row_template, $shortcut);
             $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse);
         } else {
             $parse['fl_shorcut_message'] = $this->_lang['fl_no_shortcuts'];
             $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_noshortcuts, $parse);
             $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse);
         }
     }
     #####################################################################################################
     // LOAD COLONY SHORTCUTS
     #####################################################################################################
     $colony['select'] = 'colonies';
     $colony['shortcut_options'] = Functions_Lib::build_planet_list($this->_current_user, $this->_current_planet['planet_id']);
     $parse['colonylist'] = parent::$page->parse_template($shortcut_row_template, $colony);
     if ($colony['shortcut_options'] === FALSE) {
         $parse['fl_shorcut_message'] = $this->_lang['fl_no_colony'];
         $parse['colonylist'] = parent::$page->parse_template($shortcut_noshortcuts, $parse);
     }
     #####################################################################################################
     // LOAD SAC SHORTCUTS
     #####################################################################################################
     $acs_fleets = '';
     while ($row = parent::$db->fetch_array($getCurrentAcs)) {
         $members = explode(",", $row['acs_fleet_invited']);
         foreach ($members as $a => $b) {
             if ($b == $this->_current_user['user_id']) {
                 $acs['galaxy'] = $row['acs_fleet_galaxy'];
                 $acs['system'] = $row['acs_fleet_system'];
                 $acs['planet'] = $row['acs_fleet_planet'];
                 $acs['planet_type'] = $row['acs_fleet_planet_type'];
                 $acs['id'] = $row['acs_fleet_id'];
                 $acs['name'] = $row['acs_fleet_name'];
                 $acs_fleets .= parent::$page->parse_template($shortcut_acs_row, $acs);
             }
         }
     }
     $parse['asc'] = $acs_fleets;
     $parse['maxepedition'] = $_POST['maxepedition'];
     $parse['curepedition'] = $_POST['curepedition'];
     $parse['target_mission'] = $_POST['target_mission'];
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet2_table'), $parse));
 }
Exemplo n.º 2
0
 /**
  * method topnav_bar
  * param
  * return get the top navigation bar data and parses it
  */
 private function game_navbar()
 {
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $parse['image'] = $this->_current_planet['planet_image'];
     $parse['planetlist'] = Functions_Lib::build_planet_list($this->_current_user);
     // VACATION MODE & DELETE MODE MESSAGES
     if ($this->_current_user['setting_vacations_status'] && $this->_current_user['setting_delete_account']) {
         $parse['show_umod_notice'] .= $this->_current_user['setting_delete_account'] ? '<table width="100%" style="border: 2px solid red; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_delete_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_delete_account'] + 60 * 60 * 24 * 7) . '</td></tr></table>' : '';
     } else {
         if ($this->_current_user['setting_vacations_status'] < time()) {
             $parse['show_umod_notice'] = $this->_current_user['setting_vacations_status'] ? '<table width="100%" style="border: 2px solid #1DF0F0; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_vacation_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_vacations_until']) . '</td></tr></table><br>' : '';
         }
         $parse['show_umod_notice'] .= $this->_current_user['setting_delete_account'] ? '<table width="100%" style="border: 2px solid red; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_delete_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_delete_account'] + 60 * 60 * 24 * 7) . '</td></tr></table>' : '';
     }
     // RESOURCES FORMAT
     $metal = Format_Lib::pretty_number($this->_current_planet['planet_metal']);
     $crystal = Format_Lib::pretty_number($this->_current_planet['planet_crystal']);
     $deuterium = Format_Lib::pretty_number($this->_current_planet['planet_deuterium']);
     $darkmatter = Format_Lib::pretty_number($this->_current_user['premium_dark_matter']);
     $energy = Format_Lib::pretty_number($this->_current_planet['planet_energy_max'] + $this->_current_planet['planet_energy_used']) . "/" . Format_Lib::pretty_number($this->_current_planet['planet_energy_max']);
     // OFFICERS AVAILABILITY
     $commander = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander']) ? '' : '_un';
     $admiral = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_admiral']) ? '' : '_un';
     $engineer = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_engineer']) ? '' : '_un';
     $geologist = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? '' : '_un';
     $technocrat = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_technocrat']) ? '' : '_un';
     // METAL
     if ($this->_current_planet['planet_metal'] >= $this->_current_planet['planet_metal_max']) {
         $metal = Format_Lib::color_red($metal);
     }
     // CRYSTAL
     if ($this->_current_planet['planet_crystal'] >= $this->_current_planet['planet_crystal_max']) {
         $crystal = Format_Lib::color_red($crystal);
     }
     // DEUTERIUM
     if ($this->_current_planet['planet_deuterium'] >= $this->_current_planet['planet_deuterium_max']) {
         $deuterium = Format_Lib::color_red($deuterium);
     }
     // ENERGY
     if ($this->_current_planet['planet_energy_max'] + $this->_current_planet['planet_energy_used'] < 0) {
         $energy = Format_Lib::color_red($energy);
     }
     $parse['metal'] = $metal;
     $parse['crystal'] = $crystal;
     $parse['deuterium'] = $deuterium;
     $parse['darkmatter'] = $darkmatter;
     $parse['energy'] = $energy;
     $parse['img_commander'] = $commander;
     $parse['img_admiral'] = $admiral;
     $parse['img_engineer'] = $engineer;
     $parse['img_geologist'] = $geologist;
     $parse['img_technocrat'] = $technocrat;
     return $this->parse_template($this->get_template('general/topnav'), $parse);
 }