Beispiel #1
0
    srand((double) microtime() * 1000000);
    $retval = 0;
    $a = 0;
    if ($a != $number) {
        do {
            $a++;
            $tmp = rand(0, 1 + ($roids + $retval));
            if ($tmp < 20) {
                $retval++;
            }
        } while ($a < $number);
    }
    return $retval;
}
if ($waves > 0 && $crystal >= $waves * 500) {
    $found = calcres($waves);
    $cost = $waves * 500;
    $result = mysql_query("UPDATE " . $PA["table"] . " SET crystal=crystal-{$cost},ui_roids=ui_roids+{$found} WHERE id={$Userid} AND crystal>={$cost}", $db);
    Header("Location: waves.php?msggreen=You found {$found} asteroids");
    die;
}
if ($waves > 0 && $crystal < $waves * 500) {
    Header("Location: waves.php?msgred=You dont have enough crystal!");
    die;
}
if ($sector != "") {
    $result = mysql_query("SELECT * FROM " . $PA["table"] . " WHERE id='{$sector}'", $db);
    if (mysql_num_rows($result) != 1) {
        Header("Location: waves.php?msgred=No such planet!");
        die;
    }
Beispiel #2
0
        $arrJson[] = array('html', 'res_amount_' . $iResourceId, nummertje($iAmount));
    }
    exit(json::encode($arrJson));
} else {
    if (isset($_POST['number_of_asteroid_scans'], $_POST['roid_scan_id'])) {
        $iTotalAsteroidScans = (int) db_select_one('d_all_units u, d_waves w, waves_on_planets p', 'IFNULL(SUM(amount),0)', 'u.id = ' . (int) $_POST['roid_scan_id'] . ' AND u.id = w.id AND w.id = p.wave_id AND p.planet_id = ' . PLANET_ID . ' AND u.T = \'roidscan\' AND u.r_d_required_id IN (SELECT r_d_id FROM planet_r_d WHERE planet_id = ' . PLANET_ID . ' AND eta = 0)');
        $a = (int) min($_POST['number_of_asteroid_scans'], $iTotalAsteroidScans);
        if (0 >= $a) {
            exit(json::encode(array(array('msg', 'Invalid amount!'))));
        }
        $iTotalWaveAmps = (int) db_select_one('d_all_units u, d_waves w, waves_on_planets p', 'IFNULL(SUM(amount),0)', 'u.id = w.id AND w.id = p.wave_id AND p.planet_id = ' . PLANET_ID . ' AND u.T = \'amp\' AND u.r_d_required_id IN (SELECT r_d_id FROM planet_r_d WHERE planet_id = ' . PLANET_ID . ' AND eta = 0)');
        $iAsteroids = $g_arrUser['inactive_asteroids'];
        foreach ($g_arrResources as $r) {
            $iAsteroids += $r['asteroids'];
        }
        $iAsteroidsFound = calcres($a, $iAsteroids, $iTotalWaveAmps);
        if (db_update('waves_on_planets', 'amount = amount-' . $a, 'planet_id = ' . PLANET_ID . ' AND wave_id = ' . (int) $_POST['roid_scan_id'] . '') && 0 < db_affected_rows()) {
            db_update('planets', 'inactive_asteroids = inactive_asteroids+' . $iAsteroidsFound, 'id = ' . PLANET_ID);
        }
        $iScansLefs = db_select_one('waves_on_planets', 'amount', 'planet_id = ' . PLANET_ID . ' AND wave_id = ' . (int) $_POST['roid_scan_id'] . '');
        exit(json::encode(array(array('html', 'unit_amount_' . (int) $_POST['roid_scan_id'], nummertje($iScansLefs)), array('msg', 'Your ' . nummertje($a) . ' scans found ' . nummertje($iAsteroidsFound) . ' Asteroids!'))));
    } else {
        if (isset($_GET['intel_scan_id'], $_GET['x'], $_GET['y'], $_GET['z'])) {
            $arrScan = db_fetch('SELECT *, u.id AS scan_id FROM d_all_units u WHERE id = ' . (int) $_GET['intel_scan_id'] . ' AND u.T = \'scan\' AND u.r_d_required_id IN (SELECT r_d_id FROM planet_r_d WHERE planet_id = ' . PLANET_ID . ' AND eta = 0) AND 0 < (SELECT amount FROM waves_on_planets WHERE planet_id = ' . PLANET_ID . ' AND wave_id = scan_id)');
            if (!$arrScan) {
                exit(json::encode(array(array('msg', 'Invalid scan!'))));
            }
            $arrScan = $arrScan[0];
            $arrTarget = db_select('galaxies g, planets p', 'g.id = p.galaxy_id AND p.z = ' . (int) $_GET['z'] . ' AND g.y = ' . (int) $_GET['y'] . ' AND g.x = ' . (int) $_GET['x']);
            if (!$arrTarget) {
                exit(json::encode(array(array('msg', 'Invalid coordinates!'))));