Skip to content

Commit 1e964c5

Browse files
committed
fix room creation
1 parent 552bb4e commit 1e964c5

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/Api/Controller/RoomController.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#[Route('/room', format: 'json')]
3131
class RoomController extends AbstractController
3232
{
33-
public const IS_GAME_MASTERED_ROOM = 'isGameMastered';
33+
public const string IS_GAME_MASTERED_ROOM = 'isGameMastered';
3434

3535
public function __construct(
3636
private readonly RoomRepository $roomRepository,
@@ -60,20 +60,16 @@ public function createRoom(Request $request): JsonResponse
6060
$player->setUser($user);
6161
$player->setRoom($room);
6262

63-
// Check if this should be a game-mastered room
64-
$isGameMastered = false;
6563
if ($request->getContent() !== '') {
6664
$data = $request->toArray();
6765
if (isset($data[self::IS_GAME_MASTERED_ROOM]) && $data[self::IS_GAME_MASTERED_ROOM]) {
68-
$isGameMastered = true;
6966
$room->setIsGameMastered(true);
7067
$player->setStatus(PlayerStatus::SPECTATING);
71-
// Grant ROLE_MASTER to the User, not the Player
72-
$user->setRoles(['ROLE_USER', 'ROLE_MASTER']);
7368
}
7469
}
7570

7671
$room->addPlayer($player);
72+
$user->addPlayer($player);
7773

7874
$this->roomRepository->store($room);
7975
$this->playerRepository->store($player);

src/Domain/Player/Entity/Player.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,6 @@ public function setMissionSwitchUsed(bool $missionSwitchUsed): self
360360

361361
public function isGameMaster(): bool
362362
{
363-
if ($this->user === null) {
364-
return false;
365-
}
366-
367-
return in_array('ROLE_MASTER', $this->user->getRoles(), true);
363+
return $this->status === PlayerStatus::SPECTATING;
368364
}
369365
}

0 commit comments

Comments
 (0)