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
|
|
|
|
*
|
2016-09-01 15:33:00 +00:00
|
|
|
* @ORM\Table(name="targets",uniqueConstraints={
|
2016-09-01 16:16:17 +00:00
|
|
|
* @ORM\UniqueConstraint(name="level_position", columns={"level_id", "position"})})
|
2016-09-01 15:33:00 +00:00
|
|
|
* })
|
2016-09-01 10:15:17 +00:00
|
|
|
* @ORM\Entity
|
|
|
|
*/
|
|
|
|
class Target
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var integer
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="id",type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
2016-09-01 15:33:00 +00:00
|
|
|
/**
|
|
|
|
* Incremental position in level
|
|
|
|
* @var int
|
2016-09-01 16:05:47 +00:00
|
|
|
* @ORM\Column
|
2016-09-01 15:33:00 +00:00
|
|
|
*/
|
|
|
|
private $position;
|
2016-09-01 10:15:17 +00:00
|
|
|
|
|
|
|
/**
|
2016-09-01 15:33:00 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Level", inversedBy="targets", cascade={"persist"})
|
2016-09-01 10:15:17 +00:00
|
|
|
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=false)
|
|
|
|
*/
|
|
|
|
private $level;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float
|
2016-09-01 16:05:47 +00:00
|
|
|
* @ORM\Column
|
2016-09-01 10:15:17 +00:00
|
|
|
*/
|
|
|
|
private $time;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="Emotion", inversedBy="targets")
|
|
|
|
* @ORM\JoinColumn(name="emotion_id", referencedColumnName="id", nullable=false)
|
|
|
|
*/
|
|
|
|
private $emotion;
|
|
|
|
|
2016-09-01 15:33:00 +00:00
|
|
|
/**
|
|
|
|
* Required score
|
|
|
|
* @var int
|
2016-09-01 16:05:47 +00:00
|
|
|
* @ORM\Column
|
2016-09-01 15:33:00 +00:00
|
|
|
*/
|
|
|
|
private $score;
|
|
|
|
|
2016-09-01 10:15:17 +00:00
|
|
|
/**
|
|
|
|
* @ORM\OneToMany(targetEntity="Hit", mappedBy="target", fetch="EXTRA_LAZY")
|
|
|
|
*/
|
|
|
|
private $hits;
|
|
|
|
|
2016-09-01 15:33:00 +00:00
|
|
|
public function __construct(Level $level, int $position, Emotion $emotion, int $score, float $time)
|
2016-09-01 10:15:17 +00:00
|
|
|
{
|
|
|
|
$this->hits = new ArrayCollection();
|
2016-09-01 15:33:00 +00:00
|
|
|
$this->level = $level;
|
|
|
|
$this->emotion = $emotion;
|
|
|
|
$this->score = $score;
|
|
|
|
$this->time = $time;
|
|
|
|
$this->position = $position;
|
2016-09-01 10:15:17 +00:00
|
|
|
}
|
2016-09-03 22:55:36 +00:00
|
|
|
|
|
|
|
public function addHit(Hit $hit){
|
|
|
|
$this->hits->add($hit);
|
|
|
|
}
|
2016-09-01 10:15:17 +00:00
|
|
|
}
|