/**
  * method colonize_mission
  * param $fleet_row
  * return the colonization result
  */
 public function colonize_mission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == 0) {
         $colonization_check = parent::$db->query_fetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc1.`planet_user_id` = '" . $fleet_row['fleet_owner'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_type` = '1' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpc1.`planet_destroyed` = '0') AS planet_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS pc2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pc2.`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\t\t\t\tpc2.`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\t\t\t\tpc2.`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\t\t\t\tpc2.`planet_type` = 1') AS galaxy_count,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT `research_astrophysics`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . RESEARCH . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `research_user_id` = '" . $fleet_row['fleet_owner'] . "') AS astro_level");
         // SOME REQUIRED VALUES
         $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']);
         $max_colonies = Fleets_Lib::get_max_colonies($colonization_check['astro_level']);
         $planet_count = $colonization_check['planet_count'] - 1;
         // THE TOTAL AMOUNT OF PLANETS MINUS 1 (BECAUSE THE MAIN PLANET IT'S NOT CONSIDERED)
         // DIFFERENT TYPES OF MESSAGES
         $message[1] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_maxcolo'] . ($max_colonies + 1) . $this->_lang['sys_colo_planet'];
         $message[2] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_allisok'];
         $message[3] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_notfree'];
         $message[4] = $this->_lang['sys_colo_arrival'] . $target_coords . $this->_lang['sys_colo_astro_level'];
         if ($colonization_check['galaxy_count'] == 0) {
             if ($planet_count >= $max_colonies) {
                 $this->colonize_message($fleet_row['fleet_owner'], $message[1], $fleet_row['fleet_start_time']);
                 parent::return_fleet($fleet_row['fleet_id']);
             } elseif (!$this->position_allowed($fleet_row['fleet_end_planet'], $colonization_check['astro_level'])) {
                 $this->colonize_message($fleet_row['fleet_owner'], $message[4], $fleet_row['fleet_start_time']);
                 parent::return_fleet($fleet_row['fleet_id']);
             } else {
                 if ($this->start_creation($fleet_row)) {
                     $this->colonize_message($fleet_row['fleet_owner'], $message[2], $fleet_row['fleet_start_time']);
                     if ($fleet_row['fleet_amount'] == 1) {
                         parent::$db->query("UPDATE " . USERS_STATISTICS . " AS us SET\n\t\t\t\t\t\t\t\t\t\t\t\t\tus.`user_statistic_ships_points` = us.`user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE us.`user_statistic_user_id` = (SELECT p.planet_user_id FROM " . PLANETS . " AS p\n\t\t\t\t\t\t\t\t\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\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\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\t\t\t\t\t\t\t\t\tp.planet_type = '" . $fleet_row['fleet_start_type'] . "');");
                         parent::store_resources($fleet_row);
                         parent::remove_fleet($fleet_row['fleet_id']);
                     } else {
                         parent::store_resources($fleet_row);
                         parent::$db->query("UPDATE " . FLEETS . ", " . USERS_STATISTICS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_array` = '" . $this->build_new_fleet($fleet_row['fleet_array']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_amount` = `fleet_amount` - 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_resource_deuterium` = '0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_ships_points` = `user_statistic_ships_points` - " . Statistics_Lib::calculate_points(208, 1) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_id` = '" . $fleet_row['fleet_id'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`user_statistic_user_id` = (SELECT planet_user_id FROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE 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\t\t\t\t\t\t\t\t\tplanet_system = '" . $fleet_row['fleet_start_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . $fleet_row['fleet_start_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = '" . $fleet_row['fleet_start_type'] . "');");
                     }
                 } else {
                     $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']);
                     parent::return_fleet($fleet_row['fleet_id']);
                 }
             }
         } else {
             $this->colonize_message($fleet_row['fleet_owner'], $message[3], $fleet_row['fleet_end_time']);
             parent::return_fleet($fleet_row['fleet_id']);
         }
     }
     if ($fleet_row['fleet_end_time'] < time()) {
         parent::restore_fleet($fleet_row, TRUE);
         parent::remove_fleet($fleet_row['fleet_id']);
     }
 }
Example #2
0
 /**
  * method astrophysics_table
  * param
  * return builds the astrophysics table
  */
 private function astrophysics_table($template)
 {
     $CurrentBuildtLvl = $this->_current_user[$this->_resource[$this->_element_id]];
     $BuildStartLvl = max(1, $CurrentBuildtLvl - 2);
     $Table = "";
     for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; ++$BuildLevel) {
         $bloc['tech_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
         $bloc['tech_colonies'] = Format_Lib::pretty_number(Fleets_Lib::get_max_colonies($BuildLevel));
         $bloc['tech_expeditions'] = Format_Lib::pretty_number(Fleets_Lib::get_max_expeditions($BuildLevel));
         $Table .= parent::$page->parse_template($template, $bloc);
     }
     return $Table;
 }