<?php
declare(strict_types=1);

namespace App\Services;

use App\Entity\Game;
use App\Enum\GameStatusEnum;

class GameFactory
{
    public function __construct(
        private readonly GalaxyFactory $galaxyFactory
    ) {}

    public function createGame(string $name, int $nbSectors = 1000): Game {
        $game = new Game();
        $game->setName($name);

        $galaxy = $this->galaxyFactory->createGalaxy($nbSectors, $name);

        $game->setGalaxy($galaxy);
        return $game;
    }

    public function openGame(Game $game): Game {
        $game->setOpenedAt(new \DateTimeImmutable());
        $game->setStatus(GameStatusEnum::OPEN);
        return $game;
    }

    public function closeGame(Game $game): Game {
        $game->setClosedAt(new \DateTimeImmutable());
        $game->setStatus(GameStatusEnum::CLOSED);
        return $game;
    }

}