game ends after x mines
This commit is contained in:
@@ -36,5 +36,5 @@ security:
|
|||||||
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/play, role: ROLE_USER }
|
- { path: ^/play, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
||||||
|
|||||||
@@ -35,8 +35,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
{% block fos_user_content %}
|
{% block fos_user_content %}{% endblock fos_user_content %}
|
||||||
{% endblock fos_user_content %}
|
|
||||||
<canvas id="demo-canvas"></canvas>
|
<canvas id="demo-canvas"></canvas>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,22 @@ class MineSeeker extends React.Component {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** game end control */
|
||||||
|
makeGameEndIfItEnds(bluePoints, redPoints) {
|
||||||
|
var redWins = redPoints > 3,
|
||||||
|
blueWins = bluePoints > 3;
|
||||||
|
|
||||||
|
if (redWins || blueWins) {
|
||||||
|
this.refs.gridControl.setState({
|
||||||
|
overlay: true,
|
||||||
|
overlayTitle: (redWins ? 'Red' : 'Blue') + " wins the game!",
|
||||||
|
overlaySubTitle: "Play again!"
|
||||||
|
});
|
||||||
|
|
||||||
|
this.refs.gridControl.state.sound.won.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** after rendering */
|
/** after rendering */
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
/** Create Websocket w/ Bahnhof.js */
|
/** Create Websocket w/ Bahnhof.js */
|
||||||
@@ -95,6 +111,12 @@ class MineSeeker extends React.Component {
|
|||||||
|
|
||||||
this.refs.gridControl.refs.userControl.state.bombSelected = payload.data.bomb;
|
this.refs.gridControl.refs.userControl.state.bombSelected = payload.data.bomb;
|
||||||
this.refs.gridControl.stepEvent(payload.data.coords);
|
this.refs.gridControl.stepEvent(payload.data.coords);
|
||||||
|
|
||||||
|
/** End-game control */
|
||||||
|
this.makeGameEndIfItEnds(
|
||||||
|
this.refs.gridControl.refs.userControl.refs.blue.state.mines,
|
||||||
|
this.refs.gridControl.refs.userControl.refs.red.state.mines
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -158,6 +180,9 @@ class MineSeeker extends React.Component {
|
|||||||
: 0
|
: 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** End-game control */
|
||||||
|
this.makeGameEndIfItEnds(bluePoints, redPoints);
|
||||||
|
|
||||||
this.state.session
|
this.state.session
|
||||||
.publish(this.state.channel, {
|
.publish(this.state.channel, {
|
||||||
'coords': coords,
|
'coords': coords,
|
||||||
|
|||||||
Reference in New Issue
Block a user