refactored function and variable names, and replaced variables in inner scope
default-pipeline default-pipeline #173
default-pipeline default-pipeline #173
This commit is contained in:
1 parent
886bd02f88
commit
b2535ad78a
3 files changed
+13
-12
No files matched your search
@@ -48,10 +48,8 @@ class GameFlowController
|
||||
return new JsonContent(['error' => 'no_session_found']);
|
||||
}
|
||||
|
||||
$userId = $session->get('userId');
|
||||
|
||||
if (!isset($state['currentRound']) || $state['currentRound'] == -1 || $state['currentRound'] >= static::NUMBER_OF_ROUNDS) {
|
||||
$this->startNewGame($state, $mapId, $userId);
|
||||
$this->startNewGame($state, $mapId);
|
||||
$session->set('state', $state);
|
||||
}
|
||||
|
||||
@@ -161,8 +159,8 @@ class GameFlowController
|
||||
private function saveVisit($last): void
|
||||
{
|
||||
$session = $this->request->session();
|
||||
|
||||
$userId = $session->get('userId');
|
||||
|
||||
if(isset($userId)) {
|
||||
$placeId = $last['placeId'];
|
||||
$userPlayedPlace = $this->userPlayedPlaceRepository->getByUserIdAndPlaceId($userId, $placeId);
|
||||
@@ -252,8 +250,11 @@ class GameFlowController
|
||||
return ['distance' => $distance, 'score' => $score];
|
||||
}
|
||||
|
||||
private function startNewGame(array &$state, int $mapId, $userId = null): void
|
||||
private function startNewGame(array &$state, int $mapId): void
|
||||
{
|
||||
$session = $this->request->session();
|
||||
$userId = $session->get('userId'); // in case of multiplayer it will be null and handled the same way as for anonymous players
|
||||
|
||||
$places = $this->placeRepository->getRandomNPlaces($mapId, static::NUMBER_OF_ROUNDS, $userId);
|
||||
|
||||
$state['rounds'] = [];
|
||||
|
||||
Reference in new issue
Block a user