Esempio n. 1
0
function galaxyControlled($sid, $pid)
{
    $z = getPlanetStat(z, $sid, $pid);
    $query = "SELECT ownerpid FROM galaxy{$sid} WHERE id={$z}";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    if ($row[0] == 0) {
        return false;
    }
    return true;
}
Esempio n. 2
0
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 + getPlanetStat(cannon, $sid, $pid);
}
Esempio n. 3
0
                } else {
                    if ($probe > $sentry + 40) {
                        $rand = rand(9, 11) / 10;
                        $def = floor(calcDef($sid, $pid) * $rand);
                        $report = 'Your probe report came back very positive. They report the estimated defensive capabilities are ' . $def . '. The estimated land remaining is ' . $land . '. This report is very accurate.';
                    } else {
                        if ($probe > $sentry + 25) {
                            $rand = rand(8, 12) / 10;
                            $def = floor(calcDef($sid, $pid) * $rand);
                            $report = 'Your probe report came back positive. They report the estimated defensive capabilities are ' . $def . '.';
                        } else {
                            if ($probe > $sentry + 10) {
                                $rand = rand(7, 13) / 10;
                                $def = floor(calcDef($sid, $pid) * $rand);
                                $report = 'Your probe report came back neutral. They report the estimated defensive capabilities are ' . $def . '. This report is somewhat uncertain.';
                            } else {
                                $rand = rand(5, 15) / 10;
                                $def = floor(calcDef($sid, $pid) * $rand);
                                $report = 'Your probe report came back very vague. They report the estimated defensive capabilities are ' . $def . '. This report is very uncertain.';
                            }
                        }
                    }
                }
                echo $report;
                setFleetStat(report, $report, $sid, $fid);
                setFleetStat(probetime, -1, $sid, $fid);
                addNotification('Your scan of planet <a href="./planetdetails.php?id=' . $pid . '">' . getPlanetStat(name, $sid, $pid) . '</a> is complete. The results are <a href="./report.php?id=' . $fid . '">here</a>', $sid, getFleetStat(ownerid, $sid, $fid));
            }
        }
    }
}
Esempio n. 4
0
var color=1;

