Compare commits

...

3 Commits

Author SHA1 Message Date
d849349ad0
MAPG-243 delete unused class members
All checks were successful
mapguesser/pipeline/pr-develop This commit looks good
2023-04-07 21:10:32 +02:00
f338cc7908
MAPG-243 set COMPOSER_HOME to the workspace 2023-04-07 21:10:15 +02:00
06275975f6
MAPG-243 install git in Dockerfile-test 2023-04-07 21:10:15 +02:00
3 changed files with 14 additions and 18 deletions

3
Jenkinsfile vendored
View File

@ -8,6 +8,9 @@ pipeline {
stages { stages {
stage('Install composer') { stage('Install composer') {
environment {
COMPOSER_HOME="${WORKSPACE}/.composer"
}
agent { agent {
dockerfile { dockerfile {
filename 'docker/Dockerfile-test' filename 'docker/Dockerfile-test'

View File

@ -1,4 +1,6 @@
FROM php:7.4.7-cli-buster FROM ubuntu:focal
RUN apt-get update && apt-get install -y unzip ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt install -y curl git unzip php7.4-cli php7.4-mbstring php7.4-xml
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

View File

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