Ejemplo n.º 1
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 (Officiers_Lib::is_officier_active($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'] . "';");
             }
         }
         Functions_Lib::redirect('game.php?page=officier');
     } else {
         $OfficierRowTPL = parent::$page->get_template('officier/officier_row');
         $parse['disp_off_tbl'] = '';
         $parse['premium_pay_url'] = Functions_Lib::read_config('premium_url') != '' ? Functions_Lib::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'] = Officiers_Lib::is_officier_active($this->_current_user[$this->_resource[$Element]]) ? '<font color=lime>' . $this->_lang['of_active'] . ' ' . date(Functions_Lib::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'] = Format_Lib::pretty_number($this->get_officier_price($Element, 'darkmatter_month'));
                 $bloc['week_price'] = Format_Lib::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.º 2
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     Functions_Lib::module_message(Functions_Lib::is_module_accesible(self::MODULE_ID));
     $this->_lang = parent::$lang;
     $this->_current_user = parent::$users->get_user_data();
     $this->_have_premium = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander']);
     // build the page
     $this->build_page();
 }
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     Functions_Lib::module_message(Functions_Lib::is_module_accesible(self::MODULE_ID));
     $this->_current_user = parent::$users->get_user_data();
     if (!Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander'])) {
         Functions_Lib::redirect('game.php?page=officier');
     } else {
         $this->build_page();
     }
 }
Ejemplo n.º 4
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 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
     $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($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::production_amount($metal_prod, $geologe_boost);
     $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost);
     $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost);
     if ($this->_element_id >= 4) {
         $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE);
         $ActualProd = floor($Prod[4]);
     } else {
         $Prod[4] = ProductionLib::production_amount($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++) {
         if ($this->_element_id != 42) {
             // 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::production_amount($metal_prod, $geologe_boost);
             $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost);
             $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost);
             if ($this->_element_id >= 4) {
                 $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $Prod[4] = ProductionLib::production_amount($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\">(" . Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ProdFirst)) . ")</font>";
                 } else {
                     $bloc['build_gain'] = "<font color=\"lime\">(" . Format_Lib::pretty_number(floor($Prod[4] - $ProdFirst)) . ")</font>";
                 }
             } else {
                 $bloc['build_gain'] = "";
             }
             if ($this->_element_id != 12) {
                 $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[$this->_element_id]));
                 $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ActualProd)));
                 $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4])));
                 $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualNeed)));
             } else {
                 $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[4]));
                 $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualProd)));
                 $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[3])));
                 $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::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]);
                 }
             }
         } else {
             $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
             $bloc['build_range'] = $BuildLevel * $BuildLevel - 1;
         }
         $Table .= parent::$page->parse_template($Template, $bloc);
     }
     return $Table;
 }
