src/Entity/Game.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GameRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=GameRepository::class)
  9.  */
  10. class Game
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\OneToMany(targetEntity=Player::class, mappedBy="game", orphanRemoval=true, cascade={"persist", "remove"})
  20.      */
  21.     private $players;
  22.     /**
  23.      * @ORM\OneToOne(targetEntity=Board::class, inversedBy="game", cascade={"persist", "remove"})
  24.      */
  25.     private $board;
  26.     /**
  27.      * @ORM\Column(type="datetime", nullable=true)
  28.      */
  29.     private $turnStartTime;
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=true)
  32.      */
  33.     private $gameStartTime;
  34.     /**
  35.      * @ORM\Column(type="dateinterval", nullable=true)
  36.      */
  37.     private $maxTurnTime;
  38.     /**
  39.      * @ORM\Column(type="dateinterval", nullable=true)
  40.      */
  41.     private $maxPlayerTime;
  42.     /**
  43.      * @ORM\Column(type="boolean", nullable=true)
  44.      */
  45.     private $isTournamentMatch;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=Player::class)
  48.      */
  49.     private $turn;
  50.     /**
  51.      * @ORM\Column(type="boolean")
  52.      */
  53.     private $hasEnded false;
  54.     /**
  55.      * @ORM\Column(type="integer", nullable=true)
  56.      */
  57.     private $turnCount;
  58.     /**
  59.      * @ORM\Column(type="array", nullable=true)
  60.      */
  61.     private $history = [];
  62.     public function __construct()
  63.     {
  64.         $this->players = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     /**
  71.      * @return Collection|Player[]
  72.      */
  73.     public function getPlayers(): Collection
  74.     {
  75.         return $this->players;
  76.     }
  77.     public function addPlayer(Player $player): self
  78.     {
  79.         if (!$this->players->contains($player)) {
  80.             $this->players[] = $player;
  81.             $player->setGame($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removePlayer(Player $player): self
  86.     {
  87.         if ($this->players->removeElement($player)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($player->getGame() === $this) {
  90.                 $player->setGame(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public function getBoard(): ?Board
  96.     {
  97.         return $this->board;
  98.     }
  99.     public function setBoard(?Board $board): self
  100.     {
  101.         $this->board $board;
  102.         return $this;
  103.     }
  104.     public function getTurnStartTime(): ?\DateTimeInterface
  105.     {
  106.         return $this->turnStartTime;
  107.     }
  108.     public function setTurnStartTime(?\DateTimeInterface $turnStartTime): self
  109.     {
  110.         $this->turnStartTime $turnStartTime;
  111.         return $this;
  112.     }
  113.     public function getGameStartTime(): ?\DateTimeInterface
  114.     {
  115.         return $this->gameStartTime;
  116.     }
  117.     public function setGameStartTime(?\DateTimeInterface $gameStartTime): self
  118.     {
  119.         $this->gameStartTime $gameStartTime;
  120.         return $this;
  121.     }
  122.     public function getMaxTurnTime(): ?\DateInterval
  123.     {
  124.         return $this->maxTurnTime;
  125.     }
  126.     public function setMaxTurnTime(?\DateInterval $maxTurnTime): self
  127.     {
  128.         $this->maxTurnTime $maxTurnTime;
  129.         return $this;
  130.     }
  131.     public function getMaxPlayerTime(): ?\DateInterval
  132.     {
  133.         return $this->maxPlayerTime;
  134.     }
  135.     public function setMaxPlayerTime(?\DateInterval $maxPlayerTime): self
  136.     {
  137.         $this->maxPlayerTime $maxPlayerTime;
  138.         return $this;
  139.     }
  140.     public function getIsTournamentMatch(): ?bool
  141.     {
  142.         return $this->isTournamentMatch;
  143.     }
  144.     public function setIsTournamentMatch(?bool $isTournamentMatch): self
  145.     {
  146.         $this->isTournamentMatch $isTournamentMatch;
  147.         return $this;
  148.     }
  149.     public function getTurn(): ?Player
  150.     {
  151.         return $this->turn;
  152.     }
  153.     public function setTurn(?Player $turn): self
  154.     {
  155.         $this->turn $turn;
  156.         return $this;
  157.     }
  158.     public function getHasEnded(): ?bool
  159.     {
  160.         return $this->hasEnded;
  161.     }
  162.     public function setHasEnded(bool $hasEnded): self
  163.     {
  164.         $this->hasEnded $hasEnded;
  165.         return $this;
  166.     }
  167.     public function getTurnCount(): ?int
  168.     {
  169.         return $this->turnCount;
  170.     }
  171.     public function setTurnCount(?int $turnCount): self
  172.     {
  173.         $this->turnCount $turnCount;
  174.         return $this;
  175.     }
  176.     public function getHistory(): ?array
  177.     {
  178.         return $this->history;
  179.     }
  180.     public function setHistory(?array $history): self
  181.     {
  182.         $this->history $history;
  183.         return $this;
  184.     }
  185. }