feat : allow custom starting fen

This commit is contained in:
GuillaumeSD
2024-03-17 22:13:54 +01:00
parent 72826d03b2
commit d916899731
4 changed files with 18 additions and 5 deletions

View File

@@ -196,3 +196,11 @@ const getPieceValue = (piece: PieceSymbol): number => {
return 0;
}
};
export const getStartingFen = (pgn: string): string => {
const game = new Chess();
game.loadPgn(pgn);
const history = game.history({ verbose: true });
return history[0].before;
};