MAPG-73 pass mapId to GameController and PositionController
adapt JS to send mapId make separate JS for the game
This commit is contained in:
1 parent
1ca023e612
commit
92c35a2087
6 files changed
+38
-51
No files matched your search
+7
-4
@@ -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);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
Core.startNewRound();
|
||||
};
|
||||
|
||||
xhr.open('GET', 'position.json', true);
|
||||
xhr.open('GET', 'position.json?map=' + mapId, true);
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
Core.resetGame();
|
||||
};
|
||||
|
||||
xhr.open('GET', 'game.json', true);
|
||||
xhr.open('GET', 'game.json?map=' + mapId, true);
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
Core.panoId = this.response.panoId;
|
||||
};
|
||||
|
||||
xhr.open('POST', 'position.json', true);
|
||||
xhr.open('POST', 'position.json?map=' + mapId, true);
|
||||
xhr.send(data);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user