bugfix changePlayer after bomb explosion
This commit is contained in:
@@ -156,18 +156,27 @@ class GridControl extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** set __ACTIVE__ player in the UserControl !!!! */
|
/** set __ACTIVE__ player in the UserControl !!!! */
|
||||||
changePlayer(userControl, activePlayer, inactivePlayer) {
|
changePlayer(idx, max, currentObject) {
|
||||||
userControl.setState({
|
var userControl = this.refs.userControl,
|
||||||
activePlayer: userControl.state.activePlayer ? 0 : 1
|
activePlayer = userControl.state.activePlayer ? 'blue' : 'red',
|
||||||
});
|
inactivePlayer = userControl.state.activePlayer ? 'red' : 'blue';
|
||||||
|
|
||||||
userControl.refs[activePlayer].setState({
|
if (
|
||||||
active: false
|
userControl.state.bombSelected && idx === (max - 1) ||
|
||||||
});
|
!idx && !userControl.state.bombSelected && currentObject !== 'm'
|
||||||
|
) {
|
||||||
|
userControl.setState({
|
||||||
|
activePlayer: userControl.state.activePlayer ? 0 : 1
|
||||||
|
});
|
||||||
|
|
||||||
userControl.refs[inactivePlayer].setState({
|
userControl.refs[activePlayer].setState({
|
||||||
active: true
|
active: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userControl.refs[inactivePlayer].setState({
|
||||||
|
active: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,13 +251,6 @@ class GridControl extends React.Component {
|
|||||||
? 'warning'
|
? 'warning'
|
||||||
: 'mine'
|
: 'mine'
|
||||||
].play();
|
].play();
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Csak az utolsó iterációnál kell usert váltani!! --> 10.)
|
|
||||||
*/
|
|
||||||
if (this.refs.userControl.state.bombSelected) {
|
|
||||||
this.changePlayer(userControl, activePlayer, inactivePlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** set current image in field */
|
/** set current image in field */
|
||||||
@@ -258,13 +260,6 @@ class GridControl extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
this.state.sound.click.play();
|
this.state.sound.click.play();
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Csak az utolsó iterációnál kell usert váltani!! --> 10.)
|
|
||||||
*/
|
|
||||||
if (!justOnFirstIteration) {
|
|
||||||
this.changePlayer(userControl, activePlayer, inactivePlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** set current image in field - WHEN it is a number */
|
/** set current image in field - WHEN it is a number */
|
||||||
if (!isNaN(currentObject)) {
|
if (!isNaN(currentObject)) {
|
||||||
gridFieldControl.setState({
|
gridFieldControl.setState({
|
||||||
@@ -301,10 +296,12 @@ class GridControl extends React.Component {
|
|||||||
* @param row
|
* @param row
|
||||||
* @param col
|
* @param col
|
||||||
* @param idx
|
* @param idx
|
||||||
|
* @param max
|
||||||
*/
|
*/
|
||||||
show(row, col, idx = 0) {
|
show(row, col, idx = 0, max = 0) {
|
||||||
this.handleGridField(this.state.grid[row][col], row, col, idx);
|
this.handleGridField(this.state.grid[row][col], row, col, idx);
|
||||||
this.showAppropriateFields(this.refs[this.refString(row, col)], row, col);
|
this.showAppropriateFields(this.refs[this.refString(row, col)], row, col);
|
||||||
|
this.changePlayer(idx, max, this.state.grid[row][col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +321,7 @@ class GridControl extends React.Component {
|
|||||||
|
|
||||||
var bombRadius = this.getBombRadius(coords[0], coords[1]);
|
var bombRadius = this.getBombRadius(coords[0], coords[1]);
|
||||||
for (var i = 0, j = bombRadius.length; i < j; i++) {
|
for (var i = 0, j = bombRadius.length; i < j; i++) {
|
||||||
this.show(bombRadius[i][0], bombRadius[i][1], i);
|
this.show(bombRadius[i][0], bombRadius[i][1], i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** remove BOMB from activePlayer */
|
/** remove BOMB from activePlayer */
|
||||||
|
|||||||
Reference in New Issue
Block a user