<?php
namespace App\Entity\Game\WordSearch;
use App\Entity\BaseEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass=WordRepository::class)
* @Serializer\ExclusionPolicy("ALL")
*/
class Word extends BaseEntity
{
const HORIZONTAL = 0;
const VERTICAL = 1;
const DIAGONAL_LEFT_TO_RIGHT = 2;
const DIAGONAL_RIGHT_TO_LEFT = 3;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose
* @Serializer\Groups({"word_search_list"})
*/
private $label;
/**
* @ORM\ManyToMany(targetEntity=Grid::class, mappedBy="words")
*/
private $grids;
private $reversed;
private $start;
private $end;
private $orientation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
* @Serializer\Groups({"word_search_list"})
*/
private $bgColor;
/**
* @ORM\ManyToMany(targetEntity=WordSearchParticipation::class, mappedBy="words")
*/
private $wordSearchParticipations;
/**
* @ORM\ManyToMany(targetEntity=WordSearchParticipation::class, mappedBy="wordsFound")
*/
private $wordFoundParticipations;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $points;
public function __construct() {
// $this->start = $start;
// $this->end = $end;
// $this->orientation = $orientation;
// $this->label = $label;
// $this->reversed = $reversed;
$this->grids = new ArrayCollection();
$this->wordSearchParticipations = new ArrayCollection();
$this->wordFoundParticipations = new ArrayCollection();
}
public static function init($start, $end, $orientation, $label, $reversed) {
$instance = new self();
$instance->start = $start;
$instance->end = $end;
$instance->orientation = $orientation;
$instance->label = $label;
$instance->reversed = $reversed;
return $instance;
}
public function getId(): ?int
{
return $this->id;
}
public function getOrientation(): ?string
{
return $this->orientation;
}
public function setOrientation(string $_orientation): self
{
$this->orientation = $_orientation;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $_label): self
{
$this->label = $_label;
return $this;
}
public function isReversed(): ?bool
{
return $this->reversed;
}
public function setReversed(bool $_reversed): self
{
$this->reversed = $_reversed;
return $this;
}
public function getStart(): ?int
{
return $this->start;
}
public function setStart(int $_start): self
{
$this->start = $_start;
return $this;
}
public function getEnd(): ?int
{
return $this->end;
}
public function setEnd(int $_end): self
{
$this->end = $_end;
return $this;
}
/**
* @return Collection<int, Grid>
*/
public function getGrids(): Collection
{
return $this->grids;
}
public function addGrid(Grid $grid): self
{
if (!$this->grids->contains($grid)) {
$this->grids[] = $grid;
$grid->addWord($this);
}
return $this;
}
public function removeGrid(Grid $grid): self
{
if ($this->grids->removeElement($grid)) {
$grid->removeWord($this);
}
return $this;
}
public function getBgColor(): ?string
{
return $this->bgColor;
}
public function setBgColor(?string $bgColor): self
{
$this->bgColor = $bgColor;
return $this;
}
/**
* @return Collection<int, WordSearchParticipation>
*/
public function getWordSearchParticipations(): Collection
{
return $this->wordSearchParticipations;
}
public function addWordSearchParticipation(WordSearchParticipation $wordSearchParticipation): self
{
if (!$this->wordSearchParticipations->contains($wordSearchParticipation)) {
$this->wordSearchParticipations[] = $wordSearchParticipation;
$wordSearchParticipation->addWord($this);
}
return $this;
}
public function removeWordSearchParticipation(WordSearchParticipation $wordSearchParticipation): self
{
if ($this->wordSearchParticipations->removeElement($wordSearchParticipation)) {
$wordSearchParticipation->removeWord($this);
}
return $this;
}
/**
* @return Collection<int, WordSearchParticipation>
*/
public function getWordFoundParticipations(): Collection
{
return $this->wordFoundParticipations;
}
public function addWordFoundParticipation(WordSearchParticipation $wordFoundParticipation): self
{
if (!$this->wordFoundParticipations->contains($wordFoundParticipation)) {
$this->wordFoundParticipations[] = $wordFoundParticipation;
$wordFoundParticipation->addWordFound($this);
}
return $this;
}
public function removeWordFoundParticipation(WordSearchParticipation $wordFoundParticipation): self
{
if ($this->wordFoundParticipations->removeElement($wordFoundParticipation)) {
$wordFoundParticipation->removeWordFound($this);
}
return $this;
}
public function getPoints(): ?int
{
return $this->points;
}
public function setPoints(?int $points): self
{
$this->points = $points;
return $this;
}
}