0xFableOrg / 0xFable

A fully on-chain trading card game. There will be elves, wizards & shit. Drama and broken friendships also.
https://twitter.com/0xFableGame
BSD 3-Clause Clear License
106 stars 39 forks source link

Automate turn based card draw. #116

Closed ultraviolet10 closed 7 months ago

ultraviolet10 commented 8 months ago

Refers to #107.

Adds in a useEffect in play.tsx that is triggered whenever the turn switches, and triggers the drawCard transaction. Removes the Draw button since we're now automating the action.

To test: keep ending turns in each tab, the tx is triggered in the other tab immediately (logs confirm this).

@norswap, would be nice to use this to indicate which card has been drawn? (when we have a definitive card list, with IDs and all).

norswap commented 7 months ago

TODO:

After that, let's just merge this, I'll create an issue for the better UX of showing the status of drawing.

ultraviolet10 commented 7 months ago

@norswap tried adding the timeout to the refreshGameData calls, didn't retrigger the useEffect that performs the drawCard functionality. ✌️

norswap commented 7 months ago

Great work, merging this (after rebasing on top of master) 🔥

I think we could improve it further.

e.g. the card appears before the animation in a way that is noticeable, would be great if the animation was more instantaneous with that event, and would also be great if the toast was dismissed immediately when that happens.

I think the main issue there is that the actual update occurs from the refreshGameState whereas animation etc trigger from getting receipts from the transaction, which (at least locally) occurs after. I think this might need to happen as part of a bigger update on how we can signal those things via the first thing that occurs (state update OR getting receipts).

Also testing this I noticed the issue here #128