Private
Public Access
1
0

the opponent is the next when bomb is exploded

This commit is contained in:
2016-10-31 18:16:57 +01:00
parent db2c0c8c30
commit 242e52f8e4

View File

@@ -169,6 +169,21 @@ class GridControl extends React.Component {
}
}
/** set __ACTIVE__ player in the UserControl !!!! */
changePlayer(userControl, activePlayer, inactivePlayer) {
userControl.setState({
activePlayer: userControl.state.activePlayer ? 0 : 1
});
userControl.refs[activePlayer].setState({
active: false
});
userControl.refs[inactivePlayer].setState({
active: true
});
}
/**
* Player control method
*
@@ -206,6 +221,10 @@ class GridControl extends React.Component {
if (!justOnFirstIteration) {
/** set last clicked field w/ color */
this.state.lastClicked[activePlayer] = [x, y];
if (this.refs.userControl.state.bombSelected) {
this.changePlayer(userControl, activePlayer, inactivePlayer);
}
}
/** set current image in field */
@@ -216,18 +235,7 @@ class GridControl extends React.Component {
this.state.sound.click.play();
if (!justOnFirstIteration) {
/** set __ACTIVE__ player in the UserControl !!!! */
userControl.setState({
activePlayer: userControl.state.activePlayer ? 0 : 1
});
userControl.refs[activePlayer].setState({
active: false
});
userControl.refs[inactivePlayer].setState({
active: true
});
this.changePlayer(userControl, activePlayer, inactivePlayer);
}
/** set current image in field - WHEN it is a number */