<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\User;
use App\Models\World;

class WorldPolicy
{
    public function view(?User $user, World $world): bool
    {
        if ($user && ($user->isAdmin() || $user->isModerator())) {
            return true;
        }

        return $world->isPubliclyVisible();
    }

    public function create(User $user): bool
    {
        return $user->isAdmin() || $user->isModerator();
    }

    public function update(User $user, World $world): bool
    {
        return $user->isAdmin() || $user->isModerator();
    }

    public function delete(User $user, World $world): bool
    {
        return $user->isAdmin() || $user->isModerator();
    }

    public function manage(User $user): bool
    {
        return $user->isAdmin() || $user->isModerator();
    }
}