state.movable.dests takes the Dests map, and it's possible to set custom piece movement rules by passing a custom map with .set(). However, state.premovable.dests takes Key[] and just stores the possible premove squares for a particular selected square. These values are calculated here https://github.com/lichess-org/chessground/blob/239763228a3fd88540c796d1e9f2a99a140a342f/src/board.ts#L206
and are hardcoded to use the rules of chess (premove.ts). It's not possible to set custom premove squares like state.movable.dests using .set() or mutating cg.state directly because the rules of chess are automatically used in line 206 on every selection.
Solution
Make a new optional property state.premovable.customDests which uses the Dests format like state.movable.dests. When this property is present, it is used to set state.premovable.dests instead of calling premove() and using the rules of chess. To use custom premoves you can use .set() to set premovable.customDests.
Problem
state.movable.dests
takes theDests
map, and it's possible to set custom piece movement rules by passing a custom map with.set()
. However,state.premovable.dests
takesKey[]
and just stores the possible premove squares for a particular selected square. These values are calculated here https://github.com/lichess-org/chessground/blob/239763228a3fd88540c796d1e9f2a99a140a342f/src/board.ts#L206 and are hardcoded to use the rules of chess (premove.ts
). It's not possible to set custom premove squares likestate.movable.dests
using.set()
or mutatingcg.state
directly because the rules of chess are automatically used in line 206 on every selection.Solution
Make a new optional property
state.premovable.customDests
which uses theDests
format likestate.movable.dests
. When this property is present, it is used to setstate.premovable.dests
instead of callingpremove()
and using the rules of chess. To use custom premoves you can use.set()
to setpremovable.customDests
.