From 55145c366f228c85f4c1eaba03d497fe8190c7c9 Mon Sep 17 00:00:00 2001 From: thibaud-leclere Date: Mon, 30 Mar 2026 19:43:18 +0200 Subject: [PATCH] feat: add Game entity --- src/Entity/Game.php | 132 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 src/Entity/Game.php diff --git a/src/Entity/Game.php b/src/Entity/Game.php new file mode 100644 index 0000000..736546e --- /dev/null +++ b/src/Entity/Game.php @@ -0,0 +1,132 @@ + */ + #[ORM\OneToMany(targetEntity: GameRow::class, mappedBy: 'game', cascade: ['persist'], orphanRemoval: true)] + #[ORM\OrderBy(['rowOrder' => 'ASC'])] + private Collection $rows; + + public function __construct() + { + $this->startedAt = new \DateTimeImmutable(); + $this->rows = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): static + { + $this->user = $user; + + return $this; + } + + public function getMainActor(): ?Actor + { + return $this->mainActor; + } + + public function setMainActor(Actor $mainActor): static + { + $this->mainActor = $mainActor; + + return $this; + } + + public function getStatus(): string + { + return $this->status; + } + + public function setStatus(string $status): static + { + $this->status = $status; + + return $this; + } + + public function getStartedAt(): \DateTimeImmutable + { + return $this->startedAt; + } + + public function getEndedAt(): ?\DateTimeImmutable + { + return $this->endedAt; + } + + public function setEndedAt(?\DateTimeImmutable $endedAt): static + { + $this->endedAt = $endedAt; + + return $this; + } + + /** @return Collection */ + public function getRows(): Collection + { + return $this->rows; + } + + public function addRow(GameRow $row): static + { + if (!$this->rows->contains($row)) { + $this->rows->add($row); + $row->setGame($this); + } + + return $this; + } + + public function abandon(): static + { + $this->status = self::STATUS_ABANDONED; + $this->endedAt = new \DateTimeImmutable(); + + return $this; + } +}