function changeColor(x){
  color = x;
}';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    //Create a system object for each item in db
    $pid = $row[ownerpid];
    if ($pid != 0) {
        $name = getPlanetStat(name, $sid, $pid);
    } else {
        $name = 'None';
    }
    //Get the players color if applicable
    if ($pid > 0) {
        $color = getUserStat(color, getPlanetStat(ownerid, $sid, $pid));
    } else {
        $color = -1;
    }
    //1 = RED
    //2 = YELLOW
    //3 = GREEN
    $enemy = 0;
    $query2 = "SELECT ownerid FROM planets{$sid} WHERE z=" . $row[id];
    $result2 = mysql_query($query2);
    while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
        echo '//' . $row2[ownerid] . '
   ';
        if ($row2[ownerid] != 0) {
            if ($row2[ownerid] != $id) {
                if ($enemy == 3) {
Esempio n. 5
0
}
/********
PRINT THE FLEET DETAILS
*********/
echo '<table cellspacing=5 align=center>
    <tr>
      <td><b>Name</b></td>
      <td><b>Loc</b></td>
      <td><b>Destination</b></td>
      <td><b>Arrival Time</b></td>
    </tr><tr>
      <td>' . getFleetStat(name, $sid, $fid) . '</td>
      <td><a href="./planetdetails.php?id=' . getFleetStat(loc, $sid, $fid) . '">' . getPlanetStat(name, $sid, getFleetStat(loc, $sid, $fid)) . '</a></td>';
$destination = getFleetStat(destination, $sid, $fid);
if ($destination > 0) {
    echo '<td><a href="./planetdetails.php?id=' . getFleetStat(loc, $sid, $fid) . '">' . getPlanetStat(name, $sid, getFleetStat(destination, $sid, $fid)) . '</a></td>
      <td>' . timeLeft(getFleetStat(destinationtime, $sid, $fid)) . '</td>';
} else {
    echo '<td>None</td>
      <td>---</td>';
}
echo '</tr></table><br><hr><br>';
//Print the list of ships
echo '<form name="fleetadd" action="./fleetdetails.php?id=' . $fid . '" method="post">
  <table cellspacing=5 align=center>
    <tr>
      <td></td>
      <td><b>Type</b></td>
      <td><b>Attack</b></td>
      <td><b>Defence</b></td>
      <td><b>Amt</b></td>
Esempio n. 6
0
			<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>';
/*************
CREATE FLEET
Esempio n. 7
0
             }
         }
         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) {
                     $tempdef = $tempdef - getShipStat(hp, $x);
Esempio n. 8
0
<br>
<a href="javascript:;" onClick="change(0)">Attack</a> | 
<a href="javascript:;" onClick="change(1)">Probe</a><br><br></center>
';
/*******
PRINT ATTACK MENU
***********/
echo '<div id="0" style="display:block">';
//Populate dropdown
$first = true;
$protection = false;
$query = "SELECT name,id,loc FROM fleet{$sid} WHERE ownerid={$id} AND destination=0 AND loc!={$pid}";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    $traveltime = travelTime($sid, $row[loc], $pid, $id);
    if (getPlanetStat(starttime, $sid, $pid) + 259200 < time()) {
        if ($traveltime > 0) {
            if ($first) {
                echo '<form name="fleetdd" action="./planetdetails.php?id=' . $pid . '" method="post">
            <table cellspacing=5 align="center">
              <tr>
                <td></td>
                <td><select name="fleet">';
                $first = false;
            }
            echo '<option value="' . $row[id] . '">' . $row[name] . ' [' . fleetSize($sid, $row[id]) . '] ' . ($traveltime - time()) . '</option>';
        }
    } else {
        echo 'This player is still under protection from the Fair Space Colonization Act, this player has recently started and can not be attacked for 3 days after the start of his colonization.';
        $first = false;
        $protection = true;
Esempio n. 9
0
<?php

require_once './www.playconquest.com/db_connect.php';
//include('./db_connect.php');
$servercount = getServerNumber();
for ($x = 1; $x < $servercount + 1; $x++) {
    $query = "SELECT ownerpid FROM galaxy{$x} WHERE ownerpid>0";
    $result = @mysql_query($query);
    $sid = $x;
    while ($row = mysql_fetch_array($result)) {
        $pid = $row[0];
        $id = getPlanetStat(ownerid, $sid, $pid);
        for ($y = 1; $y < getMaxServer() + 1; $y++) {
            $str = 's' . $y;
            $number = getUserStat($str, $id);
            if ($number == $sid) {
                $number = $y;
                break;
            }
        }
        $str = 'points' . $number;
        $points = getUserStat($str, $id);
        $points++;
        echo $str;
        $query2 = "UPDATE users SET {$str}={$points} WHERE id={$id}";
        $result2 = @mysql_query($query2);
    }
}
Esempio n. 10
0
<?php

/**/
include './header.php';
if (isset($_GET[id])) {
    $pid = escape_data($_GET[id]);
    //Make sure you own
    if (getPlanetStat(ownerid, $sid, $pid) != $id) {
        echo 'err';
        exit;
    }
} else {
    echo 'err';
    exit;
}
if (isset($_POST['name'])) {
    $name = '' . escape_data($_POST['name']);
    setPlanetStat(name, $name, $sid, $pid);
    changePage('./planets.php');
}
echo '<form action="./name.php?id=' . $pid . '" method="post">
		<input type="text" name="name" value="' . getPlanetStat(name, $sid, $pid) . '"> <input type="Submit" value="Change">';
include './footer.php';
Esempio n. 11
0
echo 'var systems = new Array();';
echo '
function system(id,name,img,x,y,owner,uname,ptype){
	this.x = x;
	this.y = y;
	this.id = id;
	this.name = name;
	this.owner = owner;
	this.ownername = uname;
	this.active = false;
	this.img = img;
	this.ptype = ptype;
}';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    //Create a system object for each item in db
    echo 'systems[' . $counter . '] = new system(' . $row[id] . ',"' . $row[name] . '",' . $row[img] . ',' . $row[x] . ',' . $row[y] . ',' . $row[ownerid] . ',"' . getUserStat(username, getPlanetStat(ownerid, $sid, $row[id])) . '","' . getTypeStat(name, $row[img]) . '");';
    $counter++;
}
//end js declaration
//end js
echo '</script>';
//Print Canvas
echo '<canvas id="c"></canvas><script src="planet.js"></script>';
//Print the action menu
echo '<table cellspacing=5 cellpadding=5 align=center>
	</table>';
//Print the action menu
echo '<table cellspacing=5 cellpadding=5 align=center>
		<tr>
			<td><b>Name:</b></td>
			<td><div id="name"></div></td>
Esempio n. 12
0
        $upkeep = getUpkeepCost($x, $pid);
        //Check to see if the upkeep can be paid
        $statsArray = array(1 => "steel", 0 => "cylite", 2 => "plexi");
        if ($taxesPaid) {
            //Pay the upkeep
            for ($y = 0; $y < count($statsArray); $y++) {
                $current = getPlanetStat($statsArray[$y], $x, $pid);
                $current = $current - getUpkeepCost($x, $pid);
                setPlanetStat($statsArray[$y], $current, $x, $pid);
            }
            echo 'Taxes paid for ' . $pid . '<br>';
            //Add civs
            $current = getPlanetStat(civs, $x, $pid);
            $current = $current + civProductionRate($x, $pid);
            echo 'New civs ' . $current;
            if ($current > getPlanetStat(maxcivs, $x, $pid)) {
                $current = getPlanetStat(maxcivs, $x, $pid);
            }
            echo ' set to ' . $current . '<br>';
            setPlanetStat(civs, $current, $x, $pid);
            //Add each resourceproductionrate to each resource
            for ($y = 0; $y < count($statsArray); $y++) {
                $current = getPlanetStat($statsArray[$y], $x, $pid);
                $current = $current + resourceProductionRate($statsArray[$y], $x, $pid);
                echo resourceProductionRate($statsArray[$y], $x, $pid);
                setPlanetStat($statsArray[$y], $current, $x, $pid);
                echo $current . ' is new resource<br>';
            }
        }
    }
}
Esempio n. 13
0
function addCargo($civs, $steel, $cylite, $plexi, $sid, $pid, $fid)
{
    $newcargo = calcCargo($civs, $steel, $cylite, $plexi);
    //Check if there is room on the fleet
    if (isRoom($newcargo, $sid, $fid)) {
        //Check if the planet has valid resources
        $pcivs = getPlanetStat(civs, $sid, $pid);
        if ($pcivs < $civs) {
            return -2;
        }
        $psteel = getPlanetStat(steel, $sid, $pid);
        if ($psteel < $steel) {
            return -3;
        }
        $pcylite = getPlanetStat(cylite, $sid, $pid);
        if ($pcylite < $cylite) {
            return -4;
        }
        $pplexi = getPlanetStat(plexi, $sid, $pid);
        if ($pplexi < $plexi) {
            return -5;
        }
        //Subtract from the planet and update
        $pcivs -= $civs;
        setPlanetStat(civs, $pcivs, $sid, $pid);
        $psteel -= $steel;
        setPlanetStat(steel, $psteel, $sid, $pid);
        $pcylite -= $cylite;
        setPlanetStat(cylite, $pcylite, $sid, $pid);
        $pplexi -= $plexi;
        setPlanetStat(plexi, $pplexi, $sid, $pid);
        //Get the fleet amounts and increase then update
        $pcivs = getFleetStat(civs, $sid, $fid);
        $pcivs += $civs;
        setFleetStat(civs, $pcivs, $sid, $fid);
        $psteel = getFleetStat(steel, $sid, $fid);
        $psteel += $steel;
        setFleetStat(steel, $psteel, $sid, $fid);
        $pcylite = getFleetStat(cylite, $sid, $fid);
        $pcylite += $cylite;
        setFleetStat(cylite, $pcylite, $sid, $fid);
        $pplexi = getFleetStat(plexi, $sid, $fid);
        $pplexi += $plexi;
        setFleetStat(plexi, $pplexi, $sid, $fid);
        return 1;
    }
    return -1;
}
Esempio n. 14
0
}
echo '<form name="merchant" action="./build.php?id=' . $toid . '&mid=' . $pid . '" method="post"><table cellspacing=10>
        <tr>
        <td></td>
        <td></td>
        <td><b>Civs</b></td>
        <td><b>Elin</b></td>
        <td><b>Cylite</b></td>
        <td><b>Plexi</b></td>
    </tr><tr>
        <td></td>
        <td><b>' . getPlanetStat(name, $sid, $pid) . '</td>
        <td>' . getPlanetStat(civs, $sid, $pid) . '</td>
        <td>' . getPlanetStat(steel, $sid, $pid) . '</td>
        <td>' . getPlanetStat(cylite, $sid, $pid) . '</td>
        <td>' . getPlanetStat(plexi, $sid, $pid) . '</td>
    </tr><tr>
        <td></td>
        <td>Move</td>
        <td><input type="text" name="mcivs" size=1 value=0></td>
        <td><input type="text" name="msteel" size=1 value=0></td>
        <td><input type="text" name="mcylite" size=1 value=0></td>
        <td><input type="text" name="mplexi" size=1 value=0></td>
    </tr><tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <tD><input type="submit" name="merchant" value="Hire Merchant"></td></table></form>';
