chg: dev: outsource the Grid generation and interactions to the backend #4
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user