From bb29bfdfe1a668156f1fee2ec60c8b8450cdc6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Fri, 5 Jun 2020 00:59:23 +0200 Subject: [PATCH] MAPG-103 don't use "position" everywhere --- public/index.php | 4 ++-- public/static/js/game.js | 2 +- ...tionController.php => GameFlowController.php} | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) rename src/Controller/{PositionController.php => GameFlowController.php} (89%) diff --git a/public/index.php b/public/index.php index d90278f..afce027 100644 --- a/public/index.php +++ b/public/index.php @@ -19,8 +19,8 @@ Container::$routeCollection->get('maps', 'maps', [MapGuesser\Controller\MapsCont Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCollection $routeCollection) { $routeCollection->get('game', '{mapId}', [MapGuesser\Controller\GameController::class, 'getGame']); $routeCollection->get('game-json', '{mapId}/json', [MapGuesser\Controller\GameController::class, 'getGameJson']); - $routeCollection->get('position-json', '{mapId}/position.json', [MapGuesser\Controller\PositionController::class, 'getPosition']); - $routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\PositionController::class, 'evaluateGuess']); + $routeCollection->get('newPlace-json', '{mapId}/newPlace.json', [MapGuesser\Controller\GameFlowController::class, 'getNewPlace']); + $routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'evaluateGuess']); }); Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) { $routeCollection->get('admin.maps', 'maps', [MapGuesser\Controller\MapAdminController::class, 'getMaps']); diff --git a/public/static/js/game.js b/public/static/js/game.js index fd5f5ca..0305be2 100644 --- a/public/static/js/game.js +++ b/public/static/js/game.js @@ -53,7 +53,7 @@ Game.startNewRound(); }; - xhr.open('GET', '/game/' + mapId + '/position.json', true); + xhr.open('GET', '/game/' + mapId + '/newPlace.json', true); xhr.send(); }, diff --git a/src/Controller/PositionController.php b/src/Controller/GameFlowController.php similarity index 89% rename from src/Controller/PositionController.php rename to src/Controller/GameFlowController.php index b804797..3b44efa 100644 --- a/src/Controller/PositionController.php +++ b/src/Controller/GameFlowController.php @@ -6,7 +6,7 @@ use MapGuesser\Response\JsonContent; use MapGuesser\Interfaces\Response\IContent; use MapGuesser\Repository\PlaceRepository; -class PositionController +class GameFlowController { const NUMBER_OF_ROUNDS = 5; const MAX_SCORE = 1000; @@ -21,7 +21,7 @@ class PositionController $this->placeRepository = new PlaceRepository(); } - public function getPosition(): IContent + public function getNewPlace(): IContent { $mapId = (int) $this->request->query('mapId'); @@ -33,11 +33,11 @@ class PositionController } if (count($state['rounds']) === 0) { - $newPosition = $this->placeRepository->getForMapWithValidPano($mapId); - $state['rounds'][] = $newPosition; + $place = $this->placeRepository->getForMapWithValidPano($mapId); + $state['rounds'][] = $place; $session->set('state', $state); - $data = ['panoId' => $newPosition['panoId']]; + $data = ['panoId' => $place['panoId']]; } else { $rounds = count($state['rounds']); $last = $state['rounds'][$rounds - 1]; @@ -93,11 +93,11 @@ class PositionController $exclude = array_merge($exclude, $round['placesWithoutPano'], [$round['placeId']]); } - $newPosition = $this->placeRepository->getForMapWithValidPano($mapId, $exclude); - $state['rounds'][] = $newPosition; + $place = $this->placeRepository->getForMapWithValidPano($mapId, $exclude); + $state['rounds'][] = $place; $session->set('state', $state); - $panoId = $newPosition['panoId']; + $panoId = $place['panoId']; } else { $state['rounds'] = []; $session->set('state', $state);