<?php
namespace App\Entity;
use App\Entity\Locality;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\GameRepository")
* @Vich\Uploadable
*/
class Game
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Season", inversedBy="games")
* @ORM\JoinColumn(nullable=false)
*/
private $season;
/**
* @ORM\Column(type="string", length=255)
*/
private $rival;
/**
* @ORM\OneToOne(targetEntity=Locality::class)
*/
private $locality;
/**
* @ORM\Column(type="integer")
*/
private $day;
/**
* @ORM\Column(type="datetime")
*/
private $date;
/**
* @ORM\Column(type="integer")
*/
private $goals;
/**
* @ORM\Column(type="integer")
*/
private $rivalGoals;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="game_images", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime
*/
private $updatedAt;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Convocatoria", mappedBy="game", cascade={"persist", "remove"})
*/
private $convocatoria;
/**
* @ORM\OneToMany(targetEntity=Minutes::class, mappedBy="game_id")
*/
private $minutes;
/**
* @ORM\OneToOne(targetEntity=Competition::class)
*/
private $competition;
/**
* @ORM\Column(type="integer")
*/
private $shots_goal;
/**
* @ORM\Column(type="integer")
*/
private $shots_opponent;
/**
* @ORM\Column(type="integer")
*/
private $corners_favor;
/**
* @ORM\Column(type="integer")
*/
private $corners_against;
/**
* @ORM\Column(type="integer")
*/
private $penalties_favor;
/**
* @ORM\Column(type="integer")
*/
private $penalties_against;
/**
* @ORM\Column(type="integer")
*/
private $fouls_favor;
/**
* @ORM\Column(type="integer")
*/
private $fouls_against;
/**
* @ORM\OneToOne(targetEntity=GameAlignment::class, inversedBy="game", cascade={"persist", "remove"})
*/
private $alignment;
/**
* @ORM\Column(type="integer", options={"default" : 90})
*/
private $timeMatch;
/**
* @ORM\Column(type="integer", options={"default" : 11})
*/
private $category;
/**
* @ORM\OneToOne(targetEntity=GameAlignment::class, inversedBy="game", cascade={"persist", "remove"})
*/
private $rival_alignment;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $total_shots;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $total_shots_against;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $yellow_cards;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $yellow_cards_against;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $red_cards;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $red_cards_against;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $currentPositionLeague;
/**
* @ORM\OneToMany(targetEntity=KilometersTraveled::class, mappedBy="game")
*/
private $kilometersTraveleds;
/**
* @ORM\OneToMany(targetEntity=ShotsOnGoal::class, mappedBy="game")
*/
private $shotsOnGoals;
/**
* @ORM\OneToMany(targetEntity=GamePlayerStatistics::class, mappedBy="game")
*/
private $seasonplayer;
/**
* @ORM\OneToMany(targetEntity=GamePlayerStatistics::class, mappedBy="game")
*/
private $gamePlayerStatistics;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $opponentCurrentPositionLeague;
/**
* @ORM\ManyToOne(targetEntity=Difficulty::class, inversedBy="pressureRivals")
*/
private $pressureRival;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime
*/
private $deletedAt;
public function __construct()
{
$this->minutes = new ArrayCollection();
$this->kilometersTraveleds = new ArrayCollection();
$this->shotsOnGoals = new ArrayCollection();
$this->seasonplayer = new ArrayCollection();
$this->gamePlayerStatistics = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
public function getRival(): ?string
{
return $this->rival;
}
public function setRival(string $rival): self
{
$this->rival = $rival;
return $this;
}
public function getLocality(): ?Locality
{
return $this->locality;
}
public function setLocality(Locality $locality): self
{
$this->locality = $locality;
return $this;
}
public function getDay(): ?int
{
return $this->day;
}
public function setDay(int $day): self
{
$this->day = $day;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getGoals(): ?int
{
return $this->goals;
}
public function setGoals(int $goals): self
{
$this->goals = $goals;
return $this;
}
public function getRivalGoals(): ?int
{
return $this->rivalGoals;
}
public function setRivalGoals(int $rivalGoals): self
{
$this->rivalGoals = $rivalGoals;
return $this;
}
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
* @return Game
*/
public function setUpdatedAt(\DateTime $updatedAt): Game
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @param File|null $image
* @return Game
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
return $this;
}
public function getImageFile()
{
return $this->imageFile;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getConvocatoria(): ?Convocatoria
{
return $this->convocatoria;
}
public function setConvocatoria(Convocatoria $convocatoria): self
{
$this->convocatoria = $convocatoria;
// set the owning side of the relation if necessary
if ($convocatoria->getGame() !== $this) {
$convocatoria->setGame($this);
}
return $this;
}
public function __toArray($imagePath)
{
return [
"id" => $this->getId(),
"rival" => $this->getRival(),
"locality" => $this->getLocality() ? $this->getLocality()->getName() : null,
"locality_id" => $this->getLocality() ? $this->getLocality()->getId() : null,
"day" => $this->getDay(),
"date" => $this->getDate()->format("d/m/Y H:i"),
"goals" => $this->getGoals(),
"rivalGoals" => $this->getRivalGoals(),
"image" => !empty($this->getImage()) ? $imagePath . $this->getImage() : "",
"competition" => $this->getCompetition() ? $this->getCompetition()->getName() : null,
"competition_id" => $this->getCompetition() ? $this->getCompetition()->getId() : null,
"timeMatch" => $this->getTimeMatch(),
"category" => $this->getCategory(),
"shots_goal" => $this->getShotsGoal(),
"shots_opponent" => $this->getShotsOpponent(),
"corners_favor" => $this->getCornersFavor(),
"corners_against" => $this->getCornersAgainst(),
"penalties_favor" => $this->getPenaltiesFavor(),
"penalties_against" => $this->getPenaltiesAgainst(),
"fouls_favor" => $this->getFoulsFavor(),
"fouls_against" => $this->getFoulsAgainst(),
"rival_tactic" => $this->getRivalAlignment() != null ? $this->getRivalAlignment()->getTactic() : "",
'total_shots' => $this->getTotalShots() ?? 0,
'total_shots_against' => $this->getTotalShotsAgainst() ?? 0,
'yellow_cards' => $this->getYellowCards() ?? 0,
'yellow_cards_against' => $this->getYellowCardsAgainst() ?? 0,
'red_cards' => $this->getRedCards() ?? 0,
'opponentCurrentPositionLeague' => $this->getOpponentCurrentPositionLeague() ?? 0,
'pressureRival' => $this->getPressureRival() ? $this->getPressureRival()->__toArray() : null,
'pressureRivalId' => $this->getPressureRival() ? $this->getPressureRival()->getId() : null,
'red_cards_against' => $this->getRedCardsAgainst() ?? 0,
'alignment' => $this->getAlignment() ? $this->getAlignment()->__toArray() : null,
'currentPositionLeague' => $this->getCurrentPositionLeague()
];
}
/**
* @return Collection|Minutes[]
*/
public function getMinutes(): Collection
{
return $this->minutes;
}
public function addMinute(Minutes $minute): self
{
if (!$this->minutes->contains($minute)) {
$this->minutes[] = $minute;
$minute->setGameId($this);
}
return $this;
}
public function removeMinute(Minutes $minute): self
{
if ($this->minutes->contains($minute)) {
$this->minutes->removeElement($minute);
// set the owning side to null (unless already changed)
if ($minute->getGameId() === $this) {
$minute->setGameId(null);
}
}
return $this;
}
public function getShotsGoal(): ?int
{
return $this->shots_goal;
}
public function setShotsGoal(int $shots_goal): self
{
$this->shots_goal = $shots_goal;
return $this;
}
public function getShotsOpponent(): ?int
{
return $this->shots_opponent;
}
public function setShotsOpponent(int $shots_opponent): self
{
$this->shots_opponent = $shots_opponent;
return $this;
}
public function getCornersFavor(): ?int
{
return $this->corners_favor;
}
public function setCornersFavor(int $corners_favor): self
{
$this->corners_favor = $corners_favor;
return $this;
}
public function getCornersAgainst(): ?int
{
return $this->corners_against;
}
public function setCornersAgainst(int $corners_against): self
{
$this->corners_against = $corners_against;
return $this;
}
public function getPenaltiesFavor(): ?int
{
return $this->penalties_favor;
}
public function setPenaltiesFavor(int $penalties_favor): self
{
$this->penalties_favor = $penalties_favor;
return $this;
}
public function getPenaltiesAgainst(): ?int
{
return $this->penalties_against;
}
public function setPenaltiesAgainst(int $penalties_against): self
{
$this->penalties_against = $penalties_against;
return $this;
}
public function getFoulsFavor(): ?int
{
return $this->fouls_favor;
}
public function setFoulsFavor(int $fouls_favor): self
{
$this->fouls_favor = $fouls_favor;
return $this;
}
public function getFoulsAgainst(): ?int
{
return $this->fouls_against;
}
public function setFoulsAgainst(int $fouls_against): self
{
$this->fouls_against = $fouls_against;
return $this;
}
public function getAlignment(): ?GameAlignment
{
return $this->alignment;
}
public function setAlignment(?GameAlignment $alignment): self
{
$this->alignment = $alignment;
return $this;
}
public function getTimeMatch(): ?int
{
return $this->timeMatch;
}
public function setTimeMatch(?int $timeMatch): self
{
$this->timeMatch = $timeMatch;
return $this;
}
public function getCategory(): ?int
{
return $this->category;
}
public function setCategory(int $category): self
{
$this->category = $category;
return $this;
}
public function getRivalAlignment(): ?GameAlignment
{
return $this->rival_alignment;
}
public function setRivalAlignment(?GameAlignment $alignment): self
{
$this->rival_alignment = $alignment;
return $this;
}
public function getTotalShots(): ?int
{
return $this->total_shots;
}
public function setTotalShots(?int $total_shots): self
{
$this->total_shots = $total_shots;
return $this;
}
public function getTotalShotsAgainst(): ?int
{
return $this->total_shots_against;
}
public function setTotalShotsAgainst(?int $total_shots_against): self
{
$this->total_shots_against = $total_shots_against;
return $this;
}
public function getYellowCards(): ?int
{
return $this->yellow_cards;
}
public function setYellowCards(?int $yellow_cards): self
{
$this->yellow_cards = $yellow_cards;
return $this;
}
public function getYellowCardsAgainst(): ?int
{
return $this->yellow_cards_against;
}
public function setYellowCardsAgainst(?int $yellow_cards_against): self
{
$this->yellow_cards_against = $yellow_cards_against;
return $this;
}
public function getRedCards(): ?int
{
return $this->red_cards;
}
public function setRedCards(?int $red_cards): self
{
$this->red_cards = $red_cards;
return $this;
}
public function getRedCardsAgainst(): ?int
{
return $this->red_cards_against;
}
public function setRedCardsAgainst(?int $red_cards_against): self
{
$this->red_cards_against = $red_cards_against;
return $this;
}
public function getCurrentPositionLeague(): ?int
{
return $this->currentPositionLeague;
}
public function setCurrentPositionLeague(?int $currentPositionLeague): self
{
$this->currentPositionLeague = $currentPositionLeague;
return $this;
}
/**
* @return Collection|KilometersTraveled[]
*/
public function getKilometersTraveleds(): Collection
{
return $this->kilometersTraveleds;
}
public function addKilometersTraveled(KilometersTraveled $kilometersTraveled): self
{
if (!$this->kilometersTraveleds->contains($kilometersTraveled)) {
$this->kilometersTraveleds[] = $kilometersTraveled;
$kilometersTraveled->setGame($this);
}
return $this;
}
public function removeKilometersTraveled(KilometersTraveled $kilometersTraveled): self
{
if ($this->kilometersTraveleds->contains($kilometersTraveled)) {
$this->kilometersTraveleds->removeElement($kilometersTraveled);
// set the owning side to null (unless already changed)
if ($kilometersTraveled->getGame() === $this) {
$kilometersTraveled->setGame(null);
}
}
return $this;
}
/**
* @return Collection|ShotsOnGoal[]
*/
public function getShotsOnGoals(): Collection
{
return $this->shotsOnGoals;
}
public function addShotsOnGoal(ShotsOnGoal $shotsOnGoal): self
{
if (!$this->shotsOnGoals->contains($shotsOnGoal)) {
$this->shotsOnGoals[] = $shotsOnGoal;
$shotsOnGoal->setGame($this);
}
return $this;
}
public function removeShotsOnGoal(ShotsOnGoal $shotsOnGoal): self
{
if ($this->shotsOnGoals->contains($shotsOnGoal)) {
$this->shotsOnGoals->removeElement($shotsOnGoal);
// set the owning side to null (unless already changed)
if ($shotsOnGoal->getGame() === $this) {
$shotsOnGoal->setGame(null);
}
}
return $this;
}
/**
* @return Collection|GamePlayerStatistics[]
*/
public function getSeasonplayer(): Collection
{
return $this->seasonplayer;
}
public function addSeasonplayer(GamePlayerStatistics $seasonplayer): self
{
if (!$this->seasonplayer->contains($seasonplayer)) {
$this->seasonplayer[] = $seasonplayer;
$seasonplayer->setGame($this);
}
return $this;
}
public function removeSeasonplayer(GamePlayerStatistics $seasonplayer): self
{
if ($this->seasonplayer->contains($seasonplayer)) {
$this->seasonplayer->removeElement($seasonplayer);
// set the owning side to null (unless already changed)
if ($seasonplayer->getGame() === $this) {
$seasonplayer->setGame(null);
}
}
return $this;
}
/**
* @return Collection|GamePlayerStatistics[]
*/
public function getGamePlayerStatistics(): Collection
{
return $this->gamePlayerStatistics;
}
public function addGamePlayerStatistic(GamePlayerStatistics $gamePlayerStatistic): self
{
if (!$this->gamePlayerStatistics->contains($gamePlayerStatistic)) {
$this->gamePlayerStatistics[] = $gamePlayerStatistic;
$gamePlayerStatistic->setGame($this);
}
return $this;
}
public function removeGamePlayerStatistic(GamePlayerStatistics $gamePlayerStatistic): self
{
if ($this->gamePlayerStatistics->contains($gamePlayerStatistic)) {
$this->gamePlayerStatistics->removeElement($gamePlayerStatistic);
// set the owning side to null (unless already changed)
if ($gamePlayerStatistic->getGame() === $this) {
$gamePlayerStatistic->setGame(null);
}
}
return $this;
}
public function getCompetition(): ?Competition
{
return $this->competition;
}
public function setCompetition(?Competition $competition): self
{
$this->competition = $competition;
return $this;
}
public function getOpponentCurrentPositionLeague(): ?int
{
return $this->opponentCurrentPositionLeague;
}
public function setOpponentCurrentPositionLeague(?int $opponentCurrentPositionLeague): self
{
$this->opponentCurrentPositionLeague = $opponentCurrentPositionLeague;
return $this;
}
public function getPressureRival(): ?Difficulty
{
return $this->pressureRival;
}
public function setPressureRival(?Difficulty $pressureRival): self
{
$this->pressureRival = $pressureRival;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
}