Пример #1
0
function ShowFleet1Page($CurrentUser, $CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang;
    $parse = $lang;
    $speed = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10);
    $g = $_POST['galaxy'];
    $s = $_POST['system'];
    $p = $_POST['planet'];
    $t = $_POST['planet_type'];
    if (!$g) {
        $g = $CurrentPlanet['galaxy'];
    }
    if (!$s) {
        $s = $CurrentPlanet['system'];
    }
    if (!$p) {
        $p = $CurrentPlanet['planet'];
    }
    if (!$t) {
        $t = $CurrentPlanet['planet_type'];
    }
    $FleetHiddenBlock = "";
    foreach ($reslist['fleet'] as $n => $i) {
        if ($i > 201 && $i < 217 && $_POST["ship{$i}"] > "0") {
            if ($_POST["ship{$i}"] > $CurrentPlanet[$resource[$i]] or !ctype_digit($_POST["ship{$i}"])) {
                header("location:game.php?page=fleet");
            } else {
                $fleet['fleetarray'][$i] = $_POST["ship{$i}"];
                $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";";
                $fleet['amount'] += $_POST["ship{$i}"];
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"consumption" . $i . "\" value=\"" . GetShipConsumption($i, $CurrentUser) . "\" />";
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"speed" . $i . "\"       value=\"" . GetFleetMaxSpeed("", $i, $CurrentUser) . "\" />";
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"capacity" . $i . "\"    value=\"" . $pricelist[$i]['capacity'] . "\" />";
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"ship" . $i . "\"        value=\"" . $_POST["ship{$i}"] . "\" />";
                $speedalls[$i] = GetFleetMaxSpeed("", $i, $CurrentUser);
            }
        }
    }
    if (!$fleet['fleetlist']) {
        header("location:game." . $phpEx . "?page=fleet");
    } else {
        $speedallsmin = min($speedalls);
    }
    $parse['fleetblock'] = $FleetHiddenBlock;
    $parse['speedallsmin'] = $speedallsmin;
    $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray'])));
    $parse['galaxy'] = $CurrentPlanet['galaxy'];
    $parse['system'] = $CurrentPlanet['system'];
    $parse['planet'] = $CurrentPlanet['planet'];
    $parse['galaxy_post'] = intval($_POST['galaxy']);
    $parse['system_post'] = intval($_POST['system']);
    $parse['planet_post'] = intval($_POST['planet']);
    $parse['speedfactor'] = GetGameSpeedFactor();
    $parse['planet_type'] = $CurrentPlanet['planet_type'];
    $parse['metal'] = floor($CurrentPlanet['metal']);
    $parse['crystal'] = floor($CurrentPlanet['crystal']);
    $parse['deuterium'] = floor($CurrentPlanet['deuterium']);
    $parse['g'] = $g;
    $parse['s'] = $s;
    $parse['p'] = $p;
    $parse['options_planettype'] .= "<option value=\"1\"" . ($t == 1 ? " SELECTED" : "") . ">" . $lang['fl_planet'] . "</option>";
    $parse['options_planettype'] .= "<option value=\"2\"" . ($t == 2 ? " SELECTED" : "") . ">" . $lang['fl_debris'] . "</option>";
    $parse['options_planettype'] .= "<option value=\"3\"" . ($t == 3 ? " SELECTED" : "") . ">" . $lang['fl_moon'] . "</option>";
    foreach ($speed as $a => $b) {
        $parse['options'] .= "<option value=\"" . $a . "\">" . $b . "</option>";
    }
    if ($CurrentUser['fleet_shortcut']) {
        $scarray = explode("\r\n", $CurrentUser['fleet_shortcut']);
        $i = 0;
        foreach ($scarray as $a => $b) {
            if ($b != "") {
                $c = explode(',', $b);
                if ($i == 0) {
                    $ShortCut .= "<tr height=\"20\">";
                }
                $ShortCut .= "<th><a href=\"javascript:setTarget(" . $c[1] . "," . $c[2] . "," . $c[3] . "," . $c[4] . "); shortInfo();\"";
                $ShortCut .= ">" . $c[0] . " " . $c[1] . ":" . $c[2] . ":" . $c[3] . " ";
                if ($c[4] == 1) {
                    $ShortCut .= $lang['fl_planet_shortcut'];
                } elseif ($c[4] == 2) {
                    $ShortCut .= $lang['fl_debris_shortcut'];
                } elseif ($c[4] == 3) {
                    $ShortCut .= $lang['fl_moon_shortcut'];
                }
                $ShortCut .= "</a></th>";
                if ($i == 1) {
                    $ShortCut .= "</tr>";
                }
                if ($i == 1) {
                    $i = 0;
                } else {
                    $i = 1;
                }
            }
        }
        if ($i == 1) {
            $ShortCut .= "<th></th></tr>";
        }
    } else {
        $ShortCut .= "<tr height=\"20\">";
        $ShortCut .= "<th colspan=\"2\">" . $lang['fl_no_shortcuts'] . "</th>";
        $ShortCut .= "</tr>";
    }
    $parse['shortcut'] = $ShortCut;
    $kolonien = SortUserPlanets($CurrentUser);
    if (mysql_num_rows($kolonien) > 1) {
        $i = 0;
        $w = 0;
        $tr = true;
        while ($row = mysql_fetch_array($kolonien)) {
            if ($w == 0 && $tr) {
                $ColonyList .= "<tr height=\"20\">";
                $tr = false;
            }
            if ($w == 2) {
                $ColonyList .= "</tr>";
                $w = 0;
                $tr = true;
            }
            if ($row['planet_type'] == 3) {
                $row['name'] .= " " . $lang['fl_moon_shortcut'];
            }
            if ($CurrentPlanet['galaxy'] == $row['galaxy'] && $CurrentPlanet['system'] == $row['system'] && $CurrentPlanet['planet'] == $row['planet'] && $CurrentPlanet['planet_type'] == $row['planet_type']) {
                /* HERE NOTHING HAPPENS.. =p*/
            } else {
                $ColonyList .= "<th><a href=\"javascript:setTarget(" . $row['galaxy'] . "," . $row['system'] . "," . $row['planet'] . "," . $row['planet_type'] . "); shortInfo();\">" . $row['name'] . " " . $row['galaxy'] . ":" . $row['system'] . ":" . $row['planet'] . "</a></th>";
                $w++;
                $i++;
            }
        }
        if ($i % 2 != 0) {
            $ColonyList .= "<th>&nbsp;</th></tr>";
        } elseif ($w == 2) {
            $ColonyList .= "</tr>";
        }
    } else {
        $ColonyList .= "<th colspan=\"2\">" . $lang['fl_no_colony'] . "</th>";
    }
    $parse['colonylist'] = $ColonyList;
    $aks_madnessred = doquery("SELECT * FROM {{table}} ;", 'aks');
    $aks_code_mr = '';
    $aks_invited_mr = '';
    while ($row = mysql_fetch_array($aks_madnessred)) {
        $members = explode(",", $row['eingeladen']);
        foreach ($members as $a => $b) {
            if ($b == $CurrentUser['id']) {
                $aks_fleets_mr .= "<tr height=\"20\">";
                $aks_fleets_mr .= "<th colspan=\"2\">";
                $aks_fleets_mr .= "<a href=\"javascript:";
                $aks_fleets_mr .= "setTarget(" . $row['galaxy'] . "," . $row['system'] . "," . $row['planet'] . "); ";
                $aks_fleets_mr .= "shortInfo(); ";
                $aks_fleets_mr .= "setACS(" . $row['id'] . "); ";
                $aks_fleets_mr .= "setACS_target('" . "g" . $row['galaxy'] . "s" . $row['system'] . "p" . $row['planet'] . "t" . $row['planet_type'] . "');";
                $aks_fleets_mr .= "\">";
                $aks_fleets_mr .= "(" . $row['name'] . ")";
                $aks_fleets_mr .= "</a>";
                $aks_fleets_mr .= "</th>";
                $aks_fleets_mr .= "</tr>";
            }
        }
    }
    $parse['asc'] = $aks_fleets_mr;
    $parse['maxepedition'] = $_POST['maxepedition'];
    $parse['curepedition'] = $_POST['curepedition'];
    $parse['target_mission'] = $_POST['target_mission'];
    display(parsetemplate(gettemplate('fleet/fleet1_table'), $parse));
}
Пример #2
0
if ($_POST['thisgalaxy'] != $planetrow['galaxy'] | $_POST['thissystem'] != $planetrow['system'] | $_POST['thisplanet'] != $planetrow['planet'] | $_POST['thisplanettype'] != $planetrow['planet_type']) {
    $ResultMessage = "618;" . $lang['gs_c618'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles;
    die($ResultMessage);
}
$Distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
$speedall = GetFleetMaxSpeed($FleetArray, 0, $user);
$SpeedAllMin = min($speedall);
$Duration = GetMissionDuration(10, $SpeedAllMin, $Distance, GetGameSpeedFactor());
$fleet['fly_time'] = $Duration;
$fleet['start_time'] = $Duration + time();
$fleet['end_time'] = $Duration * 2 + time();
$FleetShipCount = 0;
$FleetDBArray = "";
$FleetSubQRY = "";
$consumption = 0;
$SpeedFactor = GetGameSpeedFactor();
foreach ($FleetArray as $Ship => $Count) {
    $ShipSpeed = $pricelist[$Ship]["speed"];
    $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed);
    $basicConsumption = $pricelist[$Ship]["consumption"] * $Count;
    $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1);
    $FleetShipCount += $Count;
    $FleetDBArray .= $Ship . "," . $Count . ";";
    $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . " , ";
}
$consumption = round($consumption) + 1;
if ($TargetRow['id_level'] > $user['authlevel']) {
    $Allowed = true;
    switch ($_POST['mission']) {
        case 1:
        case 2:
Пример #3
0
 protected function GetFleet()
 {
     global $resource, $reslist, $pricelist;
     $planet = $this->user['planet'];
     $system = $this->user['system'];
     $galaxy = $this->user['galaxy'];
     $fleetarray = array();
     $totalships = 0;
     foreach ($reslist['fleet'] as $Element) {
         if ($this->CurrentPlanet[$resource[$Element]] > 0 and $Element != 212) {
             $fleetarray[$Element] = $this->CurrentPlanet[$resource[$Element]];
             $totalships += $this->CurrentPlanet[$resource[$Element]];
         }
     }
     if ($this->CurrentPlanet[$resource[21]] <= 5 and $totalships > 150 or $totalships > 5000) {
         $AllFleetSpeed = Fleets::fleet_max_speed($fleetarray, 0, $this->user);
         $MaxFleetSpeed = min($AllFleetSpeed);
         $distance = Fleets::target_distance($this->CurrentPlanet['galaxy'], $galaxy, $this->CurrentPlanet['system'], $system, $this->CurrentPlanet['planet'], $planet);
         $duration = Fleets::mission_duration(10, $MaxFleetSpeed, $distance, GetGameSpeedFactor());
         $consumption = Fleets::fleet_consumption($fleetarray, GetGameSpeedFactor(), $duration, $distance, $MaxFleetSpeed, $this->user);
         $StayDuration = 0;
         $StayTime = 0;
         $fleet['start_time'] = $duration + time();
         $fleet['end_time'] = $StayDuration + 2 * $duration + time();
         $FleetStorage = 0;
         $fleet_array2 = '';
         $FleetShipCount = 0;
         $FleetSubQRY = "";
         $Mining = array();
         foreach ($fleetarray as $Ship => $Count) {
             $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
             $FleetShipCount += $Count;
             $fleet_array2 .= $Ship . "," . $Count . ";";
             $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . " , ";
         }
         $FleetStorage -= $consumption;
         if ($this->CurrentPlanet['metal'] > $FleetStorage / 3) {
             $Mining['metal'] = $FleetStorage / 3;
             $FleetStorage = $FleetStorage - $Mining['metal'];
         } else {
             $Mining['metal'] = $this->CurrentPlanet['metal'];
             $FleetStorage = $FleetStorage - $Mining['metal'];
         }
         if ($this->CurrentPlanet['crystal'] > $FleetStorage / 2) {
             $Mining['crystal'] = $FleetStorage / 2;
             $FleetStorage = $FleetStorage - $Mining['crystal'];
         } else {
             $Mining['crystal'] = $this->CurrentPlanet['crystal'];
             $FleetStorage = $FleetStorage - $Mining['crystal'];
         }
         $QryInsertFleet = "INSERT INTO {{table}} SET ";
         $QryInsertFleet .= "`fleet_owner` = '" . $this->user['id'] . "', ";
         $QryInsertFleet .= "`fleet_mission` = '4', ";
         $QryInsertFleet .= "`fleet_amount` = '" . $FleetShipCount . "', ";
         $QryInsertFleet .= "`fleet_array` = '" . $fleet_array2 . "', ";
         $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
         $QryInsertFleet .= "`fleet_start_galaxy` = '" . $this->CurrentPlanet['galaxy'] . "', ";
         $QryInsertFleet .= "`fleet_start_system` = '" . $this->CurrentPlanet['system'] . "', ";
         $QryInsertFleet .= "`fleet_start_planet` = '" . $this->CurrentPlanet['planet'] . "', ";
         $QryInsertFleet .= "`fleet_start_type` = '" . $this->CurrentPlanet['planet_type'] . "', ";
         $QryInsertFleet .= "`fleet_end_time` = '" . $fleet['end_time'] . "', ";
         $QryInsertFleet .= "`fleet_end_stay` = '" . $StayTime . "', ";
         $QryInsertFleet .= "`fleet_end_galaxy` = '" . $galaxy . "', ";
         $QryInsertFleet .= "`fleet_end_system` = '" . $system . "', ";
         $QryInsertFleet .= "`fleet_end_planet` = '" . $planet . "', ";
         $QryInsertFleet .= "`fleet_end_type` = '1', ";
         $QryInsertFleet .= "`fleet_resource_metal` = '" . $Mining['metal'] . "', ";
         $QryInsertFleet .= "`fleet_resource_crystal` = '" . $Mining['crystal'] . "', ";
         $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $Mining['deuterium'] . "', ";
         $QryInsertFleet .= "`fleet_target_owner` = '0', ";
         $QryInsertFleet .= "`fleet_group` = '0', ";
         $QryInsertFleet .= "`start_time` = '" . time() . "';";
         doquery($QryInsertFleet, 'fleets');
         $QryUpdatePlanet = "UPDATE {{table}} SET ";
         $QryUpdatePlanet .= $FleetSubQRY;
         $QryUpdatePlanet .= "`id` = '" . $this->CurrentPlanet['id'] . "' ";
         $QryUpdatePlanet .= "WHERE ";
         $QryUpdatePlanet .= "`id` = '" . $this->CurrentPlanet['id'] . "'";
         doquery($QryUpdatePlanet, "planets");
         $this->CurrentPlanet["metal"] -= $Mining['metal'];
         $this->CurrentPlanet["crystal"] -= $Mining['crystal'];
         $this->CurrentPlanet["deuterium"] -= $consumption + $Mining['deuterium'];
     }
 }
Пример #4
0
$page .= "<script type=\"text/javascript\">\n";
$page .= "function getStorageFaktor() {\n";
$page .= "\treturn 1\n";
$page .= "}\n";
$page .= "</script>\n";
$page .= "<form action=\"floten2.php\" method=\"post\">";
$page .= $FleetHiddenBlock;
$page .= "<input type=\"hidden\" name=\"speedallsmin\"   value=\"" . $speedallsmin . "\" />";
$page .= "<input type=\"hidden\" name=\"usedfleet\"      value=\"" . str_rot13(base64_encode(serialize($fleet['fleetarray']))) . "\" />";
$page .= "<input type=\"hidden\" name=\"thisgalaxy\"     value=\"" . $planetrow['galaxy'] . "\" />";
$page .= "<input type=\"hidden\" name=\"thissystem\"     value=\"" . $planetrow['system'] . "\" />";
$page .= "<input type=\"hidden\" name=\"thisplanet\"     value=\"" . $planetrow['planet'] . "\" />";
$page .= "<input type=\"hidden\" name=\"galaxyend\"      value=\"" . intval($_POST['galaxy']) . "\" />";
$page .= "<input type=\"hidden\" name=\"systemend\"      value=\"" . intval($_POST['system']) . "\" />";
$page .= "<input type=\"hidden\" name=\"planetend\"      value=\"" . intval($_POST['planet']) . "\" />";
$page .= "<input type=\"hidden\" name=\"speedfactor\"    value=\"" . GetGameSpeedFactor() . "\" />";
$page .= "<input type=\"hidden\" name=\"thisplanettype\" value=\"" . $planetrow['planet_type'] . "\" />";
$page .= "<input type=\"hidden\" name=\"thisresource1\"  value=\"" . floor($planetrow['metal']) . "\" />";
$page .= "<input type=\"hidden\" name=\"thisresource2\"  value=\"" . floor($planetrow['crystal']) . "\" />";
$page .= "<input type=\"hidden\" name=\"thisresource3\"  value=\"" . floor($planetrow['deuterium']) . "\" />";
$page .= "<br><div><center>";
$page .= "<table width=\"519\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
$page .= "<tr height=\"20\">";
$page .= "<td colspan=\"2\" class=\"c\">" . $lang['fl_floten1_ttl'] . "</td>";
$page .= "</tr>";
$page .= "<tr height=\"20\">";
$page .= "<th width=\"50%\">" . $lang['fl_dest'] . "</th>";
$page .= "<th>";
$page .= "<input name=\"galaxy\" size=\"3\" maxlength=\"2\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" value=\"" . $g . "\" />";
$page .= "<input name=\"system\" size=\"3\" maxlength=\"3\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" value=\"" . $s . "\" />";
$page .= "<input name=\"planet\" size=\"3\" maxlength=\"2\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" value=\"" . $p . "\" />";
Пример #5
0
        $speeds[$id] = GetShipSpeed($id);
        //Cargo space
        $capacity += $pricelist[$id]['capacity'] * $fleetarray[$id];
        //Fuel use
        if ($pricelist[$id]['upgrade'] > 0 && $user[$resource[$pricelist[$id]['drive2']]] > $pricelist[$id]['upgrade']) {
            $fuel += $pricelist[$id]['consumption2'] * $fleetarray[$id];
        } else {
            $fuel += $pricelist[$id]['consumption'] * $fleetarray[$id];
        }
    }
}
//Find the minimum speed.
$speed = min($speeds);
//How Far?
$distance = GetTargetDistance($planetrow['galaxy'], $galaxy, $planetrow['system'], $system, $planetrow['planet'], $planet);
$duration = GetMissionDuration(GetGameSpeedFactor(), $speed, $distance, $fleetspeed);
//$fuelused = GetFleetFuelReq($fleetarray,$speeds,$speed,$fleetspeed,$fuel,$distance);
$fuelused = GetFleetFuelReq($fleetspeed, $fuel, $distance);
//Holding the fleet
if ($fleetmission == 15) {
    $stay = $_GET['expeditiontime'] * 3600;
} elseif ($fleetmission == 5) {
    $stay = $_GET['holdingtime'] * 3600;
} else {
    $stay = 0;
}
//Remove fuel from capacity.
$capacity -= $consumption;
//Currently need no storage... ...but add metal crystal and deut.
$StorageNeeded = 0;
if ($_GET['resource1'] <= 0) {