New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkers #316
Conversation
TODO:
|
This looks really good! I will do some more testing tomorrow and we can merge soon |
expect(move(G, ctx, { x: 1, y: 0 }, { x: 4, y: 4 })).toEqual(INVALID_MOVE); | ||
}); | ||
|
||
it('should declare player 1 as the winner', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some specific tests for some corner cases like the double jump ? Some interesting test cases:
- double jump
- when the piece becomes king
- king jumping backwards
src/games/checkers/game.ts
Outdated
let moves: IMove[] = []; | ||
let jumped = false; | ||
|
||
dirs.forEach(dir => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use:
for (const dir of does) ?
src/games/checkers/game.ts
Outdated
return a.x === b.x && a.y === b.y; | ||
} | ||
|
||
export function checkPosition(G: IG, playerID: string, piece: ICheckerPiece, coord: ICoord) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the return type explicit?
|
||
const piece = (id: number, player: number): ICheckerPiece => ({ id, playerID: player.toString(), isKing: false }); | ||
|
||
export const INITIAL_BOARD: Piece[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart to make one dimensional :)
No description provided.