From d849349ad0f4ed9c8d67ce16d5823e26c9517770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Fri, 7 Apr 2023 21:10:32 +0200 Subject: [PATCH] MAPG-243 delete unused class members --- src/Controller/GameFlowController.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Controller/GameFlowController.php b/src/Controller/GameFlowController.php index 48e4dd2..9ef5cb2 100644 --- a/src/Controller/GameFlowController.php +++ b/src/Controller/GameFlowController.php @@ -40,14 +40,8 @@ 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; @@ -61,10 +55,7 @@ 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(); @@ -154,16 +145,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(), @@ -188,8 +179,8 @@ class GameFlowController implements ISecured 'distance' => null, 'score' => 0 ]; - - $response['history'][$i]['position'] = + + $response['history'][$i]['position'] = $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) { $timeLimit = max(10, $userInChallenge->getTimeLeft()); $response['restrictions']['timeLimit'] = $timeLimit * 1000; - } + } return new JsonContent($response); }