From 37a14f567b0c2f266049e974a601b1495415fe96 Mon Sep 17 00:00:00 2001 From: Ruben Date: Sat, 3 Sep 2016 23:55:36 +0100 Subject: [PATCH] Fix /me/games --- src/Api/ScoreControllerProvider.php | 9 ++++++--- src/Models/Hit.php | 6 ++++++ src/Models/Level.php | 10 ++++++++++ src/Models/Target.php | 4 ++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Api/ScoreControllerProvider.php b/src/Api/ScoreControllerProvider.php index a886c64..b205c0c 100644 --- a/src/Api/ScoreControllerProvider.php +++ b/src/Api/ScoreControllerProvider.php @@ -77,20 +77,23 @@ class ScoreControllerProvider implements ControllerProviderInterface // set game appends hit to game $hit->setGame($game); + $hit->setTarget($target); + + $hit->setScore($data_hit['score']); // attributes $hit->setGlasses($data_hit['glasses']); foreach(Models\Hit::$ATTRIBUTES as $attribute) { - $hit->setAttribute($data_hit[$attribute]); + $hit->setAttribute($attribute, $data_hit[$attribute]); } // emotions foreach(Models\Hit::$EMOTIONS as $emotion) { - $hit->setEmotion($data_hit['emotions'][$emotion]); + $hit->setEmotion($emotion, $data_hit['emotions'][$emotion]); } //expressions foreach(Models\Hit::$EXPRESSIONS as $expression) { - $hit->setExpression($data_hit['expressions'][$expression]); + $hit->setExpression($expression, $data_hit['expressions'][$expression]); } //points diff --git a/src/Models/Hit.php b/src/Models/Hit.php index 36b05cb..cc91670 100644 --- a/src/Models/Hit.php +++ b/src/Models/Hit.php @@ -1657,6 +1657,12 @@ class Hit return $this; } + public function setTarget(Target $target) { + $this->target = $target; + $target->addHit($this); + return $this; + } + /** * Sets the value of score. * diff --git a/src/Models/Level.php b/src/Models/Level.php index 55d11b5..9e15f8c 100644 --- a/src/Models/Level.php +++ b/src/Models/Level.php @@ -81,4 +81,14 @@ class Level return $this; } + + /** + * Gets the value of id. + * + * @return integer + */ + public function getId() + { + return $this->id; + } } diff --git a/src/Models/Target.php b/src/Models/Target.php index 7d47861..9cb2320 100644 --- a/src/Models/Target.php +++ b/src/Models/Target.php @@ -71,4 +71,8 @@ class Target $this->time = $time; $this->position = $position; } + + public function addHit(Hit $hit){ + $this->hits->add($hit); + } }