fix:websocket errors & polict change

This commit is contained in:
2026-01-02 14:26:54 +00:00
parent ef277a3cfd
commit 3a7b1b9794
6 changed files with 64 additions and 42 deletions
+17 -9
View File
@@ -20,7 +20,7 @@ class GamePolicy
*/
public function view(User $user, Game $game): bool
{
if ($user->type === 'A') {
if ($user->type === "A") {
return true;
}
@@ -31,6 +31,10 @@ class GamePolicy
return true;
}
if ($game->status === "Pending") {
return true;
}
return false;
}
@@ -39,7 +43,7 @@ class GamePolicy
*/
public function create(User $user): bool
{
if ($user->type === 'A') {
if ($user->type === "A") {
return false;
}
@@ -48,28 +52,32 @@ class GamePolicy
public function join(User $user, Game $game): bool
{
if ($user->type === 'A') {
if ($user->type === "A") {
return false;
}
if (
$game->status !== 'waiting' ||
$game->status !== "Pending" ||
$game->player1_user_id === $user->id
) {
return false;
}
if ($game->player2_user_id !== null && $game->player2_user_id !== 1) {
return false;
}
return true;
}
public function resign(User $user, Game $game): bool
{
if ($user->type === 'A') {
if ($user->type === "A") {
return false;
}
if (
$game->status !== 'ongoing' ||
$game->status !== "Playing" ||
($game->player1_user_id !== $user->id &&
$game->player2_user_id !== $user->id)
) {
@@ -84,12 +92,12 @@ class GamePolicy
*/
public function update(User $user, Game $game): bool
{
if ($user->type === 'A') {
if ($user->type === "A") {
return false;
}
if (
$game->status !== 'ongoing' ||
$game->status !== "Playing" ||
($game->player1_user_id !== $user->id &&
$game->player2_user_id !== $user->id)
) {
@@ -105,7 +113,7 @@ class GamePolicy
public function delete(User $user, Game $game): bool
{
// Only admins can delete games
return $user->type === 'A';
return $user->type === "A";
}
/**