<?php

namespace App\Entity;

use App\Repository\EventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: EventRepository::class)]
class Event
{
    #[ORM\Id]
    #[ORM\Column(type: UuidType::NAME, unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id = null;

    #[ORM\Column(length: 255)]
    private ?string $name = null;

    #[ORM\Column(type: Types::TEXT, nullable: true)]
    private ?string $description = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $picture = null;

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    private ?\DateTimeInterface $startOn = null;

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    private ?\DateTimeInterface $endOn = null;

    #[ORM\Column(type: Types::ASCII_STRING, nullable: true)]
    private $moreLink;

    #[ORM\Column(type: Types::ASCII_STRING, nullable: true)]
    private $slug;

    #[ORM\Column(nullable: true)]
    private ?bool $published = null;

    #[ORM\Column(nullable: true)]
    private ?bool $private = null;

    #[ORM\Column(nullable: true)]
    private ?bool $hiddenPlanning = null;

    #[ORM\Column(nullable: true)]
    private ?bool $everyoneCanAskForGame = null;

    /**
     * @var Collection<int, Space>
     */
    #[ORM\OneToMany(targetEntity: Space::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $spaces;

    /**
     * @var Collection<int, Period>
     */
    #[ORM\OneToMany(targetEntity: Period::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $periods;

    /**
     * @var Collection<int, Slot>
     */
    #[ORM\OneToMany(targetEntity: Slot::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $slots;

    /**
     * @var Collection<int, Gamemaster>
     */
    #[ORM\ManyToMany(targetEntity: Gamemaster::class, inversedBy: 'eventsAssignedTo')]
    private Collection $gamemastersAssigned;

    /**
     * @var Collection<int, Game>
     */
    #[ORM\ManyToMany(targetEntity: Game::class, inversedBy: 'eventsAssignedTo')]
    private Collection $gameAssigned;

    /**
     * @var Collection<int, Party>
     */
    #[ORM\OneToMany(targetEntity: Party::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $parties;

    /**
     * @var Collection<int, PartyRequest>
     */
    #[ORM\OneToMany(targetEntity: PartyRequest::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $partyRequests;

    /**
     * @var Collection<int, Availability>
     */
    #[ORM\OneToMany(targetEntity: Availability::class, mappedBy: 'event', orphanRemoval: true)]
    private Collection $availabilities;

    public function __construct()
    {
        $this->spaces = new ArrayCollection();
        $this->periods = new ArrayCollection();
        $this->slots = new ArrayCollection();
        $this->gamemastersAssigned = new ArrayCollection();
        $this->gameAssigned = new ArrayCollection();
        $this->parties = new ArrayCollection();
        $this->partyRequests = new ArrayCollection();
        $this->availabilities = new ArrayCollection();
    }

