Example #1
0
                         break;
                     }
                 }
             }
             if ($count == sizeof($ashiparray)) {
                 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) {
Example #2
0
     //Special case make sure you have enough money for special galaxy owner building
     for ($x = 0; $x < count($statsArray); $x++) {
         $str = $statsArray[$x] . 'cost';
         if (getPlanetStat($statsArray[$x], $sid, $pid) < getBuildStat($str, $bid)) {
             $buildable = false;
         }
     }
 }
 //Create the building
 if ($buildable) {
     //Set the id, time then take away materials
     setPlanetStat(constructionid, $bid, $sid, $pid);
     if (getBuildStat(increases, $bid) != 'none') {
         setPlanetStat(constructiontime, calcBuildTime($bid, $sid, $pid) + time(), $sid, $pid);
     } else {
         setPlanetStat(constructiontime, getBuildStat(buildtime, $bid) + time(), $sid, $pid);
     }
     //Take the resources for special case
     if (getBuildStat(increases, $bid) == 'none') {
         for ($x = 0; $x < count($statsArray); $x++) {
             $str = $statsArray[$x] . 'cost';
             $current = getPlanetStat($statsArray[$x], $sid, $pid);
             $current = $current - getBuildStat($str, $bid);
             $query = "UPDATE planets{$sid} SET " . $statsArray[$x] . "={$current} WHERE id={$pid}";
             $result = @mysql_query($query);
         }
     } else {
         //Take the resources for default case
         for ($x = 0; $x < count($statsArray); $x++) {
             $current = getPlanetStat($statsArray[$x], $sid, $pid);
             $current = $current - getCost($statsArray[$x], $bid, $sid, $pid);
Example #3
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';
Example #4
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>';
            }
        }
    }
}
Example #5
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;
}
Example #6
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);
                        }
                    }
                }
            }
        }
    }
}