예제 #1
0
 public static function attack_target_ship($victim_id, $attacker_id)
 {
     global $db_prefix;
     global $ewd_maxhullsize;
     global $sector_max;
     global $bounty_ratio;
     global $bounty_minturns;
     global $bounty_maxvalue;
     global $level_factor;
     global $torp_dmg_rate;
     global $rating_combat_factor;
     global $upgrade_cost;
     global $upgrade_factor;
     $sql_manager = new manage_table();
     $player_manager = new manage_player();
     $manage_log = new manage_log();
     ###############################################################################################
     ###																							###
     ###   LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK LAUNCHING ATTACK  ###
     ###																							###
     ###############################################################################################
     $tables_to_lock_array = array('xenobe', 'sector_defence', 'ships', 'universe', 'bounty', 'planets', 'news', 'movement_log', 'logs', 'ibank_accounts', 'languages', 'zones', 'player_logs', 'security_logs');
     if ($sql_manager->lock_table($tables_to_lock_array)) {
         $victim_id = $this->stripnum($victim_id);
         $attacker_id = $this->stripnum($attacker_id);
         /* Get Player Data */
         $target_data = $sql_manager->playerinfo($victim_id, "");
         $attacker_data = $sql_manager->playerinfo($attacker_id, "");
         $playerscore = $player_manager->generate_score($attacker_id);
         $targetscore = $player_manager->generate_score($victim_id);
         $playerscore = $playerscore * $playerscore;
         $targetscore = $targetscore * $targetscore;
         $zone_information = $sql_manager->zone_information($target_data['sector'], 'allow_attack');
         # stage 1 - check both are in the same sector
         if ($target_data['sector'] != $attacker_data['sector'] || $target_data['on_planet'] == "Y") {
             echo "Target not in the sector, or the target is on a planet. You sir have failed.<br/>";
             # Security Log #
             $manage_log->security_log($attacker_data['ship_id'], 23, $attacker_data['ship_id'], $target_data['ship_id']);
         } else {
             if ($attacker_data['turns'] < 1) {
                 echo "You have no turns to attack with. You sir have failed.<br/>";
                 $manage_log->security_log($attacker_data['ship_id'], 24, $attacker_data['ship_id'], $target_data['ship_id'], $attacker_data['turns']);
             } else {
                 if ($attacker_data['team'] == $target_data['team'] and $target_data['team'] > 0) {
                     echo "Oi, trying to attack your friends, shame on you... SHAME ON YOU!<br/>";
                     $manage_log->security_log($attacker_data['ship_id'], 25, $attacker_data['ship_id'], $target_data['ship_id']);
                 } else {
                     if ($zone_information['allow_attack'] == "N") {
                         echo "This zone doesnt allow attacking. You sir have failed.<br/>";
                         $manage_log->security_log($attacker_data['ship_id'], 26, $attacker_data['ship_id'], $target_data['ship_id']);
                     } else {
                         if (isset($_SESSION['in_combat']) && $_SESSION['in_combat'] === true) {
                             echo "Whoooops, your allready attacking this ship! Refresh much? Admin has been notified.<br/>";
                             ## LOG THIS MULTI ATTACK ##
                             $manage_log->security_log($attacker_data['ship_id'], 27, $attacker_data['ship_id'], $target_data['ship_id']);
                         } else {
                             $manage_log->security_log($attacker_data['ship_id'], 28, $attacker_data['ship_id'], $target_data['ship_id']);
                             /* WE CAN ATTACK ... NO GOING BACK NOW JIM!!!*/
                             if (preg_match("/(\\@xenobe)\$/", $target_data['email']) === 0) {
                                 /*xenobe. we dont want to be blocking the scheduler again*/
                             } else {
                                 $_SESSION['in_combat'] = (bool) true;
                             }
                             // Set In Combat Flag
                             $success = (10 - $target_data['cloak'] + $attacker_data['sensors']) * 5;
                             if ($success < 5) {
                                 $success = 5;
                             }
                             if ($success > 95) {
                                 $success = 95;
                             }
                             $flee = (10 - $target_data['engines'] + $attacker_data['engines']) * 5;
                             if ($target_data['beams'] == $attacker_data['beams'] and $target_data['power'] == $attacker_data['power']) {
                                 /*Black holes open when 2 equally matched beams are fired directly at each other with the same power amplilification*/
                                 $roll3 = mt_rand(1, 10000);
                                 /* chance of Accidently creating a black hole!*/
                                 /*to not ruin the game, there is a 0.04% chance of a black hole appearing. and then the 2 ships have to be matched in size*/
                             } else {
                                 $roll3 = 1;
                             }
                             $roll = mt_rand(1, 100);
                             $roll2 = mt_rand(1, 100);
                             if ($flee < $roll2) {
                                 echo "Oh no they out manouvered you! UPGRADE THOSE ENGINES! <br/>";
                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                 $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                 $manage_log->player_log($target_data['ship_id'], 4, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                             } elseif ($roll > $success) {
                                 // If scanning failed, inform the target
                                 echo "Oops you where unable to lock target on the enemy ship, UPGRADE THOSE SENSORS!!!!?!<br/>";
                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                 $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                 $manage_log->player_log($target_data['ship_id'], 9, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                             } else {
                                 $shipavg = $this->ship_average_tech($target_data, "ship");
                                 if ($shipavg > $ewd_maxhullsize) {
                                     $chance = ($shipavg - $ewd_maxhullsize) * 10;
                                 } else {
                                     $chance = 0;
                                 }
                                 $random_value = mt_rand(1, 100);
                                 if ($roll3 > 9996) {
                                     $manage_log->security_log($attacker_data['ship_id'], 29, $attacker_data['ship_id'], $target_data['ship_id']);
                                     /*A black hole was accidently created*/
                                     echo "Uuuuuuuuuuuhhhhhhhh oooooohhhhhhh shsssshshshshhhhhhiiiiiii............bbbbbblllllllaaaaaccccccckkkkkkkkk kk kk kk kk kk  h    h      h     o<br/>";
                                     $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                     $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                     $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used']);
                                     $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                     # both ships suffer damage if they have EWD, otherwise both ships destroyed #
                                     if ($target_data['dev_emerwarp'] > 0) {
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $target_data['dev_emerwarp'] = $target_data['dev_emerwarp'] - 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $target_data['dev_emerwarp'], 'cleared_defences' => ' ');
                                         $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($target_data['ship_id'], 25, '', '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         #  SHIP DESTROYED  #
                                         /*Escape pods are useless....*/
                                         $sql_manager->reset_ship($target_data['ship_id']);
                                         $sql_manager->kill_ship($target_data['ship_id']);
                                         $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                         $manage_log->player_log($target_data['ship_id'], 24, '', '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                     }
                                     if ($attacker_data['dev_emerwarp'] > 0) {
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $rating_change = round($attacker_data['rating'] * 0.1);
                                         $attacker_data['dev_emerwarp'] = $attacker_data['dev_emerwarp'] - 1;
                                         $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                         $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $attacker_data['dev_emerwarp'], 'cleared_defences' => ' ', 'turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $rating_change);
                                         $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($attacker_data['ship_id'], 25, '', '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         #  SHIP DESTROYED  #
                                         /*Escape pods are useless....*/
                                         $sql_manager->reset_ship($attacker_data['ship_id']);
                                         $sql_manager->kill_ship($attacker_data['ship_id']);
                                         $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                         $manage_log->player_log($attacker_data['ship_id'], 24, '', '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                     }
                                 } else {
                                     if ($target_data['dev_emerwarp'] > 0 && $random_value > $chance) {
                                         /*They did it, they hit the EWD just in time*/
                                         echo "they hit the EWD.... we missed them ... now to take your anger out on your weapons officer.....<br/>";
                                         $rating_change = round($attacker_data['rating'] * 0.1);
                                         $dest_sector = mt_rand(1, $sector_max - 1);
                                         $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                         $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                         $updated_stats = array('turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $rating_change);
                                         $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                         /*Move the ship that hit the EWD*/
                                         $target_data['dev_emerwarp'] = $target_data['dev_emerwarp'] - 1;
                                         $updated_stats = array('sector' => $dest_sector, 'dev_emerwarp' => $target_data['dev_emerwarp'], 'cleared_defences' => ' ');
                                         $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                         $manage_log->player_log($target_data['ship_id'], 6, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                     } else {
                                         /*Go forth and attack*/
                                         if (($targetscore / $playerscore < $bounty_ratio || $target_data['turns_used'] < $bounty_minturns) && preg_match("/(\\@xenobe)\$/", $target_data['email']) === 0) {
                                             $btyamount = 0;
                                             $hasbounty = $sql_manager->get_bounty($target_data['ship_id'], 0);
                                             if ($hasbounty['btytotal'] > 0) {
                                                 $btyamount = $hasbounty['btytotal'];
                                             }
                                             if ($btyamount <= 0) {
                                                 $bounty = round($playerscore * $bounty_maxvalue);
                                                 $sql_manager->create_bounty($attacker_data['ship_id'], 0, $bounty);
                                                 # LOG BOUNTY ON PLAYER #
                                                 echo "The Federation does not approve of you attacking a smaller ship. Your now barred from all shipyards until you pay your fine.<br/>";
                                                 $manage_log->player_log($attacker_data['ship_id'], 26, $target_data['ship_id'], $bounty, '', '', "<font color='#E9AB17'>Medium Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                         }
                                         if ($target_data['dev_emerwarp'] > 0) {
                                             $manage_log->player_log($target_data['ship_id'], 7, $attacker_data['ship_id'], '', '', '', "<font color='#FF0000'>High Priority</font>", '<b><font color="#FF0000">Warning</font></b>');
                                         }
                                         ##############################
                                         ##############################
                                         ##							##
                                         ## SETTING UP ATTACK DATA	##
                                         ##							##
                                         ##############################
                                         ##############################
                                         $targetenergy = $target_data['ship_energy'];
                                         $playerenergy = $attacker_data['ship_energy'];
                                         // I added these two so we can have a value for debugging and reporting totals
                                         // If we use the variables in calcs below, change the display of stats too
                                         $targetbeams = $this->number_beams($target_data['beams']);
                                         if ($targetbeams > $target_data['ship_energy']) {
                                             $targetbeams = $target_data['ship_energy'];
                                         }
                                         $target_data['ship_energy'] = $target_data['ship_energy'] - $targetbeams;
                                         // Why dont we set targetinfo[ship_energy] to a variable instead?
                                         $playerbeams = $this->number_beams($attacker_data['beams']);
                                         if ($playerbeams > $attacker_data['ship_energy']) {
                                             $playerbeams = $attacker_data['ship_energy'];
                                         }
                                         $attacker_data['ship_energy'] = $attacker_data['ship_energy'] - $playerbeams;
                                         $playershields = $this->number_shields($attacker_data['shields']);
                                         if ($playershields > $attacker_data['ship_energy']) {
                                             $playershields = $attacker_data['ship_energy'];
                                         }
                                         $attacker_data['ship_energy'] = $attacker_data['ship_energy'] - $playershields;
                                         $targetshields = $this->number_shields($target_data['shields']);
                                         if ($targetshields > $target_data['ship_energy']) {
                                             $targetshields = $target_data['ship_energy'];
                                         }
                                         $target_data['ship_energy'] = $target_data['ship_energy'] - $targetshields;
                                         $playertorpnum = round(pow($level_factor, $attacker_data['torp_launchers'])) * 10;
                                         if ($playertorpnum > $attacker_data['torps']) {
                                             $playertorpnum = $attacker_data['torps'];
                                         }
                                         $targettorpnum = round(pow($level_factor, $target_data['torp_launchers'])) * 10;
                                         if ($targettorpnum > $target_data['torps']) {
                                             $targettorpnum = $target_data['torps'];
                                         }
                                         $playertorpdmg = $torp_dmg_rate * $playertorpnum;
                                         $targettorpdmg = $torp_dmg_rate * $targettorpnum;
                                         $playerarmor = $attacker_data['armor_pts'];
                                         $targetarmor = $target_data['armor_pts'];
                                         $playerfighters = $attacker_data['ship_fighters'];
                                         $targetfighters = $target_data['ship_fighters'];
                                         $targetdestroyed = 0;
                                         $playerdestroyed = 0;
                                         echo "You are currently attacking " . $target_data['character_name'] . " aboard " . $target_data['ship_name'] . ":<br/>";
                                         $bcs_info = null;
                                         $bcs_info[] = array("Beams (lvl)", $playerbeams . " <span class=\"table_word_faded\">(" . $attacker_data['beams'] . ")</span>", $targetbeams . " <span class=\"table_word_faded\">(" . $target_data['beams'] . ")</span>");
                                         $bcs_info[] = array("Shields (lvl)", $playershields . " <span class=\"table_word_faded\">(" . $attacker_data['shields'] . ")</span>", $targetshields . " <span class=\"table_word_faded\">(" . $target_data['shields'] . ")</span>");
                                         $bcs_info[] = array("Energy (Start)", $attacker_data['ship_energy'] . " <span class=\"table_word_faded\">(" . $playerenergy . ")</span>", $target_data['ship_energy'] . " <span class=\"table_word_faded\">(" . $targetenergy . ")</span>");
                                         $bcs_info[] = array("Torps (lvl)", $playertorpnum . " <span class=\"table_word_faded\">(" . $attacker_data['torp_launchers'] . ")</span>", $targettorpnum . " <span class=\"table_word_faded\">(" . $target_data['torp_launchers'] . ")</span>");
                                         $bcs_info[] = array("TorpDmg", $playertorpdmg, $targettorpdmg);
                                         $bcs_info[] = array("Fighters", $playerfighters, $targetfighters);
                                         $bcs_info[] = array("Armor (lvl)", $playerarmor . " <span class=\"table_word_faded\">(" . $attacker_data['armor'] . ")</span>", $targetarmor . " <span class=\"table_word_faded\">(" . $target_data['beams'] . ")</span>");
                                         $bcs_info[] = array("Escape Pod", $attacker_data['dev_escapepod'], $target_data['dev_escapepod']);
                                         /*
                                         Build table
                                         */
                                         ?>
 <div class="general-table-container">
 <?php 
                                         echo "<table><tbody>";
                                         echo "<tr>";
                                         echo "<td>Stats</td>";
                                         echo "<td>You [<span class=\"table_word_blue\">" . $attacker_data['character_name'] . "</span>]</td>";
                                         echo "<td>Target [<span class=\"table_word_orange\">" . $target_data['character_name'] . "</span>]</td>";
                                         echo "</tr>";
                                         for ($bcs_index = 0; $bcs_index < count($bcs_info); $bcs_index++) {
                                             echo "  <tr>";
                                             echo "    <td>" . $bcs_info[$bcs_index][0] . "</td>";
                                             echo "    <td>" . $bcs_info[$bcs_index][1] . "</td>";
                                             echo "    <td>" . $bcs_info[$bcs_index][2] . "</td>";
                                             echo "  </tr>";
                                         }
                                         echo "</tbody></table>";
                                         echo "<table><tbody>";
                                         echo "<tr>";
                                         echo "<td colspan=\"2\">Target Locked</td>";
                                         echo "</tr>";
                                         echo "<tr><td class=\"ship-attack-title\">Firing Beams</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($targetfighters > 0 && $playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > round($targetfighters / 2)) {
                                                 $temp = round($targetfighters / 2);
                                                 $lost = $targetfighters - $temp;
                                                 //Maybe we should report on how many beams fired , etc for comparision/bugtracking
                                                 echo $target_data['character_name'] . " lost " . $lost . " fighters<br/>";
                                                 $targetfighters = $temp;
                                                 $playerbeams = $playerbeams - $lost;
                                             } else {
                                                 $targetfighters = $targetfighters - $playerbeams;
                                                 echo $target_data['character_name'] . " lost " . $playerbeams . " fighters<br/>";
                                                 $playerbeams = 0;
                                             }
                                         }
                                         if ($playerfighters > 0 && $targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > round($playerfighters / 2)) {
                                                 $temp = round($playerfighters / 2);
                                                 $lost = $playerfighters - $temp;
                                                 echo "You lost " . $lost . " fighters<br>";
                                                 $playerfighters = $temp;
                                                 $targetbeams = $targetbeams - $lost;
                                             } else {
                                                 $playerfighters = $playerfighters - $targetbeams;
                                                 echo "You lost " . $targetbeams . " fighters<br>";
                                                 $targetbeams = 0;
                                             }
                                         }
                                         if ($playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > $targetshields) {
                                                 $playerbeams = $playerbeams - $targetshields;
                                                 $targetshields = 0;
                                                 echo $target_data['character_name'] . "'s shields are down!<br>";
                                             } else {
                                                 echo $target_data['character_name'] . "'s shields are hit for " . $playerbeams . " damage.<br>";
                                                 $targetshields = $targetshields - $playerbeams;
                                                 $playerbeams = 0;
                                             }
                                         }
                                         if ($targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > $playershields) {
                                                 $targetbeams = $targetbeams - $playershields;
                                                 $playershields = 0;
                                                 echo "Your shields are down!<br/>";
                                             } else {
                                                 echo "Your shields are hit for " . $targetbeams . " damage.<br/>";
                                                 $playershields = $playershields - $targetbeams;
                                                 $targetbeams = 0;
                                             }
                                         }
                                         if ($playerbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerbeams > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playerbeams;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playerbeams . " damage.<br/>";
                                             }
                                         }
                                         if ($targetbeams > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetbeams > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targetbeams;
                                                 echo "Your armor is hit for {$targetbeams} damage.<br>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo "  </td></tr>";
                                         echo "<tr><td class=\"ship-attack-title\">Launching Torpedos</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($targetfighters > 0 && $playertorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($playertorpdmg > round($targetfighters / 2)) {
                                                 $temp = round($targetfighters / 2);
                                                 $lost = $targetfighters - $temp;
                                                 echo $target_data['character_name'] . " lost " . $lost . " fighters<br/>";
                                                 $targetfighters = $temp;
                                                 $playertorpdmg = $playertorpdmg - $lost;
                                             } else {
                                                 $targetfighters = $targetfighters - $playertorpdmg;
                                                 echo $target_data['character_name'] . " lost " . $playertorpdmg . " fighters<br/>";
                                                 $playertorpdmg = 0;
                                             }
                                         }
                                         if ($playerfighters > 0 && $targettorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($targettorpdmg > round($playerfighters / 2)) {
                                                 $temp = round($playerfighters / 2);
                                                 $lost = $playerfighters - $temp;
                                                 echo "You lost " . $lost . " fighters<br/>";
                                                 echo "{$temp} - {$playerfighters} - {$targettorpdmg}";
                                                 $playerfighters = $temp;
                                                 $targettorpdmg = $targettorpdmg - $lost;
                                             } else {
                                                 $playerfighters = $playerfighters - $targettorpdmg;
                                                 echo "You lost " . $targettorpdmg . " fighters<br/>";
                                                 $targettorpdmg = 0;
                                             }
                                         }
                                         if ($playertorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($playertorpdmg > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playertorpdmg;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playertorpdmg . " damage.<br/>";
                                             }
                                         }
                                         if ($targettorpdmg > 0) {
                                             $bcs_stats_info = true;
                                             if ($targettorpdmg > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targettorpdmg;
                                                 echo "Your armor is hit for " . $targettorpdmg . " damage.<br/>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo "</tr></td>";
                                         echo "<tr><td class=\"ship-attack-title\">Fighter have been launched</td>";
                                         echo "<td>";
                                         $bcs_stats_info = false;
                                         if ($playerfighters > 0 && $targetfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerfighters > $targetfighters) {
                                                 echo $target_data['character_name'] . " Lost all their fighters<br/>";
                                                 $temptargfighters = 0;
                                             } else {
                                                 echo $target_data['character_name'] . " lost " . $playerfighters . " fighters.<br/>";
                                                 $temptargfighters = $targetfighters - $playerfighters;
                                             }
                                             if ($targetfighters > $playerfighters) {
                                                 echo "You lost all fighters.<br/>";
                                                 $tempplayfighters = 0;
                                             } else {
                                                 echo "You lost " . $targetfighters . " fighters.<br/>";
                                                 $tempplayfighters = $playerfighters - $targetfighters;
                                             }
                                             $playerfighters = $tempplayfighters;
                                             $targetfighters = $temptargfighters;
                                         }
                                         if ($playerfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($playerfighters > $targetarmor) {
                                                 $targetarmor = 0;
                                                 echo $target_data['character_name'] . "'s armor breached!<br/>";
                                             } else {
                                                 $targetarmor = $targetarmor - $playerfighters;
                                                 echo $target_data['character_name'] . "'s armor is hit for " . $playerfighters . " damage.<br/>";
                                             }
                                         }
                                         if ($targetfighters > 0) {
                                             $bcs_stats_info = true;
                                             if ($targetfighters > $playerarmor) {
                                                 $playerarmor = 0;
                                                 echo "Your armor has been breached!" . "<br/>";
                                             } else {
                                                 $playerarmor = $playerarmor - $targetfighters;
                                                 echo "Your armor is hit for " . $targetfighters . " damage.<br/>";
                                             }
                                         }
                                         if ($bcs_stats_info == false) {
                                             echo "No information available.<br>";
                                         }
                                         echo " </td></tr></tbody></table>";
                                         echo "<table><tbody><tr><td>Results</td></tr><tr><td>";
                                         if ($targetarmor < 1) {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			ENEMY DESTROYED			##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo $target_data['character_name'] . "'s ship has been destroyed.<br/>";
                                             if ($target_data['dev_escapepod'] == "Y") {
                                                 #LOG ATTACK LOOSE ESCAPE
                                                 $rating = round($target_data['rating'] / 2);
                                                 echo "Escape pod was launch detected! <span class=\"table_word_blue\">You destroyed their ship but they got away in their Escape Pod</span><br/>";
                                                 $sql_manager->reset_ship($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_kills($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                 /*Reload credits just in case user collected a bounty*/
                                                 $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                 $attacker_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'Y', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             } else {
                                                 # LOG ATTACK #
                                                 $sql_manager->reset_ship($target_data['ship_id']);
                                                 $sql_manager->kill_ship($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($target_data['ship_id']);
                                                 $sql_manager->update_player_ship_kills($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                 $attacker_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                             if ($playerarmor > 0) {
                                                 ######################################
                                                 ### 							   ###
                                                 ##									##
                                                 ##			YOU SURVIVED			##
                                                 ##									##
                                                 ###								   ###
                                                 ######################################
                                                 $rating_change = round($target_data['rating'] * $rating_combat_factor);
                                                 // Updating to always get a positive rating increase for xenobe and the credits they are carrying
                                                 $salv_credits = 0;
                                                 // Double Death Attack Bug Fix - Returns 0 for real players, 1 for Xenobe players
                                                 if (preg_match("/(\\@xenobe)\$/", $target_data['email']) !== 0) {
                                                     $sql_manager->disable_xenobe($target_data['email']);
                                                     if ($rating_change > 0) {
                                                         $rating_change = 0 - $rating_change;
                                                         $manage_log->player_log($target_data['ship_id'], 10, $attacker_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                                         $salv_credits = $target_data['credits'];
                                                         # BUG FIX copy the credits before killing ship*/
                                                         $sql_manager->reset_ship($target_data['ship_id']);
                                                         $sql_manager->kill_ship($target_data['ship_id']);
                                                         $sql_manager->collect_bounty($attacker_data['ship_id'], $target_data['ship_id']);
                                                         $current_credits = $sql_manager->check_credits($attacker_data['ship_id']);
                                                         $attacker_data['credits'] = $current_credits['credits'];
                                                     } else {
                                                         $salv_credits = $target_data['credits'];
                                                     }
                                                 }
                                                 $salvage_percentage = mt_rand(1, 10);
                                                 $free_ore = round($target_data['ship_ore'] / $salvage_percentage);
                                                 $free_organics = round($target_data['ship_organics'] / $salvage_percentage);
                                                 $free_goods = round($target_data['ship_goods'] / $salvage_percentage);
                                                 $free_holds = $this->number_holds($attacker_data['hull']) - $attacker_data['ship_ore'] - $attacker_data['ship_organics'] - $attacker_data['ship_goods'] - $attacker_data['ship_colonists'];
                                                 if ($free_holds > $free_goods) {
                                                     $salv_goods = $free_goods;
                                                     $free_holds = $free_holds - $free_goods;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_goods = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_goods = 0;
                                                 }
                                                 if ($free_holds > $free_ore) {
                                                     $salv_ore = $free_ore;
                                                     $free_holds = $free_holds - $free_ore;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_ore = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_ore = 0;
                                                 }
                                                 if ($free_holds > $free_organics) {
                                                     $salv_organics = $free_organics;
                                                     $free_holds = $free_holds - $free_organics;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_organics = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_organics = 0;
                                                 }
                                                 $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $target_data['hull'])) + round(pow($upgrade_factor, $target_data['engines'])) + round(pow($upgrade_factor, $target_data['power'])) + round(pow($upgrade_factor, $target_data['computer'])) + round(pow($upgrade_factor, $target_data['sensors'])) + round(pow($upgrade_factor, $target_data['beams'])) + round(pow($upgrade_factor, $target_data['torp_launchers'])) + round(pow($upgrade_factor, $target_data['shields'])) + round(pow($upgrade_factor, $target_data['armor'])) + round(pow($upgrade_factor, $target_data['cloak'])));
                                                 $ship_salvage_rate = mt_rand(10, 20);
                                                 $ship_salvage = $ship_value * $ship_salvage_rate / 100 + $salv_credits;
                                                 // Added credits for xenobe - 0 if normal player
                                                 echo "You salvaged <span class=\"table_word_green\">" . $salv_ore . "</span> units of ore,<span class=\"table_word_green\"> " . $salv_organics . "</span> units of organics, <span class=\"table_word_green\">" . $salv_goods . "</span> units of goods, and salvaged <span class=\"table_word_yellow\">" . $ship_salvage_rate . "</span>% of the ship for <span class=\"table_word_yellow\">" . $ship_salvage . "</span> credits.<br/>Your rating changed by " . NUMBER(abs($rating_change)) . " points.<br/>";
                                                 $armor_lost = $attacker_data['armor_pts'] - $playerarmor;
                                                 $fighters_lost = $attacker_data['ship_fighters'] - $playerfighters;
                                                 $attacker_data['ship_ore'] = $attacker_data['ship_ore'] + $salv_ore;
                                                 $attacker_data['ship_organics'] = $attacker_data['ship_organics'] + $salv_organics;
                                                 $attacker_data['ship_goods'] = $attacker_data['ship_goods'] + $salv_goods;
                                                 $attacker_data['credits'] = $attacker_data['credits'] + $ship_salvage;
                                                 $attacker_data['ship_energy'] = $attacker_data['ship_energy'];
                                                 $attacker_data['ship_fighters'] = $attacker_data['ship_fighters'] - $fighters_lost;
                                                 $attacker_data['armor_pts'] = $attacker_data['armor_pts'] - $armor_lost;
                                                 $attacker_data['torps'] = $attacker_data['torps'] - $playertorpnum;
                                                 $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                                 $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                                 $attacker_data['rating'] = $attacker_data['rating'] - $rating_change;
                                                 $updated_stats = array('rating' => $attacker_data['rating'], 'turns_used' => $attacker_data['turns_used'], 'turns' => $attacker_data['turns'], 'torps' => $attacker_data['torps'], 'armor_pts' => $attacker_data['armor_pts'], 'ship_fighters' => $attacker_data['ship_fighters'], 'ship_energy' => $attacker_data['ship_energy'], 'ship_ore' => $attacker_data['ship_ore'], 'ship_organics' => $attacker_data['ship_organics'], 'ship_goods' => $attacker_data['ship_goods'], 'credits' => $attacker_data['credits']);
                                                 $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                                 echo "You lost <span class=\"table_word_red\">" . $armor_lost . "</span> Armour, <span class=\"table_word_red\">" . $fighters_lost . "</span> Fighters, and used <span class=\"table_word_red\">" . $playertorpnum . "</span> Torpedoes.<br/>";
                                             }
                                         } else {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			ENEMY SURVIVED			##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo "You did not destory " . $target_data['character_name'] . "'s ship.<br>";
                                             $rating_change = round($target_data['rating'] * 0.1);
                                             $armor_lost = $target_data['armor_pts'] - $targetarmor;
                                             $fighters_lost = $target_data['ship_fighters'] - $targetfighters;
                                             $energy = $target_data['ship_energy'];
                                             $manage_log->player_log($target_data['ship_id'], 27, $attacker_data['ship_id'], $armor_lost, $fighters_lost, '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             $target_data['ship_energy'] = $target_data['ship_energy'];
                                             $target_data['ship_fighters'] = $target_data['ship_fighters'] - $fighters_lost;
                                             $target_data['armor_pts'] = $target_data['armor_pts'] - $armor_lost;
                                             $target_data['torps'] = $target_data['torps'] - $targettorpnum;
                                             $updated_stats = array('ship_energy' => $target_data['ship_energy'], 'ship_fighters' => $target_data['ship_fighters'], 'armor_pts' => $target_data['armor_pts'], 'torps' => $target_data['torps']);
                                             $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                             $armor_lost = $attacker_data['armor_pts'] - $playerarmor;
                                             $fighters_lost = $attacker_data['ship_fighters'] - $playerfighters;
                                             $energy = $attacker_data['ship_energy'];
                                             $attacker_data['ship_energy'] = $energy;
                                             $attacker_data['ship_fighters'] = $attacker_data['ship_fighters'] - $fighters_lost;
                                             $attacker_data['armor_pts'] = $attacker_data['armor_pts'] - $armor_lost;
                                             $attacker_data['torps'] = $attacker_data['torps'] - $playertorpnum;
                                             $attacker_data['turns'] = $attacker_data['turns'] - 1;
                                             $attacker_data['turns_used'] = $attacker_data['turns_used'] + 1;
                                             $attacker_data['rating'] = $attacker_data['rating'];
                                             $updated_stats = array('ship_energy' => $attacker_data['ship_energy'], 'ship_fighters' => $attacker_data['ship_fighters'], 'armor_pts' => $attacker_data['armor_pts'], 'torps' => $attacker_data['torps'], 'turns' => $attacker_data['turns'], 'turns_used' => $attacker_data['turns_used'], 'rating' => $attacker_data['rating']);
                                             $sql_manager->updatePlayer($attacker_data['ship_id'], "ships", $updated_stats);
                                             echo "You lost <span class=\"table_word_red\">" . $armor_lost . "</span> armour, <span class=\"table_word_red\">" . $fighters_lost . "</span> Fighters, and used <span class=\"table_word_red\">" . $playertorpnum . "</span> Torpedoes.<br/>";
                                         }
                                         if ($playerarmor < 1) {
                                             ######################################
                                             ### 							   ###
                                             ##									##
                                             ##			YOU LOST... WHAT!		##
                                             ##									##
                                             ###								   ###
                                             ######################################
                                             echo "Your ship has been destroyed!<br/>";
                                             if ($attacker_data['dev_escapepod'] == "Y") {
                                                 echo "Luckily you have an escape pod!<br/>";
                                                 $sql_manager->reset_ship($attacker_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                                 ## LOG EVENT ##
                                                 $sql_manager->collect_bounty($target_data['ship_id'], $attacker_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($target_data['ship_id']);
                                                 $target_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($attacker_data['ship_id'], 28, $target_data['ship_id'], 'Y', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             } else {
                                                 echo "You didnt have an escape Pod, sadly your ice cold corpse can be seen floating in space....<br/>";
                                                 $sql_manager->reset_ship($attacker_data['ship_id']);
                                                 $sql_manager->kill_ship($attacker_data['ship_id']);
                                                 $sql_manager->update_player_ship_deaths($attacker_data['ship_id']);
                                                 $sql_manager->collect_bounty($target_data['ship_id'], $attacker_data['ship_id']);
                                                 $current_credits = $sql_manager->check_credits($target_data['ship_id']);
                                                 $target_data['credits'] = $current_credits['credits'];
                                                 $manage_log->player_log($attacker_data['ship_id'], 28, $target_data['ship_id'], 'N', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                                             }
                                             if ($targetarmor > 0) {
                                                 $salvage_percentage = mt_rand(1, 10);
                                                 $free_ore = round($attacker_data['ship_ore'] / $salvage_percentage);
                                                 $free_organics = round($attacker_data['ship_organics'] / $salvage_percentage);
                                                 $free_goods = round($attacker_data['ship_goods'] / $salvage_percentage);
                                                 $free_holds = $this->number_holds($target_data['hull']) - $target_data['ship_ore'] - $target_data['ship_organics'] - $target_data['ship_goods'] - $target_data['ship_colonists'];
                                                 if ($free_holds > $free_goods) {
                                                     $salv_goods = $free_goods;
                                                     $free_holds = $free_holds - $free_goods;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_goods = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_goods = 0;
                                                 }
                                                 if ($free_holds > $free_ore) {
                                                     $salv_ore = $free_ore;
                                                     $free_holds = $free_holds - $free_ore;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_ore = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_ore = 0;
                                                 }
                                                 if ($free_holds > $free_organics) {
                                                     $salv_organics = $free_organics;
                                                     $free_holds = $free_holds - $free_organics;
                                                 } elseif ($free_holds > 0) {
                                                     $salv_organics = $free_holds;
                                                     $free_holds = 0;
                                                 } else {
                                                     $salv_organics = 0;
                                                 }
                                                 $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $attacker_data['hull'])) + round(pow($upgrade_factor, $attacker_data['engines'])) + round(pow($upgrade_factor, $attacker_data['power'])) + round(pow($upgrade_factor, $attacker_data['computer'])) + round(pow($upgrade_factor, $attacker_data['sensors'])) + round(pow($upgrade_factor, $attacker_data['beams'])) + round(pow($upgrade_factor, $attacker_data['torp_launchers'])) + round(pow($upgrade_factor, $attacker_data['shields'])) + round(pow($upgrade_factor, $attacker_data['armor'])) + round(pow($upgrade_factor, $attacker_data['cloak'])));
                                                 $ship_salvage_rate = mt_rand(10, 20);
                                                 $ship_salvage = $ship_value * $ship_salvage_rate / 100 + $salv_credits;
                                                 // Added credits for xenobe - 0 if normal player
                                                 echo $target_data['character_name'] . " salvaged <span class=\"table_word_green\">" . $salv_ore . "</span> units of ore, <span class=\"table_word_green\">" . $salv_organics . "</span> units of organics, <span class=\"table_word_green\">" . $salv_goods . "</span> units of goods, and salvaged <span class=\"table_word_yellow\">" . $ship_salvage_rate . "</span>% of the ship for <span class=\"table_word_yellow\">" . $ship_salvage . "</span> credits<br/>";
                                                 $target_data['credits'] = $target_data['credits'] + $ship_salvage;
                                                 $target_data['ship_ore'] = $target_data['ship_ore'] + $salv_ore;
                                                 $target_data['ship_organics'] = $target_data['ship_organics'] + $salv_organics;
                                                 $target_data['ship_goods'] = $target_data['ship_goods'] + $salv_goods;
                                                 $target_data['armor_pts'] = $target_data['armor_pts'] - $targetarmor;
                                                 $target_data['ship_fighters'] = $target_data['ship_fighters'] - $targetfighters;
                                                 $target_data['ship_energy'] = $target_data['ship_energy'];
                                                 $target_data['torps'] = $target_data['torps'] - $targettorpnum;
                                                 echo "<P>ACTIVATING</P>";
                                                 $updated_stats = array('credits' => $target_data['credits'], 'ship_ore' => $target_data['ship_ore'], 'ship_organics' => $target_data['ship_organics'], 'ship_goods' => $target_data['ship_goods'], 'armor_pts' => $target_data['armor_pts'], 'ship_fighters' => $target_data['ship_fighters'], 'ship_energy' => $target_data['ship_energy'], 'torps' => $target_data['torps']);
                                                 $sql_manager->updatePlayer($target_data['ship_id'], "ships", $updated_stats);
                                             }
                                         }
                                         echo "</td></td></tbody></table></div>";
                                         ## END OF ATTACK ##
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         /*Error*/
     }
     /*Now unlock the tables*/
     $sql_manager = new manage_table();
     if ($sql_manager->unlock_table()) {
         /*Now we have finished, unlock the tables.*/
     } else {
         /*Somthing went wrong*/
     }
     $_SESSION['in_combat'] = (bool) false;
 }
예제 #2
0
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: sched_planets.php
if (preg_match("/sched_planets.php/i", $_SERVER['PHP_SELF'])) {
    echo "You can not access this file directly!";
    die;
}
include "config/config.php";
$manage_log = new manage_log();
echo "<strong>PLANETS</strong><p>";
$res = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE owner >0;");
db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
// Using Planet Update Code from BNT version 0.36 due to code bugs.
// We are now using transactions to off load the SQL stuff in full to the Database Server.
$result = $db->Execute("START TRANSACTION;");
db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
while (!$res->EOF) {
    $row = $res->fields;
    $production = floor(min($row['colonists'], $colonist_limit) * $colonist_production_rate);
    $organics_production = floor($production * $organics_prate * $row['prod_organics'] / 100.0);
    // - ($production * $organics_consumption);
    $organics_production -= floor($production * $organics_consumption);
    if ($row['organics'] + $organics_production < 0) {
        $organics_production = -$row['organics'];
예제 #3
0
 public function updatePlayer($id, $table, $query)
 {
     global $db_prefix;
     $manage_log = new manage_log();
     foreach ($query as $key => $field) {
         /*Build list of fields to process*/
         $fields_to_update .= $key . " = ?, ";
     }
     $fields_to_update = substr($fields_to_update, 0, -2);
     /*FIX: Remove the last added comma*/
     $update_player = $this->connect->prepare("UPDATE " . $db_prefix . $table . " SET " . $fields_to_update . " WHERE ship_id='" . $id . "'");
     $n = 1;
     foreach ($query as $key => &$field) {
         if (is_numeric($field)) {
             # NUMBER #
             $update_player->bindParam($n, $field, PDO::PARAM_INT);
         } else {
             # STRING #
             $update_player->bindParam($n, $field, PDO::PARAM_STR);
         }
         $n++;
     }
     if ($update_player->execute()) {
         # LOG THIS #
         if ($this->is_that_xenobe($id)) {
             /*Dont want xenobes spamming the logs*/
         } else {
             $manage_log->security_log($id, 7, $table, $fields_to_update);
         }
         return true;
     } else {
         # LOG FAIL #
         $manage_log->security_log($id, 8, $update_player->errorInfo());
         return false;
     }
 }
예제 #4
0
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: sched_apocalypse.php
if (preg_match("/sched_apocalypse.php/i", $_SERVER['PHP_SELF'])) {
    echo "You can not access this file directly!";
    die;
}
include "config/config.php";
$manage_log = new manage_log();
echo "<strong>Pirate Raid</strong><br><br>";
$pirate_day = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE credits > {$planet_max_credits}");
db_op_result($db, $pirate_day, __LINE__, __FILE__, $db_logging);
$chance = 9;
$reccount = $pirate_day->RecordCount();
if ($reccount > 200) {
    $chance = 7;
    // increase chance it will happen if we have lots of planets meeting the criteria
}
$affliction = mt_rand(1, $chance);
// the chance something bad will happen
if ($pirate_day && $affliction < 3 && $reccount > 0) {
    $i = 1;
    $targetnum = mt_rand(1, $reccount);
    while (!$pirate_day->EOF) {
예제 #5
0
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: sched_tow.php
if (preg_match("/sched_tow.php/i", $_SERVER['PHP_SELF'])) {
    echo "You can not access this file directly!";
    die;
}
include "config/config.php";
$manage_log = new manage_log();
echo "<strong>ZONES</strong><br><br>";
echo "Towing bigger players out of restricted zones...";
$num_to_tow = 0;
do {
    $res = $db->Execute("SELECT ship_id,character_name,hull,sector,{$db->prefix}universe.zone_id,max_hull FROM {$db->prefix}ships,{$db->prefix}universe,{$db->prefix}zones WHERE sector=sector_id AND {$db->prefix}universe.zone_id={$db->prefix}zones.zone_id AND max_hull<>0 AND (({$db->prefix}ships.hull + {$db->prefix}ships.engines + {$db->prefix}ships.computer + {$db->prefix}ships.beams + {$db->prefix}ships.torp_launchers + {$db->prefix}ships.shields + {$db->prefix}ships.armor)/7) >max_hull AND ship_destroyed='N'");
    db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
    if ($res) {
        $num_to_tow = $res->RecordCount();
        echo "<br>{$num_to_tow} players to tow:<br>";
        while (!$res->EOF) {
            $row = $res->fields;
            echo "...towing {$row['character_name']} out of {$row['sector']} ...";
            $newsector = mt_rand(0, $sector_max - 1);
            echo " to sector {$newsector}.<br>";
            $query = $db->Execute("UPDATE {$db->prefix}ships SET sector={$newsector},cleared_defences=' ' WHERE ship_id={$row['ship_id']}");
예제 #6
0
include "config/config.php";
if (checklogin()) {
    die;
}
header("Content-type: text/html; charset=utf-8");
header("X-UA-Compatible: IE=Edge, chrome=1");
header("Cache-Control: public");
// Tell the client (and any caches) that this information can be stored in public caches.
header("Connection: Keep-Alive");
// Tell the client to keep going until it gets all data, please.
header("Vary: Accept-Encoding, Accept-Language");
header("Keep-Alive: timeout=15, max=100");
if (!isset($body_class)) {
    $body_class = "bnt";
}
$log_manager = new manage_log();
$default_logs_show_per_page = 20;
$total_records = $log_manager->count_log_total($db_prefix . 'player_logs', $user_ship_id);
$total_groups = ceil($total_records / $default_logs_show_per_page);
?>
<!DOCTYPE html>
<html lang="<?php 
echo $l->get('l_lang_attribute');
?>
">
<head>
<meta charset="utf-8">
<meta name="Description" content="Xenobe Rage - A free online game - Open source, web game, with multiplayer space exploration">
<meta name="Keywords" content="Free, online, game, Open source, web game, multiplayer, space, exploration, blacknova, traders, xenobe rage, xr, xenobe">
<meta name="Rating" content="General">
<link rel="shortcut icon" href="images/bntfavicon.ico">
예제 #7
0
 private function move_xenobe($id, $aggression, $turns)
 {
     global $db_prefix, $sector_max;
     $sql_manager = new manage_table();
     $player_manager = new manage_player();
     $manage_log = new manage_log();
     /*get xenobe current sector*/
     $xenobe_data = $sql_manager->playerinfo($id, "");
     /*check current warp links, are there any? pick one at random to warp to*/
     //$link_query = ;
     $sector_links = $sql_manager->process_query("SELECT * FROM " . $db_prefix . "links WHERE link_start='" . $xenobe_data['sector'] . "'");
     $available_links = array();
     if ($sector_links) {
         #Sector Links Detected#
         foreach ($sector_links as $row) {
             /*List all the links, and pick one at random*/
             array_push($available_links, $row['link_dest']);
         }
         $selected = array_rand($available_links, 1);
         $target_sector = $available_links[$selected];
     } else {
         #No Sector Links Detected - PICKING RANDOM FROM THE UNIVERSE#
         $target_sector = mt_rand(1, $sector_max);
         /*We want the xenobes to have a presence everywhere, for intimidation reasons*/
     }
     /*Right target sector has been selected, now we just need to move there. check for fighters and mines*/
     /*
     To override for testing purposes, you can force a single target sector using  $target_sector = 400; for example here
     */
     $total_sector_mines = $sql_manager->sector_defence_quantities($target_sector, 'M', $id, "investigate");
     $total_sector_fighters = $sql_manager->sector_defence_quantities($target_sector, 'F', $id, "investigate");
     $total_sector_fighters = (int) $total_sector_fighters;
     $total_sector_mines = (int) $total_sector_mines;
     if ($total_sector_fighters > 0 || $total_sector_mines > 0 || $total_sector_fighters > 0 && $total_sector_mines > 0) {
         if ($aggression > 0) {
             /*Attacks sector defence*/
             if ($sql_manager->move_ship($id, $target_sector, $turns)) {
                 $sector_manager = new manage_sector();
                 if ($sector_manager->sector_defence_challange($target_sector, $id)) {
                     echo "<br/>ship moved to sector<br/>";
                     /*Ship in sector, got through defences - do nothing*/
                     ##New Log ##
                     $player_manager->last_activity_stamp($id);
                     $manage_log->player_log($id, 17, $target_sector, '', '', '', "<font color='#6190a5'>Low Priority</font>", "<b>Information</b>");
                 } else {
                     echo "<br/>Ship was destroyed<br/>";
                     /*ship was destroyed trying to enter sector*/
                     if ($xenobe_data['dev_emerwarp'] == "Y") {
                         ##New Log ##
                         $manage_log->player_log($id, 19, $target_sector, '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                         $sql_manager->reset_ship($id);
                     } else {
                         ##New Log ##
                         $manage_log->player_log($id, 18, $target_sector, '', '', '', "<font color='#FF0000'><b>Extreme Priority</b></font>", '<b><font color="#FF0000">Warning</font></b>');
                         $sql_manager->reset_ship($id);
                         $sql_manager->kill_ship($id);
                     }
                     /*Need function to remove bounty? or ignore this? only remove bounty in ship to ship or ship to planet combat situations?*/
                 }
             } else {
                 ##not enough turns##
                 /*move failed, stay in sector*/
             }
         } else {
             /*Avoids sector*/
         }
     } else {
         if ($target_sector > 0) {
             if ($sql_manager->move_ship($id, $target_sector, $turns)) {
                 $player_manager->last_activity_stamp($id);
                 /*no defences sucessful move*/
             } else {
                 /*move failed, stay in sector*/
             }
         } else {
             /*Avoids sector*/
         }
     }
 }
예제 #8
0
<?php

#Feed#
include "config/config.php";
if (checklogin()) {
    die;
}
$default_logs_show_per_page = 20;
if ($_POST) {
    $group_number = filter_var($_POST["group_no"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
    //throw HTTP error if group number is not valid
    if (!is_numeric($group_number)) {
        header('HTTP/1.1 500 Invalid number!');
        exit;
    }
    //get current starting point of records
    $position = $group_number * $default_logs_show_per_page;
    $log_manager = new manage_log();
    echo $log_manager->show_log('ar_player_logs', $position, $default_logs_show_per_page, $user_ship_id);
}
예제 #9
0
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Affero General Public License as
//  published by the Free Software Foundation, either version 3 of the
//  License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: logout.php
include "config/config.php";
$manage_log = new manage_log();
// New database driven language entries
load_languages($db, $lang, array('logout', 'common', 'global_includes', 'global_funcs', 'combat', 'footer', 'news'), $langvars, $db_logging);
$title = $l_logout;
setcookie("userpass", "", 0, $gamepath, $gamedomain);
setcookie("userpass", "", 0);
// Delete from default path as well.
setcookie("userID", "", 0, $gamepath, $gamedomain);
setcookie("userID", "", 0);
$_SESSION['logged_in'] = false;
// Clear the session array, clear the session cookie
$_SESSION = array();
setcookie("PHPSESSID", "", 0, "/");
// Destroy the session entirely
session_destroy();
include "header.php";
예제 #10
0
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: sched_degrade.php
if (preg_match("/sched_degrade.php/i", $_SERVER['PHP_SELF'])) {
    echo "You can not access this file directly!";
    die;
}
include "config/config.php";
$manage_log = new manage_log();
echo "<strong>Degrading Sector Fighters with no friendly base</strong><br><br>";
$res = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE defence_type = 'F'");
db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
while (!$res->EOF) {
    $row = $res->fields;
    $res3 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($row['ship_id']));
    db_op_result($db, $res3, __LINE__, __FILE__, $db_logging);
    $sched_playerinfo = $res3->fields;
    $res2 = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE (owner = ? OR (corp = ? AND ? <> 0)) AND sector_id = ? AND energy > 0;", array($row['ship_id'], $sched_playerinfo['team'], $sched_playerinfo['team'], $row['sector_id']));
    db_op_result($db, $res2, __LINE__, __FILE__, $db_logging);
    if ($res2->EOF) {
        $resa = $db->Execute("UPDATE {$db->prefix}sector_defence SET quantity = quantity - GREATEST(ROUND(quantity * ?),1) WHERE defence_id = ? AND quantity > 0;", array($defence_degrade_rate, $row['defence_id']));
        db_op_result($db, $resa, __LINE__, __FILE__, $db_logging);
        $degrade_rate = $defence_degrade_rate * 100;
        ##New Log ##
예제 #11
0
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Affero General Public License as
//  published by the Free Software Foundation, either version 3 of the
//  License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Affero General Public License for more details.
//
//  You should have received a copy of the GNU Affero General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// File: login2.php
include "config/config.php";
$manage_log = new manage_log();
// Test to see if server is closed to logins
$playerfound = false;
$username = $_POST['handle'];
$pass = $_POST['pass'];
if ($_POST['handle'] != null) {
    $res = $db->Execute("SELECT * FROM {$db->prefix}account WHERE username='******'");
    db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
    if ($res) {
        $playerfound = $res->RecordCount();
    }
    $account_information = $res->fields;
    $lang = $account_information['lang'];
}
if (!isset($_GET['lang'])) {
    $_GET['lang'] = null;