MAPG-103 don't use "position" everywhere

This commit is contained in:
Bence Pőcze 2020-06-05 00:59:23 +02:00
parent 1179914f42
commit bb29bfdfe1
3 changed files with 11 additions and 11 deletions

View File

@ -19,8 +19,8 @@ Container::$routeCollection->get('maps', 'maps', [MapGuesser\Controller\MapsCont
Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCollection $routeCollection) {
$routeCollection->get('game', '{mapId}', [MapGuesser\Controller\GameController::class, 'getGame']); $routeCollection->get('game', '{mapId}', [MapGuesser\Controller\GameController::class, 'getGame']);
$routeCollection->get('game-json', '{mapId}/json', [MapGuesser\Controller\GameController::class, 'getGameJson']); $routeCollection->get('game-json', '{mapId}/json', [MapGuesser\Controller\GameController::class, 'getGameJson']);
$routeCollection->get('position-json', '{mapId}/position.json', [MapGuesser\Controller\PositionController::class, 'getPosition']); $routeCollection->get('newPlace-json', '{mapId}/newPlace.json', [MapGuesser\Controller\GameFlowController::class, 'getNewPlace']);
$routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\PositionController::class, 'evaluateGuess']); $routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'evaluateGuess']);
}); });
Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) {
$routeCollection->get('admin.maps', 'maps', [MapGuesser\Controller\MapAdminController::class, 'getMaps']); $routeCollection->get('admin.maps', 'maps', [MapGuesser\Controller\MapAdminController::class, 'getMaps']);

View File

@ -53,7 +53,7 @@
Game.startNewRound(); Game.startNewRound();
}; };
xhr.open('GET', '/game/' + mapId + '/position.json', true); xhr.open('GET', '/game/' + mapId + '/newPlace.json', true);
xhr.send(); xhr.send();
}, },

View File

@ -6,7 +6,7 @@ use MapGuesser\Response\JsonContent;
use MapGuesser\Interfaces\Response\IContent; use MapGuesser\Interfaces\Response\IContent;
use MapGuesser\Repository\PlaceRepository; use MapGuesser\Repository\PlaceRepository;
class PositionController class GameFlowController
{ {
const NUMBER_OF_ROUNDS = 5; const NUMBER_OF_ROUNDS = 5;
const MAX_SCORE = 1000; const MAX_SCORE = 1000;
@ -21,7 +21,7 @@ class PositionController
$this->placeRepository = new PlaceRepository(); $this->placeRepository = new PlaceRepository();
} }
public function getPosition(): IContent public function getNewPlace(): IContent
{ {
$mapId = (int) $this->request->query('mapId'); $mapId = (int) $this->request->query('mapId');
@ -33,11 +33,11 @@ class PositionController
} }
if (count($state['rounds']) === 0) { if (count($state['rounds']) === 0) {
$newPosition = $this->placeRepository->getForMapWithValidPano($mapId); $place = $this->placeRepository->getForMapWithValidPano($mapId);
$state['rounds'][] = $newPosition; $state['rounds'][] = $place;
$session->set('state', $state); $session->set('state', $state);
$data = ['panoId' => $newPosition['panoId']]; $data = ['panoId' => $place['panoId']];
} else { } else {
$rounds = count($state['rounds']); $rounds = count($state['rounds']);
$last = $state['rounds'][$rounds - 1]; $last = $state['rounds'][$rounds - 1];
@ -93,11 +93,11 @@ class PositionController
$exclude = array_merge($exclude, $round['placesWithoutPano'], [$round['placeId']]); $exclude = array_merge($exclude, $round['placesWithoutPano'], [$round['placeId']]);
} }
$newPosition = $this->placeRepository->getForMapWithValidPano($mapId, $exclude); $place = $this->placeRepository->getForMapWithValidPano($mapId, $exclude);
$state['rounds'][] = $newPosition; $state['rounds'][] = $place;
$session->set('state', $state); $session->set('state', $state);
$panoId = $newPosition['panoId']; $panoId = $place['panoId'];
} else { } else {
$state['rounds'] = []; $state['rounds'] = [];
$session->set('state', $state); $session->set('state', $state);