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 Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Users
|
|
|
|
*
|
|
|
|
* @ORM\Table(name="levels")
|
|
|
|
* @ORM\Entity
|
|
|
|
*/
|
|
|
|
class Level
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var integer
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="id",type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
2016-09-01 15:33:00 +00:00
|
|
|
/**
|
|
|
|
* Name of the level
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $name;
|
|
|
|
|
2016-09-01 10:15:17 +00:00
|
|
|
|
|
|
|
/**
|
2016-09-01 15:33:00 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="Target", mappedBy="level", cascade={"persist"})
|
2016-09-01 10:15:17 +00:00
|
|
|
*/
|
|
|
|
private $targets;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\OneToMany(targetEntity="Game", mappedBy="level", fetch="EXTRA_LAZY")
|
|
|
|
*/
|
|
|
|
private $games;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->targets = new ArrayCollection();
|
|
|
|
$this->games = new ArrayCollection();
|
|
|
|
}
|
|
|
|
|
2016-09-01 15:33:00 +00:00
|
|
|
public function createTarget(Emotion $emotion, float $score, float $time) {
|
|
|
|
$pos = $this->targets->count()+1;
|
|
|
|
$target = new Target($this, $pos, $emotion, $score, $time);
|
|
|
|
$this->targets->set($pos, $target);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the value of id.
|
|
|
|
*
|
|
|
|
* @param integer $id the id
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function setId($id)
|
|
|
|
{
|
|
|
|
$this->id = $id;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Name of the level.
|
|
|
|
*
|
|
|
|
* @param string $name the name
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function setName($name)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2016-09-01 10:15:17 +00:00
|
|
|
}
|