Ejemplo n.º 1
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     FunctionsLib::module_message(FunctionsLib::is_module_accesible(self::MODULE_ID));
     $this->_lang = parent::$lang;
     $this->_current_user = parent::$users->get_user_data();
     $this->_have_premium = OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander']);
     // build the page
     $this->build_page();
 }
Ejemplo n.º 2
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     FunctionsLib::module_message(FunctionsLib::is_module_accesible(self::MODULE_ID));
     $this->_current_user = parent::$users->get_user_data();
     if (!OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander'])) {
         FunctionsLib::redirect('game.php?page=officier');
     } else {
         $this->build_page();
     }
 }
Ejemplo n.º 3
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $pricelist = parent::$objects->getPrice();
     $reslist = parent::$objects->getObjectsList();
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // QUERYS
     $getCurrentAcs = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ACS_FLEETS . "\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}"])) {
                 FunctionsLib::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'] += FleetsLib::ship_consumption($i, $this->_current_user);
                 $fleet['speed'] = FleetsLib::fleet_max_speed('', $i, $this->_current_user);
                 $fleet['capacity'] = $pricelist[$i]['capacity'];
                 $fleet['ship'] = $_POST["ship{$i}"];
                 $speedalls[$i] = FleetsLib::fleet_max_speed('', $i, $this->_current_user);
                 $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet);
             }
         }
     }
     if (!$fleet['fleetlist']) {
         FunctionsLib::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'] = FunctionsLib::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 (OfficiersLib::isOfficierActive($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'] = FunctionsLib::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->fetchArray($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));
 }