    public function getId(): ?Uuid
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): static
    {
        $this->name = $name;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): static
    {
        $this->description = $description;

        return $this;
    }

    public function getPicture(): ?string
    {
        return $this->picture;
    }

    public function setPicture(?string $picture): static
    {
        $this->picture = $picture;

        return $this;
    }

    public function getStartOn(): ?\DateTimeInterface
    {
        return $this->startOn;
    }

    public function setStartOn(\DateTimeInterface $startOn): static
    {
        $this->startOn = $startOn;

        return $this;
    }

    public function getEndOn(): ?\DateTimeInterface
    {
        return $this->endOn;
    }

    public function setEndOn(\DateTimeInterface $endOn): static
    {
        $this->endOn = $endOn;

        return $this;
    }

    public function getMoreLink()
    {
        return $this->moreLink;
    }

    public function setMoreLink($moreLink): static
    {
        $this->moreLink = $moreLink;

        return $this;
    }

    public function getSlug()
    {
        return $this->slug;
    }

    public function setSlug($slug): static
    {
        $this->slug = $slug;

        return $this;
    }

    public function isPublished(): ?bool
    {
        return $this->published;
    }

    public function setPublished(?bool $published): static
    {
        $this->published = $published;

        return $this;
    }

    public function isPrivate(): ?bool
    {
        return $this->private;
    }

    public function setPrivate(?bool $private): static
    {
        $this->private = $private;

        return $this;
    }

    public function isHiddenPlanning(): ?bool
    {
        return $this->hiddenPlanning;
    }

    public function setHiddenPlanning(?bool $hiddenPlanning): static
    {
        $this->hiddenPlanning = $hiddenPlanning;

        return $this;
    }

    public function isEveryoneCanAskForGame(): ?bool
    {
        return $this->everyoneCanAskForGame;
    }

    public function setEveryoneCanAskForGame(?bool $everyoneCanAskForGame): static
    {
        $this->everyoneCanAskForGame = $everyoneCanAskForGame;

        return $this;
    }

    /**
     * @return Collection<int, Space>
     */
    public function getSpaces(): Collection
    {
        return $this->spaces;
    }

    public function addSpace(Space $space): static
    {
        if (!$this->spaces->contains($space)) {
            $this->spaces->add($space);
            $space->setEvent($this);
        }

        return $this;
    }

    public function removeSpace(Space $space): static
    {
        if ($this->spaces->removeElement($space)) {
            // set the owning side to null (unless already changed)
            if ($space->getEvent() === $this) {
                $space->setEvent(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Period>
     */
    public function getPeriods(): Collection
    {
        return $this->periods;
    }

    public function addPeriod(Period $period): static
    {
        if (!$this->periods->contains($period)) {
            $this->periods->add($period);
            $period->setEvent($this);
        }

        return $this;
    }

    public function removePeriod(Period $period): static
    {
        if ($this->periods->removeElement($period)) {
            // set the owning side to null (unless already changed)
            if ($period->getEvent() === $this) {
                $period->setEvent(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Slot>
     */
    public function getSlots(): Collection
    {
        return $this->slots;
    }

    public function addSlot(Slot $slot): static
    {
        if (!$this->slots->contains($slot)) {
            $this->slots->add($slot);
            $slot->setEvent($this);
        }

        return $this;
    }

    public function removeSlot(Slot $slot): static
    {
        if ($this->slots->removeElement($slot)) {
            // set the owning side to null (unless already changed)
            if ($slot->getEvent() === $this) {
                $slot->setEvent(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Gamemaster>
     */
    public function getGamemastersAssigned(): Collection
    {
        return $this->gamemastersAssigned;
    }

    public function addGamemastersAssigned(Gamemaster $gamemastersAssigned): static
    {
        if (!$this->gamemastersAssigned->contains($gamemastersAssigned)) {
            $this->gamemastersAssigned->add($gamemastersAssigned);
        }

        return $this;
    }

    public function removeGamemastersAssigned(Gamemaster $gamemastersAssigned): static
    {
        $this->gamemastersAssigned->removeElement($gamemastersAssigned);

        return $this;
    }

    /**
     * @return Collection<int, Game>
     */
    public function getGameAssigned(): Collection
    {
        return $this->gameAssigned;
    }

    public function addGameAssigned(Game $gameAssigned): static
    {
        if (!$this->gameAssigned->contains($gameAssigned)) {
            $this->gameAssigned->add($gameAssigned);
        }

        return $this;
    }

    public function removeGameAssigned(Game $gameAssigned): static
    {
        $this->gameAssigned->removeElement($gameAssigned);

        return $this;
    }

    /**
     * @return Collection<int, Party>
     */
    public function getParties(): Collection
    {
        return $this->parties;
    }

    public function addParty(Party $party): static
    {
        if (!$this->parties->contains($party)) {
            $this->parties->add($party);
            $party->setEvent($this);
        }

        return $this;
    }

    public function removeParty(Party $party): static
    {
        if ($this->parties->removeElement($party)) {
            // set the owning side to null (unless already changed)
            if ($party->getEvent() === $this) {
                $party->setEvent(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, PartyRequest>
     */
    public function getPartyRequests(): Collection
    {
        return $this->partyRequests;
    }

    public function addPartyRequest(PartyRequest $partyRequest): static
    {
        if (!$this->partyRequests->contains($partyRequest)) {
            $this->partyRequests->add($partyRequest);
            $partyRequest->setEvent($this);
        }

        return $this;
    }

    public function removePartyRequest(PartyRequest $partyRequest): static
    {
        if ($this->partyRequests->removeElement($partyRequest)) {
            // set the owning side to null (unless already changed)
            if ($partyRequest->getEvent() === $this) {
                $partyRequest->setEvent(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Availability>
     */
    public function getAvailabilities(): Collection
    {
        return $this->availabilities;
    }

    public function addAvailability(Availability $availability): static
    {
        if (!$this->availabilities->contains($availability)) {
            $this->availabilities->add($availability);
            $availability->setEvent($this);
        }

        return $this;
    }

    public function removeAvailability(Availability $availability): static
    {
        if ($this->availabilities->removeElement($availability)) {
            // set the owning side to null (unless already changed)
            if ($availability->getEvent() === $this) {
                $availability->setEvent(null);
            }
        }

        return $this;
    }
}
