Пример #1
0
function GetFleetConsumption($FleetArray, $SpeedFactor, $MissionDuration, $MissionDistance, $FleetMaxSpeed, $Player)
{
    $consumption = 0;
    $basicConsumption = 0;
    foreach ($FleetArray as $Ship => $Count) {
        if ($Ship > 0) {
            $ShipSpeed = GetFleetMaxSpeed("", $Ship, $Player);
            $ShipConsumption = GetShipConsumption($Ship, $Player);
            $spd = 35000 / ($MissionDuration * $SpeedFactor - 10) * sqrt($MissionDistance * 10 / $ShipSpeed);
            $basicConsumption = $ShipConsumption * $Count;
            $consumption += $basicConsumption * $MissionDistance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1);
        }
    }
    $consumption = round($consumption) + 1;
    return $consumption;
}
Пример #2
0
    die($ResultMessage);
}
if ($TargetRow['id_owner'] == '' and $_POST['mission'] != 8) {
    $ResultMessage = "601;" . $lang['gs_c601'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles;
    die($ResultMessage);
}
if ($TargetRow["id_owner"] == $planetrow["id_owner"] and $_POST["mission"] == 6) {
    $ResultMessage = "618;" . $lang['gs_c618'] . "|" . $CurrentFlyingFleets . " " . $UserSpyProbes . " " . $UserRecycles . " " . $UserMissiles;
    die($ResultMessage);
}
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);
Пример #3
0
            }
            if ($_POST["ship{$i}"] > $planetrow[$resource[$i]]) {
                $page .= $lang['fl_noenought'];
                $speedalls[$i] = GetFleetMaxSpeed("", $i, $user);
            } else {
                $fleet['fleetarray'][$i] = $_POST["ship{$i}"];
                // Tableau des vaisseaux avec leur nombre
                $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";";
                // Nombre total de vaisseaux
                $fleet['amount'] += $_POST["ship{$i}"];
                // Tableau des vitesses
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"consumption" . $i . "\" value=\"" . GetShipConsumption($i, $user) . "\" />";
                $FleetHiddenBlock .= "<input type=\"hidden\" name=\"speed" . $i . "\"       value=\"" . GetFleetMaxSpeed("", $i, $user) . "\" />";
                $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, $user);
            }
        }
    }
}
if (!$fleet['fleetlist']) {
    message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . $phpEx, 1);
} else {
    $speedallsmin = min($speedalls);
}
$page .= "<script type=\"text/javascript\" src=\"scripts/flotten.js\"></script>";
$page .= "<script type=\"text/javascript\">\n";
$page .= "function getStorageFaktor() {\n";
$page .= "\treturn 1\n";
$page .= "}\n";
$page .= "</script>\n";
Пример #4
0
}
// Prise des coordonnées sur la ligne de commande
$galaxy = intval($_GET['galaxy']);
$system = intval($_GET['system']);
$planet = intval($_GET['planet']);
$planettype = intval($_GET['planettype']);
$target_mission = intval($_GET['target_mission']);
$ShipData = "";
foreach ($reslist['fleet'] as $n => $i) {
    if ($planetrow[$resource[$i]] > 0) {
        $page .= "<tr height=\"20\">";
        $page .= "<th><a title=\"" . $lang['fl_fleetspeed'] . $CurrentShipSpeed . "\">" . $lang['tech'][$i] . "</a></th>";
        $page .= "<th>" . pretty_number($planetrow[$resource[$i]]);
        $ShipData .= "<input type=\"hidden\" name=\"maxship" . $i . "\" value=\"" . $planetrow[$resource[$i]] . "\" />";
        $ShipData .= "<input type=\"hidden\" name=\"consumption" . $i . "\" value=\"" . GetShipConsumption($i, $user) . "\" />";
        $ShipData .= "<input type=\"hidden\" name=\"speed" . $i . "\" value=\"" . GetFleetMaxSpeed("", $i, $user) . "\" />";
        $ShipData .= "<input type=\"hidden\" name=\"capacity" . $i . "\" value=\"" . $pricelist[$i]['capacity'] . "\" />";
        $page .= "</th>";
        // Satelitte Solaire (eux ne peuvent pas bouger !)
        if ($i == 212) {
            $page .= "<th></th><th></th>";
        } else {
            $page .= "<th><a href=\"javascript:maxShip('ship" . $i . "'); shortInfo();\">" . $lang['fl_selmax'] . "</a> </th>";
            $page .= "<th><input name=\"ship" . $i . "\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"" . $lang['tech'][$i] . $planetrow[$resource[$i]] . "\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" /></th>";
        }
        $page .= "</tr>";
    }
    $have_ships = true;
}
$btncontinue = "<tr height=\"20\"><th colspan=\"4\"><input type=\"submit\" value=\" " . $lang['fl_continue'] . " \" /></th>";
$page .= "<tr height=\"20\">";
Пример #5
0
function ShowFleet2Page($CurrentUser, $CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang, $db, $displays;
    //$parse			= $lang;
    $displays->assignContent('fleet/fleet2_table');
    $galaxy = intval($_POST['galaxy']);
    $system = intval($_POST['system']);
    $planet = intval($_POST['planet']);
    $planettype = intval($_POST['planettype']);
    $fleet_group_mr = intval($_POST['fleet_group']);
    //print_r($_POST);
    $YourPlanet = false;
    $UsedPlanet = false;
    $select = $db->query("SELECT `id_owner`,`galaxy`,`system`,`planet`,`planet_type` FROM `{{table}}`", "planets");
    while ($row = mysql_fetch_array($select)) {
        if ($galaxy == $row['galaxy'] && $system == $row['system'] && $planet == $row['planet'] && $planettype == $row['planet_type']) {
            if ($row['id_owner'] == $CurrentUser['id']) {
                $YourPlanet = true;
                $UsedPlanet = true;
            } else {
                $UsedPlanet = true;
            }
            break;
        }
    }
    if ($_POST['planettype'] == 2) {
        if ($_POST['ship209'] >= 1) {
            $missiontype = array(8 => $lang['type_mission'][8]);
        } else {
            $missiontype = array();
        }
    } elseif ($_POST['planettype'] == 1 or $_POST['planettype'] == 3) {
        if ($_POST['ship208'] >= 1 && !$UsedPlanet) {
            $missiontype = array(7 => $lang['type_mission'][7]);
        } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) {
            $missiontype = array(6 => $lang['type_mission'][6]);
        }
        if ($_POST['ship202'] >= 1 || $_POST['ship203'] >= 1 || $_POST['ship204'] >= 1 || $_POST['ship205'] >= 1 || $_POST['ship206'] >= 1 || $_POST['ship207'] >= 1 || $_POST['ship210'] >= 1 || $_POST['ship211'] >= 1 || $_POST['ship213'] >= 1 || $_POST['ship214'] >= 1 || $_POST['ship215'] >= 1 || $_POST['ship216'] >= 1 || $_POST['ship217'] >= 1 || $_POST['ship218'] >= 1 || $_POST['ship219'] >= 1 || $_POST['ship220'] >= 1 || $_POST['ship221'] >= 1 || $_POST['ship222'] >= 1 || $_POST['ship223'] >= 1 || $_POST['ship224'] >= 1 || $_POST['ship225'] >= 1 || $_POST['ship226'] >= 1) {
            if (!$YourPlanet) {
                $missiontype[1] = $lang['type_mission'][1];
            }
            $missiontype[3] = $lang['type_mission'][3];
            $missiontype[5] = $lang['type_mission'][5];
        }
    } elseif ($_POST['ship209'] >= 1 || $_POST['ship208']) {
        $missiontype[3] = $lang['type_mission'][3];
    }
    if ($YourPlanet) {
        $missiontype[4] = $lang['type_mission'][4];
    }
    if (($_POST['planettype'] == 3 || $_POST['planettype'] == 1) && $fleet_group_mr > 0 && $UsedPlanet) {
        $missiontype[2] = $lang['type_mission'][2];
    }
    if ($_POST['planettype'] == 3 && $_POST['ship214'] >= 1 && !$YourPlanet && $UsedPlanet && $CurrentUser['rpg_empereur'] == 1) {
        $missiontype[9] = $lang['type_mission'][9];
    }
    $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"])));
    $mission = $_POST['target_mission'];
    $SpeedFactor = $_POST['speedfactor'];
    $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser);
    $GenFleetSpeed = $_POST['speed'];
    $MaxFleetSpeed = min($AllFleetSpeed);
    $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
    $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
    $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser);
    $MissionSelector = "";
    if (count($missiontype) > 0) {
        if ($planet == 16) {
            $MissionSelector .= "<tr height=\"20\">";
            $MissionSelector .= "<th>";
            $MissionSelector .= "<input type=\"radio\" name=\"mission\" value=\"15\" checked=\"checked\">" . $lang['type_mission'][15] . "<br /><br />";
            $MissionSelector .= "<font color=\"red\">" . $lang['fl_expedition_alert_message'] . "</font>";
            $MissionSelector .= "</th>";
            $MissionSelector .= "</tr>";
        } else {
            $i = 0;
            foreach ($missiontype as $a => $b) {
                $MissionSelector .= "<tr height=\"20\">";
                $MissionSelector .= "<th>";
                $MissionSelector .= "<input id=\"inpuT_" . $i . "\" type=\"radio\" name=\"mission\" value=\"" . $a . "\"" . ($mission == $a ? " checked=\"checked\"" : "") . ">";
                $MissionSelector .= "<label for=\"inpuT_" . $i . "\">" . $b . "</label><br>";
                $MissionSelector .= "</th>";
                $MissionSelector .= "</tr>";
                $i++;
            }
        }
    } else {
        header("location:game.php?page=fleet");
    }
    if ($_POST['thisplanettype'] == 1) {
        $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $lang['fl_planet'] . "";
    } elseif ($_POST['thisplanettype'] == 3) {
        $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $lang['fl_moon'] . "";
    }
    $parse['metal_fleet'] = floor($CurrentPlanet["metal"]);
    $parse['crystal_fleet'] = floor($CurrentPlanet["crystal"]);
    $parse['deuterium_fleet'] = floor($CurrentPlanet["deuterium"]);
    $parse['consumption'] = $consumption;
    $parse['distance'] = $distance;
    $parse['speedfactor_fleet'] = $_POST['speedfactor'];
    $parse['thisgalaxy_fleet'] = $_POST["thisgalaxy"];
    $parse['thissystem_fleet'] = $_POST["thissystem"];
    $parse['thisplanet_fleet'] = $_POST["thisplanet"];
    $parse['galaxy_fleet'] = $_POST["galaxy"];
    $parse['system_fleet'] = $_POST["system"];
    $parse['planet_fleet'] = $_POST["planet"];
    $parse['thisplanettype_fleet'] = $_POST["thisplanettype"];
    $parse['planettype_fleet'] = $_POST["planettype"];
    $parse['speedallsmin_fleet'] = $_POST["speedallsmin"];
    $parse['speed_fleet'] = $_POST['speed'];
    $parse['speedfactor_fleet'] = $_POST["speedfactor"];
    $parse['usedfleet_fleet'] = $_POST["usedfleet"];
    $parse['maxepedition_fleet'] = $_POST['maxepedition'];
    $parse['curepedition_fleet'] = $_POST['curepedition'];
    $parse['fleet_group_fleet'] = $_POST['fleet_group'];
    $parse['acs_target_mr_fleet'] = $_POST['acs_target_mr'];
    foreach ($fleetarray as $Ship => $Count) {
        $input_extra .= "<input type=\"hidden\" name=\"ship" . $Ship . "\"        value=\"" . $Count . "\" />\n";
        $input_extra .= "<input type=\"hidden\" name=\"capacity" . $Ship . "\"    value=\"" . $pricelist[$Ship]['capacity'] . "\" />\n";
        $input_extra .= "<input type=\"hidden\" name=\"consumption" . $Ship . "\" value=\"" . GetShipConsumption($Ship, $CurrentUser) . "\" />\n";
        $input_extra .= "<input type=\"hidden\" name=\"speed" . $Ship . "\"       value=\"" . GetFleetMaxSpeed("", $Ship, $CurrentUser) . "\" />\n";
    }
    $parse['input_extra'] = $input_extra;
    $parse['missionselector'] = $MissionSelector;
    if ($planet == 16) {
        $StayBlock .= "<tr height=\"20\">";
        $StayBlock .= "<td class=\"c\" colspan=\"3\">" . $lang['fl_hold_time'] . "</td>";
        $StayBlock .= "</tr>";
        $StayBlock .= "<tr height=\"20\">";
        $StayBlock .= "<th colspan=\"3\">";
        $StayBlock .= "<select name=\"expeditiontime\" >";
        $StayBlock .= "<option value=\"1\">1</option>";
        $StayBlock .= "<option value=\"2\">2</option>";
        $StayBlock .= "</select>";
        $StayBlock .= "hora(s)";
        $StayBlock .= "</th>";
        $StayBlock .= "</tr>";
    } elseif ($missiontype[5] != '') {
        $StayBlock .= "<tr height=\"20\">";
        $StayBlock .= "<td class=\"c\" colspan=\"3\">" . $lang['fl_hold_time'] . "</td>";
        $StayBlock .= "</tr>";
        $StayBlock .= "<tr height=\"20\">";
        $StayBlock .= "<th colspan=\"3\">";
        $StayBlock .= "<select name=\"holdingtime\" >";
        $StayBlock .= "<option value=\"0\">0</option>";
        $StayBlock .= "<option value=\"1\">1</option>";
        $StayBlock .= "<option value=\"2\">2</option>";
        $StayBlock .= "<option value=\"4\">4</option>";
        $StayBlock .= "<option value=\"8\">8</option>";
        $StayBlock .= "<option value=\"16\">16</option>";
        $StayBlock .= "<option value=\"32\">32</option>";
        $StayBlock .= "</select>";
        $StayBlock .= "hora(s)";
        $StayBlock .= "</th>";
        $StayBlock .= "</tr>";
    }
    $parse['stayblock'] = $StayBlock;
    foreach ($parse as $key => $value) {
        $displays->assign($key, $value);
    }
    $displays->display();
}
Пример #6
0
    if ($TargetPlanet['ally_deposit'] < 1 and $HeDBRec != $MyDBRec and $_POST['mission'] == 5) {
        message("<font color=\"red\"><b>" . $lang['fl_no_allydeposit'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
    }
    if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] and $_POST["mission"] == 1) {
        message("<font color=\"red\"><b>" . $lang['fl_no_self_attack'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
    }
    if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] and $_POST["mission"] == 6) {
        message("<font color=\"red\"><b>" . $lang['fl_no_self_spy'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
    }
    if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] and $_POST["mission"] == 4) {
        message("<font color=\"red\"><b>" . $lang['fl_only_stay_at_home'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
    }
}
$missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
$speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
$AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $user);
$GenFleetSpeed = $_POST['speed'];
$SpeedFactor = $_POST['speedfactor'];
$MaxFleetSpeed = min($AllFleetSpeed);
if (!in_array($GenFleetSpeed, $speed_possible)) {
    message("<font color=\"red\"><b>" . $lang['fl_cheat_speed'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
}
$CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user['current_planet'] . "';", 'planets', true);
if ($MaxFleetSpeed != $_POST['speedallsmin']) {
    message("<font color=\"red\"><b>" . $lang['fl_cheat_speed'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
}
if (!$_POST['planettype']) {
    message("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error'], "fleet." . $phpEx, 2);
}
// Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu
$error = 0;
Пример #7
0
function flt_t_send_fleet($user, &$from, $to, $fleet, $mission, $options = array())
{
    //ini_set('error_reporting', E_ALL);
    //doquery('SET autocommit = 0;');
    //doquery('LOCK TABLES {{users}} READ, {{planets}} WRITE, {{fleet}} WRITE, {{aks}} WRITE, {{statpoints}} READ;');
    doquery('START TRANSACTION;');
    $from = sys_o_get_updated($user, $from['id'], $GLOBALS['time_now']);
    $from = $from['planet'];
    $speed_factor = get_fleet_speed();
    $distance = GetTargetDistance($from['galaxy'], $to['galaxy'], $from['system'], $to['system'], $from['planet'], $to['planet']);
    $fleet_speed = min(GetFleetMaxSpeed($fleet, 0, $user));
    $duration = GetMissionDuration(10, $fleet_speed, $distance, $speed_factor);
    $consumption = GetFleetConsumption($fleet, $speed_factor, $duration, $distance, $fleet_speed, $user);
    //!!
    $fleet_group = 0;
    //!!
    $options = array();
    $can_attack = flt_can_attack($from, $to, $fleet, $mission, $options);
    if ($can_attack != ATTACK_ALLOWED) {
        doquery('ROLLBACK');
        return $can_attack;
    }
    global $time_now, $sn_data;
    $fleet_start_time = $time_now + $duration;
    if ($mission == MT_EXPLORE or $mission == MT_HOLD) {
        $stay_duration = $options['stay_time'] * 3600;
        $stay_time = $fleet_start_time + $stay_duration;
    } else {
        $stay_duration = 0;
        $stay_time = 0;
    }
    $fleet_end_time = $fleet_start_time + $duration + $stay_duration;
    $fleet_ship_count = 0;
    $fleet_string = '';
    $planet_sub_query = '';
    foreach ($fleet as $unit_id => $amount) {
        if (!$amount || !$unit_id) {
            continue;
        }
        if (in_array($unit_id, $sn_data['groups']['fleet'])) {
            $fleet_ship_count += $amount;
            $fleet_string .= "{$unit_id},{$amount};";
        }
        $planet_sub_query .= "`{$sn_data[$unit_id]['name']}` = `{$sn_data[$unit_id]['name']}` - {$amount},";
    }
    $to['id_owner'] = intval($to['id_owner']);
    $QryInsertFleet = "INSERT INTO {{fleets}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '{$user['id']}', ";
    $QryInsertFleet .= "`fleet_mission` = '{$mission}', ";
    $QryInsertFleet .= "`fleet_amount` = '{$fleet_ship_count}', ";
    $QryInsertFleet .= "`fleet_array` = '{$fleet_string}', ";
    $QryInsertFleet .= "`fleet_start_time` = '{$fleet_start_time}', ";
    $QryInsertFleet .= "`fleet_start_galaxy` = '{$from['galaxy']}', ";
    $QryInsertFleet .= "`fleet_start_system` = '{$from['system']}', ";
    $QryInsertFleet .= "`fleet_start_planet` = '{$from['planet']}', ";
    $QryInsertFleet .= "`fleet_start_type` = '{$from['planet_type']}', ";
    $QryInsertFleet .= "`fleet_end_time` = '{$fleet_end_time}', ";
    $QryInsertFleet .= "`fleet_end_stay` = '{$stay_time}', ";
    $QryInsertFleet .= "`fleet_end_galaxy` = '{$to['galaxy']}', ";
    $QryInsertFleet .= "`fleet_end_system` = '{$to['system']}', ";
    $QryInsertFleet .= "`fleet_end_planet` = '{$to['planet']}', ";
    $QryInsertFleet .= "`fleet_end_type` = '{$to['planet_type']}', ";
    $QryInsertFleet .= "`fleet_resource_metal` = '{$fleet[RES_METAL]}', ";
    $QryInsertFleet .= "`fleet_resource_crystal` = '{$fleet[RES_CRYSTAL]}', ";
    $QryInsertFleet .= "`fleet_resource_deuterium` = '{$fleet[RES_DEUTERIUM]}', ";
    $QryInsertFleet .= "`fleet_target_owner` = '{$to['id_owner']}', ";
    $QryInsertFleet .= "`fleet_group` = '{$fleet_group}', ";
    $QryInsertFleet .= "`start_time` = '{$time_now}';";
    doquery($QryInsertFleet);
    $QryUpdatePlanet = "UPDATE {{planets}} SET {$planet_sub_query} `deuterium` = `deuterium` - '{$consumption}' WHERE `id` = '{$from['id']}' LIMIT 1;";
    doquery($QryUpdatePlanet);
    if (BE_DEBUG) {
        debug($QryInsertFleet);
        debug($QryUpdatePlanet);
    }
    doquery("COMMIT;");
    // doquery('SET autocommit = 1;');
    $from = doquery("SELECT * FROM {{planets}} WHERE `id` = '{$from['id']}' LIMIT 1;", '', true);
    return ATTACK_ALLOWED;
    //ini_set('error_reporting', E_ALL ^ E_NOTICE);
}
Пример #8
0
                                $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
                                if ($planet_type == PT_MOON && $fleetarray[SHIP_DEATH_STAR]) {
                                    $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!$target_mission && is_array($missiontype)) {
            $target_mission = MT_ATTACK;
        }
        ksort($missiontype);
        $speed_percent = intval($_POST['speed']);
        $fleet_speed = min(GetFleetMaxSpeed($fleetarray, 0, $user));
        $distance = GetTargetDistance($planetrow['galaxy'], $galaxy, $planetrow['system'], $system, $planetrow['planet'], $planet);
        $duration = GetMissionDuration($speed_percent, $fleet_speed, $distance, $SpeedFactor);
        $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $fleet_speed, $user, $speed_percent);
        // No Break
    // No Break
    case 1:
    case 0:
        $parse['thisgalaxy'] = $planetrow['galaxy'];
        $parse['thissystem'] = $planetrow['system'];
        $parse['thisplanet'] = $planetrow['planet'];
        $parse['thisplanet_type'] = $planetrow['planet_type'];
        // no break
}
$parse['galaxy'] = $galaxy;
$parse['system'] = $system;
Пример #9
0
function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false)
{
    global $config, $sn_data, $user, $time_now;
    if ($user['vacation']) {
        return ATTACK_OWN_VACATION;
    }
    if (empty($fleet) || !is_array($fleet)) {
        return ATTACK_NO_FLEET;
    }
    foreach ($fleet as $ship_id => $ship_count) {
        if ($ship_count > $planet_src[$sn_data[$ship_id]['name']]) {
            return ATTACK_NO_SHIPS;
        }
    }
    $speed = $options['speed'];
    if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
        return ATTACK_WRONG_SPEED;
    }
    $speed_factor = get_fleet_speed();
    $distance = GetTargetDistance($planet_src['galaxy'], $planet_dst['galaxy'], $planet_src['system'], $planet_dst['system'], $planet_src['planet'], $planet_dst['planet']);
    $fleet_speed = min(GetFleetMaxSpeed($fleet, 0, $user));
    $fleet_speed_percent = $options['fleet_speed_percent'] ? $options['fleet_speed_percent'] : 10;
    $duration = GetMissionDuration($fleet_speed_percent, $fleet_speed, $distance, $speed_factor);
    $consumption = GetFleetConsumption($fleet, $speed_factor, $duration, $distance, $fleet_speed, $user, $fleet_speed_percent);
    if ($planet_src[$sn_data[RES_DEUTERIUM]['name']] < $fleet[RES_DEUTERIUM] + $consumption) {
        return ATTACK_NO_FUEL;
    }
    $fleet_start_time = $time_now + $duration;
    $fleet_group = $options['fleet_group'];
    if ($fleet_group) {
        if ($mission != MT_AKS) {
            return ATTACK_WRONG_MISSION;
        }
        $acs = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", '', true);
        if (!$acs['id']) {
            return ATTACK_NO_ACS;
        }
        if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
            return ATTACK_ACS_WRONG_TARGET;
        }
        if ($fleet_start_time > $acs['ankunft']) {
            return ATTACK_ACS_TOO_LATE;
        }
    }
    $flying_fleets = $options['flying_fleets'];
    if (!$flying_fleets) {
        $flying_fleets = doquery("SELECT COUNT(fleet_id) AS `flying_fleets` FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true);
        $flying_fleets = $flying_fleets['flying_fleets'];
    }
    if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
        return ATTACK_NO_SLOTS;
    }
    // Checking for no planet
    if (!$planet_dst['id_owner']) {
        if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
            return ATTACK_NO_COLONIZER;
        }
        if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
            return ATTACK_ALLOWED;
        }
        return ATTACK_NO_TARGET;
    }
    if ($mission == MT_RECYCLE) {
        if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
            return ATTACK_NO_DEBRIS;
        }
        if ($fleet[SHIP_RECYCLER] <= 0) {
            return ATTACK_NO_RECYCLERS;
        }
        return ATTACK_ALLOWED;
    }
    // Got planet. Checking if it is ours
    if ($planet_dst['id_owner'] == $user['id']) {
        if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
            return ATTACK_ALLOWED;
        }
        return ATTACK_OWN;
    }
    // No, planet not ours. Cutting mission that can't be send to not-ours planet
    if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
        return ATTACK_WRONG_MISSION;
    }
    $enemy = doquery("SELECT * FROM {{users}} WHERE `id` = '{$planet_dst['id_owner']}' LIMIT 1;", '', true);
    // We cannot attack or send resource to users in VACATION mode
    if ($enemy['vacation'] && $target_mission != MT_RECYCLE) {
        return ATTACK_VACATION;
    }
    // Multi IP protection. Here we need a procedure to check proxies
    if (sys_is_multiaccount($user, $enemy)) {
        return ATTACK_SAME_IP;
    }
    $user_points = doquery("SELECT total_points FROM {{statpoints}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '{$user['id']}';", '', true);
    $user_points = $user_points['total_points'];
    $enemy_points = doquery("SELECT total_points FROM {{statpoints}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '{$enemy['id']}';", '', true);
    $enemy_points = $enemy_points['total_points'];
    // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer
    if ($mission == MT_TRANSPORT) {
        if ($user_points >= $enemy_points || $config->allow_buffing) {
            return ATTACK_ALLOWED;
        } else {
            return ATTACK_BUFFING;
        }
    }
    // Only aggresive missions passed to this point. HOLD counts as passive but aggresive
    // Is it admin with planet protection?
    if ($planet_dst['id_level'] > $user['authlevel']) {
        return ATTACK_ADMIN;
    }
    // Okay. Now skipping protection checks for inactive longer then 1 week
    if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= $time_now - 60 * 60 * 24 * 7) {
        if ($enemy_points <= $config->game_noob_points && $user_points > $config->game_noob_points || $config->game_noob_factor && $user_points > $enemy_points * $config->game_noob_factor) {
            if ($mission != MT_HOLD) {
                return ATTACK_NOOB;
            }
            if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) {
                return ATTACK_NOOB;
            }
        }
    }
    // Is it HOLD mission? If yes - there should be ally deposit
    if ($mission == MT_HOLD) {
        if ($planet_dst[$sn_data[34]['name']]) {
            return ATTACK_ALLOWED;
        }
        return ATTACK_NO_ALLY_DEPOSIT;
    }
    if ($mission == MT_SPY) {
        if ($fleet[SHIP_SPY] >= 1) {
            return ATTACK_ALLOWED;
        }
        return ATTACK_NO_SPIES;
    }
    // Is it MISSILE mission?
    if ($mission == MT_MISSILE) {
        if ($planet_src[$sn_data[44]['name']] < $sn_data[503]['require'][44]) {
            return ATTACK_NO_SILO;
        }
        if (!$fleet[503]) {
            return ATTACK_NO_MISSILE;
        }
        $distance = abs($planet_dst['system'] - $planet_src['system']);
        $mip_range = get_missile_range();
        if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
            return ATTACK_MISSILE_TOO_FAR;
        }
    }
    if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
        return ATTACK_WRONG_MISSION;
    }
    if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) {
        return flt_bashing_check($user, $enemy, $planet_dst, $mission, $duration, $fleet_group);
    }
    return ATTACK_ALLOWED;
}
Пример #10
0
function ShowFleetPage($CurrentUser, $CurrentPlanet)
{
    global $lang, $reslist, $resource;
    $parse = $lang;
    $maxfleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "';", 'fleets', true);
    $MaxFlyingFleets = $maxfleet['actcnt'];
    $MaxExpedition = $CurrentUser[$resource[124]];
    if ($MaxExpedition >= 1) {
        $maxexpde = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "' AND `fleet_mission` = '15';", 'fleets', true);
        $ExpeditionEnCours = $maxexpde['expedi'];
        $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
    } else {
        $ExpeditionEnCours = 0;
        $EnvoiMaxExpedition = 0;
    }
    $MaxFlottes = 1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * COMMANDANT;
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $galaxy = intval($_GET['galaxy']);
    $system = intval($_GET['system']);
    $planet = intval($_GET['planet']);
    $planettype = intval($_GET['planettype']);
    $target_mission = intval($_GET['target_mission']);
    $ShipData = "";
    if (!$galaxy) {
        $galaxy = $CurrentPlanet['galaxy'];
    }
    if (!$system) {
        $system = $CurrentPlanet['system'];
    }
    if (!$planet) {
        $planet = $CurrentPlanet['planet'];
    }
    if (!$planettype) {
        $planettype = $CurrentPlanet['planet_type'];
    }
    $parse['flyingfleets'] = $MaxFlyingFleets;
    $parse['maxfleets'] = $MaxFlottes;
    $parse['currentexpeditions'] = $ExpeditionEnCours;
    $parse['maxexpeditions'] = $EnvoiMaxExpedition;
    $fq = doquery("SELECT * FROM {{table}} WHERE fleet_owner='" . intval($CurrentUser['id']) . "' AND fleet_mission <> 10", "fleets");
    $i = 0;
    while ($f = mysql_fetch_array($fq)) {
        $i++;
        $FleetPageRow .= "<tr height=20>";
        $FleetPageRow .= "<th>" . $i . "</th>";
        $FleetPageRow .= "<th>";
        $FleetPageRow .= "<a>" . $missiontype[$f['fleet_mission']] . "</a>";
        if ($f['fleet_start_time'] + 1 == $f['fleet_end_time']) {
            $FleetPageRow .= "<br><a title=\"" . $lang['fl_returning'] . "\">" . $lang['fl_r'] . "</a>";
        } else {
            $FleetPageRow .= "<br><a title=\"" . $lang['fl_onway'] . "\">" . $lang['fl_a'] . "</a>";
        }
        $FleetPageRow .= "</th>";
        $FleetPageRow .= "<th><a title=\"";
        $fleet = explode(";", $f['fleet_array']);
        $e = 0;
        foreach ($fleet as $a => $b) {
            if ($b != '') {
                $e++;
                $a = explode(",", $b);
                $FleetPageRow .= $lang['tech'][$a[0]] . ":" . $a[1] . "\n";
                if ($e > 1) {
                    $FleetPageRow .= "\t";
                }
            }
        }
        $FleetPageRow .= "\">" . pretty_number($f['fleet_amount']) . "</a></th>";
        $FleetPageRow .= "<th>[" . $f['fleet_start_galaxy'] . ":" . $f['fleet_start_system'] . ":" . $f['fleet_start_planet'] . "]</th>";
        $FleetPageRow .= "<th>" . date("d M Y H:i:s", $f['fleet_start_time']) . "</th>";
        $FleetPageRow .= "<th>[" . $f['fleet_end_galaxy'] . ":" . $f['fleet_end_system'] . ":" . $f['fleet_end_planet'] . "]</th>";
        $FleetPageRow .= "<th>" . date("d M Y H:i:s", $f['fleet_end_time']) . "</th>";
        $FleetPageRow .= "<th><font color=\"lime\"><div id=\"time_0\"><font>" . pretty_time(floor($f['fleet_end_time'] + 1 - time())) . "</font></th>";
        $FleetPageRow .= "<th>";
        if ($f['fleet_mess'] == 0 || $f['fleet_mess'] == 2) {
            $FleetPageRow .= "<form action=\"SendFleetBack.php\" method=\"post\">";
            $FleetPageRow .= "<input name=\"fleetid\" value=\"" . $f['fleet_id'] . "\" type=\"hidden\">";
            $FleetPageRow .= "<input value=\"" . $lang['fl_send_back'] . "\" type=\"submit\" name=\"send\">";
            $FleetPageRow .= "</form>";
            if ($f[fleet_mission] == 1) {
                $FleetPageRow .= "<form action=\"game.php?page=fleetACS\" method=\"post\">";
                $FleetPageRow .= "<input name=\"fleetid\" value=\"" . $f['fleet_id'] . "\" type=\"hidden\">";
                $FleetPageRow .= "<input value=\"" . $lang['fl_acs'] . "\" type=\"submit\">";
                $FleetPageRow .= "</form>";
            }
        } else {
            $FleetPageRow .= "&nbsp;-&nbsp;";
        }
        $FleetPageRow .= "</th>";
        $FleetPageRow .= "</tr>";
    }
    if ($i == 0) {
        $FleetPageRow .= "<tr>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "</tr>";
    }
    $parse['fleetpagerow'] = $FleetPageRow;
    if ($MaxFlottes == $MaxFlyingFleets) {
        $parse['message_nofreeslot'] .= "<tr height=\"20\"><th colspan=\"9\"><font color=\"red\">" . $lang['fl_no_more_slots'] . "</font></th></tr>";
    }
    if (!$CurrentPlanet) {
        header("location:game.php?page=fleet");
    }
    $parse['total_ships'] = 0;
    foreach ($reslist['fleet'] as $n => $i) {
        if ($CurrentPlanet[$resource[$i]] > 0) {
            $page .= "<tr height=\"20\">";
            $page .= "<th>";
            $page .= $i == 212 ? "" : "<a title=\"" . $lang['fl_speed_title'] . GetFleetMaxSpeed("", $i, $CurrentUser) . "\">";
            $page .= $lang['tech'][$i] . "</a></th>";
            $page .= "<th>" . pretty_number($CurrentPlanet[$resource[$i]]);
            $ShipData .= "<input type=\"hidden\" name=\"maxship" . $i . "\" value=\"" . $CurrentPlanet[$resource[$i]] . "\" />";
            $parse['total_ships'] += $CurrentPlanet[$resource[$i]];
            $ShipData .= "<input type=\"hidden\" name=\"consumption" . $i . "\" value=\"" . GetShipConsumption($i, $CurrentUser) . "\" />";
            $ShipData .= "<input type=\"hidden\" name=\"speed" . $i . "\" value=\"" . GetFleetMaxSpeed("", $i, $CurrentUser) . "\" />";
            $ShipData .= "<input type=\"hidden\" name=\"capacity" . $i . "\" value=\"" . $pricelist[$i]['capacity'] . "\" />";
            $page .= "</th>";
            if ($i == 212) {
                $page .= "<th colspan='2'></th>";
            } else {
                $page .= "<th colspan='2'><input type=button onclick='document.getElementById(\"ship" . $i . "\").value = 0;' value='0' style='width:20px;'/>&nbsp;<input type=button onclick='document.getElementById(\"ship" . $i . "\").value = Math.max(0, parseInt(document.getElementById(\"ship" . $i . "\").value) - 1);' value='-' style='width:20px;'/><input id=\"ship" . $i . "\" name=\"ship" . $i . "\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"" . $lang['tech'][$i] . $CurrentPlanet[$resource[$i]] . "\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" /><input type=button onclick='document.getElementById(\"ship" . $i . "\").value = Math.max(0, parseInt(document.getElementById(\"ship" . $i . "\").value) + 1);' value='+' style='width:20px;'/>&nbsp;<input type=button onclick='document.getElementById(\"ship" . $i . "\").value = " . $CurrentPlanet[$resource[$i]] . ";' value='&Sigma;' style='width:20px;'/></th>";
            }
            $page .= "</tr>";
        }
        $have_ships = true;
    }
    $parse['total_ships'] = pretty_number($parse['total_ships']);
    $btncontinue = "<tr height=\"20\"><th colspan=\"4\"><input type=\"submit\" value=\"" . $lang['fl_continue'] . "\" /></th>";
    $page .= "<tr height=\"20\">";
    if (!$have_ships) {
        $page .= "<th colspan=\"4\">" . $lang['fl_no_ships'] . "</th>";
        $page .= "</tr>";
        $page .= $btncontinue;
    } else {
        $page .= "<th colspan=\"2\"><a href=\"javascript:noShips();shortInfo();noResources();\" >" . $lang['fl_remove_all_ships'] . "</a></th>";
        $page .= "<th colspan=\"2\"><a href=\"javascript:maxShips();shortInfo();\" >" . $lang['fl_select_all_ships'] . "</a></th>";
        $page .= "</tr>";
        if ($MaxFlottes > $MaxFlyingFleets) {
            $page .= $btncontinue;
        }
    }
    $page .= "<input type=\"hidden\" name=\"wormhole\"       value=\"" . $_GET['wormhole'] . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"wormhole_galaxy\"       value=\"" . $_GET['wormhole_galaxy'] . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"wormhole_system\"       value=\"" . $_GET['wormhole_system'] . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"wormhole_planet\"       value=\"" . $_GET['wormhole_planet'] . "\" />\n";
    $parse['body'] = $page;
    $parse['shipdata'] = $ShipData;
    $parse['galaxy'] = $galaxy;
    $parse['system'] = $system;
    $parse['planet'] = $planet;
    $parse['planettype'] = $planettype;
    $parse['target_mission'] = $target_mission;
    $parse['envoimaxexpedition'] = $EnvoiMaxExpedition;
    $parse['expeditionencours'] = $ExpeditionEnCours;
    $parse['target_mission'] = $target_mission;
    display(parsetemplate(gettemplate('fleet/fleet_table'), $parse));
}
Пример #11
0
 protected function GetFleet()
 {
     global $resource, $reslist, $pricelist;
     $planet = $this->player['planet'];
     $system = $this->player['system'];
     $galaxy = $this->player['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 = GetFleetMaxSpeed($fleetarray, 0, $this->player);
         $MaxFleetSpeed = min($AllFleetSpeed);
         $distance = GetTargetDistance($this->CurrentPlanet['galaxy'], $galaxy, $this->CurrentPlanet['system'], $system, $this->CurrentPlanet['planet'], $planet);
         $duration = GetMissionDuration(10, $MaxFleetSpeed, $distance, GetGameSpeedFactor());
         $consumption = GetFleetConsumption($fleetarray, GetGameSpeedFactor(), $duration, $distance, $MaxFleetSpeed, $this->player);
         $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'];
         }
         if ($this->CurrentPlanet['deuterium'] > $FleetStorage) {
             $Mining['deuterium'] = $FleetStorage;
             $FleetStorage = $FleetStorage - $Mining['deuterium'];
         } else {
             $Mining['deuterium'] = $this->CurrentPlanet['deuterium'];
             $FleetStorage = $FleetStorage - $Mining['deuterium'];
         }
         $QryInsertFleet = "INSERT INTO {{table}} SET ";
         $QryInsertFleet .= "`fleet_owner` = '" . $this->player['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'];
     }
 }
