send bomb info and use it on opponent
This commit is contained in:
@@ -59,12 +59,14 @@ class MineSeeker extends React.Component {
|
|||||||
|
|
||||||
this.state.session = session;
|
this.state.session = session;
|
||||||
|
|
||||||
|
/** save session to GridControl */
|
||||||
this.refs.gridControl.setState({
|
this.refs.gridControl.setState({
|
||||||
grid: this.state.gameInherited ? JSON.parse(gridServer) : gridClient,
|
grid: this.state.gameInherited ? JSON.parse(gridServer) : gridClient,
|
||||||
session: this.state.session,
|
session: this.state.session,
|
||||||
channel: this.state.channel
|
channel: this.state.channel
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** setup the web player */
|
||||||
if (this.refs.gridControl.state.webPlayer === null) {
|
if (this.refs.gridControl.state.webPlayer === null) {
|
||||||
if (this.state.gameInherited) {
|
if (this.state.gameInherited) {
|
||||||
this.refs.gridControl.state.webPlayer = 'blue';
|
this.refs.gridControl.state.webPlayer = 'blue';
|
||||||
@@ -73,7 +75,7 @@ class MineSeeker extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Connect - subscribe */
|
/** Connect - Subscribe */
|
||||||
this.state.session.subscribe(
|
this.state.session.subscribe(
|
||||||
this.state.channel,
|
this.state.channel,
|
||||||
(uri, payload, log) => {
|
(uri, payload, log) => {
|
||||||
@@ -84,6 +86,8 @@ class MineSeeker extends React.Component {
|
|||||||
/** Auto-Step if this player is not the current user */
|
/** Auto-Step if this player is not the current user */
|
||||||
if (this.refs.gridControl.state.webPlayer !== payload.data.player) {
|
if (this.refs.gridControl.state.webPlayer !== payload.data.player) {
|
||||||
console.warn('Opponent stepped: Auto-Step process');
|
console.warn('Opponent stepped: Auto-Step process');
|
||||||
|
|
||||||
|
this.refs.gridControl.refs.userControl.state.bombSelected = payload.data.bomb;
|
||||||
this.refs.gridControl.stepEvent(payload.data.coords);
|
this.refs.gridControl.stepEvent(payload.data.coords);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -113,7 +117,8 @@ class MineSeeker extends React.Component {
|
|||||||
this.state.session
|
this.state.session
|
||||||
.publish(this.state.channel, {
|
.publish(this.state.channel, {
|
||||||
'coords': coords,
|
'coords': coords,
|
||||||
'player': activePlayer
|
'player': activePlayer,
|
||||||
|
'bomb': this.refs.gridControl.refs.userControl.state.bombSelected
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user