-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix: premoved piece disappearing #120
fix: premoved piece disappearing #120
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I've fixed also another issue, when two premoved pieces target the same square the last premoved piece should be visible not the first one. In the example below, we do two premoves: rook to a1, then queen to a1, and logically the queen should be visible after these two moves not the rook Screen.Recording.2023-12-28.at.13.24.37.mov |
@@ -18,6 +19,38 @@ export function Squares() { | |||
showBoardNotation, | |||
} = useChessboard(); | |||
|
|||
const premovesHistory: any[] = useMemo(() => { |
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.
maybe this make sense to be upped to the chessboard-context
state, and keep all the premoves in this new format ?
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.
premoves: [
{
sourceSq: "f1",
targetSq: "e2",
piece: "wB",
},
{
sourceSq: "c2",
targetSq: "d3",
piece: "wP",
},
{
sourceSq: "e2",
targetSq: "d3",
piece: "wB",
},
{
sourceSq: "g1",
targetSq: "f3",
piece: "wN",
},
{
sourceSq: "f3",
targetSq: "g1",
piece: "wN",
},
{
sourceSq: "g1",
targetSq: "f3",
piece: "wN",
},
],
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.
premovesHistory: [
{
piece: "wN",
premovesRoute: [
{
sourceSq: "g1",
targetSq: "f3",
},
{
sourceSq: "f3",
targetSq: "g1",
},
{
sourceSq: "g1",
targetSq: "f3",
},
],
index: 5,
},
{
piece: "wB",
premovesRoute: [
{
sourceSq: "f1",
targetSq: "e2",
},
{
sourceSq: "e2",
targetSq: "d3",
},
],
index: 2,
},
{
piece: "wP",
premovesRoute: [
{
sourceSq: "c2",
targetSq: "d3",
},
],
index: 1,
},
],
Could an option be to look through the premove queue backwards and see what the latest premove target on the square is? Am away from my pc now until mid January so won't be able to look deeply into it |
I think the complexity is the same. Or do I miss something? |
The fix of #118