MAPG-73 pass mapId to GameController and PositionController

adapt JS to send mapId
make separate JS for the game
This commit is contained in:
bence committed 2020-05-30 15:33:28 +02:00
1 parent 1ca023e612
commit 92c35a2087
6 files changed
+38 -51

No files matched your search

+7 -4
View File
@@ -3,20 +3,23 @@
require '../main.php';
// very basic routing
$host = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER["SERVER_NAME"];
$host = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'];
$url = $_SERVER['REQUEST_URI'];
if (($pos = strpos($url, '?')) !== false) {
$url = substr($url, 0, $pos);
}
switch($url) {
case '/game':
$controller = new MapGuesser\Controller\GameController();
$mapId = isset($_GET['map']) ? (int) $_GET['map'] : 0;
$controller = new MapGuesser\Controller\GameController($mapId);
break;
case '/game.json':
$controller = new MapGuesser\Controller\GameController(true);
$mapId = isset($_GET['map']) ? (int) $_GET['map'] : 0;
$controller = new MapGuesser\Controller\GameController($mapId, true);
break;
case '/position.json':
$controller = new MapGuesser\Controller\PositionController();
$mapId = isset($_GET['map']) ? (int) $_GET['map'] : 0;
$controller = new MapGuesser\Controller\PositionController($mapId);
break;
case '/':
header('Location: ' . $host . '/game', true, 302);