Ejemplo n.º 4
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $game_metal_basic_income = FunctionsLib::read_config('metal_basic_income');
     $game_crystal_basic_income = FunctionsLib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = FunctionsLib::read_config('deuterium_basic_income');
     $game_energy_basic_income = FunctionsLib::read_config('energy_basic_income');
     $game_resource_multiplier = FunctionsLib::read_config('resource_multiplier');
     if ($this->_current_planet['planet_type'] == 3) {
         $game_metal_basic_income = 0;
         $game_crystal_basic_income = 0;
         $game_deuterium_basic_income = 0;
     }
     $this->_current_planet['planet_metal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[22]]);
     $this->_current_planet['planet_crystal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[23]]);
     $this->_current_planet['planet_deuterium_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[24]]);
     $parse['production_level'] = 100;
     $post_porcent = ProductionLib::maxProduction($this->_current_planet['planet_energy_max'], $this->_current_planet['planet_energy_used']);
     $parse['resource_row'] = '';
     $this->_current_planet['planet_metal_perhour'] = 0;
     $this->_current_planet['planet_crystal_perhour'] = 0;
     $this->_current_planet['planet_deuterium_perhour'] = 0;
     $this->_current_planet['planet_energy_max'] = 0;
     $this->_current_planet['planet_energy_used'] = 0;
     $BuildTemp = $this->_current_planet['planet_temp_max'];
     $ResourcesRowTPL = parent::$page->get_template('resources/resources_row');
     foreach ($this->_reslist['prod'] as $ProdID) {
         if ($this->_current_planet[$this->_resource[$ProdID]] > 0 && isset($this->_prod_grid[$ProdID])) {
             $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$ProdID] . '_porcent'];
             $BuildLevel = $this->_current_planet[$this->_resource[$ProdID]];
             $BuildEnergy = $this->_current_user['research_energy_technology'];
             // BOOST
             $geologe_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
             $engineer_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
             // PRODUCTION FORMULAS
             $metal_prod = eval($this->_prod_grid[$ProdID]['formule']['metal']);
             $crystal_prod = eval($this->_prod_grid[$ProdID]['formule']['crystal']);
             $deuterium_prod = eval($this->_prod_grid[$ProdID]['formule']['deuterium']);
             $energy_prod = eval($this->_prod_grid[$ProdID]['formule']['energy']);
             // PRODUCTION
             $metal = ProductionLib::productionAmount($metal_prod, $geologe_boost);
             $crystal = ProductionLib::productionAmount($crystal_prod, $geologe_boost);
             $deuterium = ProductionLib::productionAmount($deuterium_prod, $geologe_boost);
             if ($ProdID >= 4) {
                 $energy = ProductionLib::productionAmount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $energy = ProductionLib::productionAmount($energy_prod, 1, TRUE);
             }
             if ($energy > 0) {
                 $this->_current_planet['planet_energy_max'] += $energy;
             } else {
                 $this->_current_planet['planet_energy_used'] += $energy;
             }
             $this->_current_planet['planet_metal_perhour'] += $metal;
             $this->_current_planet['planet_crystal_perhour'] += $crystal;
             $this->_current_planet['planet_deuterium_perhour'] += $deuterium;
             $metal = ProductionLib::currentProduction($metal, $post_porcent);
             $crystal = ProductionLib::currentProduction($crystal, $post_porcent);
             $deuterium = ProductionLib::currentProduction($deuterium, $post_porcent);
             $energy = ProductionLib::currentProduction($energy, $post_porcent);
             $Field = 'planet_' . $this->_resource[$ProdID] . '_porcent';
             $CurrRow = array();
             $CurrRow['name'] = $this->_resource[$ProdID];
             $CurrRow['porcent'] = $this->_current_planet[$Field];
             $CurrRow['option'] = $this->build_options($CurrRow['porcent']);
             $CurrRow['type'] = $this->_lang['tech'][$ProdID];
             $CurrRow['level'] = $ProdID > 200 ? $this->_lang['rs_amount'] : $this->_lang['rs_lvl'];
             $CurrRow['level_type'] = $this->_current_planet[$this->_resource[$ProdID]];
             $CurrRow['metal_type'] = FormatLib::pretty_number($metal);
             $CurrRow['crystal_type'] = FormatLib::pretty_number($crystal);
             $CurrRow['deuterium_type'] = FormatLib::pretty_number($deuterium);
             $CurrRow['energy_type'] = FormatLib::pretty_number($energy);
             $CurrRow['metal_type'] = FormatLib::color_number($CurrRow['metal_type']);
             $CurrRow['crystal_type'] = FormatLib::color_number($CurrRow['crystal_type']);
             $CurrRow['deuterium_type'] = FormatLib::color_number($CurrRow['deuterium_type']);
             $CurrRow['energy_type'] = FormatLib::color_number($CurrRow['energy_type']);
             $parse['resource_row'] .= parent::$page->parse_template($ResourcesRowTPL, $CurrRow);
         }
     }
     $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $this->_current_planet['planet_name'], $this->_lang['rs_production_on_planet']);
     $parse['production_level'] = $this->prod_level($this->_current_planet['planet_energy_used'], $this->_current_planet['planet_energy_max']);
     $parse['metal_basic_income'] = $game_metal_basic_income;
     $parse['crystal_basic_income'] = $game_crystal_basic_income;
     $parse['deuterium_basic_income'] = $game_deuterium_basic_income;
     $parse['energy_basic_income'] = $game_energy_basic_income;
     $parse['planet_metal_max'] = $this->resource_color($this->_current_planet['planet_metal'], $this->_current_planet['planet_metal_max']);
     $parse['planet_crystal_max'] = $this->resource_color($this->_current_planet['planet_crystal'], $this->_current_planet['planet_crystal_max']);
     $parse['planet_deuterium_max'] = $this->resource_color($this->_current_planet['planet_deuterium'], $this->_current_planet['planet_deuterium_max']);
     $parse['metal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
     $parse['crystal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
     $parse['deuterium_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'])));
     $parse['energy_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_energy_max'] + $parse['energy_basic_income'] + $this->_current_planet['planet_energy_used'])));
     $parse['daily_metal'] = $this->calculate_daily($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['weekly_metal'] = $this->calculate_weekly($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['daily_crystal'] = $this->calculate_daily($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['weekly_crystal'] = $this->calculate_weekly($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['daily_deuterium'] = $this->calculate_daily($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['weekly_deuterium'] = $this->calculate_weekly($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['daily_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_metal']));
     $parse['weekly_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_metal']));
     $parse['daily_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_crystal']));
     $parse['weekly_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_crystal']));
     $parse['daily_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_deuterium']));
     $parse['weekly_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_deuterium']));
     $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
     $SubQry = '';
     if ($_POST && !parent::$users->is_on_vacations($this->_current_user)) {
         foreach ($_POST as $Field => $Value) {
             $FieldName = 'planet_' . $Field . '_porcent';
             if (isset($this->_current_planet[$FieldName])) {
                 if (!in_array($Value, $ValidList['percent'])) {
                     FunctionsLib::redirect('game.php?page=resourceSettings');
                 }
                 $Value = $Value / 10;
                 $this->_current_planet[$FieldName] = $Value;
                 $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
             }
         }
         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t`planet_id` = '" . $this->_current_planet['planet_id'] . "'\n\t\t\t\t\t\t\t\t\t{$SubQry}\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         FunctionsLib::redirect('game.php?page=resourceSettings');
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('resources/resources'), $parse));
 }
