Private
Public Access
1
0

js and config refactor

This commit is contained in:
2016-11-02 18:05:10 +01:00
parent 2ed938f22a
commit e5d9266c9d
5 changed files with 118 additions and 111 deletions

View File

@@ -5,26 +5,24 @@ class UserControl extends React.Component {
constructor() {
super();
/**
* activePlayer - red: 0, blue: 1
* @type {{activePlayer: number, mines: number}}
*/
this.state = {
activePlayer: 0,
activePlayer: 0, // activePlayer - red: 0, blue: 1
mines: 51,
bombSelected: false,
foundMines: false
};
}
youCanSelectBomb(activePlayer, clickedPlayer) {
return this.refs[activePlayer].state.haveBomb &&
this.refs[activePlayer].state.enabledBomb &&
this.state.activePlayer === clickedPlayer;
}
onClickBombSelector(clickedPlayer) {
var activePlayer = this.state.activePlayer ? 'blue' : 'red';
if (
this.refs[activePlayer].state.haveBomb &&
this.refs[activePlayer].state.enabledBomb &&
this.state.activePlayer === clickedPlayer
) {
if (this.youCanSelectBomb(activePlayer, clickedPlayer)) {
this.state.bombSelected = !this.state.bombSelected;
if (!this.state.bombSelected) {