achiements and time temp fixed

This commit is contained in:
Ruben 2016-11-03 18:19:34 +01:00
parent 4f5dadfa53
commit 4716733328
2 changed files with 13 additions and 2 deletions

View file

@ -47,13 +47,15 @@ class InterfaceControllerProvider implements ControllerProviderInterface
// id
// score
// achievements, level, time, ranking, hits
// TODO: make this difference on db-level
$timeToOutput = $game->getCreatedAt()->add(new \DateInterval("PT1H"));
$output = [
'id' => $game->getId(),
'level' => $game->getLevel()->getName(),
'ranking' => $gameRepo->getPositionForGame($game),
'score' => $game->getScore(),
'achievements' => $game->getAchievements()->count(),
'time' => $game->getCreatedAt()->format("Y-m-d H:i:s"),
'time' => $timeToOutput->format("Y-m-d H:i:s"),
'hits' => [],
];

View file

@ -82,6 +82,15 @@ class ScoreControllerProvider implements ControllerProviderInterface
$game->setLostFaceTime((float) $data['lost_face_time']);
$game->setOriginalGameAt(new \DateTime($data['time']));
// add achievements
$achievementRepo = $this->_eh->getEm()->getRepository(Models\Achievement::class);
foreach($data['achievements'] as $achievement_id) {
$achievement = $achievementRepo->find($achievement_id);
if($achievement) {
$game->addAchievement($achievement);
}
}
$map_hits = [];
foreach($data['hits'] as $data_hit) {
@ -136,7 +145,7 @@ class ScoreControllerProvider implements ControllerProviderInterface
$achievement_ids[] = $achievement->getId();
}
$achievement_ids = [2]; // override for test purpose
// $achievement_ids = [2]; // override for test purpose
/* @var $userRepo Models\UserRepository */
$userRepo = $this->_eh->getEm()->getRepository(Models\User::class);