Ejemplo n.º 5
0
 /**
  * updateResources
  *
  * @param array   $current_user   Current user
  * @param array   $current_planet Current planet
  * @param int     $UpdateTime     Update time
  * @param boolean $Simul          Simulation
  *
  * @return void
  */
 public static function updateResources(&$current_user, &$current_planet, $UpdateTime, $Simul = false)
 {
     $resource = parent::$objects->getObjects();
     $ProdGrid = parent::$objects->getProduction();
     $reslist = parent::$objects->getObjectsList();
     $game_resource_multiplier = FunctionsLib::read_config('resource_multiplier');
     $game_metal_basic_income = FunctionsLib::read_config('metal_basic_income');
     $game_crystal_basic_income = FunctionsLib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = FunctionsLib::read_config('deuterium_basic_income');
     $current_planet['planet_metal_max'] = ProductionLib::maxStorable($current_planet[$resource[22]]);
     $current_planet['planet_crystal_max'] = ProductionLib::maxStorable($current_planet[$resource[23]]);
     $current_planet['planet_deuterium_max'] = ProductionLib::maxStorable($current_planet[$resource[24]]);
     $MaxMetalStorage = $current_planet['planet_metal_max'];
     $MaxCristalStorage = $current_planet['planet_crystal_max'];
     $MaxDeuteriumStorage = $current_planet['planet_deuterium_max'];
     $Caps = array();
     $BuildTemp = $current_planet['planet_temp_max'];
     $sub_query = '';
     $parse['production_level'] = 100;
     $post_porcent = ProductionLib::maxProduction($current_planet['planet_energy_max'], $current_planet['planet_energy_used']);
     $Caps['planet_metal_perhour'] = 0;
     $Caps['planet_crystal_perhour'] = 0;
     $Caps['planet_deuterium_perhour'] = 0;
     $Caps['planet_energy_max'] = 0;
     $Caps['planet_energy_used'] = 0;
     foreach ($ProdGrid as $ProdID => $formula) {
         $BuildLevelFactor = $current_planet['planet_' . $resource[$ProdID] . '_porcent'];
         $BuildLevel = $current_planet[$resource[$ProdID]];
         $BuildEnergy = $current_user['research_energy_technology'];
         // BOOST
         $geologe_boost = 1 + 1 * (OfficiersLib::isOfficierActive($current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
         $engineer_boost = 1 + 1 * (OfficiersLib::isOfficierActive($current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
         // PRODUCTION FORMULAS
         $metal_prod = eval($ProdGrid[$ProdID]['formule']['metal']);
         $crystal_prod = eval($ProdGrid[$ProdID]['formule']['crystal']);
         $deuterium_prod = eval($ProdGrid[$ProdID]['formule']['deuterium']);
         $energy_prod = eval($ProdGrid[$ProdID]['formule']['energy']);
         // PRODUCTION
         $Caps['planet_metal_perhour'] += ProductionLib::currentProduction(ProductionLib::productionAmount($metal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_crystal_perhour'] += ProductionLib::currentProduction(ProductionLib::productionAmount($crystal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_deuterium_perhour'] += ProductionLib::currentProduction(ProductionLib::productionAmount($deuterium_prod, $geologe_boost), $post_porcent);
         if ($ProdID >= 4) {
             if ($ProdID == 12 && $current_planet['planet_deuterium'] == 0) {
                 continue;
             }
             $Caps['planet_energy_max'] += ProductionLib::productionAmount($energy_prod, $engineer_boost, true);
         } else {
             $Caps['planet_energy_used'] += ProductionLib::productionAmount($energy_prod, 1, true);
         }
     }
     if ($current_planet['planet_type'] == 3) {
         $game_metal_basic_income = 0;
         $game_crystal_basic_income = 0;
         $game_deuterium_basic_income = 0;
         $current_planet['planet_metal_perhour'] = 0;
         $current_planet['planet_crystal_perhour'] = 0;
         $current_planet['planet_deuterium_perhour'] = 0;
         $current_planet['planet_energy_used'] = 0;
         $current_planet['planet_energy_max'] = 0;
     } else {
         $current_planet['planet_metal_perhour'] = $Caps['planet_metal_perhour'];
         $current_planet['planet_crystal_perhour'] = $Caps['planet_crystal_perhour'];
         $current_planet['planet_deuterium_perhour'] = $Caps['planet_deuterium_perhour'];
         $current_planet['planet_energy_used'] = $Caps['planet_energy_used'];
         $current_planet['planet_energy_max'] = $Caps['planet_energy_max'];
     }
     $ProductionTime = $UpdateTime - $current_planet['planet_last_update'];
     $current_planet['planet_last_update'] = $UpdateTime;
     if ($current_planet['planet_energy_max'] == 0) {
         $current_planet['planet_metal_perhour'] = $game_metal_basic_income;
         $current_planet['planet_crystal_perhour'] = $game_crystal_basic_income;
         $current_planet['planet_deuterium_perhour'] = $game_deuterium_basic_income;
         $production_level = 100;
     } elseif ($current_planet['planet_energy_max'] >= $current_planet['planet_energy_used']) {
         $production_level = 100;
     } else {
         $production_level = floor($current_planet['planet_energy_max'] / $current_planet['planet_energy_used'] * 100);
     }
     if ($production_level > 100) {
         $production_level = 100;
     } elseif ($production_level < 0) {
         $production_level = 0;
     }
     if ($current_planet['planet_metal'] <= $MaxMetalStorage) {
         $MetalProduction = $ProductionTime * ($current_planet['planet_metal_perhour'] / 3600) * (0.01 * $production_level);
         $MetalBaseProduc = $ProductionTime * ($game_metal_basic_income / 3600);
         $MetalTheorical = $current_planet['planet_metal'] + $MetalProduction + $MetalBaseProduc;
         if ($MetalTheorical <= $MaxMetalStorage) {
             $current_planet['planet_metal'] = $MetalTheorical;
         } else {
             $current_planet['planet_metal'] = $MaxMetalStorage;
         }
     }
     if ($current_planet['planet_crystal'] <= $MaxCristalStorage) {
         $CristalProduction = $ProductionTime * ($current_planet['planet_crystal_perhour'] / 3600) * (0.01 * $production_level);
         $CristalBaseProduc = $ProductionTime * ($game_crystal_basic_income / 3600);
         $CristalTheorical = $current_planet['planet_crystal'] + $CristalProduction + $CristalBaseProduc;
         if ($CristalTheorical <= $MaxCristalStorage) {
             $current_planet['planet_crystal'] = $CristalTheorical;
         } else {
             $current_planet['planet_crystal'] = $MaxCristalStorage;
         }
     }
     if ($current_planet['planet_deuterium'] <= $MaxDeuteriumStorage) {
         $DeuteriumProduction = $ProductionTime * ($current_planet['planet_deuterium_perhour'] / 3600) * (0.01 * $production_level);
         $DeuteriumBaseProduc = $ProductionTime * ($game_deuterium_basic_income / 3600);
         $DeuteriumTheorical = $current_planet['planet_deuterium'] + $DeuteriumProduction + $DeuteriumBaseProduc;
         if ($DeuteriumTheorical <= $MaxDeuteriumStorage) {
             $current_planet['planet_deuterium'] = $DeuteriumTheorical;
         } else {
             $current_planet['planet_deuterium'] = $MaxDeuteriumStorage;
         }
     }
     if ($current_planet['planet_metal'] < 0) {
         $current_planet['planet_metal'] = 0;
     }
     if ($current_planet['planet_crystal'] < 0) {
         $current_planet['planet_crystal'] = 0;
     }
     if ($current_planet['planet_deuterium'] < 0) {
         $current_planet['planet_deuterium'] = 0;
     }
     if ($Simul == false) {
         // SHIPS AND DEFENSES UPDATE
         $builded = self::buildingQueue($current_user, $current_planet, $ProductionTime);
         $ship_points = 0;
         $defense_points = 0;
         if ($builded != '') {
             foreach ($builded as $element => $count) {
                 if ($element != '') {
                     // POINTS
                     switch ($element) {
                         case $element >= 202 && $element <= 215:
                             $ship_points += StatisticsLib::calculate_points($element, $count) * $count;
                             break;
                         case $element >= 401 && $element <= 503:
                             $defense_points += StatisticsLib::calculate_points($element, $count) * $count;
                             break;
                         default:
                             break;
                     }
                     $sub_query .= "`" . $resource[$element] . "` = '" . $current_planet[$resource[$element]] . "', ";
                 }
             }
         }
         // RESEARCH UPDATE
         if ($current_planet['planet_b_tech'] <= time() && $current_planet['planet_b_tech_id'] != 0) {
             $current_user['research_points'] = StatisticsLib::calculate_points($current_planet['planet_b_tech_id'], $current_user[$resource[$current_planet['planet_b_tech_id']]], 'tech');
             $current_user[$resource[$current_planet['planet_b_tech_id']]]++;
             $tech_query = "`planet_b_tech` = '0',";
             $tech_query .= "`planet_b_tech_id` = '0',";
             $tech_query .= "`" . $resource[$current_planet['planet_b_tech_id']] . "` = '" . $current_user[$resource[$current_planet['planet_b_tech_id']]] . "',";
             $tech_query .= "`user_statistic_technology_points` = `user_statistic_technology_points` + '" . $current_user['research_points'] . "',";
             $tech_query .= "`research_current_research` = '0',";
         } else {
             $tech_query = "";
         }
         parent::$db->query("UPDATE " . PLANETS . " AS p\n                INNER JOIN " . USERS_STATISTICS . " AS us ON us.user_statistic_user_id = p.planet_user_id\n                INNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\n                INNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\n                INNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id SET\n                `planet_metal` = '" . $current_planet['planet_metal'] . "',\n                `planet_crystal` = '" . $current_planet['planet_crystal'] . "',\n                `planet_deuterium` = '" . $current_planet['planet_deuterium'] . "',\n                `planet_last_update` = '" . $current_planet['planet_last_update'] . "',\n                `planet_b_hangar_id` = '" . $current_planet['planet_b_hangar_id'] . "',\n                `planet_metal_perhour` = '" . $current_planet['planet_metal_perhour'] . "',\n                `planet_crystal_perhour` = '" . $current_planet['planet_crystal_perhour'] . "',\n                `planet_deuterium_perhour` = '" . $current_planet['planet_deuterium_perhour'] . "',\n                `planet_energy_used` = '" . $current_planet['planet_energy_used'] . "',\n                `planet_energy_max` = '" . $current_planet['planet_energy_max'] . "',\n                `user_statistic_ships_points` = `user_statistic_ships_points` + '" . $ship_points . "',\n                `user_statistic_defenses_points` = `user_statistic_defenses_points`  + '" . $defense_points . "',\n                {$sub_query}\n                {$tech_query}\n                `planet_b_hangar` = '" . $current_planet['planet_b_hangar'] . "'\n                WHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
     }
 }
Ejemplo n.º 6
0
 /**
  * method fleet_ships_popup
  * param $fleet_row
  * param $text
  * param $fleet_type
  * param $current_user
  * return creates the link with the coordinates of the target planet
  */
 public static function fleet_ships_popup($fleet_row, $text, $fleet_type, $current_user = '')
 {
     $ships = explode(";", $fleet_row['fleet_array']);
     $pop_up = "<a href='#' onmouseover=\"return overlib('";
     $pop_up .= "<table width=200>";
     $espionage_tech = OfficiersLib::getMaxEspionage($current_user['research_espionage_technology'], $current_user['premium_officier_technocrat']);
     if ($espionage_tech < 2 && $fleet_row['fleet_owner'] != $current_user['user_id']) {
         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['cff_no_fleet_data'] . "<font></td></tr>";
     } elseif ($espionage_tech >= 2 && $espionage_tech < 4 && $fleet_row['fleet_owner'] != $current_user['user_id']) {
         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['cff_aproaching'] . $fleet_row['fleet_amount'] . parent::$lang['cff_ships'] . "<font></td></tr>";
     } else {
         if ($fleet_row['fleet_owner'] != $current_user['user_id']) {
             $pop_up .= "<tr><td width=100% align=left><font color=white>" . parent::$lang['cff_aproaching'] . $fleet_row['fleet_amount'] . parent::$lang['cff_ships'] . ":<font></td></tr>";
         }
         foreach ($ships as $item => $group) {
             if ($group != '') {
                 $ship = explode(',', $group);
                 if ($fleet_row['fleet_owner'] == $current_user['user_id']) {
                     $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . ":<font></td><td width=50% align=right><font color=white>" . FormatLib::pretty_number($ship[1]) . "<font></td></tr>";
                 } elseif ($fleet_row['fleet_owner'] != $current_user['user_id']) {
                     if ($espionage_tech >= 4 && $espionage_tech < 8) {
                         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . "<font></td></tr>";
                     } elseif ($espionage_tech >= 8) {
                         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . ":<font></td><td width=50% align=right><font color=white>" . FormatLib::pretty_number($ship[1]) . "<font></td></tr>";
                     }
                 }
             }
         }
     }
     $pop_up .= "</table>";
     $pop_up .= "');\" onmouseout=\"return nd();\" class=\"" . $fleet_type . "\">" . $text . "</a>";
     return $pop_up;
 }
Ejemplo n.º 7
0
 /**
  * method build_page
  * param
  * return the statistics page
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $bloc = $this->_lang;
     $mode = isset($_GET['mode']) ? $_GET['mode'] : '';
     $time = isset($_GET['time']) ? $_GET['time'] : '';
     if ($mode == 2 && ($time == 'month' or $time == 'week')) {
         $Selected = $_GET['offi'];
         $time = 'darkmatter_' . $time;
         $set_time = $time == 'darkmatter_month' ? 3600 * 24 * 30 * 3 : 3600 * 24 * 7;
         if (in_array($Selected, $this->_reslist['officier'])) {
             $Result = $this->is_officier_accesible($Selected, $time);
             $Price = $this->get_officier_price($Selected, $time);
             if ($Result !== FALSE) {
                 $this->_current_user['premium_dark_matter'] -= $Price;
                 // IF THE OFFICIER IS ACTIVE
                 if (OfficiersLib::isOfficierActive($this->_current_user[$this->_resource[$Selected]])) {
                     $this->_current_user[$this->_resource[$Selected]] += $set_time;
                     // ADD TIME
                 } else {
                     $this->_current_user[$this->_resource[$Selected]] = time() + $set_time;
                     // SET TIME
                 }
                 parent::$db->query("UPDATE " . PREMIUM . " SET\n\t\t\t\t\t\t\t\t\t\t\t`premium_dark_matter` = '" . $this->_current_user['premium_dark_matter'] . "',\n\t\t\t\t\t\t\t\t\t\t\t`" . $this->_resource[$Selected] . "` = '" . $this->_current_user[$this->_resource[$Selected]] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE `premium_user_id` = '" . $this->_current_user['user_id'] . "';");
             }
         }
         FunctionsLib::redirect('game.php?page=officier');
     } else {
         $OfficierRowTPL = parent::$page->get_template('officier/officier_row');
         $parse['disp_off_tbl'] = '';
         $parse['premium_pay_url'] = FunctionsLib::read_config('premium_url') != '' ? FunctionsLib::read_config('premium_url') : 'game.php?page=officier';
         foreach ($this->_lang['tech'] as $Element => $ElementName) {
             if ($Element >= 601 && $Element <= 605) {
                 $bloc['dpath'] = DPATH;
                 $bloc['off_id'] = $Element;
                 $bloc['off_status'] = OfficiersLib::isOfficierActive($this->_current_user[$this->_resource[$Element]]) ? '<font color=lime>' . $this->_lang['of_active'] . ' ' . date(FunctionsLib::read_config('date_format'), $this->_current_user[$this->_resource[$Element]]) . '</font>' : '<font color=red>' . $this->_lang['of_inactive'] . '</font>';
                 $bloc['off_name'] = $ElementName;
                 $bloc['off_desc'] = $this->_lang['res']['descriptions'][$Element];
                 $bloc['off_desc_short'] = $this->_lang['info'][$Element]['description'];
                 $bloc['month_price'] = FormatLib::pretty_number($this->get_officier_price($Element, 'darkmatter_month'));
                 $bloc['week_price'] = FormatLib::pretty_number($this->get_officier_price($Element, 'darkmatter_week'));
                 $bloc['img_big'] = $this->get_officier_image($Element, 'img_big');
                 $bloc['img_small'] = $this->get_officier_image($Element, 'img_small');
                 $bloc['off_link_month'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=month";
                 $bloc['off_link_week'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=week";
                 $parse['disp_off_tbl'] .= parent::$page->parse_template($OfficierRowTPL, $bloc);
             }
         }
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('officier/officier_table'), $parse));
 }
Ejemplo n.º 8
0
 /**
  * method spy_mission
  * param $fleet_row
  * return the spy result
  */
 public function spyMission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) {
         $current_data = parent::$db->queryFetch("SELECT p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, u.user_name, r.research_espionage_technology, pr.premium_officier_technocrat\n\t\t\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\t\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_galaxy` = " . $fleet_row['fleet_start_galaxy'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_system` = " . $fleet_row['fleet_start_system'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_planet` = " . $fleet_row['fleet_start_planet'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_type` = " . $fleet_row['fleet_start_type'] . ";");
         $target_data = parent::$db->queryFetch("SELECT p.`planet_id`, p.planet_user_id, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, p.planet_metal, p.planet_crystal, p.planet_deuterium, p.planet_energy_max, s.*, d.*, b.*, r.*, pr.premium_officier_technocrat\n\t\t\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\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\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\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\t\t\tINNER JOIN " . USERS . " AS u ON u.user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_type` = '" . $fleet_row['fleet_end_type'] . "';");
         $CurrentSpyLvl = OfficiersLib::getMaxEspionage($current_data['research_espionage_technology'], $current_data['premium_officier_technocrat']);
         $TargetSpyLvl = OfficiersLib::getMaxEspionage($target_data['research_espionage_technology'], $target_data['premium_officier_technocrat']);
         $fleet = explode(';', $fleet_row['fleet_array']);
         $fquery = '';
         parent::make_update($fleet_row, $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type']);
         foreach ($fleet as $a => $b) {
             if ($b != '') {
                 $a = explode(",", $b);
                 if ($a[0] == "210") {
                     $LS = $a[1];
                     $SpyToolDebris = $LS * 300;
                     $MaterialsInfo = $this->spy_target($target_data, 0, $this->_lang['sys_spy_maretials']);
                     $Materials = $MaterialsInfo['String'];
                     $PlanetFleetInfo = $this->spy_target($target_data, 1, $this->_lang['sys_spy_fleet']);
                     $PlanetFleet = $Materials;
                     $PlanetFleet .= $PlanetFleetInfo['String'];
                     $PlanetDefenInfo = $this->spy_target($target_data, 2, $this->_lang['sys_spy_defenses']);
                     $PlanetDefense = $PlanetFleet;
                     $PlanetDefense .= $PlanetDefenInfo['String'];
                     $PlanetBuildInfo = $this->spy_target($target_data, 3, $this->_lang['tech'][0]);
                     $PlanetBuildings = $PlanetDefense;
                     $PlanetBuildings .= $PlanetBuildInfo['String'];
                     $TargetTechnInfo = $this->spy_target($target_data, 4, $this->_lang['tech'][100]);
                     $TargetTechnos = $PlanetBuildings;
                     $TargetTechnos .= $TargetTechnInfo['String'];
                     $TargetForce = $PlanetFleetInfo['Count'] * $LS / 4;
                     if ($TargetForce > 100) {
                         $TargetForce = 100;
                     }
                     $TargetChances = mt_rand(0, $TargetForce);
                     $SpyerChances = mt_rand(0, 100);
                     if ($TargetChances >= $SpyerChances) {
                         $DestProba = "<font color=\"red\">" . $this->_lang['sys_mess_spy_destroyed'] . "</font>";
                     } elseif ($TargetChances < $SpyerChances) {
                         $DestProba = sprintf($this->_lang['sys_mess_spy_lostproba'], $TargetChances);
                     }
                     $AttackLink = "<center>";
                     $AttackLink .= "<a href=\"game.php?page=fleet1&galaxy=" . $fleet_row['fleet_end_galaxy'] . "&system=" . $fleet_row['fleet_end_system'] . "";
                     $AttackLink .= "&planet=" . $fleet_row['fleet_end_planet'] . "&planettype=" . $fleet_row['fleet_end_type'] . "";
                     $AttackLink .= "&target_mission=1";
                     $AttackLink .= " \">" . $this->_lang['type_mission'][1] . "";
                     $AttackLink .= "</a></center>";
                     $MessageEnd = "<center>" . $DestProba . "</center>";
                     $spionage_difference = abs($CurrentSpyLvl - $TargetSpyLvl);
                     if ($TargetSpyLvl >= $CurrentSpyLvl) {
                         $ST = pow($spionage_difference, 2);
                         $resources = 1;
                         $fleet = $ST + 2;
                         $defense = $ST + 3;
                         $buildings = $ST + 5;
                         $tech = $ST + 7;
                     }
                     if ($CurrentSpyLvl > $TargetSpyLvl) {
                         $ST = pow($spionage_difference, 2) * -1;
                         $resources = 1;
                         $fleet = $ST + 2;
                         $defense = $ST + 3;
                         $buildings = $ST + 5;
                         $tech = $ST + 7;
                     }
                     if ($resources <= $LS) {
                         $SpyMessage = $Materials . "<br />" . $AttackLink . $MessageEnd;
                     }
                     if ($fleet <= $LS) {
                         $SpyMessage = $PlanetFleet . "<br />" . $AttackLink . $MessageEnd;
                     }
                     if ($defense <= $LS) {
                         $SpyMessage = $PlanetDefense . "<br />" . $AttackLink . $MessageEnd;
                     }
                     if ($buildings <= $LS) {
                         $SpyMessage = $PlanetBuildings . "<br />" . $AttackLink . $MessageEnd;
                     }
                     if ($tech <= $LS) {
                         $SpyMessage = $TargetTechnos . "<br />" . $AttackLink . $MessageEnd;
                     }
                     FunctionsLib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], 0, $this->_lang['sys_mess_qg'], $this->_lang['sys_mess_spy_report'], $SpyMessage);
                     $TargetMessage = $this->_lang['sys_mess_spy_ennemyfleet'] . " " . $current_data['planet_name'];
                     $TargetMessage .= " <a href=\"game.php?page=galaxy&mode=3&galaxy=" . $current_data['planet_galaxy'] . "&system=" . $current_data['planet_system'] . "\">";
                     $TargetMessage .= "[" . $current_data['planet_galaxy'] . ":" . $current_data['planet_system'] . ":" . $current_data['planet_planet'] . "]</a> (" . $current_data['user_name'] . ") ";
                     $TargetMessage .= $this->_lang['sys_mess_spy_seen_at'] . " " . $target_data['planet_name'];
                     $TargetMessage .= " <a href=\"game.php?page=galaxy&mode=3&galaxy=" . $target_data['planet_galaxy'] . "&system=" . $target_data['planet_system'] . "\">";
                     $TargetMessage .= "[" . $target_data['planet_galaxy'] . ":" . $target_data['planet_system'] . ":" . $target_data['planet_planet'] . "]</a>.";
                     FunctionsLib::send_message($target_data['planet_user_id'], '', $fleet_row['fleet_start_time'], 0, $this->_lang['sys_mess_spy_control'], $this->_lang['sys_mess_spy_activity'], $TargetMessage . ' ' . sprintf($this->_lang['sys_mess_spy_lostproba'], $TargetChances));
                     if ($TargetChances >= $SpyerChances) {
                         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_invisible_start_time` = '" . time() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` + '" . (0 + $SpyToolDebris) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $target_data['id'] . "';");
                         parent::remove_fleet($fleet_row['fleet_id']);
                     } else {
                         parent::return_fleet($fleet_row['fleet_id']);
                     }
                 }
             }
         }
     } elseif ($fleet_row['fleet_mess'] == 1 && $fleet_row['fleet_end_time'] <= time()) {
         parent::restore_fleet($fleet_row, TRUE);
         parent::remove_fleet($fleet_row['fleet_id']);
     }
 }
Ejemplo n.º 9
0
 /**
  * method set_level_format
  * param $level
  * param $element
  * return return the level with format
  */
 public static function set_level_format($level, $element = '', $current_user = '')
 {
     $return_level = '';
     // check if is base level
     if ($level != 0) {
         $return_level = ' (' . parent::$lang['bd_lvl'] . ' ' . $level . ')';
     }
     // check a commander plus
     switch ($element) {
         case 106:
             if (OfficiersLib::isOfficierActive($current_user['premium_officier_technocrat'])) {
                 $return_level .= FormatLib::strong_text(FormatLib::color_green(' +' . TECHNOCRATE_SPY . parent::$lang['bd_spy']));
             }
             break;
         case 108:
             if (OfficiersLib::isOfficierActive($current_user['premium_officier_admiral'])) {
                 $return_level .= FormatLib::strong_text(FormatLib::color_green(' +' . AMIRAL . parent::$lang['bd_commander']));
             }
             break;
     }
     return $return_level;
 }
Ejemplo n.º 10
0
 private function ShowProductionTable($Template)
 {
     $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$this->_element_id] . '_porcent'];
     $BuildTemp = $this->_current_planet['planet_temp_max'];
     $CurrentBuildtLvl = $this->_current_planet[$this->_resource[$this->_element_id]];
     $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
     $BuildEnergy = $this->_current_user['research_energy_technology'];
     // BOOST
     $geologe_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
     $engineer_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
     // PRODUCTION FORMULAS
     $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']);
     $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']);
     $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']);
     $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']);
     // PRODUCTION
     $Prod[1] = ProductionLib::productionAmount($metal_prod, $geologe_boost);
     $Prod[2] = ProductionLib::productionAmount($crystal_prod, $geologe_boost);
     $Prod[3] = ProductionLib::productionAmount($deuterium_prod, $geologe_boost);
     if ($this->_element_id >= 4) {
         $Prod[4] = ProductionLib::productionAmount($energy_prod, $engineer_boost, TRUE);
         $ActualProd = floor($Prod[4]);
     } else {
         $Prod[4] = ProductionLib::productionAmount($energy_prod, 1, TRUE);
         $ActualProd = floor($Prod[$this->_element_id]);
     }
     if ($this->_element_id != 12) {
         $ActualNeed = floor($Prod[4]);
     } else {
         $ActualNeed = floor($Prod[3]);
     }
     $BuildStartLvl = $CurrentBuildtLvl - 2;
     if ($BuildStartLvl < 1) {
         $BuildStartLvl = 1;
     }
     $Table = "";
     $ProdFirst = 0;
     for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
         // PRODUCTION FORMULAS
         $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']);
         $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']);
         $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']);
         $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']);
         // PRODUCTION
         $Prod[1] = ProductionLib::productionAmount($metal_prod, $geologe_boost);
         $Prod[2] = ProductionLib::productionAmount($crystal_prod, $geologe_boost);
         $Prod[3] = ProductionLib::productionAmount($deuterium_prod, $geologe_boost);
         if ($this->_element_id >= 4) {
             $Prod[4] = ProductionLib::productionAmount($energy_prod, $engineer_boost, TRUE);
         } else {
             $Prod[4] = ProductionLib::productionAmount($energy_prod, 1, TRUE);
         }
         $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
         if ($ProdFirst > 0) {
             if ($this->_element_id != 12) {
                 $bloc['build_gain'] = "<font color=\"lime\">(" . FormatLib::pretty_number(floor($Prod[$this->_element_id] - $ProdFirst)) . ")</font>";
             } else {
                 $bloc['build_gain'] = "<font color=\"lime\">(" . FormatLib::pretty_number(floor($Prod[4] - $ProdFirst)) . ")</font>";
             }
         } else {
             $bloc['build_gain'] = "";
         }
         if ($this->_element_id != 12) {
             $bloc['build_prod'] = FormatLib::pretty_number(floor($Prod[$this->_element_id]));
             $bloc['build_prod_diff'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[$this->_element_id] - $ActualProd)));
             $bloc['build_need'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[4])));
             $bloc['build_need_diff'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[4] - $ActualNeed)));
         } else {
             $bloc['build_prod'] = FormatLib::pretty_number(floor($Prod[4]));
             $bloc['build_prod_diff'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[4] - $ActualProd)));
             $bloc['build_need'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[3])));
             $bloc['build_need_diff'] = FormatLib::color_number(FormatLib::pretty_number(floor($Prod[3] - $ActualNeed)));
         }
         if ($ProdFirst == 0) {
             if ($this->_element_id != 12) {
                 $ProdFirst = floor($Prod[$this->_element_id]);
             } else {
                 $ProdFirst = floor($Prod[4]);
             }
         }
         $Table .= parent::$page->parse_template($Template, $bloc);
     }
     return $Table;
 }