This commit is contained in:
parent
8b3c95bdc7
commit
8d8074977b
@ -253,7 +253,7 @@ class GameFlowController
|
|||||||
private function startNewGame(array &$state, int $mapId): void
|
private function startNewGame(array &$state, int $mapId): void
|
||||||
{
|
{
|
||||||
$session = $this->request->session();
|
$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
|
$userId = $session->get('userId');
|
||||||
|
|
||||||
$places = $this->placeRepository->getRandomNPlaces($mapId, static::NUMBER_OF_ROUNDS, $userId);
|
$places = $this->placeRepository->getRandomNPlaces($mapId, static::NUMBER_OF_ROUNDS, $userId);
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ class PlaceRepository
|
|||||||
//TODO: use Map and User instead of id
|
//TODO: use Map and User instead of id
|
||||||
public function getRandomNPlaces(int $mapId, int $n, ?int $userId): array
|
public function getRandomNPlaces(int $mapId, int $n, ?int $userId): array
|
||||||
{
|
{
|
||||||
if(!isset($userId)) { // anonymous single player or multiplayer game
|
if(!isset($userId)) { // anonymous single player
|
||||||
return $this->getRandomNForMapWithValidPano($mapId, $n);
|
return $this->getRandomNForMapWithValidPano($mapId, $n);
|
||||||
} else { // authorized user
|
} else { // authorized user or multiplayer game with selection based on what the host played before
|
||||||
$unvisitedPlaces = $this->getRandomUnvisitedNForMapWithValidPano($mapId, $n, $userId);
|
$unvisitedPlaces = $this->getRandomUnvisitedNForMapWithValidPano($mapId, $n, $userId);
|
||||||
$oldPlaces = $this->getRandomOldNForMapWithValidPano($mapId, $n - count($unvisitedPlaces), $userId);
|
$oldPlaces = $this->getRandomOldNForMapWithValidPano($mapId, $n - count($unvisitedPlaces), $userId);
|
||||||
return array_merge($unvisitedPlaces, $oldPlaces);
|
return array_merge($unvisitedPlaces, $oldPlaces);
|
||||||
|
Loading…
Reference in New Issue
Block a user