Skip to content

Commit

Permalink
Fix play mode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MuTsunTsai committed Mar 22, 2024
1 parent 0dac0c7 commit b7f9639
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/sw.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/js/tools/play/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ export function makeMove(fromIndex: number, toIndex: number, promotion?: string)
}
return result;
} else {
const move = chess.move({ from, to, promotion });
if(!move) return false;
if(move.flags == "k" || move.flags == "q") return generateCastlingAnimation(move);
return true;
try {
const move = chess.move({ from, to, promotion });
if(!move) return false;
if(move.flags == "k" || move.flags == "q") return generateCastlingAnimation(move);
return true;
} catch {
return false;
}
}
}

Expand Down

0 comments on commit b7f9639

Please sign in to comment.