2016-09-01 10:15:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace EmotionHero\Models;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use JMS\Serializer\Annotation as JMS;
|
|
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2016-09-01 15:33:00 +00:00
|
|
|
use EmotionHero\Application;
|
2016-09-01 10:15:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Single play of a game: combines User, Level and time
|
|
|
|
*
|
|
|
|
* @ORM\Table(name="games")
|
|
|
|
* @ORM\Entity(repositoryClass="EmotionHero\Models\GameRepository")
|
|
|
|
*/
|
|
|
|
class Game
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var integer
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="id")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue(strategy="UUID")
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="games")
|
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
|
|
|
|
*/
|
|
|
|
private $user;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="Level", inversedBy="games")
|
|
|
|
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=false)
|
|
|
|
*/
|
|
|
|
private $level;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\OneToMany(targetEntity="Hit", mappedBy="game", fetch="EXTRA_LAZY")
|
|
|
|
*/
|
|
|
|
private $hits;
|
|
|
|
|
|
|
|
/** @var float Total score of the game (sum of hits) */
|
|
|
|
private $score;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \DateTime $created
|
|
|
|
*
|
|
|
|
* @Gedmo\Timestampable(on="create")
|
|
|
|
* @ORM\Column(type="datetime")
|
|
|
|
*/
|
|
|
|
private $createdAt;
|
2016-09-01 15:33:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of id.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of user.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getUser()
|
|
|
|
{
|
|
|
|
return $this->user;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of level.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getLevel()
|
|
|
|
{
|
|
|
|
return $this->level;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of hits.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getHits()
|
|
|
|
{
|
|
|
|
return $this->hits;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of score.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getScore()
|
|
|
|
{
|
|
|
|
return $this->score;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of createdAt.
|
|
|
|
*
|
|
|
|
* @return \DateTime $created
|
|
|
|
*/
|
|
|
|
public function getCreatedAt()
|
|
|
|
{
|
|
|
|
return $this->createdAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Em should not be fetched here. Quick fix for now...
|
|
|
|
*
|
|
|
|
* @JMS\VirtualProperty
|
|
|
|
* @return Position
|
|
|
|
*/
|
|
|
|
public function getPosition() {
|
|
|
|
return Application::getInstance()->getEm()->getRepository(static::class)->getPositionForGame($this);
|
|
|
|
}
|
2016-09-01 10:15:17 +00:00
|
|
|
}
|