stub submitPass on Game
This commit is contained in:
parent
e41d889177
commit
9b419a416b
2 changed files with 23 additions and 0 deletions
|
@ -265,6 +265,17 @@ const Game = ({gameData = {}, gameRecord = []} = {}) => {
|
|||
});
|
||||
},
|
||||
|
||||
submitPass: function(player) {
|
||||
if (player !== 'black' && player !== 'white') {
|
||||
return { ...this, success: false };
|
||||
}
|
||||
this.addToRecord({ player, pos: { x: null, y: null } });
|
||||
if (this.kos.length) helper.clearKo.call(this);
|
||||
this.turn = player === 'black' ? -1 : 1;
|
||||
this.boardState = getBoardState(this);
|
||||
return {...this, legalMoves: getLegalMoves(this), success: true };
|
||||
},
|
||||
|
||||
submitResign: function(player) {
|
||||
if (player === 'black') this.winner = -1;
|
||||
if (player === 'white') this.winner = 1;
|
||||
|
|
|
@ -497,6 +497,18 @@ describe('Game end logic', () => {
|
|||
Game().initGame().submitResign('black')
|
||||
.getMeta().should.eql({...initialMeta, winner: -1});
|
||||
done();
|
||||
});
|
||||
|
||||
it('pass changes game turn', done => {
|
||||
Game().initGame().submitPass('black')
|
||||
.getMeta().turn.should.eql(-1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('pass adds null move to gameRecord', done => {
|
||||
Game().initGame().submitPass('black').getMeta()
|
||||
.gameRecord.should.eql([ { player: 'black', pos: { x: null, y: null } } ])
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue