Private
Public Access
1
0

chg: usr: re-implement the waiting for opponent dialog - refactor its gfx - & add online user selection dialog #4

This commit is contained in:
2026-04-11 22:20:21 +02:00
parent 6b3e19b063
commit 826690769f
13 changed files with 1540 additions and 277 deletions

View File

@@ -10,6 +10,8 @@
namespace App\Controller;
use App\Entity\PlayedGame;
use App\Repository\PlayedGameRepository;
use App\Util\RpcManager;
use App\Util\TopicManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -81,6 +83,29 @@ class MercureController extends AbstractController
return $this->json(['success' => true]);
}
#[Route('/api/game/waiting', name: 'MineSeekerBundle_api_game_waiting', methods: ['GET'])]
public function waiting(PlayedGameRepository $repo): JsonResponse
{
$games = $repo->findWaitingGames();
$result = array_map(static function (PlayedGame $g): array {
$name = match (true) {
null !== $g->getRed() => $g->getRed()->getUsername(),
null !== $g->getRedAnon() => $g->getRedAnon()->getUserName(),
null !== $g->getBlue() => $g->getBlue()->getUsername(),
default => $g->getBlueAnon()?->getUserName() ?? 'Unknown',
};
return [
'gameAssoc' => $g->getGameAssoc(),
'name' => $name,
'since' => $g->getCreated()?->format(\DateTimeInterface::ATOM) ?? '',
];
}, $games);
return $this->json($result);
}
private function resolveUserName(Request $request): string
{
$user = $this->getUser();