diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js index 5acc2c9..6642eb3 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js @@ -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 */