Пример #12
0
function ShowFleet3Page($CurrentUser, &$CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang, $svn_root, $db, $displays;
    include_once $svn_root . 'includes/functions/IsVacationMode.' . $phpEx;
    //$parse = $lang;
    if (IsVacationMode($CurrentUser)) {
        exit($displays->message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
    }
    $displays->assignContent('fleet/fleet3_table');
    $fleet_group_mr = 0;
    if ($_POST['fleet_group'] != 0) {
        if ($_POST['mission'] == 2) {
            $aks_count_mr = $db->query("SELECT * FROM {{table}} WHERE id = '" . $_POST['fleet_group'] . "'", 'sac');
            if (mysql_num_rows($aks_count_mr) > 0) {
                $fleet_group_mr = $_POST['fleet_group'];
            }
        }
    }
    if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
        $_POST['mission'] = 1;
    }
    $TargetPlanet = $db->query("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . $_POST['galaxy'] . "' AND `system` = '" . $_POST['system'] . "' AND `planet` = '" . $_POST['planet'] . "' AND `planet_type` = '" . $_POST['planettype'] . "';", 'planets', true);
    $MyDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $CurrentUser['id'] . "';", 'users', true);
    $protection = $db->game_config['noobprotection'];
    $protectiontime = $db->game_config['noobprotectiontime'];
    $protectionmulti = $db->game_config['noobprotectionmulti'];
    if ($protectiontime < 1) {
        $protectiontime = 9999999999999999;
    }
    $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"])));
    if ($TargetPlanet["destruyed"] != 0) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!is_array($fleetarray)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    foreach ($fleetarray as $Ship => $Count) {
        if ($Count > $CurrentPlanet[$resource[$Ship]]) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
    }
    $error = 0;
    $galaxy = intval($_POST['galaxy']);
    $system = intval($_POST['system']);
    $planet = intval($_POST['planet']);
    $planettype = intval($_POST['planettype']);
    $fleetmission = $_POST['mission'];
    if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($fleetmission == 8) {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets");
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = $db->query("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets");
    }
    if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['mission'] != 15) {
        if (mysql_num_rows($select) < 1 && $fleetmission != 7) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
    } else {
        $MaxExpedition = $CurrentUser[$resource[124]];
        if ($MaxExpedition >= 1) {
            $maxexpde = $db->query("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "' AND `fleet_mission` = '15';", 'fleets', true);
            $ExpeditionEnCours = $maxexpde['expedi'];
            $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
        } else {
            $ExpeditionEnCours = 0;
            $EnvoiMaxExpedition = 0;
        }
        if ($EnvoiMaxExpedition == 0) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $select = mysql_fetch_array($select);
    if ($select['id_owner'] == $CurrentUser['id']) {
        $YourPlanet = true;
        $UsedPlanet = true;
    } elseif (!empty($select['id_owner'])) {
        $YourPlanet = false;
        $UsedPlanet = true;
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
    }
    if (empty($fleetmission)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($TargetPlanet['id_owner'] == '') {
        $HeDBRec = $MyDBRec;
    } elseif ($TargetPlanet['id_owner'] != '') {
        $HeDBRec = $db->query("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . $TargetPlanet['id_owner'] . "';", 'users', true);
    }
    $UserPoints = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $MyDBRec['id'] . "';", 'statpoints', true);
    $User2Points = $db->query("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';", 'statpoints', true);
    $MyGameLevel = $UserPoints['total_points'];
    $HeGameLevel = $User2Points['total_points'];
    //PROTECCION
    include_once "./includes/functions/classes/class.noobs.php";
    $noobs = new proteccion_noob();
    $noobs->prin = $MyGameLevel;
    $noobs->mission = $_POST['mission'];
    $noobs->seco = $HeGameLevel;
    $noobs->vacation = $HeDBRec['urlaubs_modus'];
    $noobs_users = $noobs->check();
    if ($noobs_users['status']) {
        $span = explode("_", $noobs_users['lang_g']);
        $array = array("s" => "red", "w" => "lime", "v" => "lime");
        //$ResultMessage = "{$array[$span[1]]}; ".$lang[$noobs_users['lang_f']]." |".$CurrentFlyingFleets." ".$UserSpyProbes." ".$UserRecycles." ".$UserMissiles;
        //die ( $ResultMessage );
        $displays->message("<font color=\"{$array[$span[1]]}\"><b>" . $lang[$noobs_users['lang_f']] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    /*
    	if($HeDBRec['onlinetime'] >= (time()-60 * 60 * 24 * 7))
    	{
    		if ($MyGameLevel > ($HeGameLevel * $protectionmulti)
    			&& $TargetPlanet['id_owner'] != ''
    			&& ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)
    			&& $protection == 1
    			&& $HeGameLevel < ($protectiontime * 1000))
    			$displays->message("<font color=\"lime\"><b>".$lang['fl_week_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    
    		if (($MyGameLevel * $protectionmulti) < $HeGameLevel
    			&& $TargetPlanet['id_owner'] != ''
    			&& ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)
    			&& $protection == 1
    			&& $MyGameLevel < ($protectiontime * 1000))
    			$displays->message("<font color=\"red\"><b>".$lang['fl_strong_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    	}
    
    	if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8)
    		$displays->message("<font color=\"lime\"><b>".$lang['fl_in_vacation_player']."</b></font>", "game." . $phpEx . "?page=fleet", 2);
    */
    //FIN DE PROTECCION
    $FlyingFleets = mysql_fetch_assoc($db->query("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='{$CurrentUser['id']}'", 'fleets'));
    $ActualFleets = $FlyingFleets["Number"];
    if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * 3 <= $ActualFleets) {
        $displays->message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
        $displays->message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['mission'] != 15) {
        if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) {
            exit(header("location:game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) {
            $displays->message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
    $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser);
    $GenFleetSpeed = $_POST['speed'];
    $SpeedFactor = $_POST['speedfactor'];
    $MaxFleetSpeed = min($AllFleetSpeed);
    if (!in_array($GenFleetSpeed, $speed_possible)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($MaxFleetSpeed != $_POST['speedallsmin']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planettype']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    if (!isset($fleetarray)) {
        exit(header("location:game." . $phpEx . "?page=fleet"));
    }
    $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
    $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
    $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser);
    $fleet['start_time'] = $duration + time();
    if ($_POST['mission'] == 15) {
        $StayDuration = $_POST['expeditiontime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600;
    } elseif ($_POST['mission'] == 5) {
        $StayDuration = $_POST['holdingtime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
    } else {
        $StayDuration = 0;
        $StayTime = 0;
    }
    $StorageNeeded = 0;
    $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
    $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
    $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
    if ($_POST['resource1'] < 1) {
        $TransMetal = 0;
    } else {
        $TransMetal = $_POST['resource1'];
        $StorageNeeded += $TransMetal;
    }
    if ($_POST['resource2'] < 1) {
        $TransCrystal = 0;
    } else {
        $TransCrystal = $_POST['resource2'];
        $StorageNeeded += $TransCrystal;
    }
    if ($_POST['resource3'] < 1) {
        $TransDeuterium = 0;
    } else {
        $TransDeuterium = $_POST['resource3'];
        $StorageNeeded += $TransDeuterium;
    }
    $FleetShipCount = 0;
    $FleetStorage = 0;
    $fleet_array = "";
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_array .= $Ship . "," . $Count . ";";
        $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
        $FleetShipCount += $Count;
        $CurrentPlanet[$resource[$Ship]] = $CurrentPlanet[$resource[$Ship]] - $Count;
    }
    $StockMetal = $CurrentPlanet['metal'];
    $StockCrystal = $CurrentPlanet['crystal'];
    $StockDeuterium = $CurrentPlanet['deuterium'];
    $StockDeuterium -= $consumption;
    $StockOk = false;
    if ($StockMetal >= $TransMetal) {
        if ($StockCrystal >= $TransCrystal) {
            if ($StockDeuterium >= $TransDeuterium) {
                $StockOk = true;
            }
        }
    }
    if (!$StockOk) {
        $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($StorageNeeded > $FleetStorage) {
        $displays->message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $db->game_config['adm_attack'] == 0) {
        $displays->message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2);
    }
    $fleet['end_time'] = $StayDuration + 2 * $duration + time();
    if ($fleet_group_mr != 0) {
        $AksStartTime = mysql_fetch_array($db->query("SELECT MAX(`fleet_start_time`) AS Start, MAX(`fleet_end_time`) AS End FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", 'fleets'));
        if ($AksStartTime['Start'] > $fleet['start_time']) {
            $fleet['start_time'] = $AksStartTime['Start'] + 1;
            $fleet['end_time'] = $AksStartTime['End'] + 1;
        } else {
            $AksTime = mysql_fetch_array($db->query("SELECT fleet_start_time, fleet_end_time FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '1';", 'fleets'));
            if ($AksTime['fleet_start_time'] < $fleet['start_time']) {
                $QryUpdateFleets = "UPDATE {{table}} SET ";
                $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
                $QryUpdateFleets .= "`fleet_end_time` = '" . $fleet['end_time'] . "' ";
                $QryUpdateFleets .= "WHERE ";
                $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "' AND ";
                $QryUpdateFleets .= "`fleet_mission` = '1';";
                $db->query($QryUpdateFleets, "fleets");
                $SelectFleets = $db->query("SELECT * FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "' AND `fleet_mission` = '2' ORDER BY `fleet_id` ASC ;", 'fleets');
                $nb = mysql_num_rows($SelectFleets);
                $i = 0;
                if ($nb > 0) {
                    while ($row = mysql_fetch_array($SelectFleets)) {
                        $i++;
                        $row['fleet_start_time'] = $fleet['start_time'] + $i;
                        $row['fleet_end_time'] = $fleet['end_time'] + $i;
                        $QryUpdateFleets = "UPDATE {{table}} SET ";
                        $QryUpdateFleets .= "`fleet_start_time` = '" . $row['fleet_start_time'] . "', ";
                        $QryUpdateFleets .= "`fleet_end_time` = '" . $row['fleet_end_time'] . "' ";
                        $QryUpdateFleets .= "WHERE ";
                        $QryUpdateFleets .= "`fleet_id` = '" . $row['fleet_id'] . "';";
                        $db->query($QryUpdateFleets, "fleets");
                    }
                }
                $fleet['start_time'] = $fleet['start_time'] + $nb + 1;
                $fleet['end_time'] = $fleet['end_time'] + $nb + 1;
            }
        }
    }
    $CurrentPlanet["fleet"] = $fleetarray;
    $FleetStorage -= $consumption;
    $CurrentPlanet["metal"] -= $TransMetal;
    $CurrentPlanet["crystal"] -= $TransCrystal;
    $CurrentPlanet["deuterium"] -= $TransDeuterium + $consumption;
    $QryInsertFleet = "INSERT INTO {{table}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '" . $CurrentUser['id'] . "', ";
    $QryInsertFleet .= "`fleet_mission` = '" . $_POST['mission'] . "', ";
    $QryInsertFleet .= "`fleet_amount` = '" . $FleetShipCount . "', ";
    $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', ";
    $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
    $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', ";
    $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', ";
    $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', ";
    $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', ";
    $QryInsertFleet .= "`fleet_end_time` = '" . $fleet['end_time'] . "', ";
    $QryInsertFleet .= "`fleet_end_stay` = '" . $StayTime . "', ";
    $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', ";
    $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', ";
    $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', ";
    $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', ";
    $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', ";
    $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', ";
    $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', ";
    $QryInsertFleet .= "`fleet_target_owner` = '" . $TargetPlanet['id_owner'] . "', ";
    $QryInsertFleet .= "`fleet_group` = '" . $fleet_group_mr . "', ";
    $QryInsertFleet .= "`start_time` = '" . time() . "';";
    $db->query($QryInsertFleet, 'fleets');
    $parse['mission'] = $missiontype[$_POST['mission']];
    $parse['distance'] = pretty_number($distance);
    $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']);
    $parse['consumption'] = pretty_number($consumption);
    $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'];
    $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet'];
    $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']);
    $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']);
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_list .= "</tr><tr height=\"20\">";
        $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>";
        $fleet_list .= "<th>" . pretty_number($Count) . "</th>";
    }
    $parse['fleet_list'] = $fleet_list;
    foreach ($parse as $key => $value) {
        $displays->assign($key, $value);
    }
    $displays->display();
}
Пример #13
0
function ShowFleetPage($CurrentUser, $CurrentPlanet)
{
    global $lang, $reslist, $resource, $db, $displays;
    //$parse				= $lang;
    $displays->assignContent('fleet/fleet_table');
    $maxfleet = $db->query("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets', true);
    $MaxFlyingFleets = $maxfleet['actcnt'];
    $MaxExpedition = $CurrentUser[$resource[124]];
    if ($MaxExpedition >= 1) {
        $maxexpde = $db->query("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "' AND `fleet_mission` = '15';", 'fleets', true);
        $ExpeditionEnCours = $maxexpde['expedi'];
        $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
    } else {
        $ExpeditionEnCours = 0;
        $EnvoiMaxExpedition = 0;
    }
    $MaxFlottes = 1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * 3;
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $galaxy = intval($_GET['galaxy']);
    $system = intval($_GET['system']);
    $planet = intval($_GET['planet']);
    $planettype = intval($_GET['planettype']);
    $target_mission = intval($_GET['target_mission']);
    $ShipData = "";
    if (!$galaxy) {
        $galaxy = $CurrentPlanet['galaxy'];
    }
    if (!$system) {
        $system = $CurrentPlanet['system'];
    }
    if (!$planet) {
        $planet = $CurrentPlanet['planet'];
    }
    if (!$planettype) {
        $planettype = $CurrentPlanet['planet_type'];
    }
    $parse['flyingfleets'] = $MaxFlyingFleets;
    $parse['maxfleets'] = $MaxFlottes;
    $parse['currentexpeditions'] = $ExpeditionEnCours;
    $parse['maxexpeditions'] = $EnvoiMaxExpedition;
    $fq = $db->query("SELECT * FROM {{table}} WHERE fleet_owner='{$CurrentUser['id']}' AND fleet_mission <> 10", "fleets");
    $i = 0;
    while ($f = mysql_fetch_array($fq)) {
        $i++;
        $FleetPageRow .= "<tr height=20>";
        $FleetPageRow .= "<th>" . $i . "</th>";
        $FleetPageRow .= "<th>";
        $FleetPageRow .= "<a>" . $missiontype[$f[fleet_mission]] . "</a>";
        if ($f['fleet_start_time'] + 1 == $f['fleet_end_time']) {
            $FleetPageRow .= "<br><a title=\"" . $lang['fl_returning'] . "\">" . $lang['fl_r'] . "</a>";
        } else {
            $FleetPageRow .= "<br><a title=\"" . $lang['fl_onway'] . "\">" . $lang['fl_a'] . "</a>";
        }
        $FleetPageRow .= "</th>";
        $FleetPageRow .= "<th><a title=\"";
        $fleet = explode(";", $f['fleet_array']);
        $e = 0;
        foreach ($fleet as $a => $b) {
            if ($b != '') {
                $e++;
                $a = explode(",", $b);
                $FleetPageRow .= $lang['tech'][$a[0]] . ":" . $a[1] . "\n";
                if ($e > 1) {
                    $FleetPageRow .= "\t";
                }
            }
        }
        $FleetPageRow .= "\">" . pretty_number($f[fleet_amount]) . "</a></th>";
        $FleetPageRow .= "<th>[" . $f[fleet_start_galaxy] . ":" . $f[fleet_start_system] . ":" . $f[fleet_start_planet] . "]</th>";
        $FleetPageRow .= "<th>" . gmdate("d M Y H:i:s", $f['fleet_start_time']) . "</th>";
        $FleetPageRow .= "<th>[" . $f[fleet_end_galaxy] . ":" . $f[fleet_end_system] . ":" . $f[fleet_end_planet] . "]</th>";
        $FleetPageRow .= "<th>" . gmdate("d M Y H:i:s", $f['fleet_end_time']) . "</th>";
        $FleetPageRow .= "<th><font color=\"lime\"><div id=\"time_0\"><font>" . pretty_time(floor($f['fleet_end_time'] + 1 - time())) . "</font></th>";
        $FleetPageRow .= "<th>";
        if ($f['fleet_mess'] == 0 || $f['fleet_mess'] == 2) {
            $FleetPageRow .= "<form action=\"?page=fleetback\" method=\"post\">";
            $FleetPageRow .= "<input name=\"fleetid\" value=\"" . $f['fleet_id'] . "\" type=\"hidden\">";
            $FleetPageRow .= "<input value=\"" . $lang['fl_send_back'] . "\" type=\"submit\" name=\"send\">";
            $FleetPageRow .= "</form>";
            if ($f["fleet_mission"] == 1 || $f["fleet_mission"] == 2) {
                $FleetPageRow .= "<form action=\"game.php?page=fleetsac\" method=\"post\">";
                $FleetPageRow .= "<input name=\"fleetid\" value=\"" . $f['fleet_id'] . "\" type=\"hidden\">";
                $FleetPageRow .= "<input value=\"" . $lang['fl_acs'] . "\" type=\"submit\">";
                $FleetPageRow .= "</form>";
            }
        } else {
            $FleetPageRow .= "&nbsp;-&nbsp;";
        }
        $FleetPageRow .= "</th>";
        $FleetPageRow .= "</tr>";
    }
    if ($i == 0) {
        $FleetPageRow .= "<tr>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "<th>-</th>";
        $FleetPageRow .= "</tr>";
    }
    $parse['fleetpagerow'] = $FleetPageRow;
    if ($MaxFlottes == $MaxFlyingFleets) {
        $parse['message_nofreeslot'] .= "<tr height=\"20\"><th colspan=\"9\"><font color=\"red\">" . $lang['fl_no_more_slots'] . "</font></th></tr>";
    }
    if (!$CurrentPlanet) {
        header("location:game.php?page=fleet");
    }
    foreach ($reslist['fleet'] as $n => $i) {
        if ($CurrentPlanet[$resource[$i]] > 0) {
            $displays->newblock("list_fleet");
            //$page .= "<tr height=\"20\">";
            //$page .= "<th>";
            $parses["link"] = $i == 212 ? $lang['tech'][$i] : "<a title=\"" . $lang['fl_speed_title'] . GetFleetMaxSpeed("", $i, $CurrentUser) . "\">" . $lang['tech'][$i] . "</a>";
            $parses["numero"] = pretty_number($CurrentPlanet[$resource[$i]]);
            $enviar["ship" . $i] = str_replace(".", "", $parses["numero"]);
            if ($i != 212) {
                $parses["max"] = "<a href=\"javascript:maxShip2('" . str_replace(".", "", $parses["numero"]) . "','ship" . $i . "');\">" . $lang['fl_max'] . "</a>";
                $parses["input"] = "<input id=\"ship" . $i . "\" name=\"ship" . $i . "\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"" . $lang['tech'][$i] . $CurrentPlanet[$resource[$i]] . "\"  />";
            }
            foreach ($parses as $key => $value) {
                $displays->assign($key, $value);
            }
            unset($parses);
            $have_ships = true;
        }
        //$have_ships = true;
    }
    $btncontinue = "<tr height=\"20\"><th colspan=\"4\"><input type=\"submit\" value=\"" . $lang['fl_continue'] . "\" /></th>";
    $page .= "<tr height=\"20\">";
    if (!$have_ships) {
        $page .= "<th colspan=\"4\">" . $lang['fl_no_ships'] . "</th>";
        $page .= "</tr>";
        $page .= $btncontinue;
    } else {
        $page .= "<th colspan=\"2\"><a href=\"javascript:noShips();\" >" . $lang['fl_remove_all_ships'] . "</a></th>";
        $page .= "<th colspan=\"2\"><a href=\"#\" onclick=\" ";
        //javascript:maxShips();\" >".$lang['fl_select_all_ships']."</a></th>";
        foreach ($enviar as $key => $value) {
            $page .= "maxShip2('" . $value . "','" . $key . "');";
        }
        $page .= "\" >" . $lang['fl_select_all_ships'] . "</a></th>";
        if ($MaxFlottes > $MaxFlyingFleets) {
            $page .= $btncontinue;
        }
    }
    $parse['body'] = $page;
    $parse['shipdata'] = $ShipData;
    $parse['galaxy'] = $galaxy;
    $parse['system'] = $system;
    $parse['planet'] = $planet;
    $parse['planettype'] = $planettype;
    $parse['target_mission'] = $target_mission;
    $parse['envoimaxexpedition'] = $EnvoiMaxExpedition;
    $parse['expeditionencours'] = $ExpeditionEnCours;
    $parse['target_mission'] = $target_mission;
    $displays->gotoBlock("_ROOT");
    foreach ($parse as $key => $value) {
        $displays->assign($key, $value);
    }
    $displays->display();
}
Пример #14
0
    $target_structure = intval($_POST['structures']);
    if ($target_structure && !in_array($target_structure, $sn_data['groups']['defense_active'])) {
        $cant_attack = ATTACK_WRONG_STRUCTURE;
        die("{$cant_attack}|{$lang['fl_attack_error'][$cant_attack]}|{$CurrentFlyingFleets}|{$UserSpyProbes}|{$UserRecycles}|{$UserMissiles}");
    }
    $mips_sent = $fleet_array[503];
    $distance = abs($target_system - $planetrow['system']);
    $mipRange = $user['impulse_motor_tech'] * 5 - 1;
    $arrival = $time_now + round((30 + 60 * $distance) / get_fleet_speed());
    doquery("INSERT INTO `{{iraks}}` SET\r\n     `zielid` = '{$TargetRow['id_owner']}', `galaxy` = '{$target_galaxy}', `system` = '{$target_system}', `planet` = '{$target_planet}',\r\n     `owner` = '{$user['id']}', `galaxy_angreifer` = '{$planetrow['galaxy']}', `system_angreifer` = '{$planetrow['system']}', `planet_angreifer` = '{$planetrow['planet']}',\r\n     `zeit` = '{$arrival}', `anzahl` = '{$mips_sent}', `primaer` = '{$target_structure}';");
    $FleetSubQRY = "`{$sn_data[503]['name']}` = `{$sn_data[503]['name']}` - '{$mips_sent}', ";
    $Ship = 503;
    //doquery("UPDATE `{{planets}}` SET  WHERE `id` = '{$user['current_planet']}' LIMIT 1;");
} else {
    $Distance = GetTargetDistance($planetrow['galaxy'], $target_galaxy, $planetrow['system'], $target_system, $planetrow['planet'], $target_planet);
    $speedall = GetFleetMaxSpeed($fleet_array, 0, $user);
    $SpeedAllMin = min($speedall);
    $Duration = GetMissionDuration(10, $SpeedAllMin, $Distance, get_fleet_speed());
    $fleet_start_time = $Duration + time();
    $fleet_end_time = $Duration * 2 + time();
    $consumption = 0;
    $SpeedFactor = get_fleet_speed();
    foreach ($fleet_array as $Ship => $Count) {
        $ShipSpeed = $sn_data[$Ship]["speed"];
        $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed);
        $basicConsumption = $sn_data[$Ship]["consumption"] * $Count;
        $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1);
    }
    $consumption = round($consumption) + 1;
    if ($UserDeuterium < $consumption) {
        $ResultMessage = "13|{$lang['gs_c13']}|{$CurrentFlyingFleets}|{$UserSpyProbes}|{$UserRecycles}|{$UserMissiles}";
Пример #15
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));
}
Пример #16
0
function ShowFleet3Page($CurrentUser, $CurrentPlanet)
{
    global $resource, $pricelist, $reslist, $phpEx, $lang, $xgp_root, $game_config;
    include_once $xgp_root . 'includes/functions/IsVacationMode.' . $phpEx;
    $parse = $lang;
    if (IsVacationMode($CurrentUser)) {
        die(message($lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
    }
    $fleet_group_mr = 0;
    if ($_POST['fleet_group'] > 0) {
        if ($_POST['mission'] == 2) {
            $target = "g" . intval($_POST["galaxy"]) . "s" . intval($_POST["system"]) . "p" . intval($_POST["planet"]) . "t" . intval($_POST["planettype"]);
            if ($_POST['acs_target_mr'] == $target) {
                $aks_count_mr = doquery("SELECT * FROM {{table}} WHERE id = '" . intval($_POST['fleet_group']) . "'", 'aks');
                if (mysql_num_rows($aks_count_mr) > 0) {
                    $fleet_group_mr = $_POST['fleet_group'];
                }
            }
        }
    }
    if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
        $_POST['mission'] = 1;
    }
    $TargetPlanet = doquery("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM {{table}} WHERE `galaxy` = '" . intval($_POST['galaxy']) . "' AND `system` = '" . intval($_POST['system']) . "' AND `planet` = '" . intval($_POST['planet']) . "' AND `planet_type` = '" . intval($_POST['planettype']) . "';", 'planets', true);
    $MyDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($CurrentUser['id']) . "';", 'users', true);
    $IsHereWormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['galaxy'] . "' AND `start_system` = '" . $_POST['system'] . "' AND `start_planet` = '" . $_POST['planet'] . "') OR (`end_galaxy` = '" . $_POST['galaxy'] . "' AND `end_system` = '" . $_POST['system'] . "' AND `end_planet` = '" . $_POST['planet'] . "');", 'wormholes', true);
    $protection = $game_config['noobprotection'];
    $protectiontime = $game_config['noobprotectiontime'];
    $protectionmulti = $game_config['noobprotectionmulti'];
    if ($protectiontime < 1) {
        $protectiontime = 9999999999999999;
    }
    $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"])));
    if ($TargetPlanet["destruyed"] != 0) {
        die(header("Location: game.php?page=fleet"));
    }
    if (!is_array($fleetarray)) {
        die(header("Location: game.php?page=fleet"));
    }
    foreach ($fleetarray as $Ship => $Count) {
        if ($Count > $CurrentPlanet[$resource[$Ship]]) {
            die(header("Location: game." . $phpEx . "?page=fleet"));
        }
    }
    $error = 0;
    $galaxy = intval($_POST['galaxy']);
    $system = intval($_POST['system']);
    $planet = intval($_POST['planet']);
    $planettype = intval($_POST['planettype']);
    $fleetmission = intval($_POST['mission']);
    if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($fleetmission == 8) {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "'", "planets");
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
        $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '" . $galaxy . "' AND system = '" . $system . "' AND planet = '" . $planet . "' AND planet_type = '" . $planettype . "'", "planets");
    }
    if ($CurrentPlanet['galaxy'] == $galaxy && $CurrentPlanet['system'] == $system && $CurrentPlanet['planet'] == $planet && $CurrentPlanet['planet_type'] == $planettype) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['mission'] != 15) {
        if (mysql_num_rows($select) < 1 && $fleetmission != 7) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
    } else {
        $MaxExpedition = $CurrentUser[$resource[124]];
        if ($MaxExpedition >= 1) {
            $maxexpde = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '" . intval($CurrentUser['id']) . "' AND `fleet_mission` = '15';", 'fleets', true);
            $ExpeditionEnCours = $maxexpde['expedi'];
            $EnvoiMaxExpedition = 1 + floor($MaxExpedition / 3);
        } else {
            $ExpeditionEnCours = 0;
            $EnvoiMaxExpedition = 0;
        }
        if ($EnvoiMaxExpedition == 0) {
            message("<font color=\"red\"><b>" . $lang['fl_expedition_tech_required'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
            message("<font color=\"red\"><b>" . $lang['fl_expedition_fleets_limit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $select = mysql_fetch_array($select);
    if ($select['id_owner'] == $CurrentUser['id']) {
        $YourPlanet = true;
        $UsedPlanet = true;
    } elseif (!empty($select['id_owner'])) {
        $YourPlanet = false;
        $UsedPlanet = true;
    } else {
        $YourPlanet = false;
        $UsedPlanet = false;
    }
    if (empty($fleetmission)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($TargetPlanet['id_owner'] == '') {
        $HeDBRec = $MyDBRec;
    } elseif ($TargetPlanet['id_owner'] != '') {
        $HeDBRec = doquery("SELECT `id`,`onlinetime`,`ally_id`,`urlaubs_modus` FROM {{table}} WHERE `id` = '" . intval($TargetPlanet['id_owner']) . "';", 'users', true);
    }
    $UserPoints = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($MyDBRec['id']) . "';", 'statpoints', true);
    $User2Points = doquery("SELECT `total_points` FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . intval($HeDBRec['id']) . "';", 'statpoints', true);
    $MyGameLevel = $UserPoints['total_points'];
    $HeGameLevel = $User2Points['total_points'];
    if ($HeDBRec['onlinetime'] >= time() - 60 * 60 * 24 * 7) {
        if ($MyGameLevel > $HeGameLevel * $protectionmulti && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $HeGameLevel < $protectiontime * 1000) {
            message("<font color=\"lime\"><b>" . $lang['fl_week_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($MyGameLevel * $protectionmulti < $HeGameLevel && $TargetPlanet['id_owner'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9) && $protection == 1 && $MyGameLevel < $protectiontime * 1000) {
            message("<font color=\"red\"><b>" . $lang['fl_strong_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    if ($HeDBRec['urlaubs_modus'] && $_POST['mission'] != 8) {
        message("<font color=\"lime\"><b>" . $lang['fl_in_vacation_player'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    $FlyingFleets = mysql_fetch_assoc(doquery("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='" . intval($CurrentUser['id']) . "'", 'fleets'));
    $ActualFleets = $FlyingFleets["Number"];
    if (1 + $CurrentUser[$resource[108]] + $CurrentUser['rpg_commandant'] * COMMANDANT <= $ActualFleets) {
        message($lang['fl_no_slots'], "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] + $_POST['resource4'] < 1 && $_POST['mission'] == 3) {
        message("<font color=\"lime\"><b>" . $lang['fl_empty_transport'] . "</b></font>", "game." . $phpEx . "?page=fleet", 1);
    }
    if ($_POST['mission'] != 15) {
        if ($TargetPlanet['id_owner'] == '' && $_POST['mission'] < 7) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet['id_owner'] != '' && $_POST['mission'] == 7) {
            message("<font color=\"red\"><b>" . $lang['fl_planet_populed'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($IsHereWormHole) {
            message("<font color=\"red\"><b>Hay un agujero de gusano en esa posicion</b></font>", "fleet." . $phpEx, 2);
        }
        if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $_POST['mission'] == 4) {
            message("<font color=\"red\"><b>" . $lang['fl_stay_not_on_enemy'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet['ally_deposit'] < 1 && $HeDBRec != $MyDBRec && $_POST['mission'] == 5) {
            message("<font color=\"red\"><b>" . $lang['fl_not_ally_deposit'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
        if ($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"] && ($_POST["mission"] == 1 or $_POST["mission"] == 6)) {
            exit(header("Location: game." . $phpEx . "?page=fleet"));
        }
        if ($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"] && $_POST["mission"] == 4) {
            message("<font color=\"red\"><b>" . $lang['fl_deploy_only_your_planets'] . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
        }
    }
    $missiontype = array(1 => $lang['type_mission'][1], 2 => $lang['type_mission'][2], 3 => $lang['type_mission'][3], 4 => $lang['type_mission'][4], 5 => $lang['type_mission'][5], 6 => $lang['type_mission'][6], 7 => $lang['type_mission'][7], 8 => $lang['type_mission'][8], 9 => $lang['type_mission'][9], 15 => $lang['type_mission'][15]);
    $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
    $AllFleetSpeed = GetFleetMaxSpeed($fleetarray, 0, $CurrentUser);
    $GenFleetSpeed = $_POST['speed'];
    $SpeedFactor = $game_config['fleet_speed'] / 2500;
    $MaxFleetSpeed = min($AllFleetSpeed);
    if (!in_array($GenFleetSpeed, $speed_possible)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($MaxFleetSpeed != $_POST['speedallsmin']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planettype']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | $_POST['thissystem'] != $CurrentPlanet['system'] | $_POST['thisplanet'] != $CurrentPlanet['planet'] | $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if (!isset($fleetarray)) {
        exit(header("Location: game." . $phpEx . "?page=fleet"));
    }
    if ($_POST['wormhole'] == 'on') {
        $WormHole = doquery("SELECT * FROM {{table}} WHERE (`start_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `start_system` = '" . $_POST['wormhole_system'] . "' AND `start_planet` = '" . $_POST['wormhole_planet'] . "') OR (`end_galaxy` = '" . $_POST['wormhole_galaxy'] . "' AND `end_system` = '" . $_POST['wormhole_system'] . "' AND `end_planet` = '" . $_POST['wormhole_planet'] . "');", 'wormholes', true);
        if ($WormHole) {
            if ($WormHole['state'] == 0) {
                message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet");
            }
            if ($WormHole['time'] < time() and $WormHole['state'] == 1) {
                message('El Agujero de gusano esta inestable', "game." . $phpEx . "?page=fleet");
            }
            if ($fleetarray[210] >= 1) {
                message('Las Sondas de espionaje no pueden atravesar los Agujeros de gusano', "game." . $phpEx . "?page=fleet");
            }
            if ($WormHole['start_galaxy'] == $_POST['wormhole_galaxy'] and $WormHole['start_system'] == $_POST['wormhole_system'] and $WormHole['start_planet'] == $_POST['wormhole_planet']) {
                $Orientation = 'end';
            } else {
                $Orientation = 'start';
            }
            $distance1 = GetTargetDistance($_POST['thisgalaxy'], $_POST['wormhole_galaxy'], $_POST['thissystem'], $_POST['wormhole_system'], $_POST['thisplanet'], $_POST['wormhole_planet']);
            $distance2 = GetTargetDistance($WormHole[$Orientation . '_galaxy'], $_POST['galaxy'], $WormHole[$Orientation . '_system'], $_POST['system'], $WormHole[$Orientation . '_planet'], $_POST['planet']);
            $distance = $distance1 + $distance2;
            $wormhole_id = $WormHole['id'] . ',' . $Orientation;
        } else {
            message('El Agujero de gusano no existe', "game." . $phpEx . "?page=fleet");
        }
    } else {
        $wormhole_id = 0;
        $distance = GetTargetDistance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
    }
    $duration = GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
    $consumption = GetFleetConsumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $CurrentUser);
    $fleet['start_time'] = $duration + time();
    if ($_POST['mission'] == 15) {
        $StayDuration = $_POST['expeditiontime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600;
    } elseif ($_POST['mission'] == 5) {
        $StayDuration = $_POST['holdingtime'] * 3600;
        $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
    } else {
        $StayDuration = 0;
        $StayTime = 0;
    }
    $fleet['end_time'] = $StayDuration + 2 * $duration + time();
    $FleetStorage = 0;
    $FleetShipCount = 0;
    $fleet_array = "";
    $FleetSubQRY = "";
    foreach ($fleetarray as $Ship => $Count) {
        $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
        $FleetShipCount += $Count;
        $fleet_array .= $Ship . "," . $Count . ";";
        $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", ";
    }
    $FleetStorage -= $consumption;
    $StorageNeeded = 0;
    $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
    $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
    $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
    $_POST['resource4'] = max(0, (int) trim($_POST['resource4']));
    if ($_POST['resource1'] < 1) {
        $TransMetal = 0;
    } else {
        $TransMetal = $_POST['resource1'];
        $StorageNeeded += $TransMetal;
    }
    if ($_POST['resource2'] < 1) {
        $TransCrystal = 0;
    } else {
        $TransCrystal = $_POST['resource2'];
        $StorageNeeded += $TransCrystal;
    }
    if ($_POST['resource3'] < 1) {
        $TransDeuterium = 0;
    } else {
        $TransDeuterium = $_POST['resource3'];
        $StorageNeeded += $TransDeuterium;
    }
    if ($_POST['resource4'] < 1) {
        $TransTritium = 0;
    } else {
        $TransTritium = $_POST['resource4'];
        $StorageNeeded += $TransTritium;
    }
    $StockMetal = $CurrentPlanet['metal'];
    $StockCrystal = $CurrentPlanet['crystal'];
    $StockDeuterium = $CurrentPlanet['deuterium'];
    $StockTritium = $CurrentPlanet['tritium'];
    $StockDeuterium -= $consumption;
    $StockOk = false;
    if ($StockMetal >= $TransMetal) {
        if ($StockCrystal >= $TransCrystal) {
            if ($StockDeuterium >= $TransDeuterium) {
                if ($StockTritium >= $TransTritium) {
                    $StockOk = true;
                }
            }
        }
    }
    if (!$StockOk) {
        message("<font color=\"red\"><b>" . $lang['fl_no_enought_deuterium'] . pretty_number($consumption) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($StorageNeeded > $FleetStorage) {
        message("<font color=\"red\"><b>" . $lang['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . $phpEx . "?page=fleet", 2);
    }
    if ($TargetPlanet['id_level'] > $CurrentUser['authlevel'] && $game_config['adm_attack'] == 0) {
        message($lang['fl_admins_cannot_be_attacked'], "game." . $phpEx . "?page=fleet", 2);
    }
    if ($fleet_group_mr != 0) {
        $AksStartTime = doquery("SELECT MAX(`fleet_start_time`) AS Start FROM {{table}} WHERE `fleet_group` = '" . $fleet_group_mr . "';", "fleets", true);
        if ($AksStartTime['Start'] >= $fleet['start_time']) {
            $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
            $fleet['start_time'] = $AksStartTime['Start'];
        } else {
            $QryUpdateFleets = "UPDATE {{table}} SET ";
            $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
            $QryUpdateFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' ";
            $QryUpdateFleets .= "WHERE ";
            $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "';";
            doquery($QryUpdateFleets, 'fleets');
            $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
        }
    }
    $QryInsertFleet = "INSERT INTO {{table}} SET ";
    $QryInsertFleet .= "`fleet_owner` = '" . intval($CurrentUser['id']) . "', ";
    $QryInsertFleet .= "`fleet_mission` = '" . intval($_POST['mission']) . "',  ";
    $QryInsertFleet .= "`fleet_amount` = '" . intval($FleetShipCount) . "', ";
    $QryInsertFleet .= "`fleet_array` = '" . $fleet_array . "', ";
    $QryInsertFleet .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
    $QryInsertFleet .= "`fleet_start_galaxy` = '" . intval($_POST['thisgalaxy']) . "', ";
    $QryInsertFleet .= "`fleet_start_system` = '" . intval($_POST['thissystem']) . "', ";
    $QryInsertFleet .= "`fleet_start_planet` = '" . intval($_POST['thisplanet']) . "', ";
    $QryInsertFleet .= "`fleet_start_type` = '" . intval($_POST['thisplanettype']) . "', ";
    $QryInsertFleet .= "`fleet_end_time` = '" . intval($fleet['end_time']) . "', ";
    $QryInsertFleet .= "`fleet_end_stay` = '" . intval($StayTime) . "', ";
    $QryInsertFleet .= "`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "', ";
    $QryInsertFleet .= "`fleet_end_system` = '" . intval($_POST['system']) . "', ";
    $QryInsertFleet .= "`fleet_end_planet` = '" . intval($_POST['planet']) . "', ";
    $QryInsertFleet .= "`fleet_end_type` = '" . intval($_POST['planettype']) . "', ";
    $QryInsertFleet .= "`fleet_resource_metal` = '" . $TransMetal . "', ";
    $QryInsertFleet .= "`fleet_resource_crystal` = '" . $TransCrystal . "', ";
    $QryInsertFleet .= "`fleet_resource_deuterium` = '" . $TransDeuterium . "', ";
    $QryInsertFleet .= "`fleet_resource_tritium` = '" . $TransTritium . "', ";
    $QryInsertFleet .= "`fleet_target_owner` = '" . intval($TargetPlanet['id_owner']) . "', ";
    $QryInsertFleet .= "`fleet_wormhole` = '" . $wormhole_id . "', ";
    $QryInsertFleet .= "`fleet_group` = '" . intval($fleet_group_mr) . "',  ";
    $QryInsertFleet .= "`start_time` = '" . time() . "';";
    doquery($QryInsertFleet, 'fleets');
    $QryUpdatePlanet = "UPDATE `{{table}}` SET ";
    $QryUpdatePlanet .= $FleetSubQRY;
    $QryUpdatePlanet .= "`metal` = `metal` - " . $TransMetal . ", ";
    $QryUpdatePlanet .= "`crystal` = `crystal` - " . $TransCrystal . ", ";
    $QryUpdatePlanet .= "`deuterium` = `deuterium` - " . ($TransDeuterium + $consumption) . ", ";
    $QryUpdatePlanet .= "`tritium` = `tritium` - " . $TransTritium . " ";
    $QryUpdatePlanet .= "WHERE ";
    $QryUpdatePlanet .= "`id` = " . intval($CurrentPlanet['id']) . " LIMIT 1;";
    doquery($QryUpdatePlanet, "planets");
    $parse['mission'] = $missiontype[$_POST['mission']];
    $parse['distance'] = pretty_number($distance);
    $parse['speedallsmin'] = pretty_number($_POST['speedallsmin']);
    $parse['consumption'] = pretty_number($consumption);
    $parse['from'] = $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'];
    $parse['destination'] = $_POST['galaxy'] . ":" . $_POST['system'] . ":" . $_POST['planet'];
    $parse['start_time'] = date("M D d H:i:s", $fleet['start_time']);
    $parse['end_time'] = date("M D d H:i:s", $fleet['end_time']);
    foreach ($fleetarray as $Ship => $Count) {
        $fleet_list .= "</tr><tr height=\"20\">";
        $fleet_list .= "<th>" . $lang['tech'][$Ship] . "</th>";
        $fleet_list .= "<th>" . pretty_number($Count) . "</th>";
    }
    $parse['fleet_list'] = $fleet_list;
    display(parsetemplate(gettemplate('fleet/fleet3_table'), $parse), false);
}
Пример #17
0
$page .= "<input type=\"hidden\" name=\"planet\"         value=\"" . $_POST["planet"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"thisplanettype\" value=\"" . $_POST["thisplanettype"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"planettype\"     value=\"" . $_POST["planettype"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"speedallsmin\"   value=\"" . $_POST["speedallsmin"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"speed\"          value=\"" . $_POST['speed'] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"speedfactor\"    value=\"" . $_POST["speedfactor"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"usedfleet\"      value=\"" . $_POST["usedfleet"] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"maxepedition\"   value=\"" . $_POST['maxepedition'] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"curepedition\"   value=\"" . $_POST['curepedition'] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"fleet_group\"    value=\"" . $_POST['fleet_group'] . "\" />\n";
$page .= "<input type=\"hidden\" name=\"acs_target_mr\"  value=\"" . $_POST['acs_target_mr'] . "\" />\n";
foreach ($fleetarray as $Ship => $Count) {
    $page .= "<input type=\"hidden\" name=\"ship" . $Ship . "\"        value=\"" . $Count . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"capacity" . $Ship . "\"    value=\"" . $pricelist[$Ship]['capacity'] . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"consumption" . $Ship . "\" value=\"" . GetShipConsumption($Ship, $user) . "\" />\n";
    $page .= "<input type=\"hidden\" name=\"speed" . $Ship . "\"       value=\"" . GetFleetMaxSpeed("", $Ship, $user) . "\" />\n";
}
$page .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"519\">\n";
$page .= "<tbody>\n";
$page .= "<tr align=\"left\" height=\"20\">\n";
$page .= "<td class=\"c\" colspan=\"2\">" . $TableTitle . "</td>\n";
$page .= "</tr>\n";
$page .= "<tr align=\"left\" valign=\"top\">\n";
$page .= "<th width=\"50%\">\n";
$page .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"259\">\n";
$page .= "<tbody>\n";
$page .= "<tr height=\"20\">\n";
$page .= "<td class=\"c\" colspan=\"2\">" . $lang['fl_mission'] . "</td>\n";
$page .= "</tr>\n";
$page .= $MissionSelector;
$page .= "</tbody>\n";
Пример #18
0
function GetFleetConsumption($FleetArray, $SpeedFactor, $MissionDuration, $MissionDistance, $FleetMaxSpeed, $Player)
{
    $consumption = 0;
    $basicConsumption = 0;
    if (!is_array($FleetArray)) {
        ReportError("\$FleetArray is not an array, line 108, unlocalised.php", 'Invalid argument supplied for foreach()', 1);
    }
    foreach ($FleetArray as $Ship => $Count) {
        if ($Ship > 0) {
            $ShipSpeed = GetFleetMaxSpeed("", $Ship, $Player);
            $ShipConsumption = GetShipConsumption($Ship, $Player);
            $spd = 35000 / ($MissionDuration * $SpeedFactor - 10) * sqrt($MissionDistance * 10 / $ShipSpeed);
            $basicConsumption = $ShipConsumption * $Count;
            $consumption += $basicConsumption * $MissionDistance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1);
        }
    }
    $consumption = round($consumption) + 1;
    return $consumption;
}