示例#1
0
 for ($x = 1; $x < getShipNumber() + 1; $x++) {
     $str = "ship" . $x;
     $dshiparray[$x] = getFleetStat($str, $sid, $dfid);
     $defence += getShipStat(defend, $x) * $dshiparray[$x];
 }
 //Add the defense numbers
 $defence += getPlanetStat(cannon, $sid, $dpid);
 //Make attack between 90-110%
 $attack = $attack * rand(90, 110) / 100;
 //Make defence between 95-115%
 $defence = $defence * rand(95, 115) / 100;
 //Add research
 $aplayerid = getFleetStat(ownerid, $sid, $afid);
 $dplayerid = getFleetStat(ownerid, $sid, $dfid);
 $attack *= getResearch(2, $sid, getFleetStat(ownerid, $sid, $afid));
 $defence *= getResearch(6, $sid, getFleetStat(ownerid, $sid, $dfid));
 setFleetStat(combatid, 0, $sid, $afid);
 /************************
 Do destruction of ships,
 Take attack, subtract hp, winners destroy all losers
 *************************/
 if ($attack > $defence) {
     //Destroy losers fleet
     destroyFleet($sid, $dfid);
     $endstr1 = 'You conquered <a href="./planetdetails.php?id=' . $dpid . '">' . getPlanetStat(name, $sid, $dpid) . '</a> with the fleet ' . getFleetStat(name, $sid, $afid) . ' Your attack won with ' . $attack . ' attack to ' . $defence . ' defence.';
     $endstr2 = 'Your planet <a href="./planetdetails.php?id=' . $dpid . '">' . getPlanetStat(name, $sid, $dpid) . '</a> was conquered by <a href="./profile.php?id=' . $aplayerid . '">' . getUserStat(username, $aplayerid) . '</a> with ' . $attack . ' attack to ' . $defence . ' defense.';
     $tempdef = $defence;
     echo $endstr1;
     //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.
     $dahp = calchp($sid, $afid);
示例#2
0
function calcShipBuildTime($shipid, $sid, $id)
{
    $time = getShipStat(buildtime, $shipid);
    $sub = $time * getResearch(9, $sid, $id) - $time;
    return floor($time - $sub);
}