add submitResign to Game
This commit is contained in:
parent
7aed5b7bf9
commit
ef0e53756e
2 changed files with 15 additions and 0 deletions
|
@ -263,6 +263,13 @@ const Game = ({gameData = {}, gameRecord = []} = {}) => {
|
|||
gameData: { komi, handicap, boardSize },
|
||||
gameRecord: [...this.gameRecord.slice(0, index)]
|
||||
});
|
||||
},
|
||||
|
||||
submitResign: function(player) {
|
||||
if (player === 'black') this.winner = -1;
|
||||
if (player === 'white') this.winner = 1;
|
||||
this.turn = 0;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -469,6 +469,14 @@ describe('Game history functionality', () => {
|
|||
fifthMoveGame.boardState['10-4'].stone.should.eql(1)
|
||||
fifthMoveGame.boardState['4-10'].stone.should.eql(0)
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Game end logic', () => {
|
||||
it('resignation results in game end', done => {
|
||||
Game().initGame().submitResign('black')
|
||||
.getMeta().should.eql({...initialMeta, winner: -1});
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue