Ejemplo n.º 1
0
<?


include("config.php");
include("languages/$lang");
$title = "Logout";

setcookie("username","",0);
setcookie("password","",0);

include("header.php");

connectdb();

$result = $db->Execute("SELECT * FROM $dbtables[players] WHERE email='$username'");
$playerinfo = $result->fields;

$current_score = gen_score($playerinfo[player_id]);
playerlog($playerinfo[player_id], LOG_LOGOUT, $ip);

bigtitle();
echo "$l_logout_score ".NUMBER($current_score).".<BR>";
$l_logout_text=str_replace("[name]",$username,$l_logout_text);
echo $l_logout_text;

include("footer.php");

?>
Ejemplo n.º 2
0
function IGB_borrow()
{
  global $playerinfo, $account, $amount, $ibank_loanlimit, $ibank_loanfactor;
  global $l_igb_invalidamount,$l_igb_notwoloans, $l_igb_loantoobig;
  global $l_igb_takenaloan, $l_igb_loancongrats, $l_igb_loantransferred;
  global $l_igb_loanfee, $l_igb_amountowned, $IGB_lrate, $IGB_crate, $l_igb_loanreminder, $l_igb_cloanreminder;
  global $db, $dbtables, $l_igb_back, $l_igb_logout;

  $amount = StripNonNum($amount);
  if(($amount * 1) != $amount)
    IGB_error($l_igb_invalidamount, "IGB.php?kk=".date("U")."&command=loans");

  if($amount <= 0)
    IGB_error($l_igb_invalidamount, "IGB.php?kk=".date("U")."&command=loans");

  if($account[loan] != 0)
    IGB_error($l_igb_notwoloans, "IGB.php?kk=".date("U")."&command=loans");

  $score = gen_score($playerinfo[player_id]);
  $maxtrans = $score * $score * $ibank_loanlimit;

  if($amount > $maxtrans)
    IGB_error($l_igb_loantoobig, "IGB.php?kk=".date("U")."&command=loans");

  $amount2 = $amount * $ibank_loanfactor;
  $amount3= $amount + $amount2;

  $hours = $IGB_lrate / 60;
  $mins = $IGB_lrate % 60;

  $l_igb_loanreminder = str_replace("[hours]", $hours, $l_igb_loanreminder);
  $l_igb_loanreminder = str_replace("[mins]", $mins, $l_igb_loanreminder);

  $chours = $IGB_crate / 60;
  $cmins = $IGB_crate % 60;

  $l_igb_cloanreminder = str_replace("[hours]", $chours, $l_igb_cloanreminder);
  $l_igb_cloanreminder = str_replace("[mins]", $cmins, $l_igb_cloanreminder);

  echo "<tr><td colspan=2 align=center valign=top><font size=2 face=\"courier new\" color=#00FF00>$l_igb_takenaloan<br>---------------------------------</td></tr>" .
       "<tr valign=top><td colspan=2 align=center><font size=2 face=\"courier new\" color=#00FF00>$l_igb_loancongrats<br><br></tr>" .
       "<tr valign=top>" .
       "<td><font size=2 face=\"courier new\" color=#00FF00>$l_igb_loantransferred :</td><td nowrap align=right><font size=2 face=\"courier new\" color=#00FF00>" . NUMBER($amount) . " C<br>" .
       "<tr valign=top>" .
       "<td><font size=2 face=\"courier new\" color=#00FF00>$l_igb_loanfee :</td><td nowrap align=right><font size=2 face=\"courier new\" color=#00FF00>" . NUMBER($amount2) . " C<br>" .
       "<tr valign=top>" .
       "<td><font size=2 face=\"courier new\" color=#00FF00>$l_igb_amountowned :</td><td nowrap align=right><font size=2 face=\"courier new\" color=#00FF00>" . NUMBER($amount3) . " C<br>" .
       "<tr valign=top>" .
       "<td colspan=2 align=center><font size=2 face=\"courier new\" color=#00FF00>---------------------------------<br><br>$l_igb_loanreminder $l_igb_cloanreminder</td>" .
       "<tr valign=top>" .
       "<td nowrap><font size=2 face=\"courier new\" color=#00FF00><a href=IGB.php?kk=".date("U")."&command=login>$l_igb_back</a></td><td nowrap align=right><font size=2 face=\"courier new\" color=#00FF00>&nbsp;<a href=\"main.php?kk=".date("U")."\">$l_igb_logout</a></td>" .
       "</tr>";

  $db->Execute("UPDATE $dbtables[ibank_accounts] SET loan=$amount3, loantime=NOW() WHERE player_id=$playerinfo[player_id]");
  $db->Execute("UPDATE $dbtables[players] SET credits=credits+$amount WHERE player_id=$playerinfo[player_id]");
  $db->Execute("INSERT INTO $dbtables[ibank_statement] SET player_id=$playerinfo[player_id], amount=$amount, trans_type=3"); // Type 3 = loan
}
Ejemplo n.º 3
0
//$db->Execute("LOCK TABLES $dbtables[players] WRITE, $dbtables[ships] WRITE, $dbtables[universe] WRITE, $dbtables[bounty] WRITE, $dbtables[zones] READ, $dbtables[planets] WRITE, $dbtables[news] WRITE, $dbtables[logs] WRITE, $dbtables[ship_types] READ");
$result = $db->Execute ("SELECT * FROM $dbtables[players] WHERE email='$username'");
$playerinfo=$result->fields;
// Find out what my ship is
$res = $db->Execute("SELECT * FROM $dbtables[ships] WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship] LIMIT 1");
$shipinfo = $res->fields;

$ship_id = stripnum($ship_id);

$res = $db->Execute("SELECT * FROM $dbtables[ship_types],$dbtables[ships] WHERE $dbtables[ship_types].type_id=$dbtables[ships].type AND  $dbtables[ships].ship_id=$ship_id LIMIT 1");
$targetshipinfo = $res->fields;
$result2 = $db->Execute ("SELECT * FROM $dbtables[players] WHERE player_id=$targetshipinfo[player_id]");
$targetinfo=$result2->fields;

$playerscore = gen_score($playerinfo[player_id]);
$targetscore = gen_score($targetinfo[player_id]);

//$playerscore = $playerscore * $playerscore;
//$targetscore = $targetscore * $targetscore;

bigtitle();

srand((double)microtime()*1000000);

/* check to ensure target is in the same sector as player */
if($targetinfo[sector] != $playerinfo[sector] || $targetinfo[on_planet] == "Y" || $targetshipinfo[sector] != $playerinfo[sector])
{
  echo "$l_att_notarg<BR><BR>";
}
elseif($playerinfo[turns] < 1)
{
Ejemplo n.º 4
0
// Blacknova Traders - A web-based massively multiplayer space combat and trading game
// Copyright (C) 2001-2012 Ron Harwood and the BNT development team
//
//  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: sched_ranking.php
if (preg_match("/sched_ranking.php/i", $_SERVER['PHP_SELF'])) {
    echo "You can not access this file directly!";
    die;
}
echo "<strong>Ranking</strong><br><br>";
$res = $db->Execute("SELECT ship_id FROM {$db->prefix}ships WHERE ship_destroyed='N'");
db_op_result($db, $res, __LINE__, __FILE__, $db_logging);
while (!$res->EOF) {
    gen_score($res->fields['ship_id']);
    $res->MoveNext();
}
echo "<br>";
$multiplier = 0;
Ejemplo n.º 5
0
        echo "{$l_notenough_cargo}  <a href=planet.php?planet_id={$planet_id}>{$l_clickme}</a> {$l_toplanetmenu}<br><br>";
    } elseif ($trade_energy > $free_power) {
        echo "{$l_notenough_power} <a href=planet.php?planet_id={$planet_id}>{$l_clickme}</a> {$l_toplanetmenu}<br><br>";
    } elseif ($playerinfo['turns'] < 1) {
        echo "{$l_notenough_turns}<br><br>";
    } elseif ($playerinfo['credits'] < $total_cost) {
        echo "{$l_notenough_credits}<br><br>";
    } elseif ($trade_organics > $planetinfo['organics']) {
        echo "{$l_exceed_organics}  ";
    } elseif ($trade_ore > $planetinfo['ore']) {
        echo "{$l_exceed_ore}  ";
    } elseif ($trade_goods > $planetinfo['goods']) {
        echo "{$l_exceed_goods}  ";
    } elseif ($trade_energy > $planetinfo['energy']) {
        echo "{$l_exceed_energy}  ";
    } else {
        echo "{$l_totalcost}: {$total_cost}<br>{$l_traded_ore}: {$trade_ore}<br>{$l_traded_organics}: {$trade_organics}<br>{$l_traded_goods}: {$trade_goods}<br>{$l_traded_energy}: {$trade_energy}<br><br>";
        // Update ship cargo, credits and turns
        $trade_result = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-1, turns_used=turns_used+1, credits=credits-{$total_cost}, ship_ore=ship_ore+{$trade_ore}, ship_organics=ship_organics+{$trade_organics}, ship_goods=ship_goods+{$trade_goods}, ship_energy=ship_energy+{$trade_energy} WHERE ship_id={$playerinfo['ship_id']}");
        db_op_result($db, $trade_result, __LINE__, __FILE__, $db_logging);
        $trade_result2 = $db->Execute("UPDATE {$db->prefix}planets SET ore=ore-{$trade_ore}, organics=organics-{$trade_organics}, goods=goods-{$trade_goods}, energy=energy-{$trade_energy}, credits=credits+{$total_cost} WHERE planet_id={$planet_id}");
        db_op_result($db, $trade_result2, __LINE__, __FILE__, $db_logging);
        echo "{$l_trade_complete}<br><br>";
    }
}
gen_score($planetinfo['owner']);
TEXT_GOTOMAIN();
?>
</div></div>
<?php 
include "footer.php";
Ejemplo n.º 6
0
include "header.php";
?>
<div class="tablecell content both-border">
	<div class="pad">
