Fix game route dumping players into the terminal for non-PLAYING sessions
GameController::index() only special-cased READY; every other status (including a freshly-created session still waiting for players, and even an already WON/LOST one) fell straight through to rendering the live game terminal - which is broken there since screens/rights/pwd are never initialized before startSession() flips CREATED -> READY. The dashboard's "Enter Game" button links to this route regardless of status, so any player clicking it on a CREATED session hit this directly. Now CREATED redirects back to the dashboard with an explanatory flash, and WON/LOST redirect to their respective pages instead of re-rendering a dead terminal.
This commit is contained in:
@@ -134,6 +134,19 @@ final class GameController extends AbstractController
|
|||||||
// Lazily pick up readiness changes from other players since our last request
|
// Lazily pick up readiness changes from other players since our last request
|
||||||
$dashboardService->checkAllPlayersReady($session);
|
$dashboardService->checkAllPlayersReady($session);
|
||||||
|
|
||||||
|
if ($session->getStatus() === SessionStatus::CREATED) {
|
||||||
|
$this->addFlash('info', 'This session is still waiting for more players to join.');
|
||||||
|
return $this->redirectToRoute('game_dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($session->getStatus() === SessionStatus::WON) {
|
||||||
|
return $this->redirectToRoute('game_won', ['session' => $session->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($session->getStatus() === SessionStatus::LOST) {
|
||||||
|
return $this->redirectToRoute('game_lost', ['session' => $session->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($session->getStatus() === SessionStatus::READY) {
|
if ($session->getStatus() === SessionStatus::READY) {
|
||||||
$isReady = false;
|
$isReady = false;
|
||||||
if ($player) {
|
if ($player) {
|
||||||
|
|||||||
Reference in New Issue
Block a user