echo "</td></tr>";
        }
    } else {
        if (!$busy) {
            echo "<table><tr><td class=c>Для этого необходимо построить исследовательскую лабораторию!</td></tr></table>";
        }
    }
}
// ***********************************************************************
echo "</table>";
if ($_GET['mode'] === "Verteidigung" || $_GET['mode'] === "Flotte") {
    echo "</form>";
}
echo "</table>\n";
if ($_GET['mode'] === "Verteidigung" || $_GET['mode'] === "Flotte") {
    $result = GetShipyardQueue($aktplanet['planet_id']);
    $rows = dbrows($result);
    if ($rows) {
        $first = true;
        $c = "";
        $b = "";
        $a = "";
        $total_time = 0;
        while ($rows--) {
            $queue = dbarray($result);
            if ($first) {
                $g = $now - $queue['start'];
                $first = false;
            }
            $c .= $queue['end'] - $queue['start'] . ",";
            $b .= "\"" . loca("NAME_" . $queue['obj_id']) . "\",";
示例#2
0
function AddShipyard($player_id, $planet_id, $gid, $value, $now = 0)
{
    global $db_prefix, $GlobalUni;
    $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
    if (in_array($gid, $defmap)) {
        UserLog($player_id, "DEFENSE", "Запустить постройку " . loca("NAME_{$gid}") . " ({$value}) на планете {$planet_id}");
    } else {
        UserLog($player_id, "SHIPYARD", "Запустить постройку " . loca("NAME_{$gid}") . " ({$value}) на планете {$planet_id}");
    }
    $techmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
    if (!in_array($gid, $techmap)) {
        return;
    }
    $uni = $GlobalUni;
    if ($uni['freeze']) {
        return;
    }
    // Щитовые купола можно строить не более 1 единицы.
    if (($gid == 407 || $gid == 408) && $value > 1) {
        $value = 1;
    }
    $planet = GetPlanet($planet_id);
    // Если на планете уже есть щитовой купол, то не строим.
    if (($gid == 407 || $gid == 408) && $planet["d" . $gid] > 0) {
        return;
    }
    // Если в очереди уже строится купол такого же типа, то не добавлять ещё один купол в очередь.
    // Ограничить количество заказанных ракет уже строящимися
    $result = GetShipyardQueue($planet_id);
    $tasknum = dbrows($result);
    $rak_space = $planet['b44'] * 10 - ($planet['d502'] + 2 * $planet['d503']);
    while ($tasknum--) {
        $queue = dbarray($result);
        if ($queue['obj_id'] == 407 || $queue['obj_id'] == 408) {
            if ($queue['obj_id'] == $gid) {
                return;
            }
            // в очереди строится купол такого же типа.
        }
        if ($queue['obj_id'] == 502 || $queue['obj_id'] == 503) {
            if ($queue['obj_id'] == 502) {
                $rak_space -= $queue['level'];
            } else {
                $rak_space -= 2 * $queue['level'];
            }
        }
    }
    if ($gid == 502) {
        $value = min($rak_space, $value);
    }
    if ($gid == 503) {
        $value = min(floor($rak_space / 2), $value);
    }
    if ($value <= 0) {
        return;
    }
    $user = LoadUser($player_id);
    $res = ShipyardPrice($gid);
    $m = $res['m'];
    $k = $res['k'];
    $d = $res['d'];
    $e = $res['e'];
    $m *= $value;
    $k *= $value;
    $d *= $value;
    if (IsEnoughResources($planet, $m, $k, $d, $e) && ShipyardMeetRequirement($user, $planet, $gid)) {
        $speed = $uni['speed'];
        $now = ShipyardLatestTime($planet_id, $now);
        $shipyard = $planet["b21"];
        $nanits = $planet["b15"];
        $seconds = ShipyardDuration($gid, $shipyard, $nanits, $speed);
        // Списать ресурсы.
        AdjustResources($m, $k, $d, $planet_id, '-');
        AddQueue($player_id, "Shipyard", $planet_id, $gid, $value, $now, $seconds);
    }
}