try achievements

This commit is contained in:
Ruben 2016-09-10 01:10:37 +01:00
parent 322c883422
commit 5541b5b563
2 changed files with 41 additions and 1 deletions

View file

@ -37,6 +37,19 @@ foreach($queries as $sql){ echo "$sql;\n"; }
$tool->updateSchema($classes);
// add achievements
for ($i=1; $i < 10; $i++) {
$achievement = $em->getRepository(EmotionHero\Models\Achievement::class)->find($i);
if(empty($achievement))
{
$achievement = new EmotionHero\Models\Achievement($i);
$achievement->setTitle("zomaar iets #".$i);
$em->persist($achievement);
$em->flush();
}
}
die();
// ADD EMOTIONS

View file

@ -56,6 +56,17 @@ class Game
*/
private $originalGameAt;
/**
* @var ArrayCollection[Achievements]
* @ORM\ManyToMany(targetEntity="Achievement", cascade={"persist"})
* @ORM\JoinTable(name="games_achievements",
* joinColumns={@ORM\JoinColumn(name="game_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="achievement_id", referencedColumnName="id")}
* )
*/
private $achievements;
/**
* @var \DateTime $created
*
@ -67,6 +78,7 @@ class Game
public function __construct()
{
$this->hits = new ArrayCollection();
$this->achievements = new ArrayCollection();
}
public function addHit(Hit $hit) {
@ -241,10 +253,25 @@ class Game
if($diffExpression) {
/* @var $diffExpressionText string */
$diffExpressionText = $betterHit->getExpressions()::$EXPRESSIONS_2ND_PERSON[$diffExpression];
$text .= " To show your empathy, you have to " . $diffExpressionText ." " . $diff . "% " . $diffText .".";
$text .= " To show more empathy, try to " . $diffExpressionText ." " . $diff . "% " . $diffText .".";
}
}
return $text;
}
/**
* Gets the achievements
*
* @return ArrayCollection[Achievements]
*/
public function getAchievements()
{
return $this->achievements;
}
public function addAchievement(Achievement $a)
{
$this->achievements->add($a);
}
}