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});
|
||||
// }
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -368,14 +368,8 @@ class GridControl extends React.Component {
|
||||
return (
|
||||
<div className="game-wrapper">
|
||||
<UserControl ref="userControl"
|
||||
blue="Olcsó János"
|
||||
red="Eszet Lenke"
|
||||
bombClear={this.bombClear.bind(this)}/>
|
||||
<div className="grid">
|
||||
{/*{this.renderGridFields()}*/}
|
||||
{grid}
|
||||
</div>
|
||||
{/*{this.playingSound()}*/}
|
||||
<div className="grid"> {grid} </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ class UserControl extends React.Component {
|
||||
<div className="users">
|
||||
<User ref="blue"
|
||||
color="blue"
|
||||
name={this.props.blue}
|
||||
active={this.state.activePlayer === 1}
|
||||
onClickBombSelector={this.onClickBombSelector.bind(this, 1)}/>
|
||||
<div className="active-mines-container">
|
||||
@@ -56,7 +55,6 @@ class UserControl extends React.Component {
|
||||
<div className="clear"></div>
|
||||
<User ref="red"
|
||||
color="red"
|
||||
name={this.props.red}
|
||||
active={this.state.activePlayer === 0}
|
||||
onClickBombSelector={this.onClickBombSelector.bind(this, 0)}/>
|
||||
<div className="resign">
|
||||
|
||||
@@ -5,7 +5,7 @@ class User extends React.Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
name: props.name,
|
||||
name: "...",
|
||||
active: props.active,
|
||||
color: props.color === 'blue' ? 1 : 0,
|
||||
mines: 0,
|
||||
|
||||
Reference in New Issue
Block a user