@@ -194,14 +194,17 @@ class MineseekerTopic implements TopicInterface
|
||||
->getRepository('MineSeekerBundle:PlayedGame')
|
||||
->findOneByGameAssoc($gameAssoc);
|
||||
|
||||
/** @var $users {array} */
|
||||
$users = $this->getUserCollection($playedGame);
|
||||
|
||||
$red = "" !== $users['red'] || "" !== $users['redAnon'] ? 1 : 0;
|
||||
$blue = "" !== $users['blue'] || "" !== $users['blueAnon'] ? 1 : 0;
|
||||
$one = $topic->count() === 1;
|
||||
$two = $topic->count() === 2;
|
||||
|
||||
/** This checks it is a reconnection */
|
||||
if (
|
||||
(null !== $users['red'] || null !== $users['redAnon']) &&
|
||||
(null !== $users['blue'] || null !== $users['blueAnon'])
|
||||
) {
|
||||
/** @var $users array Save users to database */
|
||||
if (($one && ($red + $blue === 0)) || ($two && ($red + $blue === 1))) {
|
||||
/** @var $users {array} w/ save users to database */
|
||||
$users = $this->saveUserToDb($topic, $userName, $user, $topic->count());
|
||||
}
|
||||
|
||||
@@ -226,6 +229,7 @@ class MineseekerTopic implements TopicInterface
|
||||
->getRepository('MineSeekerBundle:PlayedGame')
|
||||
->findOneByGameAssoc($gameAssoc);
|
||||
|
||||
/** the user is not anonym */
|
||||
if (!is_string($user)) {
|
||||
$FOSUser = $this->em
|
||||
->getRepository('JotunheimrUserBundle:User')
|
||||
@@ -234,7 +238,6 @@ class MineseekerTopic implements TopicInterface
|
||||
if ($count == 1) {
|
||||
/** @var $random {integer} Active player: red: 0, blue: 1 */
|
||||
$random = rand(0, 1);
|
||||
|
||||
!$random ? $playedGame->setRed($FOSUser) : $playedGame->setBlue($FOSUser);
|
||||
} else {
|
||||
null === $playedGame->getRed() && null === $playedGame->getRedAnon()
|
||||
@@ -246,12 +249,12 @@ class MineseekerTopic implements TopicInterface
|
||||
|
||||
$anon = new Gamer();
|
||||
$anon->setUserName($userName);
|
||||
$anon->setConnTimestamp(new \DateTime());
|
||||
$this->em->persist($anon);
|
||||
|
||||
if ($count == 1) {
|
||||
/** @var $random {integer} Active player: red: 0, blue: 1 */
|
||||
$random = rand(0, 1);
|
||||
|
||||
!$random ? $playedGame->setRedAnon($anon) : $playedGame->setBlueAnon($anon);
|
||||
} else {
|
||||
null === $playedGame->getRed() && null === $playedGame->getRedAnon()
|
||||
|
||||
Reference in New Issue
Block a user