Private
Public Access
1
0

chg: dev: outsource the Grid generation and interactions to the backend #4

This commit is contained in:
2026-04-10 12:23:21 +02:00
parent 76143fca3e
commit fe2de91e91
9 changed files with 586 additions and 554 deletions

View File

@@ -39,11 +39,11 @@ class MercureController extends AbstractController
) {
}
/** POST /api/game/start — save the grid and create the PlayedGame record */
/** POST /api/game/start — generate the grid on the server and create the PlayedGame record */
public function start(Request $request): JsonResponse
{
$data = $request->toArray();
$result = $this->rpcManager->saveGrid([$data['grid'], $data['gameAssoc']]);
$data = $request->toArray();
$result = $this->rpcManager->saveGrid($data['gameAssoc']);
return $this->json(['success' => $result]);
}
@@ -64,12 +64,12 @@ class MercureController extends AbstractController
return $this->json(['success' => true]);
}
/** POST /api/game/step/{gameAssoc} — persist the step and broadcast game event via Mercure */
/** POST /api/game/step/{gameAssoc} — persist the step, broadcast via Mercure, and return revealed cells */
public function step(string $gameAssoc, Request $request): JsonResponse
{
$this->topicManager->publish($gameAssoc, $this->resolveUserName($request), $request->toArray());
$result = $this->topicManager->publish($gameAssoc, $this->resolveUserName($request), $request->toArray());
return $this->json(['success' => true]);
return $this->json($result);
}
/** POST /api/game/leave/{gameAssoc} — broadcast disconnect event via Mercure */