MAPG-235 highscores added to the end of challenge
This commit is contained in:
1 parent
599d8bf153
commit
b00fe4ebe3
6 files changed
+150
-10
No files matched your search
@@ -193,6 +193,14 @@ class GameFlowController
|
||||
|
||||
if (!isset($currentPlace)) { // game finished
|
||||
$response['finished'] = true;
|
||||
|
||||
// list all players who finished the challenge
|
||||
$response['finishers'] = [];
|
||||
foreach ($this->userInChallengeRepository->getAllByChallengeWithUsers($challenge) as $userInChallenge) {
|
||||
if ($userInChallenge->getCurrentRound() == $currentRound && $userInChallenge->getUser()->getId() != $userId) {
|
||||
$response['finishers'][] = $userInChallenge->getUser()->getDisplayName();
|
||||
}
|
||||
}
|
||||
} else { // continue game
|
||||
$response['place'] = [
|
||||
'panoId' => $currentPlace->getPanoIdCached(),
|
||||
|
||||
@@ -32,6 +32,14 @@ class UserInChallengeRepository
|
||||
yield from $this->pdm->selectMultipleFromDb($select, UserInChallenge::class);
|
||||
}
|
||||
|
||||
public function getAllByChallengeWithUsers(Challenge $challenge) : Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('challenge_id', '=', $challenge->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, UserInChallenge::class, true, [User::class]);
|
||||
}
|
||||
|
||||
public function getByUserIdAndChallenge(int $userId, Challenge $challenge): ?UserInChallenge
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
|
||||
Reference in new issue
Block a user