Ejemplo n.º 5
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $game_metal_basic_income = Functions_Lib::read_config('metal_basic_income');
     $game_crystal_basic_income = Functions_Lib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = Functions_Lib::read_config('deuterium_basic_income');
     $game_energy_basic_income = Functions_Lib::read_config('energy_basic_income');
     $game_resource_multiplier = Functions_Lib::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'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[22]]);
     $this->_current_planet['planet_crystal_max'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[23]]);
     $this->_current_planet['planet_deuterium_max'] = Production_Lib::max_storable($this->_current_planet[$this->_resource[24]]);
     $parse['production_level'] = 100;
     $post_porcent = Production_Lib::max_production($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 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
             $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($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 = Production_Lib::production_amount($metal_prod, $geologe_boost);
             $crystal = Production_Lib::production_amount($crystal_prod, $geologe_boost);
             $deuterium = Production_Lib::production_amount($deuterium_prod, $geologe_boost);
             if ($ProdID >= 4) {
                 $energy = Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $energy = Production_Lib::production_amount($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 = Production_Lib::current_production($metal, $post_porcent);
             $crystal = Production_Lib::current_production($crystal, $post_porcent);
             $deuterium = Production_Lib::current_production($deuterium, $post_porcent);
             $energy = Production_Lib::current_production($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'] = Format_Lib::pretty_number($metal);
             $CurrRow['crystal_type'] = Format_Lib::pretty_number($crystal);
             $CurrRow['deuterium_type'] = Format_Lib::pretty_number($deuterium);
             $CurrRow['energy_type'] = Format_Lib::pretty_number($energy);
             $CurrRow['metal_type'] = Format_Lib::color_number($CurrRow['metal_type']);
             $CurrRow['crystal_type'] = Format_Lib::color_number($CurrRow['crystal_type']);
             $CurrRow['deuterium_type'] = Format_Lib::color_number($CurrRow['deuterium_type']);
             $CurrRow['energy_type'] = Format_Lib::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'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
     $parse['crystal_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
     $parse['deuterium_total'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($this->_current_planet['planet_deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'])));
     $parse['energy_total'] = Format_Lib::color_number(Format_Lib::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'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_metal']));
     $parse['weekly_metal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['weekly_metal']));
     $parse['daily_crystal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_crystal']));
     $parse['weekly_crystal'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['weekly_crystal']));
     $parse['daily_deuterium'] = Format_Lib::color_number(Format_Lib::pretty_number($parse['daily_deuterium']));
     $parse['weekly_deuterium'] = Format_Lib::color_number(Format_Lib::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'])) {
                     Functions_Lib::redirect('game.php?page=resourceSettings');
                 }
                 $Value = $Value / 10;
                 $this->_current_planet[$FieldName] = $Value;
                 $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
             }
         }
         parent::$db->query("UPDATE " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t`planet_id` = '" . $this->_current_planet['planet_id'] . "'\r\n\t\t\t\t\t\t\t\t\t{$SubQry}\r\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         Functions_Lib::redirect('game.php?page=resourceSettings');
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('resources/resources'), $parse));
 }
