current username checked && refactor && remove players in channel when they are more than 2
This commit is contained in:
@@ -8,11 +8,13 @@ class MineSeeker extends React.Component {
|
||||
|
||||
var gameAssoc = props.gameId !== '' ? props.gameId : this.makeGameAssoc(50);
|
||||
var channel = "acme/channel/" + gameAssoc;
|
||||
var userName = props.userName;
|
||||
|
||||
this.state = {
|
||||
gameInherited: props.gameId !== '',
|
||||
gameAssoc: gameAssoc,
|
||||
channel: channel,
|
||||
userName: userName,
|
||||
session: null,
|
||||
createGrid: false,
|
||||
stepCache: null
|
||||
@@ -66,12 +68,14 @@ class MineSeeker extends React.Component {
|
||||
channel: this.state.channel
|
||||
});
|
||||
|
||||
/** setup the web player */
|
||||
/** setup the web player && save player name */
|
||||
if (this.refs.gridControl.state.webPlayer === null) {
|
||||
if (this.state.gameInherited) {
|
||||
this.refs.gridControl.state.webPlayer = 'blue';
|
||||
this.refs.gridControl.refs.userControl.refs.blue.setState({name: this.state.userName});
|
||||
} else {
|
||||
this.refs.gridControl.state.webPlayer = 'red';
|
||||
this.refs.gridControl.refs.userControl.refs.red.setState({name: this.state.userName});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +90,19 @@ class MineSeeker extends React.Component {
|
||||
/** Auto-Step if this player is not the current user */
|
||||
if (this.refs.gridControl.state.webPlayer !== payload.data.player) {
|
||||
console.warn('Opponent stepped: Auto-Step process');
|
||||
|
||||
|
||||
this.refs.gridControl.refs.userControl.state.bombSelected = payload.data.bomb;
|
||||
this.refs.gridControl.stepEvent(payload.data.coords);
|
||||
}
|
||||
} else {
|
||||
console.info("User has been subscribed to the channel!");
|
||||
console.info(
|
||||
(typeof payload.user !== 'undefined' ? payload.user : 'user') + " has been subscribed to the channel!"
|
||||
);
|
||||
|
||||
// /** Save the opponent's player name */
|
||||
// if (this.state.gameInherited) {
|
||||
// this.refs.gridControl.refs.userControl.refs.blue.setState({name: payload.user});
|
||||
// }
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user