Happy0 / ssb-chess

A library for building scuttlebutt chess clients with
GNU General Public License v2.0
63 stars 16 forks source link

Accidental resignation is very easy #77

Closed christianbundy closed 6 years ago

christianbundy commented 6 years ago

I'd be happy to help with this if you think it's trivial (or not!), but I'd personally love a confirm dialog after clicking "Resign". Thanks for all your work on this project, it's a ton of fun!

Happy0 commented 6 years ago

Thanks - glad people are enjoying it! Gone are the lonely days when I was playing against my raspberry pi using a command line client to ssb-chess on the terminal over SSH =p.

You're right, confirmation is sorely needed =p.

If you fancy having a stab at this yourself, this is the area where the resign button is rendered, and the callback for when it's clicked:

https://github.com/Happy0/ssb-chess/blob/master/ui/game/gameActions.js#L43

The easiest approach would probably be to display a modal 'are you sure?' browser dialog in the callback handler, then perform the resignation in response to a 'yes'.

However, it might be neater to display a 'yes' or 'no' option where the buttons are on the right (removing all other buttons until the user responds). I think you're familiar with mutant-js' when. Perhaps you could add another 'when' somewhere for when the user is confirming aye or naw to resigning? Kind of like this: https://github.com/Happy0/ssb-chess/blob/master/ui/game/gameActions.js#L106

It's not ~ super ~ trivial, but it's not ~ super ~ difficult either. I think reading about mithril components: (https://mithril.js.org/#components) and mutant observables ( https://github.com/mmckegg/mutant) would make it a bit easier. I think I seen you getting a bit familiar with 'when' when you were sorting out a patchbay issue)

Give me a shout if you'd like a hand :). Or of course, you can leave it to me. Let me know what you'd prefer!

Happy0 commented 6 years ago

Fixed :)