/** * MissionCaseTransport.php * * @version 1 * @copyright 2008 By Chlorel for XNova */ function MissionCaseTransport($FleetRow) { global $lang; $QryStartPlanet = "SELECT * FROM {{table}} "; $QryStartPlanet .= "WHERE "; $QryStartPlanet .= "`galaxy` = '" . $FleetRow['fleet_start_galaxy'] . "' AND "; $QryStartPlanet .= "`system` = '" . $FleetRow['fleet_start_system'] . "' AND "; $QryStartPlanet .= "`planet` = '" . $FleetRow['fleet_start_planet'] . "' AND "; $QryStartPlanet .= "`planet_type` = '" . $FleetRow['fleet_start_type'] . "';"; $StartPlanet = doquery($QryStartPlanet, 'planets', true); $StartName = $StartPlanet['name']; $StartOwner = $StartPlanet['id_owner']; $QryTargetPlanet = "SELECT * FROM {{table}} "; $QryTargetPlanet .= "WHERE "; $QryTargetPlanet .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryTargetPlanet .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryTargetPlanet .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND "; $QryTargetPlanet .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "';"; $TargetPlanet = doquery($QryTargetPlanet, 'planets', true); $TargetName = $TargetPlanet['name']; $TargetOwner = $TargetPlanet['id_owner']; if ($FleetRow['fleet_mess'] == 0) { if ($FleetRow['fleet_start_time'] < time()) { StoreGoodsToPlanet($FleetRow, false); $Message = sprintf($lang['sys_tran_mess_owner'], $TargetName, GetTargetAdressLink($FleetRow, ''), $FleetRow['fleet_resource_metal'], $lang['Metal'], $FleetRow['fleet_resource_crystal'], $lang['Crystal'], $FleetRow['fleet_resource_deuterium'], $lang['Deuterium'], $FleetRow['fleet_resource_appolonium'], $lang['Appolonium']); SendSimpleMessage($StartOwner, '', $FleetRow['fleet_start_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); if ($TargetOwner != $StartOwner) { $Message = sprintf($lang['sys_tran_mess_user'], $StartName, GetStartAdressLink($FleetRow, ''), $TargetName, GetTargetAdressLink($FleetRow, ''), $FleetRow['fleet_resource_metal'], $lang['Metal'], $FleetRow['fleet_resource_crystal'], $lang['Crystal'], $FleetRow['fleet_resource_deuterium'], $lang['Deuterium'], $FleetRow['fleet_resource_appolonium'], $lang['Appolonium']); SendSimpleMessage($TargetOwner, '', $FleetRow['fleet_start_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); } $QryUpdateFleet = "UPDATE {{table}} SET "; $QryUpdateFleet .= "`fleet_resource_metal` = '0' , "; $QryUpdateFleet .= "`fleet_resource_crystal` = '0' , "; $QryUpdateFleet .= "`fleet_resource_deuterium` = '0' , "; $QryUpdateFleet .= "`fleet_resource_appolonium` = '0' , "; $QryUpdateFleet .= "`fleet_mess` = '1' "; $QryUpdateFleet .= "WHERE `fleet_id` = '" . $FleetRow['fleet_id'] . "' "; $QryUpdateFleet .= "LIMIT 1 ;"; doquery($QryUpdateFleet, 'fleets'); } } else { if ($FleetRow['fleet_end_time'] < time()) { $Message = sprintf($lang['sys_tran_mess_back'], $StartName, GetStartAdressLink($FleetRow, '')); SendSimpleMessage($StartOwner, '', $FleetRow['fleet_end_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $Message); RestoreFleetToPlanet($FleetRow, true); //Piratenangriff nach Zufallsprinzip $zufall = 0; $zufall = rand(1, 10); if ($zufall == 7) { Piratenangriff($FleetRow); $zufall = 0; } // Ende Piratenangriff doquery("DELETE FROM {{table}} WHERE fleet_id=" . $FleetRow["fleet_id"], 'fleets'); } } }
function MissionCaseStay($FleetRow) { global $lang, $resource; if ($FleetRow['fleet_mess'] == 0) { if ($FleetRow['fleet_start_time'] <= time()) { $QryGetTargetPlanet = "SELECT * FROM {{table}} "; $QryGetTargetPlanet .= "WHERE "; $QryGetTargetPlanet .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryGetTargetPlanet .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryGetTargetPlanet .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND "; $QryGetTargetPlanet .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "';"; $TargetPlanet = doquery($QryGetTargetPlanet, 'planets', true); $TargetUserID = $TargetPlanet['id_owner']; $TargetAdress = sprintf($lang['sys_adress_planet'], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); $TargetAddedGoods = sprintf($lang['sys_stay_mess_goods'], $lang['Metal'], pretty_number($FleetRow['fleet_resource_metal']), $lang['Crystal'], pretty_number($FleetRow['fleet_resource_crystal']), $lang['Deuterium'], pretty_number($FleetRow['fleet_resource_deuterium']), $lang['Appolonium'], pretty_number($FleetRow['fleet_resource_appolonium'])); $TargetMessage = $lang['sys_stay_mess_start'] . "<a href=\"galaxy.php?mode=3&galaxy=" . $FleetRow['fleet_end_galaxy'] . "&system=" . $FleetRow['fleet_end_system'] . "\">"; $TargetMessage .= $TargetAdress . "</a>" . $lang['sys_stay_mess_end'] . "<br />" . $TargetAddedGoods; SendSimpleMessage($TargetUserID, '', $FleetRow['fleet_start_time'], 5, $lang['sys_mess_tower'], $lang['sys_stay_mess_stay_now'], $TargetMessage); RestoreFleetToPlanet($FleetRow, false); doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets'); } } else { if ($FleetRow['fleet_end_time'] <= time()) { $TargetAdress = sprintf($lang['sys_adress_planet'], $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet']); $TargetAddedGoods = sprintf($lang['sys_stay_mess_goods'], $lang['Metal'], pretty_number($FleetRow['fleet_resource_metal']), $lang['Crystal'], pretty_number($FleetRow['fleet_resource_crystal']), $lang['Deuterium'], pretty_number($FleetRow['fleet_resource_deuterium']), $lang['Appolonium'], pretty_number($FleetRow['fleet_resource_appolonium'])); $TargetMessage = $lang['sys_stay_mess_back'] . "<a href=\"galaxy.php?mode=3&galaxy=" . $FleetRow['fleet_start_galaxy'] . "&system=" . $FleetRow['fleet_start_system'] . "\">"; $TargetMessage .= $TargetAdress . "</a>" . $lang['sys_stay_mess_bend'] . "<br />" . $TargetAddedGoods; SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 5, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $TargetMessage); //Piratenangriff nach Zufallsprinzip $zufall = 0; $zufall = rand(1, 10); if ($zufall == 7) { Piratenangriff($FleetRow); $zufall = 0; } // Ende Piratenangriff RestoreFleetToPlanet($FleetRow, true); doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets'); } } }
function MissionCaseAttack($FleetRow) { global $phpEx, $xnova_root_path, $pricelist, $lang, $resource, $CombatCaps, $game_config; includelang('tech'); includelang('system'); if ($FleetRow['fleet_mess'] == 0 && $FleetRow['fleet_start_time'] <= time()) { if (!isset($CombatCaps[202]['sd'])) { message('<font color=red>' . $lang['sys_no_vars'] . '</font><br />(Error: <font color=red>(!isset($pricelist[202][\'sd\']))</font>. Please report this to an admin.)', $lang['sys_error'], 'fleet.php', 15); } include $xnova_root_path . "includes/functions/MissionCaseEvoAttack.php"; $strunitsgesamt = $result['lost']['att'] + $result['lost']['def']; $user1lostunits = $result['lost']['att']; $user1shotunits = $result['lost']['def']; $user2lostunits = $result['lost']['def']; $user2shotunits = $result['lost']['att']; $strtruemmerfeld = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1] + $result['debree']['att'][2] + $result['debree']['def'][2]; $strtruemmermetal = $result['debree']['att'][0] + $result['debree']['def'][0]; $strtruemmercrystal = $result['debree']['att'][1] + $result['debree']['def'][1]; $strtruemmerappolonium = $result['debree']['att'][2] + $result['debree']['def'][2]; $FleetDebris = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1] + $result['debree']['att'][2] + $result['debree']['def'][2]; $StrAttackerUnits = sprintf($lang['sys_attacker_lostunits'], $result['lost']['att']); $StrDefenderUnits = sprintf($lang['sys_defender_lostunits'], $result['lost']['def']); $StrRuins = sprintf($lang['sys_gcdrunits'], $result['debree']['def'][0] + $result['debree']['att'][0], $lang['Metal'], $result['debree']['def'][1] + $result['debree']['att'][1], $lang['Crystal'], $result['debree']['def'][2] + $result['debree']['att'][2], $lang['Appolonium']); $DebrisField = $StrAttackerUnits . "<br />" . $StrDefenderUnits . "<br />" . $StrRuins; $MoonChance = $FleetDebris / 100000; if ($FleetDebris > 2000000) { $MoonChance = 20; } if ($FleetDebris < 100000) { $UserChance = 0; $ChanceMoon = ""; } elseif ($FleetDebris >= 100000) { $UserChance = mt_rand(1, 100); $ChanceMoon = sprintf($lang['sys_moonproba'], $MoonChance); } if ($UserChance > 0 && $UserChance <= $MoonChance && $targetGalaxy['id_luna'] == 0) { $TargetPlanetName = CreateOneMoonRecord($FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'], $TargetUserID, $FleetRow['fleet_start_time'], '', $MoonChance); $GottenMoon = sprintf($lang['sys_moonbuilt'], $TargetPlanetName, $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); $GottenMoon .= "<br />"; //Abfrage der Größe des Trümmerfeldes? $QrySelectGalaxy = "SELECT * FROM {{table}} "; $QrySelectGalaxy .= "WHERE "; $QrySelectGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QrySelectGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QrySelectGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; $QrySelectGalaxy .= "LIMIT 1;"; $TargetGalaxy = doquery($QrySelectGalaxy, 'galaxy', true); // Trümmerfeld wird gelöscht da der Mond aus den Trümmern entstanden ist!. $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`metal` = `metal` - '" . $TargetGalaxy["metal"] . "', "; $QryUpdateGalaxy .= "`crystal` = `crystal` - '" . $TargetGalaxy["crystal"] . "',"; $QryUpdateGalaxy .= "`appolonium` = `appolonium` - '" . $TargetGalaxy["appolonium"] . "' "; $QryUpdateGalaxy .= "WHERE "; $QryUpdateGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryUpdateGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryUpdateGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; $QryUpdateGalaxy .= "LIMIT 1;"; doquery($QryUpdateGalaxy, 'galaxy'); } elseif ($UserChance = 0 or $UserChance > $MoonChance) { $GottenMoon = ""; } $OwnedUser = doquery('SELECT * FROM {{table}} WHERE id=' . $FleetRow['fleet_owner'], 'users', true); $formatted_cr = formatCR($result, $steal, $MoonChance, $GottenMoon, $totaltime); $raport = $formatted_cr['html']; $rid = md5($raport); $QryInsertRapport = 'INSERT INTO {{table}} SET '; $QryInsertRapport .= '`time` = UNIX_TIMESTAMP(), '; foreach ($attackFleets as $fleetID => $attacker) { $users2[$attacker['user']['id']] = $attacker['user']['id']; } foreach ($defense as $fleetID => $defender) { $users2[$defender['user']['id']] = $defender['user']['id']; } $QryInsertRapport .= '`owners` = "' . implode(',', $users2) . '", '; $QryInsertRapport .= '`rid` = "' . $rid . '", '; $QryInsertRapport .= '`raport` = "' . mysql_real_escape_string($raport) . '"'; doquery($QryInsertRapport, 'rw') or die("Error inserting CR to database" . mysql_error() . "<br /><br />Trying to execute:" . mysql_query()); $angreifer = $formatted_cr['angreifer']; $dpath = !$user["dpath"] ? DEFAULT_SKINPATH : $user["dpath"]; $rid = md5($raport); $QryInserttopkb = "INSERT INTO {{table}} SET "; $QryInserttopkb .= "`time` = UNIX_TIMESTAMP(), "; $QryInserttopkb .= "`id_owner1` = '" . $FleetRow['fleet_owner'] . "', "; $QryInserttopkb .= "`angreifer` = '" . $angreifer . "', "; $QryInserttopkb .= "`id_owner2` = '" . $targetUser['id'] . "', "; $QryInserttopkb .= "`defender` = '" . $targetUser['username'] . "', "; $QryInserttopkb .= "`gesamtunits` = '" . $strunitsgesamt . "', "; $QryInserttopkb .= "`gesamttruemmer` = '" . $strtruemmerfeld . "', "; $QryInserttopkb .= "`rid` = '" . $rid . "', "; $QryInserttopkb .= "`a_zestrzelona` = '" . $a_zestrzelona . "', "; $QryInserttopkb .= "`raport` = '" . mysql_real_escape_string($raport) . "',"; $QryInserttopkb .= "`fleetresult` = '" . $result['won'] . "';"; doquery("LOCK TABLE {{table}} WRITE", 'topkb'); doquery($QryInserttopkb, 'topkb'); doquery("UNLOCK TABLES", ''); $user1stat = $FleetRow['fleet_owner']; $user2stat = $TargetUserID; $raport = '<a href # OnClick=\'f( "rw.php?raport=' . $rid . '", "");\' >'; $raport .= '<center>'; if ($result['won'] == "a") { $raport .= '<font color=\'green\'>'; } elseif ($result['won'] == "w") { $raport .= '<font color=\'orange\'>'; } elseif ($result['won'] == "r") { $raport .= '<font color=\'red\'>'; } $raport .= $lang['sys_mess_attack_report'] . ' [' . $FleetRow['fleet_end_galaxy'] . ':' . $FleetRow['fleet_end_system'] . ':' . $FleetRow['fleet_end_planet'] . '] </font></a><br /><br />'; $raport .= '<font color=\'red\'>' . $lang['sys_perte_attaquant'] . ': ' . $result['lost']['att'] . '</font>'; $raport .= '<font color=\'green\'> ' . $lang['sys_perte_defenseur'] . ': ' . $result['lost']['def'] . '</font><br />'; $raport .= $lang['sys_gain'] . ' ' . $lang['Metal'] . ':<font color=\'#adaead\'>' . $steal['metal'] . '</font> ' . $lang['Crystal'] . ':<font color=\'#ef51ef\'>' . $steal['crystal'] . '</font> ' . $lang['Deuterium'] . ':<font color=\'#f77542\'>' . $steal['deuterium'] . '</font> ' . $lang['Appolonium'] . ':<font color=\'#ffa07a\'>' . $steal['appolonium'] . '</font><br />'; $raport .= $lang['sys_debris'] . ' ' . $lang['Metal'] . ': <font color=\'#adaead\'>' . ($result['debree']['att'][0] + $result['debree']['def'][0]) . '</font> ' . $lang['Crystal'] . ': <font color=\'#ef51ef\'>' . ($result['debree']['att'][1] + $result['debree']['def'][1]) . '</font> ' . $lang['Appolonium'] . ': <font color=\'#ef51ef\'>' . ($result['debree']['att'][2] + $result['debree']['def'][2]) . '</font><br /></center>'; SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport); $raport2 = '<a href # OnClick=\'f( "rw.php?raport=' . $rid . '", "");\' >'; $raport2 .= '<center>'; if ($result['won'] == "a") { $raport2 .= '<font color=\'red\'>'; } elseif ($result['won'] == "w") { $raport2 .= '<font color=\'orange\'>'; } elseif ($result['won'] == "r") { $raport2 .= '<font color=\'green\'>'; } $raport2 .= $lang['sys_mess_attack_report'] . ' [' . $FleetRow['fleet_end_galaxy'] . ':' . $FleetRow['fleet_end_system'] . ':' . $FleetRow['fleet_end_planet'] . '] </font></a><br /><br />'; foreach ($users2 as $id) { if ($id != $FleetRow['fleet_owner'] && $id != 0) { SendSimpleMessage($id, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport2); } } $user1 = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user1stat . "';", 'users'); while ($user1data = mysql_fetch_assoc($user1)) { $strtruemmermetaluser1 = $strtruemmermetal + $user1data['kbmetal']; $strtruemmercrystaluser1 = $strtruemmercrystal + $user1data['kbcrystal']; $strtruemmerappoloniumuser1 = $strtruemmerappolonium + $user1data['kbappolonium']; $user1lostunits = $user1lostunits + $user1data['lostunits']; $user1shotunits = $user1shotunits + $user1data['desunits']; $user1wons = $user1data['wons']; $user1loos = $user1data['loos']; $user1draws = $user1data['draws']; } $user2 = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user2stat . "';", 'users'); while ($user2data = mysql_fetch_assoc($user2)) { $strtruemmermetaluser2 = $strtruemmermetal + $user2data['kbmetal']; $strtruemmercrystaluser2 = $strtruemmercrystal + $user2data['kbcrystal']; $strtruemmerappoloniumuser2 = $strtruemmerappolonium + $user2data['kbappolonium']; $user2lostunits = $user2lostunits + $user2data['lostunits']; $user2shotunits = $user2shotunits + $user2data['desunits']; $user2wons = $user2data['wons']; $user2loos = $user2data['loos']; $user2draws = $user2data['draws']; } if ($result['won'] == "a") { $user1wons = $user1wons + 1; $user2loos = $user2loos + 1; } elseif ($result['won'] == "w") { $user1draws = $user1draws + 1; $user2draws = $user2draws + 1; } elseif ($result['won'] == "r") { $user1loos = $user1loos + 1; $user2wons = $user2wons + 1; } $QryUpdateuserstat = "UPDATE {{table}} SET "; $QryUpdateuserstat .= "`wons` = '" . $user1wons . "', "; $QryUpdateuserstat .= "`loos` = '" . $user1loos . "', "; $QryUpdateuserstat .= "`draws` = '" . $user1draws . "', "; $QryUpdateuserstat .= "`kbmetal` = '" . $strtruemmermetaluser1 . "', "; $QryUpdateuserstat .= "`kbcrystal` = '" . $strtruemmercrystaluser1 . "', "; $QryUpdateuserstat .= "`kbappolonium` = '" . $strtruemmerappoloniumuser1 . "', "; $QryUpdateuserstat .= "`lostunits` = '" . $user1lostunits . "', "; $QryUpdateuserstat .= "`desunits` = '" . $user1shotunits . "' "; $QryUpdateuserstat .= "WHERE "; $QryUpdateuserstat .= "`id` = '" . $FleetRow['fleet_owner'] . "';"; doquery($QryUpdateuserstat, 'users'); $QryUpdateuser2stat = "UPDATE {{table}} SET "; $QryUpdateuser2stat .= "`wons` = '" . $user2wons . "', "; $QryUpdateuser2stat .= "`loos` = '" . $user2loos . "', "; $QryUpdateuser2stat .= "`draws` = '" . $user2draws . "', "; $QryUpdateuser2stat .= "`kbmetal` = '" . $strtruemmermetaluser2 . "', "; $QryUpdateuser2stat .= "`kbcrystal` = '" . $strtruemmercrystaluser2 . "', "; $QryUpdateuser2stat .= "`kbappolonium` = '" . $strtruemmerappoloniumuser2 . "', "; $QryUpdateuser2stat .= "`lostunits` = '" . $user2lostunits . "', "; $QryUpdateuser2stat .= "`desunits` = '" . $user2shotunits . "' "; $QryUpdateuser2stat .= "WHERE "; $QryUpdateuser2stat .= "`id` = '" . $targetUser['id'] . "';"; doquery($QryUpdateuser2stat, 'users'); $CurrentUser = doquery("SELECT * FROM {{table}} WHERE id = " . $FleetRow['fleet_owner'], 'users', true); $CurrentUserID = $CurrentUser['id']; $AddPoint = $CurrentUser['xpraid'] + 1; $QryUpdateOfficier = "UPDATE {{table}} SET "; $QryUpdateOfficier .= "`xpraid` = '" . $AddPoint . "' "; $QryUpdateOfficier .= "WHERE id = '" . $CurrentUserID . "' "; $QryUpdateOfficier .= "LIMIT 1 ;"; doquery($QryUpdateOfficier, 'users'); $RaidsTotal = $CurrentUser['raids'] + 1; if ($result['won'] == "a") { $RaidsWin = $CurrentUser['raidswin'] + 1; $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsWin . "', "; $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; doquery($QryUpdateRaidsCompteur, 'users'); } elseif ($result['won'] == "r" || $result['won'] == "w") { $RaidsLoose = $CurrentUser['raidsloose'] + 1; $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; $QryUpdateRaidsCompteur .= "`raidsloose` ='" . $RaidsLoose . "', "; $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; doquery($QryUpdateRaidsCompteur, 'users'); } } elseif ($FleetRow['fleet_end_time'] <= time()) { $Message = sprintf($lang['sys_tran_mess_angriffback'], $TargetName, GetTargetAdressLink($FleetRow, ''), pretty_number($FleetRow['fleet_resource_metal']), $lang['Metal'], pretty_number($FleetRow['fleet_resource_crystal']), $lang['Crystal'], pretty_number($FleetRow['fleet_resource_deuterium']), $lang['Deuterium'], pretty_number($FleetRow['fleet_resource_appolonium']), $lang['Appolonium']); SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $Message); RestoreFleetToPlanet($FleetRow); doquery('DELETE FROM {{table}} WHERE `fleet_id`=' . $FleetRow['fleet_id'], 'fleets'); //Piratenangriff nach Zufallsprinzip $zufall = 0; $zufall = rand(1, 10); if ($zufall == 7) { Piratenangriff($FleetRow); $zufall = 0; } // Ende Piratenangriff } }
function MissionCaseSpy($FleetRow) { global $lang, $resource; if (isset($FleetRow['fleet_start_time']) <= time()) { $CurrentUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $FleetRow['fleet_owner'] . "';", 'users', true); $CurrentUserID = $FleetRow['fleet_owner']; $QryGetTargetPlanet = "SELECT * FROM {{table}} "; $QryGetTargetPlanet .= "WHERE "; $QryGetTargetPlanet .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryGetTargetPlanet .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryGetTargetPlanet .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND "; $QryGetTargetPlanet .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "';"; $TargetPlanet = doquery($QryGetTargetPlanet, 'planets', true); $TargetUserID = $TargetPlanet['id_owner']; $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '" . $FleetRow['fleet_start_galaxy'] . "' AND `system` = '" . $FleetRow['fleet_start_system'] . "' AND `planet` = '" . $FleetRow['fleet_start_planet'] . "';", 'planets', true); $CurrentSpyLvl = $CurrentUser['spy_tech']; $CurrentEspia = $CurrentUser['rpg_espion']; $TargetUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $TargetUserID . "';", 'users', true); $TargetSpyLvl = $TargetUser['spy_tech']; $TargetEspia = $TargetUser['rpg_espion']; $fleet = explode(";", $FleetRow['fleet_array']); $fquery = ""; $LS = 0; // Planeten aktualisieren und erneut auslesen // ============================================================================= PlanetResourceUpdate($TargetUser, $TargetPlanet, time()); // ============================================================================= foreach ($fleet as $a => $b) { if ($b != '') { $a = explode(",", $b); $fquery .= "{$resource[$a[0]]}={$resource[$a[0]]} + {$a[1]}, \n"; if ($FleetRow['fleet_mess'] != "1") { if ($a[0] == "210") { $LS = $a[1]; $QryTargetGalaxy = "SELECT * FROM {{table}} WHERE "; $QryTargetGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryTargetGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryTargetGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "';"; $TargetGalaxy = doquery($QryTargetGalaxy, 'galaxy', true); $CristalDebris = $TargetGalaxy['crystal']; $SpyToolDebris = $LS * 300; $MaterialsInfo = SpyTarget($TargetPlanet, 0, $lang['sys_spy_maretials']); $Materials = $MaterialsInfo['String']; $PlanetFleetInfo = SpyTarget($TargetPlanet, 1, $lang['sys_spy_fleet']); $PlanetFleet = $Materials; $PlanetFleet .= $PlanetFleetInfo['String']; $PlanetDefenInfo = SpyTarget($TargetPlanet, 2, $lang['sys_spy_defenses']); $PlanetDefense = $PlanetFleet; $PlanetDefense .= $PlanetDefenInfo['String']; $PlanetBuildInfo = SpyTarget($TargetPlanet, 3, $lang['tech'][0]); $PlanetBuildings = $PlanetDefense; $PlanetBuildings .= $PlanetBuildInfo['String']; $TargetTechnInfo = SpyTarget($TargetUser, 4, $lang['tech'][100]); $TargetTechnos = $PlanetBuildings; $TargetTechnos .= $TargetTechnInfo['String']; // Offiziere $TargetOffieInfo = SpyTarget($TargetUser, 5, $lang['tech'][600]); $TargetOffie = $TargetTechnos; $TargetOffie .= $TargetOffieInfo['String']; // Stehende Flotten $TargetAllyInfo = SpyTarget($TargetPlanet, 6, $lang['sys_spy_stayfleets']); $TargetAllyFleet = $TargetOffie; $TargetAllyFleet .= $TargetAllyInfo['String']; $TargetForce = $PlanetFleetInfo['Count'] * $LS / 4; if ($TargetForce > 100) { $TargetForce = 100; } $TargetChances = rand(0, $TargetForce); $SpyerChances = rand(0, 100); if ($TargetChances >= $SpyerChances) { $DestProba = "<font color=\"red\">" . $lang['sys_mess_spy_destroyed'] . "</font>"; } elseif ($TargetChances < $SpyerChances) { $DestProba = sprintf($lang['sys_mess_spy_lostproba'], $TargetChances); } $AttackLink = "<center>"; $AttackLink .= "<a href=\"fleet.php?galaxy=" . $FleetRow['fleet_end_galaxy'] . "&system=" . $FleetRow['fleet_end_system'] . ""; $AttackLink .= "&planet=" . $FleetRow['fleet_end_planet'] . "&planettype=" . $FleetRow['fleet_end_type'] . ""; $AttackLink .= "&target_mission=1"; $AttackLink .= " \">" . $lang['type_mission'][1] . ""; $AttackLink .= "</a></center>"; $MessageEnd = "<center>" . $DestProba . "</center>"; $pT = $TargetSpyLvl + $TargetEspia - ($CurrentSpyLvl + $CurrentEspia); $pW = $CurrentSpyLvl + $CurrentEspia - ($TargetSpyLvl + $TargetEspia); if ($TargetSpyLvl + $TargetEspia > $CurrentSpyLvl + $CurrentEspia) { $ST = $LS - pow($pT, 2); } if ($CurrentSpyLvl + $CurrentEspia > $TargetSpyLvl + $TargetEspia) { $ST = $LS + pow($pW, 2); } if ($TargetSpyLvl == $CurrentSpyLvl) { $ST = $CurrentSpyLvl; } if ($ST <= "1") { $SpyMessage = $Materials . "<br />" . $AttackLink . $MessageEnd; } if ($ST == "2") { $SpyMessage = $PlanetFleet . "<br />" . $AttackLink . $MessageEnd; } if ($ST == "3") { $SpyMessage = $PlanetDefense . "<br />" . $AttackLink . $MessageEnd; } if ($ST == "4") { $SpyMessage = $PlanetBuildings . "<br />" . $AttackLink . $MessageEnd; } if ($ST == "5") { $SpyMessage = $TargetTechnos . "<br />" . $AttackLink . $MessageEnd; } if ($ST == "6") { $SpyMessage = $TargetOffie . "<br />" . $AttackLink . $MessageEnd; } if ($ST >= "7") { $SpyMessage = $TargetAllyFleet . "<br />" . $AttackLink . $MessageEnd; } SendSimpleMessage($CurrentUserID, '', $FleetRow['fleet_start_time'], 0, $lang['sys_mess_qg'], $lang['sys_mess_spy_report'], $SpyMessage); $TargetMessage = $lang['sys_mess_spy_ennemyfleet'] . " " . $CurrentPlanet['name']; $TargetMessage .= "<a href=\"galaxy.php?mode=3&galaxy=" . $CurrentPlanet['galaxy'] . "&system=" . $CurrentPlanet['system'] . "\">"; $TargetMessage .= "[" . $CurrentPlanet['galaxy'] . ":" . $CurrentPlanet['system'] . ":" . $CurrentPlanet['planet'] . "]</a> "; $TargetMessage .= $lang['sys_mess_spy_seen_at'] . " " . $TargetPlanet['name']; $TargetMessage .= " [" . $TargetPlanet['galaxy'] . ":" . $TargetPlanet['system'] . ":" . $TargetPlanet['planet'] . "]."; $TargetMessage .= "<center>" . $DestProba . "</center>"; SendSimpleMessage($TargetUserID, '', $FleetRow['fleet_start_time'], 0, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $TargetMessage); } if ($TargetChances >= $SpyerChances) { $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`crystal` = `crystal` + '" . $SpyToolDebris . "' "; $QryUpdateGalaxy .= "WHERE `id_planet` = '" . $TargetPlanet['id'] . "';"; doquery($QryUpdateGalaxy, 'galaxy'); $FleetRow['fleet_array'] = ""; doquery("DELETE FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUserID . "' AND `fleet_mission`=6 AND `fleet_id`='" . $FleetRow['fleet_id'] . "';", 'fleets'); //Piratenangriff nach Zufallsprinzip $zufall = 0; $zufall = rand(1, 10); if ($zufall == 7) { Piratenangriff($FleetRow); $zufall = 0; } // Ende Piratenangriff } else { doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = '" . $FleetRow['fleet_id'] . "';", 'fleets'); } } } else { // Rueckkehr der Spiosonden if ($FleetRow['fleet_end_time'] <= time()) { RestoreFleetToPlanet($FleetRow, true); doquery("DELETE FROM {{table}} WHERE `fleet_id` = " . $FleetRow['fleet_id'], 'fleets'); } } } } }
/** * MissionCaseRecycling.php * @Licence GNU (GPL) * @version 2.2 * @copyright 2009 * @Team Space Beginner */ function MissionCaseRecycling($FleetRow) { global $pricelist, $lang; if ($FleetRow["fleet_mess"] == 0) { if ($FleetRow['fleet_start_time'] <= time()) { $QrySelectGalaxy = "SELECT * FROM {{table}} "; $QrySelectGalaxy .= "WHERE "; $QrySelectGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QrySelectGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QrySelectGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; $QrySelectGalaxy .= "LIMIT 1;"; $TargetGalaxy = doquery($QrySelectGalaxy, 'galaxy', true); $FleetRecord = explode(";", $FleetRow['fleet_array']); $RecyclerCapacity = 0; $OtherFleetCapacity = 0; foreach ($FleetRecord as $Item => $Group) { if ($Group != '') { $Class = explode(",", $Group); if ($Class[0] == 209 or $Class[0] == 219) { $RecyclerCapacity += $pricelist[$Class[0]]["capacity"] * $Class[1]; } else { $OtherFleetCapacity += $pricelist[$Class[0]]["capacity"] * $Class[1]; } } } $IncomingFleetGoods = $FleetRow["fleet_resource_metal"] + $FleetRow["fleet_resource_crystal"] + $FleetRow["fleet_resource_deuterium"] + $FleetRow["fleet_resource_appolonium"]; if ($IncomingFleetGoods > $OtherFleetCapacity) { $RecyclerCapacity -= $IncomingFleetGoods - $OtherFleetCapacity; } if ($TargetGalaxy["metal"] + $TargetGalaxy["crystal"] + $TargetGalaxy["appolonium"] <= $RecyclerCapacity) { $RecycledGoods["metal"] = $TargetGalaxy["metal"]; $RecycledGoods["crystal"] = $TargetGalaxy["crystal"]; $RecycledGoods["appolonium"] = $TargetGalaxy["appolonium"]; } else { if ($TargetGalaxy["metal"] >= $RecyclerCapacity / 3 and $TargetGalaxy["crystal"] >= $RecyclerCapacity / 3 and $TargetGalaxy["appolonium"] >= $RecyclerCapacity / 3) { $RecycledGoods["metal"] = $RecyclerCapacity / 3; $RecycledGoods["crystal"] = $RecyclerCapacity / 3; $RecycledGoods["appolonium"] = $RecyclerCapacity / 3; } else { if ($TargetGalaxy["appolonium"] >= $RecyclerCapacity) { $RecycledGoods["appolonium"] = $RecyclerCapacity; $RecycledGoods["metal"] = 0; $RecycledGoods["crystal"] = 0; } else { if ($TargetGalaxy["crystal"] >= $RecyclerCapacity) { $RecycledGoods["crystal"] = $RecyclerCapacity; $RecycledGoods["metal"] = 0; $RecycledGoods["appolonium"] = 0; } else { if ($TargetGalaxy["metal"] >= $RecyclerCapacity) { $RecycledGoods["metal"] = $RecyclerCapacity; $RecycledGoods["crystal"] = 0; $RecycledGoods["appolonium"] = 0; } else { if ($TargetGalaxy["appolonium"] <= $RecyclerCapacity and $TargetGalaxy["appolonium"] > 0) { $RecycledGoods["appolonium"] = $TargetGalaxy["appolonium"]; if ($TargetGalaxy["metal"] >= $RecyclerCapacity - $RecycledGoods["appolonium"]) { $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["appolonium"]; } if ($TargetGalaxy["crystal"] >= $RecyclerCapacity - $RecycledGoods["appolonium"] - $RecycledGoods["metal"]) { $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["appolonium"] - $RecycledGoods["metal"]; } } else { if ($TargetGalaxy["crystal"] <= $RecyclerCapacity and $TargetGalaxy["crystal"] > 0) { $RecycledGoods["crystal"] = $TargetGalaxy["crystal"]; if ($TargetGalaxy["metal"] >= $RecyclerCapacity - $RecycledGoods["crystal"]) { $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"]; } if ($TargetGalaxy["appolonium"] >= $RecyclerCapacity - $RecycledGoods["crystal"] - $RecycledGoods["metal"]) { $RecycledGoods["appolonium"] = $RecyclerCapacity - $RecycledGoods["crystal"] - $RecycledGoods["metal"]; } } else { if ($TargetGalaxy["metal"] <= $RecyclerCapacity and $TargetGalaxy["metal"] > 0) { $RecycledGoods["metal"] = $TargetGalaxy["metal"]; if ($TargetGalaxy["crystal"] >= $RecyclerCapacity - $RecycledGoods["metal"]) { $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"]; } if ($TargetGalaxy["appolonium"] >= $RecyclerCapacity - $RecycledGoods["crystal"] - $RecycledGoods["metal"]) { $RecycledGoods["appolonium"] = $RecyclerCapacity - $RecycledGoods["crystal"] - $RecycledGoods["metal"]; } } } } } } } } } $NewCargo['Metal'] = $FleetRow["fleet_resource_metal"] + $RecycledGoods["metal"]; $NewCargo['Crystal'] = $FleetRow["fleet_resource_crystal"] + $RecycledGoods["crystal"]; $NewCargo['Appolonium'] = $FleetRow["fleet_resource_appolonium"] + $RecycledGoods["appolonium"]; $QryUpdateGalaxy = "UPDATE {{table}} SET "; $QryUpdateGalaxy .= "`metal` = `metal` - '" . $RecycledGoods["metal"] . "', "; $QryUpdateGalaxy .= "`crystal` = `crystal` - '" . $RecycledGoods["crystal"] . "', "; $QryUpdateGalaxy .= "`appolonium` = `appolonium` - '" . $RecycledGoods["appolonium"] . "' "; $QryUpdateGalaxy .= "WHERE "; $QryUpdateGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; $QryUpdateGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; $QryUpdateGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; $QryUpdateGalaxy .= "LIMIT 1;"; doquery($QryUpdateGalaxy, 'galaxy'); $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal'], pretty_number($RecycledGoods["appolonium"]), $lang['Appolonium']); SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 4, $lang['sys_mess_tower'], $lang['sys_recy_report'], $Message); $QryUpdateFleet = "UPDATE {{table}} SET "; $QryUpdateFleet .= "`fleet_resource_metal` = '" . $NewCargo['Metal'] . "', "; $QryUpdateFleet .= "`fleet_resource_crystal` = '" . $NewCargo['Crystal'] . "', "; $QryUpdateFleet .= "`fleet_resource_appolonium` = '" . $NewCargo['Appolonium'] . "', "; $QryUpdateFleet .= "`fleet_mess` = '1' "; $QryUpdateFleet .= "WHERE "; $QryUpdateFleet .= "`fleet_id` = '" . $FleetRow['fleet_id'] . "' "; $QryUpdateFleet .= "LIMIT 1;"; doquery($QryUpdateFleet, 'fleets'); } } else { if ($FleetRow['fleet_end_time'] <= time()) { // Mettre le message de retour de flotte $Message = sprintf($lang['sys_tran_mess_recback'], $TargetName, GetTargetAdressLink($FleetRow, ''), pretty_number($FleetRow['fleet_resource_metal']), $lang['Metal'], pretty_number($FleetRow['fleet_resource_crystal']), $lang['Crystal'], pretty_number($FleetRow['fleet_resource_appolonium']), $lang['Appolonium']); SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 4, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $Message); RestoreFleetToPlanet($FleetRow, true); //Piratenangriff nach Zufallsprinzip $zufall = 0; $zufall = rand(1, 10); if ($zufall == 7) { Piratenangriff($FleetRow); $zufall = 0; } // Ende Piratenangriff doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets'); } } }