Skip to content

Commit

Permalink
add move event
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Hendrik Helms committed Feb 12, 2023
1 parent 3840328 commit 41bff37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/TheChessboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
BoardState,
PromotionEvent,
PromotedTo,
MoveEvent,
} from '@/typings/Chessboard';
const props = defineProps({
Expand All @@ -33,6 +34,7 @@ const emit = defineEmits<{
(e: 'draw', isDraw: boolean): void;
(e: 'check', isInCheck: PieceColor): void;
(e: 'promotion', promotion: PromotionEvent): void;
(e: 'move', move: MoveEvent): void;
}>();
let board: Api | undefined;
Expand Down Expand Up @@ -116,6 +118,8 @@ function changeTurn(): (orig: Key, dest: Key) => Promise<void> {
if (boardState.showThreats) {
board.setShapes(getThreats(game.moves({ verbose: true })));
}
emit('move', game.history({ verbose: true }).at(-1));
};
}
</script>
Expand Down
8 changes: 7 additions & 1 deletion src/typings/Chessboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type BoardApi from '@/classes/BoardApi';
import type { Square } from 'chess.js';
import type { Move, Square } from 'chess.js';
import type { Key } from 'chessground/types';
import type { BoardConfig } from './BoardConfig';

Expand Down Expand Up @@ -56,3 +56,9 @@ export interface PromotionEvent {
}

export type PromotedTo = PromotionEvent['promotedTo'];

export type MoveEvent =
| (Move & {
fen: string;
})
| undefined;

0 comments on commit 41bff37

Please sign in to comment.