Private
Public Access
1
0

some refactor #13

This commit is contained in:
2016-11-18 20:42:29 +01:00
parent 541e2e605c
commit 25cc3910f5
3 changed files with 15 additions and 30 deletions

View File

@@ -52,21 +52,10 @@ class GridControl extends React.Component {
/** if the (5x5) target not fits the grid */
if (!isBombTargetCenter) {
if (col < 2) {
col = 2;
}
if (row < 2) {
row = 2;
}
if (row > this.state.grid.length - 3) {
row = this.state.grid.length - 3;
}
if (col > this.state.grid[0].length - 3) {
col = this.state.grid[0].length - 3;
}
col = col < 2 ? 2 : col;
row = row < 2 ? 2 : row;
row = row > this.state.grid.length - 3 ? this.state.grid.length - 3 : row;
col = col > this.state.grid[0].length - 3 ? this.state.grid[0].length - 3 : col;
}
return [
@@ -362,9 +351,10 @@ class GridControl extends React.Component {
/**
* On Hover when you want to drop BOMB
* Target grid field
* @param coords
*/
onHoverWithBomb(coords) {
onHoverGridField(coords) {
if (this.refs.userControl.state.bombSelected) {
var activePlayer = this.refs.userControl.state.activePlayer ? 'blue' : 'red';
@@ -393,7 +383,7 @@ class GridControl extends React.Component {
col={k}
ref={this.refString(i, k)}
key={i + k * Math.random() * 0.5}
handleHoverOn={this.onHoverWithBomb.bind(this, [i, k])}
handleHoverOn={this.onHoverGridField.bind(this, [i, k])}
onClick={this.props.onClick.bind(null, [i, k])}/>
);
}