abandon game

This commit is contained in:
Mashy 2019-09-11 15:49:36 +10:00
parent 60bd7f65ba
commit 4a13656b9d
2 changed files with 14 additions and 4 deletions

View File

@ -1,15 +1,24 @@
const preact = require('preact');
const { connect } = require('preact-redux');
const addState = connect(
function receiveState(state) {
const { animating } = state;
return { animating };
}
);
function Scoreboard(args) {
const {
abandon,
animating,
isPlayer,
player,
isGame,
clear,
} = args;
let scoreText = () => {
const scoreText = () => {
if (player.score === 'Zero') return '▫▫▫▫';
if (player.score === 'One') return '■▫▫▫';
if (player.score === 'Two') return '■■▫▫';
@ -38,13 +47,13 @@ function Scoreboard(args) {
<div>{player.name}</div>
</div>
<div>
{(isPlayer && isGame) ? <button onClick={clear}>Clear</button> : null}
{(isPlayer && isGame && !animating) ? <button onClick={clear}>Clear</button> : null}
</div>
<div>
{abandon ? <button onClick={abandon}>Abandon</button> : null}
{(abandon && !animating) ? <button onClick={abandon}>Abandon</button> : null}
</div>
</div>
);
}
module.exports = Scoreboard;
module.exports = addState(Scoreboard);

View File

@ -179,6 +179,7 @@ function registerEvents(store) {
store.dispatch(actions.setActiveConstruct(first));
}
}
if (v.phase === 'Finished') setGame(null);
return store.dispatch(actions.setInstance(v));
}