Ejemplo n.º 6
0
 /**
  * method acs_attack
  * param $attackers
  * param $defenders
  * return the attack result
  */
 private function acs_attack(&$attackers, &$defenders)
 {
     $totalResourcePoints = array('attacker' => 0, 'defender' => 0);
     $resourcePointsAttacker = array('metal' => 0, 'crystal' => 0);
     foreach ($attackers as $fleetID => $attacker) {
         foreach ($attacker['detail'] as $element => $amount) {
             $resourcePointsAttacker['metal'] += $this->_pricelist[$element]['metal'] * $amount;
             $resourcePointsAttacker['crystal'] += $this->_pricelist[$element]['crystal'] * $amount;
             $totalResourcePoints['attacker'] += $this->_pricelist[$element]['metal'] * $amount;
             $totalResourcePoints['attacker'] += $this->_pricelist[$element]['crystal'] * $amount;
         }
     }
     $resourcePointsDefender = array('metal' => 0, 'crystal' => 0);
     foreach ($defenders as $fleetID => $defender) {
         foreach ($defender['def'] as $element => $amount) {
             //Line20
             if ($element < 300) {
                 $resourcePointsDefender['metal'] += $this->_pricelist[$element]['metal'] * $amount;
                 $resourcePointsDefender['crystal'] += $this->_pricelist[$element]['crystal'] * $amount;
                 $totalResourcePoints['defender'] += $this->_pricelist[$element]['metal'] * $amount;
                 $totalResourcePoints['defender'] += $this->_pricelist[$element]['crystal'] * $amount;
             } else {
                 if (!isset($originalDef[$element])) {
                     $originalDef[$element] = 0;
                 }
                 $originalDef[$element] += $amount;
                 $totalResourcePoints['defender'] += $this->_pricelist[$element]['metal'] * $amount;
                 $totalResourcePoints['defender'] += $this->_pricelist[$element]['crystal'] * $amount;
             }
         }
     }
     $max_rounds = 6;
     for ($round = 0, $rounds = array(); $round < $max_rounds; $round++) {
         $attackDamage = array('total' => 0);
         $attackShield = array('total' => 0);
         $attackAmount = array('total' => 0);
         $defenseDamage = array('total' => 0);
         $defenseShield = array('total' => 0);
         $defenseAmount = array('total' => 0);
         $attArray = array();
         $defArray = array();
         foreach ($attackers as $fleetID => $attacker) {
             $attackDamage[$fleetID] = 0;
             $attackShield[$fleetID] = 0;
             $attackAmount[$fleetID] = 0;
             foreach ($attacker['detail'] as $element => $amount) {
                 $attTech = 1 + 0.1 * $attacker['user']['research_weapons_technology'];
                 // WEAPONS
                 $defTech = 1 + 0.1 * $attacker['user']['research_shielding_technology'];
                 // SHIELD
                 $shieldTech = 1 + 0.1 * $attacker['user']['research_armour_technology'];
                 // ARMOUR
                 $attackers[$fleetID]['techs'] = array($shieldTech, $defTech, $attTech);
                 $thisAtt = $amount * $this->_combat_caps[$element]['attack'] * $attTech * (mt_rand(80, 120) / 100);
                 //attaque
                 $thisDef = $amount * $this->_combat_caps[$element]['shield'] * $defTech;
                 //bouclier
                 $thisShield = $amount * ($this->_pricelist[$element]['metal'] + $this->_pricelist[$element]['crystal']) / 10 * $shieldTech;
                 //coque
                 $attArray[$fleetID][$element] = array('def' => $thisDef, 'shield' => $thisShield, 'att' => $thisAtt);
                 $attackDamage[$fleetID] += $thisAtt;
                 $attackDamage['total'] += $thisAtt;
                 $attackShield[$fleetID] += $thisDef;
                 $attackShield['total'] += $thisDef;
                 $attackAmount[$fleetID] += $amount;
                 $attackAmount['total'] += $amount;
             }
         }
         foreach ($defenders as $fleetID => $defender) {
             $defenseDamage[$fleetID] = 0;
             $defenseShield[$fleetID] = 0;
             $defenseAmount[$fleetID] = 0;
             foreach ($defender['def'] as $element => $amount) {
                 $attTech = 1 + 0.1 * $defender['user']['research_weapons_technology'];
                 //attaquue
                 $defTech = 1 + 0.1 * $defender['user']['research_shielding_technology'];
                 //bouclier
                 $shieldTech = 1 + 0.1 * $defender['user']['research_armour_technology'];
                 //coque
                 $defenders[$fleetID]['techs'] = array($shieldTech, $defTech, $attTech);
                 $thisAtt = $amount * $this->_combat_caps[$element]['attack'] * $attTech * (mt_rand(80, 120) / 100);
                 //attaque
                 $thisDef = $amount * $this->_combat_caps[$element]['shield'] * $defTech;
                 //bouclier
                 $thisShield = $amount * ($this->_pricelist[$element]['metal'] + $this->_pricelist[$element]['crystal']) / 10 * $shieldTech;
                 //coque
                 if ($element == 407 || $element == 408) {
                     $thisAtt = 0;
                 }
                 $defArray[$fleetID][$element] = array('def' => $thisDef, 'shield' => $thisShield, 'att' => $thisAtt);
                 $defenseDamage[$fleetID] += $thisAtt;
                 $defenseDamage['total'] += $thisAtt;
                 $defenseShield[$fleetID] += $thisDef;
                 $defenseShield['total'] += $thisDef;
                 $defenseAmount[$fleetID] += $amount;
                 $defenseAmount['total'] += $amount;
             }
         }
         $rounds[$round] = array('attackers' => $attackers, 'defenders' => $defenders, 'attack' => $attackDamage, 'defense' => $defenseDamage, 'attackA' => $attackAmount, 'defenseA' => $defenseAmount, 'infoA' => $attArray, 'infoD' => $defArray);
         if ($defenseAmount['total'] <= 0 || $attackAmount['total'] <= 0) {
             break;
         }
         // Calculate hit percentages (ACS only but ok)
         $attackPct = array();
         foreach ($attackAmount as $fleetID => $amount) {
             if (!is_numeric($fleetID)) {
                 continue;
             }
             $attackPct[$fleetID] = $amount / $attackAmount['total'];
         }
         $defensePct = array();
         foreach ($defenseAmount as $fleetID => $amount) {
             if (!is_numeric($fleetID)) {
                 continue;
             }
             $defensePct[$fleetID] = $amount / $defenseAmount['total'];
         }
         // CALCUL DES PERTES !!!
         $attacker_n = array();
         $attacker_shield = 0;
         foreach ($attackers as $fleetID => $attacker) {
             $attacker_n[$fleetID] = array();
             foreach ($attacker['detail'] as $element => $amount) {
                 $defender_moc = $amount * ($defenseDamage['total'] * $attackPct[$fleetID]) / $attackAmount[$fleetID];
                 if ($amount > 0) {
                     if ($attArray[$fleetID][$element]['def'] / $amount < $defender_moc) {
                         $max_removePoints = floor($amount * $defenseAmount['total'] / $attackAmount[$fleetID] * $attackPct[$fleetID]);
                         $defender_moc -= $attArray[$fleetID][$element]['def'];
                         $attacker_shield += $attArray[$fleetID][$element]['def'];
                         $ile_removePoints = floor($defender_moc / (($this->_pricelist[$element]['metal'] + $this->_pricelist[$element]['crystal']) / 10));
                         if ($max_removePoints < 0) {
                             $max_removePoints = 0;
                         }
                         if ($ile_removePoints < 0) {
                             $ile_removePoints = 0;
                         }
                         if ($ile_removePoints > $max_removePoints) {
                             $ile_removePoints = $max_removePoints;
                         }
                         $attacker_n[$fleetID][$element] = ceil($amount - $ile_removePoints);
                         if ($attacker_n[$fleetID][$element] <= 0) {
                             $attacker_n[$fleetID][$element] = 0;
                         }
                     } else {
                         $attacker_n[$fleetID][$element] = round($amount);
                         $attacker_shield += $defender_moc;
                     }
                 } else {
                     $attacker_n[$fleetID][$element] = round($amount);
                     $attacker_shield += $defender_moc;
                 }
             }
         }
         $defender_n = array();
         $defender_shield = 0;
         foreach ($defenders as $fleetID => $defender) {
             $defender_n[$fleetID] = array();
             foreach ($defender['def'] as $element => $amount) {
                 $attacker_moc = $amount * ($attackDamage['total'] * $defensePct[$fleetID]) / $defenseAmount[$fleetID];
                 if ($amount > 0) {
                     if ($defArray[$fleetID][$element]['def'] / $amount < $attacker_moc) {
                         $max_removePoints = floor($amount * $attackAmount['total'] / $defenseAmount[$fleetID] * $defensePct[$fleetID]);
                         $attacker_moc -= $defArray[$fleetID][$element]['def'];
                         $defender_shield += $defArray[$fleetID][$element]['def'];
                         $ile_removePoints = floor($attacker_moc / (($this->_pricelist[$element]['metal'] + $this->_pricelist[$element]['crystal']) / 10));
                         if ($max_removePoints < 0) {
                             $max_removePoints = 0;
                         }
                         if ($ile_removePoints < 0) {
                             $ile_removePoints = 0;
                         }
                         if ($ile_removePoints > $max_removePoints) {
                             $ile_removePoints = $max_removePoints;
                         }
                         $defender_n[$fleetID][$element] = ceil($amount - $ile_removePoints);
                         if ($defender_n[$fleetID][$element] <= 0) {
                             $defender_n[$fleetID][$element] = 0;
                         }
                     } else {
                         $defender_n[$fleetID][$element] = round($amount);
                         $defender_shield += $attacker_moc;
                     }
                 } else {
                     $defender_n[$fleetID][$element] = round($amount);
                     $defender_shield += $attacker_moc;
                 }
             }
         }
         // "Rapidfire"
         foreach ($attackers as $fleetID => $attacker) {
             foreach ($defenders as $fleetID2 => $defender) {
                 foreach ($attacker['detail'] as $element => $amount) {
                     if ($amount > 0) {
                         foreach ($this->_combat_caps[$element]['sd'] as $c => $d) {
                             if (isset($defender['def'][$c])) {
                                 if ($d > 0) {
                                     $e = $d / $defender['techs'][0] / ($defender['techs'][1] * $attacker['techs'][2]);
                                     $defender_n[$fleetID2][$c] -= ceil($amount * $e * (mt_rand(50, 120) / 100) / 2 * $defensePct[$fleetID2] * ($amount / $attackAmount[$fleetID]));
                                     if ($defender_n[$fleetID2][$c] <= 0) {
                                         $defender_n[$fleetID2][$c] = 0;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach ($defender['def'] as $element => $amount) {
                     if ($amount > 0) {
                         foreach ($this->_combat_caps[$element]['sd'] as $c => $d) {
                             if (isset($attacker['detail'][$c])) {
                                 if ($d > 0) {
                                     $e = $d / $defender['techs'][0] / ($defender['techs'][1] * $attacker['techs'][2]);
                                     $attacker_n[$fleetID][$c] -= ceil($amount * $e * (mt_rand(50, 120) / 100) / 2 * $attackPct[$fleetID] * ($amount / $defenseAmount[$fleetID2]));
                                     if ($attacker_n[$fleetID][$c] <= 0) {
                                         $attacker_n[$fleetID][$c] = 0;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $rounds[$round]['attackShield'] = $attacker_shield;
         $rounds[$round]['defShield'] = $defender_shield;
         foreach ($attackers as $fleetID => $attacker) {
             $attackers[$fleetID]['detail'] = array_map('round', $attacker_n[$fleetID]);
         }
         foreach ($defenders as $fleetID => $defender) {
             $defenders[$fleetID]['def'] = array_map('round', $defender_n[$fleetID]);
         }
     }
     if ($attackAmount['total'] <= 0) {
         $won = "r";
         // defender
     } elseif ($defenseAmount['total'] <= 0) {
         $won = "a";
         // attacker
     } else {
         $won = "w";
         // draw
         $rounds[count($rounds)] = array('attackers' => $attackers, 'defenders' => $defenders, 'attack' => $attackDamage, 'defense' => $defenseDamage, 'attackA' => $attackAmount, 'defenseA' => $defenseAmount);
     }
     // CDR
     foreach ($attackers as $fleetID => $attacker) {
         // flotte attaquant en CDR
         foreach ($attacker['detail'] as $element => $amount) {
             $totalResourcePoints['attacker'] -= $this->_pricelist[$element]['metal'] * $amount;
             $totalResourcePoints['attacker'] -= $this->_pricelist[$element]['crystal'] * $amount;
             $resourcePointsAttacker['metal'] -= $this->_pricelist[$element]['metal'] * $amount;
             $resourcePointsAttacker['crystal'] -= $this->_pricelist[$element]['crystal'] * $amount;
         }
     }
     $resourcePointsDefenderDefs = array('metal' => 0, 'crystal' => 0);
     foreach ($defenders as $fleetID => $defender) {
         foreach ($defender['def'] as $element => $amount) {
             if ($element < 300) {
                 // flotte defenseur en CDR
                 $resourcePointsDefender['metal'] -= $this->_pricelist[$element]['metal'] * $amount;
                 $resourcePointsDefender['crystal'] -= $this->_pricelist[$element]['crystal'] * $amount;
                 $totalResourcePoints['defender'] -= $this->_pricelist[$element]['metal'] * $amount;
                 $totalResourcePoints['defender'] -= $this->_pricelist[$element]['crystal'] * $amount;
             } else {
                 // defs defenseur en CDR + reconstruction
                 $totalResourcePoints['defender'] -= $this->_pricelist[$element]['metal'] * $amount;
                 $totalResourcePoints['defender'] -= $this->_pricelist[$element]['crystal'] * $amount;
                 if (Officiers_Lib::is_officier_active($defender['user']['premium_officier_technocrat'])) {
                     $lost = floor(($originalDef[$element] - $amount) / ENGINEER_DEFENSE);
                 } else {
                     $lost = $originalDef[$element] - $amount;
                 }
                 $giveback = round($lost * (mt_rand(70 * 0.8, 70 * 1.2) / 100));
                 $defenders[$fleetID]['def'][$element] += $giveback;
                 $resourcePointsDefenderDefs['metal'] += $this->_pricelist[$element]['metal'] * ($lost - $giveback);
                 $resourcePointsDefenderDefs['crystal'] += $this->_pricelist[$element]['crystal'] * ($lost - $giveback);
             }
         }
     }
     $game_fleet_cdr = Functions_Lib::read_config('fleet_cdr');
     $game_defs_cdr = Functions_Lib::read_config('defs_cdr');
     $totalLost = array('att' => $totalResourcePoints['attacker'], 'def' => $totalResourcePoints['defender']);
     $debAttMet = $resourcePointsAttacker['metal'] * ($game_fleet_cdr / 100);
     $debAttCry = $resourcePointsAttacker['crystal'] * ($game_fleet_cdr / 100);
     $debDefMet = $resourcePointsDefender['metal'] * ($game_fleet_cdr / 100) + $resourcePointsDefenderDefs['metal'] * ($game_defs_cdr / 100);
     $debDefCry = $resourcePointsDefender['crystal'] * ($game_fleet_cdr / 100) + $resourcePointsDefenderDefs['crystal'] * ($game_defs_cdr / 100);
     return array('won' => $won, 'debree' => array('att' => array($debAttMet, $debAttCry), 'def' => array($debDefMet, $debDefCry)), 'rw' => $rounds, 'lost' => $totalLost);
 }
Ejemplo n.º 7
0
 public static function update_resource(&$current_user, &$current_planet, $UpdateTime, $Simul = FALSE)
 {
     $resource = parent::$objects->get_objects();
     $ProdGrid = parent::$objects->get_production();
     $reslist = parent::$objects->get_objects_list();
     $game_resource_multiplier = Functions_Lib::read_config('resource_multiplier');
     $game_metal_basic_income = Functions_Lib::read_config('metal_basic_income');
     $game_crystal_basic_income = Functions_Lib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = Functions_Lib::read_config('deuterium_basic_income');
     $CurrentPlanet['planet_metal_max'] = Production_Lib::max_storable($current_planet[$resource[22]]);
     $current_planet['planet_crystal_max'] = Production_Lib::max_storable($current_planet[$resource[23]]);
     $current_planet['planet_deuterium_max'] = Production_Lib::max_storable($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 = Production_Lib::max_production($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 * (Officiers_Lib::is_officier_active($current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
         $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($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'] += Production_Lib::current_production(Production_Lib::production_amount($metal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_crystal_perhour'] += Production_Lib::current_production(Production_Lib::production_amount($crystal_prod, $geologe_boost), $post_porcent);
         $Caps['planet_deuterium_perhour'] += Production_Lib::current_production(Production_Lib::production_amount($deuterium_prod, $geologe_boost), $post_porcent);
         if ($ProdID >= 4) {
             if ($ProdID == 12 && $current_planet['planet_deuterium'] == 0) {
                 continue;
             }
             $Caps['planet_energy_max'] += Production_Lib::production_amount($energy_prod, $engineer_boost, TRUE);
         } else {
             $Caps['planet_energy_used'] += Production_Lib::production_amount($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::building_queue($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 += Statistics_Lib::calculate_points($element, $count) * $count;
                             break;
                         case $element >= 401 && $element <= 503:
                             $defense_points += Statistics_Lib::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'] = Statistics_Lib::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\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS_STATISTICS . " AS us ON us.user_statistic_user_id = p.planet_user_id\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = p.planet_user_id SET\r\n\t\t\t\t\t\t\t\t\t`planet_metal` = '" . $current_planet['planet_metal'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_crystal` = '" . $current_planet['planet_crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_deuterium` = '" . $current_planet['planet_deuterium'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_last_update` = '" . $current_planet['planet_last_update'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_b_hangar_id` = '" . $current_planet['planet_b_hangar_id'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_metal_perhour` = '" . $current_planet['planet_metal_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_crystal_perhour` = '" . $current_planet['planet_crystal_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour` = '" . $current_planet['planet_deuterium_perhour'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_energy_used` = '" . $current_planet['planet_energy_used'] . "',\r\n\t\t\t\t\t\t\t\t\t`planet_energy_max` = '" . $current_planet['planet_energy_max'] . "',\r\n\t\t\t\t\t\t\t\t\t`user_statistic_ships_points` = `user_statistic_ships_points` + '" . $ship_points . "',\r\n\t\t\t\t\t\t\t\t\t`user_statistic_defenses_points` = `user_statistic_defenses_points`  + '" . $defense_points . "',\r\n\t\t\t\t\t\t\t\t\t{$sub_query}\r\n\t\t\t\t\t\t\t\t\t{$tech_query}\r\n\t\t\t\t\t\t\t\t\t`planet_b_hangar` = '" . $current_planet['planet_b_hangar'] . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $current_planet['planet_id'] . "';");
     }
 }
Ejemplo n.º 8
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));
 }
Ejemplo n.º 9
0
 /**
  * method game_menu
  * param
  * return get the left menu data and parses it
  */
 private function game_menu()
 {
     $menu_block1 = '';
     $menu_block2 = '';
     $menu_block3 = '';
     $modules_array = Functions_Lib::read_config('modules');
     $modules_array = explode(';', $modules_array);
     $sub_template = $this->get_template('general/left_menu_row_view');
     $tota_rank = $this->_current_user['user_statistic_total_rank'] == '' ? $this->_current_planet['stats_users'] : $this->_current_user['user_statistic_total_rank'];
     $pages = array(array('changelog', VERSION, '', 'FFF', '', '0', '0'), array('overview', $this->_lang['lm_overview'], '', 'FFF', '', '1', '1'), array('imperium', $this->_lang['lm_empire'], '', 'FFF', '', '1', '2'), array('resources', $this->_lang['lm_resources'], '', 'FFF', '', '1', '3'), array('resourceSettings', $this->_lang['lm_resources_settings'], '', 'FFF', '', '1', '4'), array('station', $this->_lang['lm_station'], '', 'FFF', '', '1', '3'), array('trader', $this->_lang['lm_trader'], '', 'FF8900', '', '1', '5'), array('research', $this->_lang['lm_research'], '', 'FFF', '', '1', '6'), array('shipyard', $this->_lang['lm_shipyard'], '', 'FFF', '', '1', '7'), array('fleet1', $this->_lang['lm_fleet'], '', 'FFF', '', '1', '8'), array('movement', $this->_lang['lm_movement'], '', 'FFF', '', '1', '9'), array('techtree', $this->_lang['lm_technology'], '', 'FFF', '', '1', '10'), array('galaxy', $this->_lang['lm_galaxy'], 'mode=0', 'FFF', '', '1', '11'), array('defense', $this->_lang['lm_defenses'], '', 'FFF', '', '1', '12'), array('alliance', $this->_lang['lm_alliance'], '', 'FFF', '', '2', '13'), array('forums', $this->_lang['lm_forums'], '', 'FFF', '', '2', '14'), array('officier', $this->_lang['lm_officiers'], '', 'FF8900', '', '2', '15'), array('statistics', $this->_lang['lm_statistics'], 'range=' . $tota_rank, 'FFF', '', '2', '16'), array('search', $this->_lang['lm_search'], '', 'FFF', '', '2', '17'), array('messages', $this->_lang['lm_messages'], '', 'FFF', '', '3', '18'), array('notes', $this->_lang['lm_notes'], '', 'FFF', 'true', '3', '19'), array('buddy', $this->_lang['lm_buddylist'], '', 'FFF', 'true', '3', '20'), array('options', $this->_lang['lm_options'], '', 'FFF', '', '3', '21'), array('banned', $this->_lang['lm_banned'], '', 'FFF', '', '3', '22'), array('logout', $this->_lang['lm_logout'], '', 'FFF', '', '3', ''));
     // BUILD THE MENU
     foreach ($pages as $key => $data) {
         // IF THE MODULE IT'S NOT ENABLED, CONTINUE!
         if (isset($modules_array[$data[6]]) && $modules_array[$data[6]] == 0 && $modules_array[$data[6]] != '') {
             continue;
         }
         if (!Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander']) && $data[0] == 'imperium') {
             continue;
         }
         // BUILD URL
         if ($data[2] != '') {
             $link = 'game.php?page=' . $data[0] . '&' . $data[2];
         } else {
             $link = 'game.php?page=' . $data[0];
         }
         // POP UP OR NOT
         if ($data[4] == 'true') {
             $link_type = '<a href="#" onClick="f(\'' . $link . '\', \'' . $data[1] . '\')"><font color="' . ($data[3] != 'FFF' ? $data[3] : '') . '">' . $data[1] . '</font></a>';
         } else {
             $link_type = '<a href="' . $link . '"><font color="' . ($data[3] != 'FFF' ? $data[3] : '') . '">' . $data[1] . '</font></a>';
         }
         // COLOR AND URL
         $parse['color'] = $data[3];
         $parse['menu_link'] = $link_type;
         // ONLY FOR THE CHANGELOG
         if ($data[5] == 0) {
             $parse['changelog'] = '(' . $link_type . ')';
         }
         // MENU BLOCK [1 - 2 - 3]
         switch ($data[5]) {
             case '1':
                 $menu_block1 .= $this->parse_template($sub_template, $parse);
                 break;
             case '2':
                 $menu_block2 .= $this->parse_template($sub_template, $parse);
                 break;
             case '3':
                 $menu_block3 .= $this->parse_template($sub_template, $parse);
                 break;
         }
     }
     // PARSE THE MENU AND OTHER DATA
     $parse['dpath'] = DPATH;
     $parse['version'] = VERSION;
     $parse['servername'] = Functions_Lib::read_config('game_name');
     $parse['year'] = $this->_current_year;
     $parse['menu_block1'] = $menu_block1;
     $parse['menu_block2'] = $menu_block2;
     $parse['menu_block3'] = $menu_block3;
     $parse['admin_link'] = $this->_current_user['user_authlevel'] > 0 ? "<tr><td><div align=\"center\"><a href=\"admin.php\" target=\"_blank\"> <font color=\"lime\">" . $this->_lang['lm_administration'] . "</font></a></div></td></tr>" : "";
     return $this->parse_template($this->get_template('general/left_menu_view'), $parse);
 }
 /**
  * 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 (Officiers_Lib::is_officier_active($current_user['premium_officier_technocrat'])) {
                 $return_level .= Format_Lib::strong_text(Format_Lib::color_green(' +' . TECHNOCRATE_SPY . parent::$lang['bd_spy']));
             }
             break;
         case 108:
             if (Officiers_Lib::is_officier_active($current_user['premium_officier_admiral'])) {
                 $return_level .= Format_Lib::strong_text(Format_Lib::color_green(' +' . AMIRAL . parent::$lang['bd_commander']));
             }
             break;
     }
     return $return_level;
 }