From 5b03dc2c28235a7d995e076a961deb2a54402f6b Mon Sep 17 00:00:00 2001 From: Lang Date: Mon, 31 Oct 2016 15:35:29 +0100 Subject: [PATCH] send bomb info and use it on opponent --- .../SeekerBundle/Resources/public/js/mine-seeker/app.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js index 750ca12..56e43d8 100644 --- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js +++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/app.js @@ -59,12 +59,14 @@ class MineSeeker extends React.Component { this.state.session = session; + /** save session to GridControl */ this.refs.gridControl.setState({ grid: this.state.gameInherited ? JSON.parse(gridServer) : gridClient, session: this.state.session, channel: this.state.channel }); + /** setup the web player */ if (this.refs.gridControl.state.webPlayer === null) { if (this.state.gameInherited) { 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.channel, (uri, payload, log) => { @@ -84,6 +86,8 @@ 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 { @@ -113,7 +117,8 @@ class MineSeeker extends React.Component { this.state.session .publish(this.state.channel, { 'coords': coords, - 'player': activePlayer + 'player': activePlayer, + 'bomb': this.refs.gridControl.refs.userControl.state.bombSelected }); } }