random player on start #5
This commit is contained in:
@@ -44,9 +44,7 @@ class MineSeeker extends React.Component {
|
|||||||
|
|
||||||
this.refs.gridControl.showLeftMines();
|
this.refs.gridControl.showLeftMines();
|
||||||
|
|
||||||
this.refs.gridControl.refs.userControl.setState({ activePlayer: false});
|
this.refs.gridControl.refs.userControl.setState({activePlayer: false});
|
||||||
this.refs.gridControl.refs.userControl.refs.red.setState({ active: false });
|
|
||||||
this.refs.gridControl.refs.userControl.refs.blue.setState({ active: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,9 +90,6 @@ class MineSeeker extends React.Component {
|
|||||||
renderGridFields: this.state.gameAssoc
|
renderGridFields: this.state.gameAssoc
|
||||||
});
|
});
|
||||||
|
|
||||||
/** setup the web player */
|
|
||||||
this.refs.gridControl.state.webPlayer === null && this.refs.gridControl.setState({webPlayer: this.state.gameInherited ? 'blue' : 'red'});
|
|
||||||
|
|
||||||
/** Connect - Subscribe */
|
/** Connect - Subscribe */
|
||||||
this.state.session.subscribe(
|
this.state.session.subscribe(
|
||||||
this.state.channel,
|
this.state.channel,
|
||||||
@@ -127,17 +122,29 @@ class MineSeeker extends React.Component {
|
|||||||
(typeof payload.user !== 'undefined' ? payload.user : 'user') + " has been subscribed to the channel!"
|
(typeof payload.user !== 'undefined' ? payload.user : 'user') + " has been subscribed to the channel!"
|
||||||
);
|
);
|
||||||
|
|
||||||
/** remove overlay when every user has been came */
|
/** setup the web player */
|
||||||
this.refs.gridControl.setState({overlay: payload.userCnt < 2});
|
null === this.refs.gridControl.state.webPlayer && this.refs.gridControl.setState({
|
||||||
|
webPlayer: payload.user === payload.users.blue || payload.user === payload.users.blueAnon
|
||||||
/** Set up player names w/ server data */
|
? 'blue'
|
||||||
this.refs.gridControl.refs.userControl.refs.red.setState({
|
: 'red'
|
||||||
name: payload.users.red !== '' ? payload.users.red : payload.users.redAnon
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.refs.gridControl.refs.userControl.refs.blue.setState({
|
/** every user has been came */
|
||||||
name: payload.users.blue !== '' ? payload.users.blue : payload.users.blueAnon
|
if (payload.userCnt === 2) {
|
||||||
});
|
/** every time the blue starts */
|
||||||
|
this.refs.gridControl.refs.userControl.setState({activePlayer: 1});
|
||||||
|
|
||||||
|
/** Set up player names w/ server data */
|
||||||
|
this.refs.gridControl.refs.userControl.refs.red.setState({
|
||||||
|
name: payload.users.red !== '' ? payload.users.red : payload.users.redAnon
|
||||||
|
});
|
||||||
|
|
||||||
|
this.refs.gridControl.refs.userControl.refs.blue.setState({
|
||||||
|
name: payload.users.blue !== '' ? payload.users.blue : payload.users.blueAnon
|
||||||
|
});
|
||||||
|
|
||||||
|
this.refs.gridControl.setState({overlay: false});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.info(payload.msg);
|
console.info(payload.msg);
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ class UserControl extends React.Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* activePlayer - red: 0, blue: 1
|
||||||
|
* @type {{activePlayer: boolean, mines: number, bombSelected: boolean, foundMines: boolean}}
|
||||||
|
*/
|
||||||
this.state = {
|
this.state = {
|
||||||
activePlayer: 0, // activePlayer - red: 0, blue: 1
|
activePlayer: false,
|
||||||
mines: 51,
|
mines: 51,
|
||||||
bombSelected: false,
|
bombSelected: false,
|
||||||
foundMines: false
|
foundMines: false
|
||||||
|
|||||||
@@ -173,7 +173,16 @@ class MineseekerTopic implements TopicInterface
|
|||||||
->getRepository('JotunheimrUserBundle:User')
|
->getRepository('JotunheimrUserBundle:User')
|
||||||
->findOneByUsername($userName);
|
->findOneByUsername($userName);
|
||||||
|
|
||||||
$count == 1 ? $playedGame->setRed($FOSUser) : $playedGame->setBlue($FOSUser);
|
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()
|
||||||
|
? $playedGame->setRed($FOSUser)
|
||||||
|
: $playedGame->setBlue($FOSUser);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// $request = $this->requestStack->getCurrentRequest(); // TODO nem megy...
|
// $request = $this->requestStack->getCurrentRequest(); // TODO nem megy...
|
||||||
|
|
||||||
@@ -181,7 +190,16 @@ class MineseekerTopic implements TopicInterface
|
|||||||
$anon->setUserName($userName);
|
$anon->setUserName($userName);
|
||||||
$this->em->persist($anon);
|
$this->em->persist($anon);
|
||||||
|
|
||||||
$count == 1 ? $playedGame->setRedAnon($anon) : $playedGame->setBlueAnon($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()
|
||||||
|
? $playedGame->setRedAnon($anon)
|
||||||
|
: $playedGame->setBlueAnon($anon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($playedGame);
|
$this->em->persist($playedGame);
|
||||||
|
|||||||
Reference in New Issue
Block a user