/**
  * 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 = Officiers_Lib::get_max_espionage($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>" . Format_Lib::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>" . Format_Lib::pretty_number($ship[1]) . "<font></td></tr>";
                     }
                 }
             }
         }
     }
     $pop_up .= "</table>";
     $pop_up .= "');\" onmouseout=\"return nd();\" class=\"" . $fleet_type . "\">" . $text . "</a>";
     return $pop_up;
 }
Example #2
0
 /**
  * method spy_mission
  * param $fleet_row
  * return the spy result
  */
 public function spy_mission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) {
         $current_data = parent::$db->query_fetch("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->query_fetch("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 = Officiers_Lib::get_max_espionage($current_data['research_espionage_technology'], $current_data['premium_officier_technocrat']);
         $TargetSpyLvl = Officiers_Lib::get_max_espionage($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;
                     }
                     Functions_Lib::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>.";
                     Functions_Lib::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']);
     }
 }