orcnog / orcnog-card-viewer

MIT License
4 stars 0 forks source link

Some potential V10 fixes #14

Closed kristianserrano closed 1 year ago

kristianserrano commented 1 year ago
kristianserrano commented 1 year ago

Sounds good, thanks, and you're welcome. 😁

orcnog commented 1 year ago

@kristianserrano So, after testing this I am finding that if I intentionally tell the macro to share (and execute it), then any subsequent deal action from any stack is also shared, and if I intentionally tell the macro not to share (and execute), then subsequent deal actions from a stack are not shared.

While we could overcome this by unsetting that global when we're don using it... I'm feeling like using something global to temporarily control this seems like a risky or at least irresponsible approach. It assumes we'll only ever be doing exactly one thing at a time (which is probably a safe assumption, but who knows... say someone writes a macro that deals, draws, and passes simultaneously; then the timing of setting/unsetting/resetting that var becomes nearly impossible to manage).

There's got to be a way to flag a .deal function so we know the source. Ideally I want to attach some property to the call that can be read in the hook. "action" seems like my only option at the moment. I'd like to explore making that custom action string work without erroring out.

If it's trying to match the "action" string against a chatAction property, perhaps there's a way to add additional chatActions so that it does match?

kristianserrano commented 1 year ago

I think in this scenario, shareToAll would be a required value, but it's default would be false. Thus I was thinking that if one wanted to explicitly share that action, one should be setting it to true for each deal, draw, and pass in their custom macro. I think using async and await might help as well.

I'm still sorting through the logic paths in the code to see what triggers when and where and what data is being passed for what, but I think I have it mostly sorted.

Looking at the hooks and actions has been interesting, and I've learned there are combinations of hook events and actions. For example, dealCards can have deal or pass, and passCards can have draw or pass. The good thing about that is you can infer the action to determine if it's being passed to a pile or hand based on origin and destination types, which means you can support setting options for passing to a hand, passing to a pile, drawing, and dealing.

I'll keep investigating alternatives to the global variable/property/setting approach.

kristianserrano commented 1 year ago

Flags for the win!