-
Notifications
You must be signed in to change notification settings - Fork 18
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
Place pieces anywhere. #215
Comments
Your issue is caused because the current implementation of the Invalid moves will cause the internal chess.js game to throw an error and will terminate the method early. This creates several issues:
The solution to this is to properly handle the exception instead of just terminating the method. It would require keeping the chess.js in sync with board, even when an illegal move is played. This can be done manually with chess.js I might implement the fix, but I don't know how speedy it will be because I don't need to use this feature so it is not a priority for me. But I would encourage your to implement it yourself if you want! A work around to at least make the board more functional (albeit still with most of the problems mentioned above) is to set the <script setup lang="ts">
import '@/assets/board.css';
import { TheChessboard, type BoardApi, type BoardConfig } from '@/index';
let boardAPI: BoardApi | undefined;
const boardConfig: BoardConfig = {
movable: { free: true },
};
</script>
<template>
<TheChessboard
:board-config="boardConfig"
player-color="both"
@board-created="(api) => (boardAPI = api)"
/>
</template> This will allow you to move the pieces freely, but you will still encounter a lot of issues if you try to play a game. |
Yea, thanks for the detailed explanation. I didn't know it works with setting the player color, then #217 is useless (atleast now it works without setting the But to fix the issue we probably need chess.js to allow illegal moves in the .move method, handling all the edge cases you described above is really annoying. |
Well, definitely I think chess.js has no intention of allowing illegal moves. I've contributed a little to chess.js and so I've taken a look at all the codebase and it would be quite a radical change to allow illegal moves. That is really what their I did write a PR that (among other things) fixes the history problems on chess.js side, but it's been sitting in limbo for a while so doesn't really look like it'll be accepted. |
Much appreciated. Thanks for the response. Let me try those suggestions. |
@bradintheusa did you get it to work for your needs? |
Not yet. I'm still deciding on the best way to do it. |
Im going to close this for now, since it technically works. If you can't find a good way fix your case, please reopen the issue. |
If I set
movable: { free: true,},
I can move a piece where I want but then it seems to turn off and I can't move any more pieces. Is there a way to keep it on?The text was updated successfully, but these errors were encountered: