39001-vm/match.php
2026-03-05 10:39:31 +00:00

123 lines
4.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
session_start();
require_once __DIR__ . '/includes/rooms.php';
ensure_rooms_schema();
$roomId = (int) ($_GET['id'] ?? 0);
if ($roomId <= 0) {
http_response_code(404);
echo 'Room not found';
exit;
}
$room = get_room($roomId);
if (!$room) {
http_response_code(404);
echo 'Room not found';
exit;
}
$sessionPlayer = get_session_player($roomId);
if (!$sessionPlayer) {
$_SESSION['flash'] = 'Сначала войдите в комнату.';
header('Location: /room.php?id=' . $roomId);
exit;
}
$phpVersion = PHP_VERSION;
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Матч — <?= htmlspecialchars($room['name']) ?> | Bomber Rooms</title>
<?php
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time(); ?>" />
</head>
<body>
<nav class="navbar navbar-light bg-white border-bottom small shadow-sm sticky-top">
<div class="container">
<a class="navbar-brand fw-semibold text-dark" href="/">Bomber Rooms</a>
<div class="d-flex gap-2">
<a class="btn btn-outline-dark btn-sm" href="room.php?id=<?= (int) $roomId ?>">Комната</a>
<a class="btn btn-dark btn-sm" href="/">Лобби</a>
</div>
</div>
</nav>
<main class="py-4">
<div class="container">
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3 mb-4">
<div>
<p class="text-uppercase text-muted small mb-1">Матч #<?= (int) $roomId ?></p>
<h1 class="h4 fw-semibold mb-0"><?= htmlspecialchars($room['name']) ?></h1>
</div>
<div class="panel px-3 py-2 small text-muted">
Управление: WASD / ←↑→↓, бомба — Space
</div>
</div>
<div class="row g-4">
<div class="col-lg-8">
<div class="panel p-3">
<div id="game-board" class="game-board" aria-live="polite"></div>
</div>
<div class="d-flex justify-content-between align-items-center mt-3 small text-muted">
<span id="match-status">Ожидание состояния...</span>
<span>PHP <?= htmlspecialchars($phpVersion) ?></span>
</div>
</div>
<div class="col-lg-4">
<div class="panel p-4 h-100">
<h2 class="h6 text-uppercase text-muted">Состав и статус</h2>
<ul id="match-players" class="list-unstyled small mb-3"></ul>
<button id="place-bomb" class="btn btn-dark w-100 mb-2">Поставить бомбу</button>
<a class="btn btn-outline-dark w-100" href="room.php?id=<?= (int) $roomId ?>">Вернуться в комнату</a>
<div class="mt-4 small text-muted">
<div class="mb-1">Бонусы: увеличение взрыва, +бомбы, скорость</div>
<div>Realtime синхронизация включена через pushstream.</div>
</div>
</div>
</div>
</div>
</div>
</main>
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="match-toast" class="toast align-items-center text-bg-dark border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body" id="match-toast-body">Статус обновлен.</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
</div>
</div>
<script>
window.ROOM_ID = <?= (int) $roomId ?>;
window.PLAYER_TOKEN = <?= json_encode($sessionPlayer['token']) ?>;
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?= time(); ?>"></script>
</body>
</html>