bugfix points saving and exploded bombs to db && you can resign #6
This commit is contained in:
@@ -101,7 +101,11 @@ class MineseekerTopic implements TopicInterface
|
||||
$userName = is_string($user) ? $user : $user->getUsername();
|
||||
|
||||
/** Save every step by user to db */
|
||||
$this->saveStepToDb($topic, $event);
|
||||
if (null === $event['resign']) {
|
||||
$this->saveStepToDb($topic, $event);
|
||||
} else {
|
||||
$this->saveResignToDb($topic, $event['resign']);
|
||||
}
|
||||
|
||||
$topic->broadcast([
|
||||
'userTopicId' => $connection->resourceId,
|
||||
@@ -122,6 +126,22 @@ class MineseekerTopic implements TopicInterface
|
||||
return 'mineseeker.topic';
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Resign event to database
|
||||
*/
|
||||
private function saveResignToDb($topic, $color)
|
||||
{
|
||||
$gameAssoc = explode('/', $topic->getId())[2];
|
||||
|
||||
$playedGame = $this->em
|
||||
->getRepository('MineSeekerBundle:PlayedGame')
|
||||
->findOneByGameAssoc($gameAssoc);
|
||||
|
||||
$playedGame->setResign($color);
|
||||
$this->em->persist($playedGame);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save steps and point information to database
|
||||
*
|
||||
@@ -146,6 +166,8 @@ class MineseekerTopic implements TopicInterface
|
||||
|
||||
$playedGame->setBluePoints($event['bluePoints']);
|
||||
$playedGame->setRedPoints($event['redPoints']);
|
||||
$playedGame->setBlueExplodedBomb($event['blueExplodedBomb'] ? true : null);
|
||||
$playedGame->setRedExplodedBomb($event['redExplodedBomb'] ? true : null);
|
||||
$this->em->persist($playedGame);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
Reference in New Issue
Block a user