<?php 
if (checklogin()) {
    die;
}
$result = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id=?", array($user_ship_id));
db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
$playerinfo = $result->fields;
$result2 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id=?", array($ship_id));
db_op_result($db, $result2, __LINE__, __FILE__, $db_logging);
$targetinfo = $result2->fields;
$playerscore = gen_score($playerinfo['ship_id']);
$targetscore = gen_score($targetinfo['ship_id']);
$playerscore = $playerscore * $playerscore;
$targetscore = $targetscore * $targetscore;
bigtitle();
// Kami Multi Browser Window Attack Fix
if (array_key_exists('ship_selected', $_SESSION) == false || $_SESSION['ship_selected'] != $ship_id) {
    echo "You need to Click on the ship first.<BR><BR>";
    TEXT_GOTOMAIN();
    include "footer.php";
    die;
}
unset($_SESSION['ship_selected']);
// Check to ensure target is in the same sector as player
if ($targetinfo['sector'] != $playerinfo['sector']) {
    echo $l_planet_noscan;
} else {
Ejemplo n.º 7
0
         </TR>
         <TR bgcolor=$color_line1>
            <TD><b><font size=2 color=white>$l_traded_ore: </font><b></TD><TD align=right><b><font size=2 color=white>" . NUMBER($trade_ore) . "</font></b></TD>
         </TR>
         <TR bgcolor=$color_line2>
            <TD><b><font size=2 color=white>$l_traded_organics: </font><b></TD><TD align=right><b><font size=2 color=white>" . NUMBER($trade_organics) . "</font></b></TD>
         </TR>
         <TR bgcolor=$color_line1>
            <TD><b><font size=2 color=white>$l_traded_goods: </font><b></TD><TD align=right><b><font size=2 color=white>" . NUMBER($trade_goods) . "</font></b></TD>
         </TR>
         <TR bgcolor=$color_line2>
            <TD><b><font size=2 color=white>$l_traded_energy: </font><b></TD><TD align=right><b><font size=2 color=white>" . NUMBER($trade_energy) . "</font></b></TD>
         </TR>
      </TABLE>
      ";

			//echo "$l_totalcost: $total_cost<BR>$l_traded_ore: $trade_ore<BR>$l_traded_organics: $trade_organics<BR>$l_traded_goods: $trade_goods<BR>$l_traded_energy: $trade_energy<BR><BR>";
			/* Update ship cargo, credits and turns */
			$trade_result = $db->Execute ("UPDATE $dbtables[players] SET turns=turns-1, turns_used=turns_used+1, credits=credits-$total_cost where player_id=$playerinfo[player_id]");
			$trade_result = $db->Execute ("UPDATE $dbtables[ships] SET ship_ore=ship_ore+$trade_ore, ship_organics=ship_organics+$trade_organics, ship_goods=ship_goods+$trade_goods, ship_energy=ship_energy+$trade_energy where player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
			$trade_result2 = $db->Execute ("UPDATE $dbtables[planets] SET ore=ore-$trade_ore, organics=organics-$trade_organics, goods=goods-$trade_goods, energy=energy-$trade_energy, credits=credits+$total_cost WHERE planet_id=$planet_id");
			echo "$l_trade_complete<BR><BR>";
		}
	}

    gen_score($planetinfo[owner]);
    TEXT_GOTOMAIN();
	include("footer.php");

