function hasResources($sid, $fid) { if (getFleetStat(civs, $sid, $fid) != 0 || getFleetStat(steel, $sid, $fid) != 0 || getFleetStat(cylite, $sid, $fid) != 0 || getFleetStat(plexi, $sid, $fid) != 0) { return true; } return false; }
function calcDef($sid, $pid) { $query = "SELECT id FROM fleet{$sid} WHERE loc={$pid} AND destination=0"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { for ($i = 1; $i < getShipNumber() + 1; $i++) { $str = "ship" . $i; $num += getShipStat(defend, $i) * getFleetStat($str, $sid, $row[id]); } } if (!($num > 0)) { $num = 0; } return $num + getPlantStat(cannon, $sid, $pid); }
break; } } for ($x = 1; $x < sizeof($ashiparray) + 1; $x++) { $str = "ship" . $x; setFleetStat($str, $ashiparray[$x], $sid, $afid); } } //The planet was conquered so change owner setPlanetStat(ownerid, getFleetStat(ownerid, $sid, $afid), $sid, $dpid); setPlanetStat(lastshipq, 0, $sid, $dpid); $query = "DELETE FROM shipq{$sid} WHERE pid={$dpid}"; $result = @mysql_query($query); } else { //Destroy losers fleet $endstr1 = 'You attacked <a href="./planetdetails.php?id=' . $dpid . '">' . getPlanetStat(name, $sid, $dpid) . '</a> with the fleet ' . getFleetStat(name, $sid, $afid) . '. Your attack lost with ' . $attack . ' attack to ' . $defence . ' defence.'; $endstr2 = 'Your planet <a href="./planetdetails.php?id=' . $dpid . '">' . getPlanetStat(name, $sid, $dpid) . '</a> was attacked by <a href="./profile.php?id=' . $aplayerid . '">' . getUserStat(username, $aplayerid) . '</a>. You defended with ' . $defence . ' defense to ' . $attack . ' attack.'; destroyFleet($sid, $afid); echo $endstr1; $tempdef = $attack; //For total dmg, do dmg to an attacking ship, if the saved dmg is enough to destroy the ship, //subtract it from the shiparraycounter then at the end update. //Check if the dmg is more than the hp of the fleet $dahp = calchp($sid, $dfid); echo $dahp; if ($dahp < $tempdef) { destroyFleet($sid, $dfid); } else { while ($tempdef > 1) { for ($x = 1; $x < sizeof($dshiparray) + 1; $x++) { if ($dshiparray[$x] > 0) {
while ($row = mysql_fetch_array($result)) { echo '<tr> <td><a href="./fname.php?id=' . $row[id] . '">' . $row[name] . '</a></td>'; //Print the planet name if on a planet or traveling if traveling if ($row[destination] > 0) { if (landFleet($sid, $row[id])) { echo '<td><a href="./planetdetails.php?id=' . $row[destination] . '">' . getPlanetStat(name, $sid, $row[destination]) . '</a></td>'; } else { echo '<td>Traveling</td>'; } } else { echo '<td><a href="./planetdetails.php?id=' . $row[loc] . '">' . getPlanetStat(name, $sid, $row[loc]) . '</a></td>'; } //Continue printing echo '<td>' . fleetSize($sid, $row[id]) . '</td>'; if (getFleetStat(destination, $sid, $row[id]) > 0) { $timeleft = timeLeft($row[destinationtime]); echo '<td><a href="./planetdetails.php?id=' . $row[destination] . '">' . getPlanetStat(name, $sid, $row[destination]) . '</a></td>'; if ($timeleft > 0) { echo '<td>' . $timeleft . '</td>'; } else { echo '<td>In Combat</td>'; } } else { echo '<td align="center">None</td> <td align="center">---</td>'; } echo '<td><a href="./fleetdetails.php?id=' . $row[id] . '">Details</a></td>'; echo '<td><a href="./fleet.php?d=' . $row[id] . '">X</a></td>'; } echo '</table></div>';
//Fleet exists $fid = $row2[0]; } else { //No fleet exists, create $pname = getPlanetStat(name, $sid, $pid); $query = "INSERT INTO fleet{$sid}(loc,inport,ownerid,name) VALUES({$pid},1,{$id},'{$pname}')"; $result = @mysql_query($query); echo mysql_error(); $query = "SELECT id FROM fleet{$sid} WHERE inport=1 AND loc={$pid} AND ownerid={$id}"; $result = mysql_query($query); $row2 = mysql_fetch_array($result); $fid = $row2[0]; } //Add the ship to the fleet $str = "ship" . $shiptype; $curnum = getFleetStat($str, $sid, $fid); $curnum++; if (setFleetStat($str, $curnum, $sid, $fid)) { echo 'You have completed your ship. It is in your planets home fleet.<br>'; } else { echo 'ERROR #1 contact sup'; } //Delete the ship build record $query = "DELETE FROM shipq{$sid} WHERE id={$sf}"; $result = @mysql_query($query); if (!$result) { echo 'Err 2'; } //Check to see if there is another ship in the queue, if there isnt set the time to 0 $query = "SELECT id FROM shipq{$sid} WHERE pid={$pid} AND ownerid={$id}"; $result = mysql_query($query);
//Check that they own the fleet if (getFleetStat(ownerid, $sid, $fid) != $id) { echo 'err'; exit; } //Check that the fleet has a probe value if (!(getSpyNum($sid, $fid) > 0)) { echo 'err2'; exit; } //Check if it is already probing if (getFleetStat(probes, $sid, $fid) > 0) { echo 'This fleets probes are already launched.'; } else { setFleetStat(probes, $pid, $sid, $fid); $traveltime = travelTime($sid, getFleetStat(loc, $sid, $fid), $pid, $id); setFleetStat(probetime, $traveltime, $sid, $fid); echo 'You have sent your probes.<br>'; } } //See if the person owns the planet if (getPlanetStat(ownerid, $sid, $pid) == $id) { if ($goer) { changePage('./build.php?id=' . $pid . '&err=' . $goer); } else { changePage('./build.php?id=' . $pid); } include './footer.php'; exit; } /************
<?php /**/ include './header.php'; if (isset($_GET[id])) { $fid = escape_data($_GET[id]); //Make sure you own if (getFleetStat(ownerid, $sid, $fid) != $id) { echo 'err'; exit; } } else { echo 'err'; exit; } if (isset($_POST['name'])) { $name = '' . escape_data($_POST['name']); setFleetStat(name, $name, $sid, $fid); changePage('./fleet.php'); } echo '<form action="./fname.php?id=' . $fid . '" method="post"> <input type="text" name="name" value="' . getFleetStat(name, $sid, $fid) . '"> <input type="Submit" value="Change">'; include './footer.php';
function getSpyNum($sid, $fid) { $query = "SELECT id FROM mastership"; $result = mysql_query($query); $numship = mysql_num_rows($result); for ($x = 5; $x < $numship + 1; $x++) { $str = 'ship' . $x; $num += getShipStat(spy, $x) * getFleetStat($str, $sid, $fid); } return $num; }
<?php /**/ include './header.php'; if (isset($_GET[id])) { $fid = (int) escape_data($_GET[id]); //check if owner if (getFleetStat(ownerid, $sid, $fid) != $id) { echo 'err'; exit; } } else { echo 'err'; exit; } $query = "SELECT report,probetime FROM fleet{$sid} WHERE id={$fid}"; $result = mysql_query($query); $row = mysql_fetch_array($result); if ($row[1] > 0) { echo 'There is no report for this fleet.'; } else { echo $row[0]; } include './footer.php';