Compare commits

..

7 Commits

Author SHA1 Message Date
a05fa0c85a
MAPG-243 fixup! MAPG-243 install git in Dockerfile-test
Some checks failed
mapguesser/pipeline/pr-develop There was a failure building this commit
2023-04-07 21:04:23 +02:00
b71d918a8d
MAPG-243 fixup! MAPG-243 install soko-web by composer
Some checks failed
mapguesser/pipeline/pr-develop There was a failure building this commit
2023-04-07 20:57:12 +02:00
39fb0b89ca
MAPG-243 fixup! MAPG-243 install git in Dockerfile-test
Some checks failed
mapguesser/pipeline/pr-develop There was a failure building this commit
2023-04-07 20:53:40 +02:00
7114248f70
MAPG-243 set COMPOSER_HOME to the workspace
Some checks failed
mapguesser/pipeline/pr-develop There was a failure building this commit
2023-04-07 20:37:07 +02:00
0798d146f9
MAPG-243 install git in Dockerfile-test
Some checks failed
mapguesser/pipeline/pr-develop There was a failure building this commit
2023-04-07 20:29:00 +02:00
0a428fa6af
MAPG-243 replace and adapt to soko-web 2023-04-07 20:28:14 +02:00
68eace5ca8
MAPG-243 install soko-web by composer 2023-04-07 20:27:26 +02:00

View File

@ -40,8 +40,14 @@ class GameFlowController implements ISecured
private PlaceRepository $placeRepository;
private MapRepository $mapRepository;
private UserRepository $userRepository;
private UserPlayedPlaceRepository $userPlayedPlaceRepository;
private ChallengeRepository $challengeRepository;
private UserInChallengeRepository $userInChallengeRepository;
private PlaceInChallengeRepository $placeInChallengeRepository;
@ -55,7 +61,10 @@ class GameFlowController implements ISecured
$this->multiConnector = new MultiConnector();
$this->multiRoomRepository = new MultiRoomRepository();
$this->placeRepository = new PlaceRepository();
$this->mapRepository = new MapRepository();
$this->userRepository = new UserRepository();
$this->userPlayedPlaceRepository = new UserPlayedPlaceRepository();
$this->challengeRepository = new ChallengeRepository();
$this->userInChallengeRepository = new UserInChallengeRepository();
$this->placeInChallengeRepository = new PlaceInChallengeRepository();
$this->guessRepository = new GuessRepository();
@ -145,16 +154,16 @@ class GameFlowController implements ISecured
private function prepareChallengeResponse(int $userId, Challenge $challenge, int $currentRound, bool $withHistory = false): array
{
$currentPlace = $this->placeRepository->getByRoundInChallenge($challenge, $currentRound);
// if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing)
if (!isset($currentPlace) || $withHistory) {
$withRelations = [User::class, PlaceInChallenge::class, Place::class];
foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) {
foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) {
$round = $guess->getPlaceInChallenge()->getRound();
if ($guess->getUser()->getId() === $userId) {
$response['history'][$round]['position'] =
$response['history'][$round]['position'] =
$guess->getPlaceInChallenge()->getPlace()->getPosition()->toArray();
$response['history'][$round]['result'] = [
'guessPosition' => $guess->getPosition()->toArray(),
@ -179,8 +188,8 @@ class GameFlowController implements ISecured
'distance' => null,
'score' => 0
];
$response['history'][$i]['position'] =
$response['history'][$i]['position'] =
$this->placeRepository->getByRoundInChallenge($challenge, $i)->getPosition()->toArray();
}
}
@ -241,7 +250,7 @@ class GameFlowController implements ISecured
if ($challenge->getTimeLimitType() === 'game' && $challenge->getTimeLimit() !== null && $userInChallenge->getCurrentRound() > 0) {
$timeLimit = max(10, $userInChallenge->getTimeLeft());
$response['restrictions']['timeLimit'] = $timeLimit * 1000;
}
}
return new JsonContent($response);
}