some refactor #13
This commit is contained in:
@@ -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])}/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user