Merge branch 'game_logic'
This commit is contained in:
commit
2922be86e1
2 changed files with 15 additions and 0 deletions
|
@ -263,6 +263,13 @@ const Game = ({gameData = {}, gameRecord = []} = {}) => {
|
||||||
gameData: { komi, handicap, boardSize },
|
gameData: { komi, handicap, boardSize },
|
||||||
gameRecord: [...this.gameRecord.slice(0, index)]
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -489,6 +489,14 @@ describe('Game history functionality', () => {
|
||||||
fifthMoveGame.boardState['10-4'].stone.should.eql(1)
|
fifthMoveGame.boardState['10-4'].stone.should.eql(1)
|
||||||
fifthMoveGame.boardState['4-10'].stone.should.eql(0)
|
fifthMoveGame.boardState['4-10'].stone.should.eql(0)
|
||||||
done();
|
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