Esempio n. 15
0
        $id = getPlanetStat(ownerid, $sid, $pid);
        //Check if something is actually building
        $cid = getPlanetStat(constructionid, $sid, $pid);
        if ($cid > 0 && $cid != 8) {
            //Check if it is finished
            if (timeLeft(getPlanetStat(constructiontime, $sid, $pid)) < 1) {
                if (getBuildStat(increases, $cid) != "none") {
                    $pstat = getPlanetStat(getBuildStat(increases, $cid), $sid, $pid);
                    $increase = getBuildStat(increaseamt, $cid);
                    $pstat = $pstat + $increase;
                    if (setPlanetStat(getBuildStat(increases, $cid), $pstat, $sid, $pid)) {
                        if (setPlanetStat(constructionid, 0, $sid, $pid)) {
                            addNotification(getBuildStat(name, $cid) . ' has finished building.', $sid, $id);
                        }
                    }
                } else {
                    if (setPlanetStat(constructionid, 0, $sid, $pid)) {
                        if (!galaxyControlled($sid, $pid)) {
                            $z = getPlanetStat(z, $sid, $pid);
                            $query = "UPDATE galaxy{$sid} SET ownerpid={$pid} WHERE id={$z}";
                            $result = @mysql_query($query);
                            addNotification(getBuildStat(name, $cid) . ' has finished building. You now have control over this system.', $sid, $id);
                        } else {
                            addNotification(getBuildStat(name, $cid) . ' has finished building. This action has failed. Someone has gained control of the system before you. You must destroy the enemy ' . getBuildStat(name, $cid) . ' or conquer the planet.', $sid, $id);
                        }
                    }
                }
            }
        }
    }
}