?>
Ejemplo n.º 8
0
function planetcombat()
{
	global $upgrade_cost, $upgrade_factor;
    global $playerinfo;
	global $shipinfo;
    global $ownerinfo;
	global $ownershipinfo;
    global $sectorinfo;
    global $planetinfo;
    global $torpedo_price;
    global $colonist_price;
    global $ore_price;
    global $organics_price;
    global $goods_price;
    global $energy_price;
	global $ibank_paymentfee;
    global $planetbeams;
    global $planetfighters;
    global $planetshields;
    global $planettorps;
    global $attackerbeams;
    global $attackerfighters;
    global $attackershields;
    global $attackertorps;
    global $attackerarmor;
    global $torp_dmg_rate;
    global $level_factor;
    global $attackertorpdamage;
    global $start_energy;
    global $min_value_capture;
    global $l_cmb_atleastoneturn;
    global $l_cmb_atleastoneturn, $l_cmb_shipenergybb, $l_cmb_shipenergyab, $l_cmb_shipenergyas, $l_cmb_shiptorpsbtl, $l_cmb_shiptorpsatl;
    global $l_cmb_planettorpdamage, $l_cmb_attackertorpdamage, $l_cmb_beams, $l_cmb_fighters, $l_cmb_shields, $l_cmb_torps;
    global $l_cmb_torpdamage, $l_cmb_armor, $l_cmb_you, $l_cmb_planet, $l_cmb_combatflow, $l_cmb_defender, $l_cmb_attackingplanet;
    global $l_cmb_youfireyourbeams, $l_cmb_defenselost, $l_cmb_defenselost2, $l_cmb_planetarybeams, $l_cmb_planetarybeams;
    global $l_cmb_youdestroyedplanetshields, $l_cmb_beamsexhausted, $l_cmb_breachedyourshields, $l_cmb_destroyedyourshields;
    global $l_cmb_breachedyourarmor, $l_cmb_destroyedyourarmor, $l_cmb_torpedoexchangephase, $l_cmb_nofightersleft;
    global $l_cmb_youdestroyfighters, $l_cmb_planettorpsdestroy, $l_cmb_planettorpsdestroy2, $l_cmb_torpsbreachedyourarmor;
    global $l_cmb_planettorpsdestroy3, $l_cmb_youdestroyedallfighters, $l_cmb_youdestroyplanetfighters, $l_cmb_fightercombatphase;
    global $l_cmb_youdestroyedallfighters2, $l_cmb_youdestroyplanetfighters2, $l_cmb_allyourfightersdestroyed, $l_cmb_fightertofighterlost;
    global $l_cmb_youbreachedplanetshields, $l_cmb_shieldsremainup, $l_cmb_fighterswarm, $l_cmb_swarmandrepel, $l_cmb_engshiptoshipcombat;
    global $l_cmb_shipdock, $l_cmb_approachattackvector, $l_cmb_noshipsdocked, $l_cmb_yourshipdestroyed, $l_cmb_escapepod;
    global $l_cmb_finalcombatstats, $l_cmb_youlostfighters, $l_cmb_youlostarmorpoints, $l_cmb_energyused, $l_cmb_planetdefeated;
    global $l_cmb_citizenswanttodie, $l_cmb_youmaycapture, $l_cmb_youmaycapture2, $l_cmb_planetnotdefeated, $l_cmb_planetstatistics;
    global $l_cmb_fighterloststat, $l_cmb_energyleft;
    global $db, $dbtables;
    //$debug = true;




    if($playerinfo[turns] < 1)
    {
        echo "$l_cmb_atleastoneturn<BR><BR>";
        TEXT_GOTOMAIN();
        include("footer.php");
        die();
    }

    // Planetary defense system calculation

    $planetbeams 		= calcplanetbeams();
    $planetfighters		= calcplanetfighters();
    $planetshields		= calcplanetshields();
    $planettorps		= calcplanettorps();

    // Attacking ship calculations

    $attackerbeams		= NUM_BEAMS($shipinfo[beams]);
    $attackerfighters	= $shipinfo[ship_fighters];
    $attackershields	= NUM_SHIELDS($shipinfo[shields]);
    $attackertorps		= round(mypw($level_factor, $shipinfo[torp_launchers])) * 2;
    $attackerarmor		= $shipinfo[armour_pts];

    // Now modify player beams, shields and torpedos on available materiel
    $starting_energy = $shipinfo[ship_energy];

    // Beams
    if ($debug)
        echo "$l_cmb_shipenergybb: $shipinfo[ship_energy]<BR>\n";
    if ($attackerbeams > $shipinfo[ship_energy])
        $attackerbeams   = $shipinfo[ship_energy];
    $shipinfo[ship_energy] = $shipinfo[ship_energy] - $attackerbeams;
    if ($debug)
        echo "$l_cmb_shipenergyab (before shields): $shipinfo[ship_energy]<BR>\n";

    // Shields
    if ($attackershields > $shipinfo[ship_energy])
        $attackershields = $shipinfo[ship_energy];
    $shipinfo[ship_energy] = $shipinfo[ship_energy] - $attackershields;
    if ($debug)
        echo "$l_cmb_shipenergyas: $shipinfo[ship_energy]<BR>\n";

    // Torpedos
    if ($debug)
        echo "$l_cmb_shiptorpsbtl: $attackertorps ($shipinfo[torps] / $shipinfo[torp_launchers])<BR>\n";
    if ($attackertorps > $shipinfo[torps])
        $attackertorps = $shipinfo[torps];
    $shipinfo[torps] = $shipinfo[torps] - $attackertorps;
    if ($debug)
        echo "$l_cmb_shiptorpsatl: $attackertorps ($shipinfo[torps] / $shipinfo[torp_launchers])<BR>\n";

    // Setup torp damage rate for both Planet and Ship
    $planettorpdamage	= $torp_dmg_rate * $planettorps;
    $attackertorpdamage	= $torp_dmg_rate * $attackertorps;
    if ($debug)
        echo "$l_cmb_planettorpdamage: $planettorpdamage<BR>\n";
    if ($debug)
        echo "$l_cmb_attackertorpdamage: $attackertorpdamage<BR>\n";


    echo "
    <CENTER>
    <HR>
    <table width='75%' border='0'>
    <tr ALIGN='CENTER'>
    <td width='9%' height='27'></td>
    <td width='12%' height='27'><FONT COLOR='WHITE'>$l_cmb_beams</FONT></td>
    <td width='17%' height='27'><FONT COLOR='WHITE'>$l_cmb_fighters</FONT></td>
    <td width='18%' height='27'><FONT COLOR='WHITE'>$l_cmb_shields</FONT></td>
    <td width='11%' height='27'><FONT COLOR='WHITE'>$l_cmb_torps</FONT></td>
    <td width='22%' height='27'><FONT COLOR='WHITE'>$l_cmb_torpdamage</FONT></td>
    <td width='11%' height='27'><FONT COLOR='WHITE'>$l_cmb_armor</FONT></td>
    </tr>
    <tr ALIGN='CENTER'>
    <td width='9%'> <FONT COLOR='RED'>$l_cmb_you</td>
    <td width='12%'><FONT COLOR='RED'><B>$attackerbeams</B></FONT></td>
    <td width='17%'><FONT COLOR='RED'><B>$attackerfighters</B></FONT></td>
    <td width='18%'><FONT COLOR='RED'><B>$attackershields</B></FONT></td>
    <td width='11%'><FONT COLOR='RED'><B>$attackertorps</B></FONT></td>
    <td width='22%'><FONT COLOR='RED'><B>$attackertorpdamage</B></FONT></td>
    <td width='11%'><FONT COLOR='RED'><B>$attackerarmor</B></FONT></td>
    </tr>
    <tr ALIGN='CENTER'>
    <td width='9%'> <FONT COLOR='#6098F8'>$l_cmb_planet</FONT></td>
    <td width='12%'><FONT COLOR='#6098F8'><B>$planetbeams</B></FONT></td>
    <td width='17%'><FONT COLOR='#6098F8'><B>$planetfighters</B></FONT></td>
    <td width='18%'><FONT COLOR='#6098F8'><B>$planetshields</B></FONT></td>
    <td width='11%'><FONT COLOR='#6098F8'><B>$planettorps</B></FONT></td>
    <td width='22%'><FONT COLOR='#6098F8'><B>$planettorpdamage</B></FONT></td>
    <td width='11%'><FONT COLOR='#6098F8'><B>N/A</B></FONT></td>
    </tr>
    </table>
    <HR>
    </CENTER>
    ";
    // Begin actual combat calculations

    $planetdestroyed   = 0;
    $attackerdestroyed = 0;

    echo "<BR><CENTER><B><FONT SIZE='+2'>$l_cmb_combatflow</FONT></B><BR><BR>\n";
    echo "<table width='75%' border='0'><tr align='center'><td><FONT COLOR='RED'>$l_cmb_you</FONT></td><td><FONT COLOR='#6098F8'>$l_cmb_defender</FONT></td>\n";
    echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_attackingplanet $playerinfo[sector]</b></FONT></td><td></td>";
    echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youfireyourbeams</b></FONT></td><td></td>\n";
    if($planetfighters > 0 && $attackerbeams > 0)
    {
        if($attackerbeams > $planetfighters)
        {
            $l_cmb_defenselost = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_defenselost);
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_defenselost</B></FONT>";
            $planetfighters = 0;
            $attackerbeams = $attackerbeams - $planetfighters;
        }
        else
        {
            $l_cmb_defenselost2 = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_defenselost2);
            $planetfighters = $planetfighters - $attackerbeams;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_defenselost2</B></FONT>";
            $attackerbeams = 0;
        }
    }

    if($attackerfighters > 0 && $planetbeams > 0)
    {
        // If there are more beams on the planet than attacker has fighters
        if($planetbeams > round($attackerfighters / 2))
        {
            // Half the attacker fighters
            $temp = round($attackerfighters / 2);
            // Attacker loses half his fighters
            $lost = $attackerfighters - $temp;
            // Set attacker fighters to 1/2 it's original value
            $attackerfighters = $temp;
            // Subtract half the attacker fighters from available planetary beams
            $planetbeams = $planetbeams - $lost;
            $l_cmb_planetarybeams = str_replace("[cmb_temp]", $temp, $l_cmb_planetarybeams);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planetarybeams</B></FONT><TD></TD>";
        }
        else
        {
            $l_cmb_planetarybeams2 = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_planetarybeams2);
            $attackerfighters = $attackerfighters - $planetbeams;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planetarybeams2</B></FONT><TD></TD>";
            $planetbeams = 0;
        }
    }
    if($attackerbeams > 0)
    {
        if($attackerbeams > $planetshields)
        {
            $attackerbeams = $attackerbeams - $planetshields;
            $planetshields = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedplanetshields</FONT></B><td></td>";
        }
        else
        {
            $l_cmb_beamsexhausted = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_beamsexhausted);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_beamsexhausted</FONT></B><td></td>";
            $planetshields = $planetshields - $attackerbeams;
            $attackerbeams = 0;
        }
    }
    if($planetbeams > 0)
    {
        if($planetbeams > $attackershields)
        {
            $planetbeams = $planetbeams - $attackershields;
            $attackershields = 0;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_breachedyourshields</FONT></B></td>";
        }
        else
        {
            $attackershields = $attackershields - $planetbeams;
            $l_cmb_destroyedyourshields = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_destroyedyourshields);
            echo "<tr align='center'><td></td><FONT COLOR='#6098F8'><B>$l_cmb_destroyedyourshields</FONT></B></td>";
            $planetbeams = 0;
        }
    }
    if($planetbeams > 0)
    {
        if($planetbeams > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_breachedyourarmor</B></FONT></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planetbeams;
            $l_cmb_destroyedyourarmor = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_destroyedyourarmor);
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_destroyedyourarmor</FONT></B></td>";
        }
    }
    echo "<tr align='center'><td><FONT COLOR='YELLOW'><B>$l_cmb_torpedoexchangephase</b></FONT></td><td><b><FONT COLOr='YELLOW'>$l_cmb_torpedoexchangephase</b></FONT></td><BR>";
    if($planetfighters > 0 && $attackertorpdamage > 0)
    {
        if($attackertorpdamage > $planetfighters)
        {
            $l_cmb_nofightersleft = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_nofightersleft);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_nofightersleft</FONT></B></td><td></td>";
            $planetfighters = 0;
            $attackertorpdamage = $attackertorpdamage - $planetfighters;
        }
        else
        {
            $planetfighters = $planetfighters - $attackertorpdamage;
            $l_cmb_youdestroyfighters = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_youdestroyfighters);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyfighters</FONT></B></td><td></td>";
            $attackertorpdamage = 0;
        }
    }
    if($attackerfighters > 0 && $planettorpdamage > 0)
    {
        if($planettorpdamage > round($attackerfighters / 2))
        {
            $temp = round($attackerfighters / 2);
            $lost = $attackerfighters - $temp;
            $attackerfighters = $temp;
            $planettorpdamage = $planettorpdamage - $lost;
            $l_cmb_planettorpsdestroy = str_replace("[cmb_temp]", $temp, $l_cmb_planettorpsdestroy);
            echo "<tr align='center'><td></td><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy</B></FONT></td>";
        }
        else
        {
            $attackerfighters = $attackerfighters - $planettorpdamage;
            $l_cmb_planettorpsdestroy2 = str_replace("[cmb_planettorpdamage]", $planettorpdamage, $l_cmb_planettorpsdestroy2);
            echo "<tr align='center'><td></td><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy2</B></FONT></td>";
            $planettorpdamage = 0;
        }
    }
    if($planettorpdamage > 0)
    {
        if($planettorpdamage > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_torpsbreachedyourarmor</B></FONT></td><td></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planettorpdamage;
            $l_cmb_planettorpsdestroy3 = str_replace("[cmb_planettorpdamage]", $planettorpdamage, $l_cmb_planettorpsdestroy3);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy3</B></FONT></td><td></td>";
        }
    }
    if($attackertorpdamage > 0 && $planetfighters > 0)
    {
        $planetfighters = $planetfighters - $attackertorpdamage;
        if ($planetfighters < 0)
        {
            $planetfighters = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedallfighters</B></FONT></td><td></td>";
        }
        else
        {
            $l_cmb_youdestroyplanetfighters = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_youdestroyplanetfighters);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyplanetfighters</B></FONT></td><td></td>";
        }
    }
    echo "<tr align='center'><td><FONT COLOR='YELLOW'><B>$l_cmb_fightercombatphase</b></FONT></td><td><b><FONT COLOr='YELLOW'>$l_cmb_fightercombatphase</b></FONT></td><BR>";
    if($attackerfighters > 0 && $planetfighters > 0)
    {
        if($attackerfighters > $planetfighters)
        {
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedallfighters2</B></FONT></td><td></td>";
            $tempplanetfighters = 0;
        }
        else
        {
            $l_cmb_youdestroyplanetfighters2 = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_youdestroyplanetfighters2);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyplanetfighters2</B></FONT></td><td></td>";
            $tempplanetfighters = $planetfighters - $attackerfighters;
        }
        if($planetfighters > $attackerfighters)
        {
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_allyourfightersdestroyed</B></FONT></td><td></td>";
            $tempplayfighters = 0;
        }
        else
        {
            $tempplayfighters = $attackerfighters - $planetfighters;
            $l_cmb_fightertofighterlost = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fightertofighterlost);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_fightertofighterlost</B></FONT></td><td></td>";
        }
        $attackerfighters = $tempplayfighters;
        $planetfighters = $tempplanetfighters;
    }
    if($attackerfighters > 0 && $planetshields > 0)
    {
        if($attackerfighters > $planetshields)
        {
            $attackerfighters = $attackerfighters - round($planetshields / 2);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youbreachedplanetshields</B></FONT></td><td></td>";
            $planetshields = 0;
        }
        else
        {
            $l_cmb_shieldsremainup = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_shieldsremainup);
            echo "<tr align='center'><td></td><FONT COLOR='#6098F8'><B>$l_cmb_shieldsremainup</B></FONT></td>";
            $planetshields = $planetshields - $attackerfighters;
        }
    }
    if($planetfighters > 0)
    {
        if($planetfighters > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_fighterswarm</B></FONT></td><td></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planetfighters;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_swarmandrepel</B></FONT></td><td></td>";
        }
    }

    echo "</TABLE></CENTER>\n";
    // Send each docked ship in sequence to attack agressor
    $result4 = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $playersonplanet = $result4->RecordCount();

    if ($playersonplanet > 0)
    {
        $l_cmb_shipdock = str_replace("[cmb_shipsonplanet]", $shipsonplanet, $l_cmb_shipdock);
        echo "<BR><BR><CENTER>$l_cmb_shipdock<BR>$l_cmb_engshiptoshipcombat</CENTER><BR><BR>\n";
        while (!$result4->EOF)
        {
            $onplanet = $result4->fields;
            //$shipinfo[ship_fighters] 	= $attackerfighters;
            //$shipinfo[armour_pts] 	= $attackerarmor;
            //$shipinfo[torps]			= $shipinfo[torps] - $attackertorps;

            if ($attackerfighters < 0)
                $attackerfighters = 0;
            if ($attackertorps    < 0)
                $attackertorps = 0;
            if ($attackershields  < 0)
                $attackershields = 0;
            if ($attackerbeams    < 0)
                $attackerbeams = 0;
            if ($attackerarmor    < 1)
                break;

            echo "<BR>-$onplanet[character_name] $l_cmb_approachattackvector-<BR>";
            shiptoship($onplanet[currentship]);
            $result4->MoveNext();
        }
    }
    else
        echo "<BR><BR><CENTER>$l_cmb_noshipsdocked</CENTER><BR><BR>\n";

    if($attackerarmor < 1)
    {
		// Planet attacked and attacked blew up
        $free_ore = round($shipinfo[ship_ore]/2);
        $free_organics = round($shipinfo[ship_organics]/2);
        $free_goods = round($shipinfo[ship_goods]/2);
        $ship_value=$upgrade_cost*(round(mypw($upgrade_factor, $shipinfo[hull]))+round(mypw($upgrade_factor, $shipinfo[engines]))+round(mypw($upgrade_factor, $shipinfo[power]))+round(mypw($upgrade_factor, $shipinfo[computer]))+round(mypw($upgrade_factor, $shipinfo[sensors]))+round(mypw($upgrade_factor, $shipinfo[beams]))+round(mypw($upgrade_factor, $shipinfo[torp_launchers]))+round(mypw($upgrade_factor, $shipinfo[shields]))+round(mypw($upgrade_factor, $shipinfo[armor]))+round(mypw($upgrade_factor, $shipinfo[cloak])));
        $ship_salvage_rate=rand(0,10);
        $ship_salvage=$ship_value*$ship_salvage_rate/100;
		// Triple salvage if this is an outlaw
		$result3 = $db->Execute ("SELECT amount FROM $dbtables[bounty] WHERE placed_by=0 AND bounty_on=$playerinfo[player_id]");
		$fugitive="";
		if (!$result3->EOF) {
			echo "Triple hull salvage goes to $ownerinfo[character_name] because you were a fugitive!<br>";
			$ship_salvage *=3;
			$fugitive = "Fugitive from justice ";
		}

        echo "<BR><CENTER><FONT SIZE='+2' COLOR='RED'><B>$l_cmb_yourshipdestroyed</FONT></B></CENTER><BR>";
		// news
		$headline="Planet Attacked!";
		$newstext=$fugitive.$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." led an attack today against ".$ownerinfo[character_name]."'s planet ".$planetinfo[name]." but was brought down by heavy planetary defenses. ";
		if ($playerinfo[score] < $ownerinfo[score]) {
			$newstext = $newstext . $playerinfo[character_name]." knew it would be an uphill battle and it was. Too bad.";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." thought it would be an easy battle but underestimated the planet defenses. Next time look before you leap.";
		}
		if ($fugitive != "") {
			$newstext .= " $ownerinfo[character_name] collected triple salvage from the outlaw's ship wreckage!";
		}
		$newstext = addslashes($newstext);
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");

        if($shipinfo[dev_escapepod] == "Y")
        {
            echo "<CENTER><FONT COLOR='WHITE'>$l_cmb_escapepod</FONT></CENTER><BR><BR>";
            $db->Execute("UPDATE $dbtables[players] SET on_planet='N',sector=0 WHERE player_id=$playerinfo[player_id]");
			// Immediately release any ships being towed 
    		if ($shipinfo[tow] > 0) {
				$db->Execute("UPDATE $dbtables[ships] SET player_id=0,on_planet='N',sector=$shipinfo[sector] WHERE ship_id=$shipinfo[tow]");
  			}
		$db->Execute("UPDATE $dbtables[ships] SET ship_destroyed ='Y', sector=0, tow=0 WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
            collect_bounty($planetinfo[owner],$playerinfo[player_id]);
        }
        else
        {
            db_kill_player($playerinfo[player_id],$playerinfo[currentship],$planetinfo[owner]);
            collect_bounty($planetinfo[owner],$playerinfo[player_id]);
        }
    }
    else
    {
		// ********************* Attacker survived ****************************
        $free_ore=0;
        $free_goods=0;
        $free_organics=0;
        $ship_salvage_rate=0;
        $ship_salvage=0;
        $planetrating = $ownershipinfo[hull] + $ownershipinfo[engines] + $ownershipinfo[computer] + $ownershipinfo[beams] + $ownershipinfo[torp_launchers] + $ownershipinfo[shields] + $ownershipinfo[armor];
        if($ownerinfo[rating]!=0)
        {
            $rating_change=($ownerinfo[rating]/abs($ownerinfo[rating]))*$planetrating*10;
        }
        else
        {
            $rating_change=-100;
        }
        echo "<CENTER><BR><B><FONT SIZE='+2'>$l_cmb_finalcombatstats</FONT></B><BR><BR>";
        $fighters_lost = $shipinfo[ship_fighters] - $attackerfighters;
        $l_cmb_youlostfighters = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_youlostfighters);
        $l_cmb_youlostfighters = str_replace("[cmb_playerinfo_ship_fighters]", $shipinfo[ship_fighters], $l_cmb_youlostfighters);
        echo "$l_cmb_youlostfighters<BR>";
        $armor_lost = $shipinfo[armour_pts] - $attackerarmor;
        $l_cmb_youlostarmorpoints = str_replace("[cmb_armor_lost]", $armor_lost, $l_cmb_youlostarmorpoints);
        $l_cmb_youlostarmorpoints = str_replace("[cmb_playerinfo_armour_pts]", $shipinfo[armour_pts], $l_cmb_youlostarmorpoints);
        $l_cmb_youlostarmorpoints = str_replace("[cmb_attackerarmor]", $attackerarmor, $l_cmb_youlostarmorpoints);
        echo "$l_cmb_youlostarmorpoints<BR>";
        $energy=$shipinfo[ship_energy];
        $energy_lost = $starting_energy - $shipinfo[ship_energy];
        $l_cmb_energyused = str_replace("[cmb_energy_lost]", $energy_lost, $l_cmb_energyused);
        $l_cmb_energyused = str_replace("[cmb_playerinfo_ship_energy]", $starting_energy, $l_cmb_energyused);
        echo "$l_cmb_energyused<BR></CENTER>";
        $db->Execute("UPDATE $dbtables[players] SET rating=rating-$rating_change WHERE player_id=$playerinfo[player_id]");
		$db->Execute("UPDATE $dbtables[ships] SET ship_energy=$energy,ship_fighters=ship_fighters-$fighters_lost, torps=torps-$attackertorps,armour_pts=armour_pts-$armor_lost WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
    }

    $result4 = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $shipsonplanet = $result4->RecordCount();

    if($planetshields < 1 && $planetfighters < 1 && $attackerarmor > 0 && $shipsonplanet == 0)
    {
		// ************************  Planet defeated ***********************************
        echo "<BR><BR><CENTER><FONT COLOR='GREEN'><B>$l_cmb_planetdefeated</b></FONT></CENTER><BR><BR>";
		// news
		$headline="Planetary Defeat!";
		$newstext=$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." defeated ".$ownerinfo[character_name]."s planet ".$planetinfo[name].". ";
		if ($playerinfo[score] < $ownerinfo[score]) {
			$newstext = $newstext . $playerinfo[character_name]." knew it would be a difficult battle but succeeded!";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." crushed the weak.";
		}
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");
	
        if($min_value_capture != 0)
        {
            $playerscore = gen_score($playerinfo[player_id]);
            $playerscore *= $playerscore;

            $planetscore = $planetinfo[organics] * $organics_price + $planetinfo[ore] * $ore_price + $planetinfo[goods] * $goods_price + $planetinfo[energy] * $energy_price + $planetinfo[fighters] * $fighter_price + $planetinfo[torps] * $torpedo_price + $planetinfo[colonists] * $colonist_price + $planetinfo[credits];
            $planetscore = $planetscore * $min_value_capture / 100;

            //            echo "playerscore $playerscore, planetscore $planetscore";
            if($playerscore < $planetscore)
            {
                echo "<CENTER>$l_cmb_citizenswanttodie</CENTER><BR><BR>";
                $db->Execute("DELETE FROM $dbtables[planets] WHERE planet_id=$planetinfo[planet_id]");
                playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED_D, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
                adminlog(LOG_ADMIN_PLANETDEL, "$playerinfo[character_name]|$ownerinfo[character_name]|$playerinfo[sector]");
                gen_score($ownerinfo[player_id]);
            }
            else
            {
                $l_cmb_youmaycapture = str_replace("[cmb_planetinfo_planet_id]", $planetinfo[planet_id], $l_cmb_youmaycapture);
                echo "<CENTER><font color=red>$l_cmb_youmaycapture</font></CENTER><BR><BR>";
                playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
                gen_score($ownerinfo[player_id]);
				// Make sure that credits are reduced on the planet
                $update7a = $db->Execute("UPDATE $dbtables[planets] SET owner=0, fighters=0, torps=torps-$planettorps, base='N', defeated='Y',credits=(credits*(1-$ibank_paymentfee*5)) WHERE planet_id=$planetinfo[planet_id]");
            }
        }
        else
        {
            $l_cmb_youmaycapture2 = str_replace("[cmb_planetinfo_planet_id]", $planetinfo[planet_id], $l_cmb_youmaycapture2);
            echo "<CENTER>$l_cmb_youmaycapture2</CENTER><BR><BR>";
            playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
            gen_score($ownerinfo[player_id]);
            $update7a = $db->Execute("UPDATE $dbtables[planets] SET owner=0,fighters=0, torps=torps-$planettorps, base='N', defeated='Y', credits=(credits*(1-$ibank_paymentfee*5)) WHERE planet_id=$planetinfo[planet_id]");
        }
        calc_ownership($planetinfo[sector_id]);
    }
    else if($attackerarmor < 1)
    {
		// *****************************   Planet not defeated and attacker blew up ************************
        echo "<BR><BR><CENTER><FONT COLOR='#6098F8'><B>$l_cmb_planetnotdefeated</B></FONT></CENTER><BR><BR>";
        if ($debug)
            echo "<BR><BR>$l_cmb_planetstatistics<BR><BR>";
        $fighters_lost = $planetinfo[fighters] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo[fighters], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        if ($debug)
            echo "$l_cmb_fighterloststat<BR>";
        $energy=$planetinfo[energy];
        if ($debug)
            echo "$l_cmb_energyleft: $planetinfo[energy]<BR>";
        playerlog($ownerinfo[player_id], LOG_PLANET_NOT_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]|".NUMBER($free_ore)."|".NUMBER($free_organics)."|".NUMBER($free_goods)."|$ship_salvage_rate|".NUMBER($ship_salvage));
        gen_score($ownerinfo[player_id]);
        $update7b = $db->Execute("UPDATE $dbtables[planets] SET energy=$energy,fighters=fighters-$fighters_lost, torps=torps-$planettorps, ore=ore+$free_ore, goods=goods+$free_goods, organics=organics+$free_organics, credits=credits+$ship_salvage WHERE planet_id=$planetinfo[planet_id]");
        if ($debug)
            echo "<BR>Set: energy=$energy, fighters lost=$fighters_lost, torps=$planetinfo[torps], sectorid=$sectorinfo[sector_id]<BR>";
    } else {
		// *****************************   Planet not defeated and attacker survived ************************
        echo "<BR><BR><CENTER><FONT COLOR='#6098F8'><B>$l_cmb_planetnotdefeated</B></FONT></CENTER><BR><BR>";
        $fighters_lost = $planetinfo[fighters] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo[fighters], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        $energy=$planetinfo[energy];
        playerlog($ownerinfo[player_id], LOG_PLANET_SURVIVED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
        gen_score($ownerinfo[player_id]);
        $update7b = $db->Execute("UPDATE $dbtables[planets] SET energy=$energy,fighters=fighters-$fighters_lost, torps=torps-$planettorps WHERE planet_id=$planetinfo[planet_id]");
		// news
		$headline="Planet Attack Fails!";
		$newstext=$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." attacked ".$ownerinfo[character_name]."'s planet ".$planetinfo[name]." but the planet's citizens put up an unexpected defense and forced $playerinfo[character_name] to retreat! SUN will continue to report this story as the news breaks!";
		$newstext = addslashes($newstext);
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");
 	}
    $update = $db->Execute("UPDATE $dbtables[players] SET turns=turns-1, turns_used=turns_used+1 WHERE player_id=$playerinfo[player_id]");
}
Ejemplo n.º 9
0
function planetcombat()
{
    global $playerinfo, $ownerinfo, $sectorinfo, $planetinfo, $torpedo_price, $colonist_price, $ore_price, $organics_price, $goods_price, $energy_price;
    global $planetbeams, $planetfighters, $planetshields, $planettorps, $attackerbeams, $attackerfighters, $attackershields, $upgrade_factor, $upgrade_cost;
    global $attackertorps, $attackerarmor, $torp_dmg_rate, $level_factor, $attackertorpdamage, $start_energy, $min_value_capture, $l_cmb_atleastoneturn;
    global $l_cmb_atleastoneturn, $l_cmb_shipenergybb, $l_cmb_shipenergyab, $l_cmb_shipenergyas, $l_cmb_shiptorpsbtl, $l_cmb_shiptorpsatl;
    global $l_cmb_planettorpdamage, $l_cmb_beams, $l_cmb_fighters, $l_cmb_shields, $l_cmb_torps;
    global $l_cmb_torpdamage, $l_cmb_armor, $l_cmb_you, $l_cmb_planet, $l_cmb_combatflow, $l_cmb_defender, $l_cmb_attackingplanet;
    global $l_cmb_youfireyourbeams, $l_cmb_defenselost, $l_cmb_defenselost2, $l_cmb_planetarybeams, $l_cmb_planetarybeams2;
    global $l_cmb_youdestroyedplanetshields, $l_cmb_beamsexhausted, $l_cmb_breachedyourshields, $l_cmb_destroyedyourshields;
    global $l_cmb_breachedyourarmor, $l_cmb_destroyedyourarmor, $l_cmb_torpedoexchangephase, $l_cmb_nofightersleft;
    global $l_cmb_youdestroyfighters, $l_cmb_planettorpsdestroy, $l_cmb_planettorpsdestroy2, $l_cmb_torpsbreachedyourarmor;
    global $l_cmb_planettorpsdestroy3, $l_cmb_youdestroyedallfighters, $l_cmb_youdestroyplanetfighters, $l_cmb_fightercombatphase;
    global $l_cmb_youdestroyedallfighters2, $l_cmb_youdestroyplanetfighters2, $l_cmb_allyourfightersdestroyed, $l_cmb_fightertofighterlost;
    global $l_cmb_youbreachedplanetshields, $l_cmb_shieldsremainup, $l_cmb_fighterswarm, $l_cmb_swarmandrepel, $l_cmb_engshiptoshipcombat;
    global $l_cmb_shipdock, $l_cmb_approachattackvector, $l_cmb_noshipsdocked, $l_cmb_yourshipdestroyed, $l_cmb_escapepod;
    global $l_cmb_finalcombatstats, $l_cmb_youlostfighters, $l_cmb_youlostarmorpoints, $l_cmb_energyused, $l_cmb_planetdefeated;
    global $l_cmb_citizenswanttodie, $l_cmb_youmaycapture, $l_cmb_planetnotdefeated, $l_cmb_planetstatistics;
    global $l_cmb_fighterloststat, $l_cmb_energyleft;
    global $db, $db_logging;
    if ($playerinfo['turns'] < 1) {
        echo $l_cmb_atleastoneturn . "<br><br>";
        TEXT_GOTOMAIN();
        ?>
</div></div>
<?php 
        include "footer.php";
        die;
    }
    // Planetary defense system calculation
    $planetbeams = calcplanetbeams();
    $planetfighters = $planetinfo['fighters'];
    $planetshields = calcplanetshields();
    $planettorps = calcplanettorps();
    // Attacking ship calculations
    $attackerbeams = NUM_BEAMS($playerinfo['beams']);
    $attackerfighters = $playerinfo['ship_fighters'];
    $attackershields = NUM_SHIELDS($playerinfo['shields']);
    $attackertorps = round(pow($level_factor, $playerinfo['torp_launchers'])) * 2;
    $attackerarmor = $playerinfo['armor_pts'];
    // Now modify player beams, shields and torpedos on available materiel
    $start_energy = $playerinfo['ship_energy'];
    // Beams
    if ($attackerbeams > $playerinfo['ship_energy']) {
        $attackerbeams = $playerinfo['ship_energy'];
    }
    $playerinfo['ship_energy'] = $playerinfo['ship_energy'] - $attackerbeams;
    // Shields
    if ($attackershields > $playerinfo['ship_energy']) {
        $attackershields = $playerinfo['ship_energy'];
    }
    $playerinfo['ship_energy'] = $playerinfo['ship_energy'] - $attackershields;
    // Torpedos
    if ($attackertorps > $playerinfo['torps']) {
        $attackertorps = $playerinfo['torps'];
    }
    $playerinfo['torps'] = $playerinfo['torps'] - $attackertorps;
    // Setup torp damage rate for both Planet and Ship
    $planettorpdamage = $torp_dmg_rate * $planettorps;
    $attackertorpdamage = $torp_dmg_rate * $attackertorps;
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>STATS</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    // Begin actual combat calculations
    $planetdestroyed = 0;
    $attackerdestroyed = 0;
    echo "<br/>You are now engaging the planet in sector " . $playerinfo[sector] . "!<br/><br/>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Firing Your Beams</span></td></tr>";
    if ($planetfighters > 0 && $attackerbeams > 0) {
        if ($attackerbeams > $planetfighters) {
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary defense lost " . $planetfighters . " fighters to your beams</span></td></tr>";
            $attackerbeams = $attackerbeams - $planetfighters;
            $planetfighters = 0;
        } else {
            $planetfighters = $planetfighters - $attackerbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary defense lost " . $planetfighters . " fighters, but there are more coming!</span></td></tr>";
            $attackerbeams = 0;
        }
    }
    if ($attackerfighters > 0 && $planetbeams > 0) {
        // If there are more beams on the planet than attacker has fighters
        if ($planetbeams > round($attackerfighters / 2)) {
            // Half the attacker fighters
            $temp = round($attackerfighters / 2);
            // Attacker loses half his fighters
            $lost = $attackerfighters - $temp;
            // Set attacker fighters to 1/2 it's original value
            $attackerfighters = $temp;
            // Subtract half the attacker fighters from available planetary beams
            $planetbeams = $planetbeams - $lost;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams destroy " . $temp . " of your fighters</span></td></tr>";
        } else {
            $attackerfighters = $attackerfighters - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams destroy " . $planetbeams . " of your fighters</span></td></tr>";
            $planetbeams = 0;
        }
    }
    if ($attackerbeams > 0) {
        if ($attackerbeams > $planetshields) {
            $attackerbeams = $attackerbeams - $planetshields;
            $planetshields = 0;
            echo "<tr><td><span class=\"table_word_green\">Your beams have destroyed the planetary shields</span></td><td></td></tr>";
        } else {
            echo "<tr><td><span class=\"table_word_orange\">You destroy " . $attackerbeams . " planetary shields before your beams are exhausted</span></td><td></td></tr>";
            $planetshields = $planetshields - $attackerbeams;
            $attackerbeams = 0;
        }
    }
    if ($planetbeams > 0) {
        if ($planetbeams > $attackershields) {
            $planetbeams = $planetbeams - $attackershields;
            $attackershields = 0;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have breached your shields</span></td></tr>";
        } else {
            $attackershields = $attackershields - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have destroyed " . $planetbeams . " of your shields</span></td></tr>";
            $planetbeams = 0;
        }
    }
    if ($planetbeams > 0) {
        if ($planetbeams > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have breached your armor</span></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams have destroyed " . $planetbeams . " points of armor</span></td></tr>";
        }
    }
    if ($planetshields > 0) {
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planets shields have been breached!</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Torpedo Exchange Phase</span></td></tr>";
    if ($planetfighters > 0 && $attackertorpdamage > 0) {
        if ($attackertorpdamage > $planetfighters) {
            echo "<tr><td>Your torpedos destroy " . $planetfighters . " planetary fighters, no fighters are left</td><td></td></tr>";
            $attackertorpdamage = $attackertorpdamage - $planetfighters;
            $planetfighters = 0;
        } else {
            $planetfighters = $planetfighters - $attackertorpdamage;
            echo "<tr><td><span class=\"table_word_orange\">Your torpedos destroy " . $attackertorpdamage . " planetary fighters</span></td><td></td></tr>";
            $attackertorpdamage = 0;
        }
    }
    if ($attackerfighters > 0 && $planettorpdamage > 0) {
        if ($planettorpdamage > round($attackerfighters / 2)) {
            $temp = round($attackerfighters / 2);
            $lost = $attackerfighters - $temp;
            $attackerfighters = $temp;
            $planettorpdamage = $planettorpdamage - $lost;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary torpedos destroy " . $temp . " of your fighters</span></td></tr>";
        } else {
            $attackerfighters = $attackerfighters - $planettorpdamage;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary torpedos destroy " . $planettorpdamage . " of your fighters</span></td></tr>";
            $planettorpdamage = 0;
        }
    }
    if ($planettorpdamage > 0) {
        if ($planettorpdamage > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td><span class=\"table_word_red\">Planetary torpedos have breached your armor</span></td><td></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planettorpdamage;
            echo "<tr><td><span class=\"table_word_orange\">Planetary torpedos have destroyed " . $planettorpdamage . " points of armor</span></td><td></td></tr>";
        }
    }
    if ($attackertorpdamage > 0 && $planetfighters > 0) {
        $planetfighters = $planetfighters - $attackertorpdamage;
        if ($planetfighters < 0) {
            $planetfighters = 0;
            echo "<tr><td><span class=\"table_word_green\">Your torpedos have destroyed all the planetary fighters</span></td><td></td></tr>";
        } else {
            echo "<tr><td><span class=\"table_word_orange\">Your torpedos destroy " . $attackertorpdamage . " planetary fighters</span></td><td></td></tr>";
        }
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planet has no torpedoes</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Fighter Combat Phase</span></td></tr>";
    if ($attackerfighters > 0 && $planetfighters > 0) {
        if ($attackerfighters > $planetfighters) {
            echo "<tr><td><span class=\"table_word_green\">Your fighters have destroyed all the planetary fighters</span></td><td></td></tr>";
            $tempplanetfighters = 0;
        } else {
            echo "<tr><td><span class=\"table_word_orange\">Your fighters have destroyed " . $attackerfighters . " planetary fighters</span></td><td></td></tr>";
            $tempplanetfighters = $planetfighters - $attackerfighters;
        }
        if ($planetfighters > $attackerfighters) {
            echo "<tr><td><span class=\"table_word_red\">All your fighters were destroyed</span></td><td></td></tr>";
            $tempplayfighters = 0;
        } else {
            $tempplayfighters = $attackerfighters - $planetfighters;
            echo "<tr><td><span class=\"table_word_orange\">You lost " . $planetfighters . " fighters in fighter to fighter combat</span></td><td></td></tr>";
        }
        $attackerfighters = $tempplayfighters;
        $planetfighters = $tempplanetfighters;
    }
    if ($attackerfighters > 0 && $planetshields > 0) {
        if ($attackerfighters > $planetshields) {
            $attackerfighters = $attackerfighters - round($planetshields / 2);
            echo "<tr><td><span class=\"table_word_green\">Your fighters have breached the planetary shields</span></td><td></td></tr>";
            $planetshields = 0;
        } else {
            echo "<tr><td></td><td><span class=\"table_word_orange\">Your fighters destroyed " . $attackerfighters . " planetary shields, but they remain up</span></td></tr>";
            $planetshields = $planetshields - $attackerfighters;
        }
    }
    if ($planetfighters > 0) {
        if ($planetfighters > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td><span class=\"table_word_red\">Planetary fighters swarm your ship, your armor has been breached</span></td><td></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planetfighters;
            echo "<tr><td><span class=\"table_word_orange\">Planetary fighters swarm your ship, but your armor repels them</span></td><td></td></tr>";
        }
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planet has no fighters</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    // Send each docked ship in sequence to attack agressor
    $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id={$planetinfo['planet_id']} AND on_planet='Y'");
    db_op_result($db, $result4, __LINE__, __FILE__, $db_logging);
    $shipsonplanet = $result4->RecordCount();
    if ($shipsonplanet > 0) {
        echo "<br/>There are " . $shipsonplanet . " ships docked at Spacedock!<br>Engaging in Ship to Ship combat.<br/><br/>";
        while (!$result4->EOF) {
            $onplanet = $result4->fields;
            if ($attackerfighters < 0) {
                $attackerfighters = 0;
            }
            if ($attackertorps < 0) {
                $attackertorps = 0;
            }
            if ($attackershields < 0) {
                $attackershields = 0;
            }
            if ($attackerbeams < 0) {
                $attackerbeams = 0;
            }
            if ($attackerarmor < 1) {
                break;
            }
            echo "<br/>" . $onplanet[ship_name] . " is approaching on an attack vector<br/>";
            /*ENGAGE EACH SHIP ONE BY ONE!!!*/
            shiptoship($onplanet['ship_id']);
            $result4->MoveNext();
        }
    } else {
        /*no SHIPS on the planet, noting to worry about*/
    }
    if ($attackerarmor < 1) {
        $free_ore = round($playerinfo['ship_ore'] / 2);
        $free_organics = round($playerinfo['ship_organics'] / 2);
        $free_goods = round($playerinfo['ship_goods'] / 2);
        $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $playerinfo['hull'])) + round(pow($upgrade_factor, $playerinfo['engines'])) + round(pow($upgrade_factor, $playerinfo['power'])) + round(pow($upgrade_factor, $playerinfo['computer'])) + round(pow($upgrade_factor, $playerinfo['sensors'])) + round(pow($upgrade_factor, $playerinfo['beams'])) + round(pow($upgrade_factor, $playerinfo['torp_launchers'])) + round(pow($upgrade_factor, $playerinfo['shields'])) + round(pow($upgrade_factor, $playerinfo['armor'])) + round(pow($upgrade_factor, $playerinfo['cloak'])));
        $ship_salvage_rate = mt_rand(0, 10);
        $ship_salvage = $ship_value * $ship_salvage_rate / 100;
        echo "<br><center><font size='+2' COLOR='red'>{$l_cmb_yourshipdestroyed}</font></center><br>";
        if ($playerinfo['dev_escapepod'] == "Y") {
            echo "<center><font color='white'>{$l_cmb_escapepod}</font></center><br><br>";
            $resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0,engines=0,power=0,sensors=0,computer=0,beams=0,torp_launchers=0,torps=0,armor=0,armor_pts=100,cloak=0,shields=0,sector=0,ship_organics=0,ship_ore=0,ship_goods=0,ship_energy={$start_energy},ship_colonists=0,ship_fighters=100,dev_warpedit=0,dev_genesis=0,dev_beacon=0,dev_emerwarp=0,dev_escapepod='N',dev_fuelscoop='N',dev_minedeflector=0,on_planet='N',dev_lssd='N' WHERE ship_id={$playerinfo['ship_id']}");
            db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
            collect_bounty($planetinfo['owner'], $playerinfo['ship_id']);
        } else {
            db_kill_player($playerinfo['ship_id']);
            collect_bounty($planetinfo['owner'], $playerinfo['ship_id']);
        }
    } else {
        $free_ore = 0;
        $free_goods = 0;
        $free_organics = 0;
        $ship_salvage_rate = 0;
        $ship_salvage = 0;
        $planetrating = $ownerinfo['hull'] + $ownerinfo['engines'] + $ownerinfo['computer'] + $ownerinfo['beams'] + $ownerinfo['torp_launchers'] + $ownerinfo['shields'] + $ownerinfo['armor'];
        if ($ownerinfo['rating'] != 0) {
            $rating_change = $ownerinfo['rating'] / abs($ownerinfo['rating']) * $planetrating * 10;
        } else {
            $rating_change = -100;
        }
        echo "<br/>Final Combat Stats<br/><br/>";
        $fighters_lost = $playerinfo['ship_fighters'] - $attackerfighters;
        echo "You lost " . $fighters_lost . " out of " . $playerinfo['ship_fighters'] . " total fighters.<br/>";
        $armor_lost = $playerinfo['armor_pts'] - $attackerarmor;
        echo "You lost " . $armor_lost . " out of " . $playerinfo['armor_pts'] . " total armor points, you have " . $attackerarmor . " points remaining.<br/>";
        $energy = $playerinfo['ship_energy'];
        $energy_lost = $start_energy - $playerinfo['ship_energy'];
        echo "You used " . $energy_lost . " energy, from a total of " . $start_energy . " energy.<br/>";
        $resx = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy={$energy},ship_fighters=ship_fighters-{$fighters_lost}, torps=torps-{$attackertorps},armor_pts=armor_pts-{$armor_lost}, rating=rating-{$rating_change} WHERE ship_id={$playerinfo['ship_id']}");
        db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
    }
    $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id={$planetinfo['planet_id']} AND on_planet='Y'");
    db_op_result($db, $result4, __LINE__, __FILE__, $db_logging);
    $shipsonplanet = $result4->RecordCount();
    #################
    ### LOG AND UPDATE THE STATS
    ##################
    if ($planetshields < 1 && $planetfighters < 1 && $attackerarmor > 0 && $shipsonplanet == 0) {
        echo "<br/><br/><span class=\"table_word_green\">Planet defeated</span><br/><br/>";
        // Patch to stop players dumping credits for other players.
        $self_tech = get_avg_tech($playerinfo);
        $target_tech = round(get_avg_tech($ownerinfo));
        $roll = mt_rand(0, (int) $target_tech);
        if ($roll > $self_tech) {
            // Reset Planet Assets.
            $sql = "UPDATE {$db->prefix}planets ";
            $sql .= "SET organics = '0', ore = '0', goods = '0', energy = '0', colonists = '2', credits = '0', fighters = '0', torps = '0', corp = '0', base = 'N', sells = 'N', prod_organics = '20', prod_ore = '20', prod_goods = '20', prod_energy = '20', prod_fighters = '10', prod_torp = '10' ";
            $sql .= "WHERE `dev_planets`.`planet_id` ={$planetinfo['planet_id']} LIMIT 1;";
            $resx = $db->Execute($sql);
            db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
            echo "<div style='text-align:center; font-size:18px; color:#f00;'>The planet become unstable due to not being looked after, and all life and assets have been destroyed.</div>\n";
        }
        if ($min_value_capture != 0) {
            $playerscore = gen_score($playerinfo['ship_id']);
            $playerscore *= $playerscore;
            $planetscore = $planetinfo['organics'] * $organics_price + $planetinfo['ore'] * $ore_price + $planetinfo['goods'] * $goods_price + $planetinfo['energy'] * $energy_price + $planetinfo['fighters'] * $fighter_price + $planetinfo['torps'] * $torpedo_price + $planetinfo['colonists'] * $colonist_price + $planetinfo['credits'];
            $planetscore = $planetscore * $min_value_capture / 100;
            if ($playerscore < $planetscore) {
                echo "The citizens of this planet have decided they'd rather die than serve a pathetic ruler like you. They use a laser drill to dig a hole to the planet's core. You barely have time to escape into orbit before the whole planet is reduced to a ball of molten lava.<br/><br/>";
                $resx = $db->Execute("DELETE FROM {$db->prefix}planets WHERE planet_id={$planetinfo['planet_id']}");
                db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
                playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED_D, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
                adminlog($db, LOG_ADMIN_PLANETDEL, "{$playerinfo['character_name']}|{$ownerinfo['character_name']}|{$playerinfo['sector']}");
                gen_score($ownerinfo['ship_id']);
            } else {
                echo "You may <a href='planet.php?planet_id=", $planetinfo['planet_id'] . "&amp;command=capture'>capture</a> the planet or just leave it undefended.<br><br>";
                playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
                gen_score($ownerinfo['ship_id']);
                $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0, fighters=0, torps=torps-{$planettorps}, base='N', defeated='Y' WHERE planet_id={$planetinfo['planet_id']}");
                db_op_result($db, $update7a, __LINE__, __FILE__, $db_logging);
            }
        } else {
            echo "You may <a href='planet.php?planet_id=", $planetinfo['planet_id'] . "&amp;command=capture'>capture</a> the planet or just leave it undefended.<br><br>";
            playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
            gen_score($ownerinfo['ship_id']);
            $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0,fighters=0, torps=torps-{$planettorps}, base='N', defeated='Y' WHERE planet_id={$planetinfo['planet_id']}");
            db_op_result($db, $update7a, __LINE__, __FILE__, $db_logging);
        }
        calc_ownership($planetinfo['sector_id']);
    } else {
        echo "<br><br><span class=\"table_word_red\">Planet Not Defeated</span><br><br>";
        $fighters_lost = $planetinfo['fighters'] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo['fighters'], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        $energy = $planetinfo['energy'];
        playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_NOT_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}|{$free_ore}|{$free_organics}|{$free_goods}|{$ship_salvage_rate}|{$ship_salvage}");
        gen_score($ownerinfo['ship_id']);
        $update7b = $db->Execute("UPDATE {$db->prefix}planets SET energy={$energy},fighters=fighters-{$fighters_lost}, torps=torps-{$planettorps}, ore=ore+{$free_ore}, goods=goods+{$free_goods}, organics=organics+{$free_organics}, credits=credits+{$ship_salvage} WHERE planet_id={$planetinfo['planet_id']}");
        db_op_result($db, $update7b, __LINE__, __FILE__, $db_logging);
    }
    $update = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-1, turns_used=turns_used+1 WHERE ship_id={$playerinfo['ship_id']}");
    db_op_result($db, $update, __LINE__, __FILE__, $db_logging);
}
Ejemplo n.º 10
0
<?php 
            include "footer.php";
            die;
        }
        if ($amount > $playerinfo['credits']) {
            echo "{$l_by_notenough}<br><br>";
            TEXT_GOTOMAIN();
            ?>
</div></div>
<?php 
            include "footer.php";
            die;
        }
        if ($bounty_maxvalue != 0) {
            $percent = $bounty_maxvalue * 100;
            $score = gen_score($playerinfo['ship_id']);
            $maxtrans = $score * $score * $bounty_maxvalue;
            $previous_bounty = 0;
            $pb = $db->Execute("SELECT SUM(amount) AS totalbounty FROM {$db->prefix}ships WHERE bounty_on = ? AND placed_by = ?;", array($bounty_on, $playerinfo['ship_id']));
            db_op_result($db, $pb, __LINE__, __FILE__, $db_logging);
            if ($pb) {
                $prev = $pb->fields;
                $previous_bounty = $prev['totalbounty'];
            }
            if ($amount + $previous_bounty > $maxtrans) {
                $l_by_toomuch = str_replace("[percent]", $percent, $l_by_toomuch);
                echo "{$l_by_toomuch}<br><br>";
                TEXT_GOTOMAIN();
                ?>
</div></div>
<?php 
Ejemplo n.º 11
0
    echo "$l_by_yourself<BR><BR>";
    TEXT_GOTOMAIN();
    include("footer.php");
    die();
 }
 if($amount > $playerinfo['credits'])
 {
    echo "$l_by_notenough<BR><BR>";
    TEXT_GOTOMAIN();
    include("footer.php");
    die();
 }
 if($bounty_maxvalue != 0)
 {
    $percent = $bounty_maxvalue * 100;
    $score = gen_score($playerinfo[player_id]);
    $maxtrans = $score * $score * $bounty_maxvalue;
    $previous_bounty = 0;
    $pb = $db->Execute("SELECT SUM(amount) AS totalbounty FROM $dbtables[players] WHERE bounty_on = $bounty_on AND placed_by = $playerinfo[player_id]");
    if($pb)
    {
       $prev = $pb->fields;
       $previous_bounty = $prev[totalbounty];
    }
    if($amount + previous_bounty > $maxtrans)
    {   
       echo "$l_by_toomuch<BR><BR>";
       TEXT_GOTOMAIN();
       include("footer.php");
       die();
    }
Ejemplo n.º 12
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";
?>
<div class="tablecell content both-border">
	<div class="pad">
<?php 
$current_score = 0;
if (!isset($username)) {
    $username = '';
} else {
    $result = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id='{$user_ship_id}'");
    db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
    $playerinfo = $result->fields;
    $current_score = gen_score($playerinfo['ship_id']);
    ##New Log ##
    $manage_log->player_log($playerinfo['ship_id'], 2, '', '', '', '', "<font color='#6190a5'>Low Priority</font>", "<b>Logged Out</b>");
}
bigtitle();
echo $l_logout_score . " " . $current_score . ".<br>";
$l_logout_text = str_replace("[name]", $username, $l_logout_text);
$l_logout_text = str_replace("[here]", "<a href='index.php'>" . $l_here . "</a>", $l_logout_text);
echo $l_logout_text;
?>
</div></div>
<?php 
include "footer.php";
Ejemplo n.º 13
0
	// Check to make sure that this is not just a ship that is being towed
	$res3 = $db->Execute("SELECT tow FROM $dbtables[ships] WHERE player_id=$parked[player_id] AND tow=$parked[ship_id]");
	if ($res3->EOF) {
	  $res4=$db->Execute("SELECT * FROM $dbtables[players] WHERE player_id=$parked[player_id] AND currentship=$parked[ship_id]");
	  if ($res4->EOF) {
		// Get bank account of those who are parked
		$res2 = $db->Execute("SELECT balance FROM $dbtables[ibank_accounts] WHERE player_id=$parked[player_id] ");
		$row = $res2->fields;
		$row[balance] -= $mooringFee;
		if ($row[balance] <0) {
			echo "We are taking a ship of player $parked[player_id]!<br>";
			$db->Execute("UPDATE $dbtables[ibank_accounts] SET balance=0, loantime=loantime WHERE player_id=$parked[player_id]");
			$db->Execute("UPDATE $dbtables[ships] SET player_id=1 WHERE ship_id=$parked[ship_id]");
			echo "The Federation took your ship $parked[ship_name] for failure to pay the space dock mooring fee.<br>";
			playerlog($parked[player_id], LOG_RAW, "The Federation took your ship $parked[ship_name] for failure to pay the space dock mooring fee.");
			gen_score($parked[player_id]);
		} else {
			echo "Deducting $mooringFee credits from $parked[player_id] player<br>";
			//echo "UPDATE $dbtables[ibank_accounts] SET balance=balance-$mooringFee, loantime=loantime WHERE player_id=$parked[player_id]<br>";
			$db->Execute("UPDATE $dbtables[ibank_accounts] SET balance=balance-$mooringFee, loantime=loantime WHERE player_id=$parked[player_id]");
		}
		if ($row[balance] < 10000) {
			// Send out warning
			echo "Your IGB account is running dangerously low and your ship $parked[ship_name] is in danger of being taken by the Federation for failure to pay the Sector $parked[sector] space dock fee!<br>";
			playerlog($parked[player_id], LOG_RAW, "Your IGB account is running dangerously low and your ship $parked[ship_name] is in danger of being taken by the Federation for failure to pay the Sector $parked[sector] space dock fee! You only have $row[balance] credits left in your IGB account.");
		}
	   }
	}
    $res->MoveNext();
  }
echo "<BR>";
Ejemplo n.º 14
0
function IGB_borrow()
{
    global $playerinfo, $account, $amount, $ibank_loanlimit, $ibank_loanfactor;
    global $l_igb_invalidamount, $l_igb_notwoloans, $l_igb_loantoobig;
    global $l_igb_takenaloan, $l_igb_loancongrats, $l_igb_loantransferred;
    global $l_igb_loanfee, $l_igb_amountowned, $IGB_lrate, $l_igb_loanreminder, $l_igb_loanreminder2;
    global $db, $db_logging, $l_igb_back, $l_igb_logout;
    $amount = StripNonNum($amount);
    if ($amount * 1 != $amount) {
        IGB_error($l_igb_invalidamount, "igb.php?command=loans");
    }
    if ($amount <= 0) {
        IGB_error($l_igb_invalidamount, "igb.php?command=loans");
    }
    if ($account['loan'] != 0) {
        IGB_error($l_igb_notwoloans, "igb.php?command=loans");
    }
    $score = gen_score($playerinfo['ship_id']);
    $maxtrans = $score * $score * $ibank_loanlimit;
    if ($amount > $maxtrans) {
        IGB_error($l_igb_loantoobig, "igb.php?command=loans");
    }
    $amount2 = $amount * $ibank_loanfactor;
    $amount3 = $amount + $amount2;
    $hours = $IGB_lrate / 60;
    $mins = $IGB_lrate % 60;
    $l_igb_loanreminder = str_replace("[hours]", $hours, $l_igb_loanreminder);
    $l_igb_loanreminder = str_replace("[mins]", $mins, $l_igb_loanreminder);
    echo "<tr><td colspan=2 align=center valign=top>{$l_igb_takenaloan}<br>---------------------------------</td></tr>" . "<tr valign=top><td colspan=2 align=center>{$l_igb_loancongrats}<br><br></tr>" . "<tr valign=top>" . "<td>{$l_igb_loantransferred} :</td><td nowrap align=right>" . NUMBER($amount) . " C<br>" . "<tr valign=top>" . "<td>{$l_igb_loanfee} :</td><td nowrap align=right>" . NUMBER($amount2) . " C<br>" . "<tr valign=top>" . "<td>{$l_igb_amountowned} :</td><td nowrap align=right>" . NUMBER($amount3) . " C<br>" . "<tr valign=top>" . "<td colspan=2 align=center>---------------------------------<br><br>{$l_igb_loanreminder}<br><br>\"" . $l_igb_loanreminder2 . "\"</td>" . "<tr valign=top>" . "<td nowrap><a href='igb.php?command=login'>{$l_igb_back}</a></td><td nowrap align=right>&nbsp;<a href=\"main.php\">{$l_igb_logout}</a></td>" . "</tr>";
    $resx = $db->Execute("UPDATE {$db->prefix}ibank_accounts SET loan={$amount3}, loantime=NOW() WHERE ship_id={$playerinfo['ship_id']}");
    db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
    $resx = $db->Execute("UPDATE {$db->prefix}ships SET credits=credits+{$amount} WHERE ship_id={$playerinfo['ship_id']}");
    db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
}
Ejemplo n.º 15
0
<?

  if (preg_match("/sched_ranking.php/i", $PHP_SELF)) {
      echo "You can not access this file directly!";
      die();
  }
  $temp_time=time();
  echo "<B>RANKING</B><BR><BR>";
  $res = $db->Execute("SELECT player_id FROM $dbtables[players] WHERE turns_used > 100");
  while(!$res->EOF)
  {
    gen_score($res->fields[player_id]);
    $res->MoveNext();
  }
  echo "<BR>";
  $multiplier = 0;
  $temp_runtime= time() - $temp_time;
  echo "<p>Ranking took $temp_runtime seconds to execute.<p>";

?>