echo "</td></tr>"; } // Кнопка строительства. echo "<td class=c colspan=2 align=center><input type=submit value=\"Строить\"></td></tr>"; } else { if (!$busy) { echo "<table><tr><td class=c>Для этого необходимо построить верфь!</td></tr></table>"; } } } // ************************************************ Оборона ************************************************ $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503); if ($_GET['mode'] === "Verteidigung") { $prem = PremiumStatus($GlobalUser); // Проверить не строится ли Верфь или Фабрика нанитов. $result = GetBuildQueue($aktplanet['planet_id']); $queue = dbarray($result); $busy = $queue['tech_id'] == 21 || $queue['tech_id'] == 15; if ($busy) { echo "<br><br><font color=#FF0000>Невозможно строить ни корабли ни оборонительные сооружения, так как верфь либо фабрика нанитов усовершенствуются</font><br><br>"; } if ($GlobalUser['vacation']) { echo "<font color=#FF0000><center>Режим отпуска минимум до " . date("Y-m-d H:i:s", $GlobalUser['vacation_until']) . "</center></font>"; } echo "<form action=index.php?page=buildings&session={$session}&mode=" . $_GET['mode'] . " method=post>"; echo "<table align=top><tr><td style='background-color:transparent;'> "; if ($GlobalUser['useskin']) { echo "<table width=\"530\">\n"; } else { echo "<table width=\"468\">\n"; }
function BuildEnque($planet_id, $id, $destroy, $now = 0) { global $db_prefix, $GlobalUni; $speed = $GlobalUni['speed']; if ($GlobalUni['freeze']) { return; } $planet = GetPlanet($planet_id); $user = LoadUser($planet['owner_id']); $prem = PremiumStatus($user); if ($prem['commander']) { $maxcnt = 5; } else { $maxcnt = 1; } if ($now == 0) { $now = time(); } // Запишем действие пользователя, даже если он делает что-то не так if ($destroy) { UserLog($planet['owner_id'], "BUILD", "Снос " . loca("NAME_{$id}") . " " . ($planet['b' . $id] - 1) . " на планете {$planet_id}"); } else { UserLog($planet['owner_id'], "BUILD", "Постройка " . loca("NAME_{$id}") . " " . ($planet['b' . $id] + 1) . " на планете {$planet_id}"); } $result = GetBuildQueue($planet_id); $cnt = dbrows($result); if ($cnt >= $maxcnt) { return; } // Очередь построек заполнена // Загрузить очередь. Отсортирована по порядку list_id $queue = array(); for ($i = 0; $i < $cnt; $i++) { $queue[$i] = dbarray($result); } // Нельзя в одну секунду добавлять в очередь несколько построек. for ($i = 0; $i < $cnt; $i++) { if ($queue[$i]['start'] == $now) { return; } } // Определить добавляемый уровень и порядок постройки (list_id). $nowlevel = $planet['b' . $id]; $list_id = 0; for ($i = 0; $i < $cnt; $i++) { if ($queue[$i]['tech_id'] == $id) { $nowlevel = $queue[$i]['level']; } if ($queue[$i]['list_id'] > $list_id) { $list_id = $queue[$i]['list_id']; } } $list_id++; if ($destroy) { $lvl = $nowlevel - 1; } else { $lvl = $nowlevel + 1; } if ($lvl < 0) { return; } // Невозможно построить/снести отрицательный уровень if ($list_id == 1) { $text = CanBuild($user, $planet, $id, $lvl, $destroy); } else { $text = ''; } if ($text === '') { // Списать ресурсы для самой первой постройки if ($list_id == 1) { $res = BuildPrice($id, $lvl); $m = $res['m']; $k = $res['k']; $d = $res['d']; $e = $res['e']; AdjustResources($m, $k, $d, $planet_id, '-'); } if ($destroy) { $BuildEvent = "Demolish"; } else { $BuildEvent = "Build"; } $duration = floor(BuildDuration($id, $lvl, $planet['b14'], $planet['b15'], $speed)); $row = array('', $user['player_id'], $planet_id, $list_id, $id, $lvl, $destroy, $now, $now + $duration); $sub_id = AddDBRow($row, "buildqueue"); if ($list_id == 1) { AddQueue($user['player_id'], $BuildEvent, $sub_id, $id, $lvl, $now, $duration, 20); } } }
$num = dbrows($result); for ($i = 0; $i < $num; $i++) { $planet = dbarray($result); if ($planet['type'] == 0 || $planet['planet_id'] == $aktplanet['planet_id']) { $num--; $i--; continue; } if ($i % 2 == 0) { echo "<tr>\n"; } echo "<th> " . $planet['name'] . "<br> <a href=\"index.php?page=overview&session={$session}&cp=" . $planet['planet_id'] . "\" title=\"" . $planet['name'] . " [" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]\">"; echo "<img src=\"" . GetPlanetImage(UserSkin(), $planet) . "\" width=\"50\" height=\"50\" title=\"" . $planet['name'] . " [" . $planet['g'] . ":" . $planet['s'] . ":" . $planet['p'] . "]\" ></a>\n"; echo "<br><center>"; // Вывести текущее строительство $qresult = GetBuildQueue($planet['planet_id']); $cnt = dbrows($qresult); if ($cnt > 0) { $queue = dbarray($qresult); echo loca("NAME_" . $queue['tech_id']); } else { echo ""; } dbfree($qresult); echo "</center></th>\n"; if ($i == $num - 1) { echo "</tr>\n\n"; } else { if ($i % 2 != 0) { echo "</tr>\n\n"; }
function get_building($planet_id) { $result = GetBuildQueue($planet_id); if (dbrows($result) > 0) { $queue = dbarray($result); return $queue; } else { return null; } }