Closed buhodev closed 1 year ago
Thanks for your clear feature request! Extending the Move type with check
seems the cleanest solution, just like you suggest. I've extended it with both check
and checkmate
for 0.8.4, does it resolve this issue for you?
It works like a charm ✨ Thank you very much for your quick implementation!
When implementing sounds, my mental modal consists on these three types of sounds:
It's really easy to implement sounds for the first three types of movements (all of them can be inferred from the
detail
property of themove
event.) But when it comes to implement the sound for thecheck
movement, that state/property is not present there (like thecaptured
property, that appears when a player captures a piece).To account for this, my current implementation uses the
inCheck
prop:What's the problem?
When the
inCheck
prop changes totrue
, thecheck
sound is played. But, the condition for the standard movement is met as well, so themove
sound is played too along with thecheck
sound.I can try to fix this problem adding another condition in the
handleMove
function. There are two ways we can accomplish that:The first one is playing the standard sound only when the
inCheck
property isfalse
and keeping the logic for playing thecheck
event outside thehandleMove
function like before:The second way is moving the logic for playing the check sound inside the
handleMove
function (as another condition):Is the problem solved this way? Nope! There's a subtle bug.
When player 1 executes the move that produces the
inCheck
state, the standard move sound is played right after, not the check sound. However, for the next move (when player 2 escapes from the check), the check sound is played then, although there's notinCheck
state anymore.My question is: is it possible to have a
detail.checked
ordetail.check
property in themove
event (something like thedetail.captured
property that is exposed when the player captures a piece?)Reproduction