Create account / Log in

"Draw A Card" button; how to reshuffle discards automaticall

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

"Draw A Card" button; how to reshuffle discards automaticall

Postby Bridger » February 4th, 2020, 1:03 am

I have a single deck which cards are drawn from using buttons throughout the module (one button draws cards to your hand, another draws a card directly into the discard pile but reads it's value to the chat, etc.).

I would like these draw buttons to be able to detect if the deck is empty and, if so, reshuffle the discards before performing the draw action.

Is this possible?
Bridger
 
Posts: 17
Joined: March 19th, 2015, 10:27 pm

Re: "Draw A Card" button; how to reshuffle discards automati

Postby JoelCFC25 » February 4th, 2020, 3:59 am

I imagine so. You'd probably change your "Draw" buttons to have 2 triggers, each with a different property match expression (PME) that references the number of cards in the deck (accessible via <deck-name-here>_numPieces).

The first trigger would be the case when your deck has 1 or more cards left, i.e. <deck-name-here>_numPieces > 0. In this case draw normally.

The second trigger's PME would be <deck-name-here>_numPieces = 0. In this instance, you fire a GKC or something that is applied to all cards in the discard pile which activates either the Send to Location or a Return to Deck trait on every single card, sending it shooting back to the deck. Then draw normally.

There are probably more ways to approach this, but it's what came to me off the bat.
JoelCFC25
 
Posts: 689
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: "Draw A Card" button; how to reshuffle discards automati

Postby Bridger » February 4th, 2020, 3:55 pm

How do I create a trigger on a button? Or is the button just a single global key command button and I put the triggers on the 'Card' prototype?

The "buttons" i'm referring to here are buttons placed into the window itself (Global Key Commands), not game pieces which have the 'button' trait.
Bridger
 
Posts: 17
Joined: March 19th, 2015, 10:27 pm

Re: "Draw A Card" button; how to reshuffle discards automati

Postby JoelCFC25 » February 4th, 2020, 4:15 pm

Ah, do you mean buttons in your toolbar? Well, then perhaps the strategy is combine everything you need to do in a Multi-Action Button, which simply hides and carries out multiple GKCs bound to their own toolbar buttons in a sequence.

The Multi-Action button would call other buttons that:
1. Does a GKC to fire the "go back to the draw pile" keystroke on all cards in the discard--but with a PME that the draw pile must be empty, otherwise this is a do-nothing button
2. Does a GKC to fire the "draw 1 from the deck" command.

End result is a single button that draws 1, but also silently returns all the discards to the deck first if necessary. I'm a bit pressed for time to mock something up but it feels like that should be what you need.
JoelCFC25
 
Posts: 689
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: "Draw A Card" button; how to reshuffle discards automati

Postby Bridger » February 4th, 2020, 7:01 pm

Thanks for the help Joel. I'm not certain how to setup the PME you wrote about. Is that using the "Matching Properties" box and an "if" statement about number of pieces in a deck? I can figure out what to put into the 'if true' section, but what if the number of pieces in the deck is not 0? How do I setup the 'false' section of the if statement to ensure it doesn't fire anywhere? Just write in a deckname which doesn't exist?

I tried setting it up like I just described, but the problem is that I can't get it to apply the command to the whole deck. The cards have a 'return to deck' trait mapped to CTRL+SHIFT+R, and using that I can get the global hotkey button to work with this property match: {If(GetProperty("Main Deck_numPieces")==0,DeckName=="Discard",DeckName=="Main Deck")}. I had the 'fail' condition to just have cards in the main deck go to the main deck (so nothing happens).

However, an ideal situation would be to trigger the actual 'reshuffle' function of the *deck* itself. I have been unable to trigger that with global key commands though. That is bound to CTRL+R, and if I press that key anywhere in any window, the discards shuffle back into the main deck as expected. However, global hotkeys which trigger Ctrl+R can't seem to 'target' the deck reshuffle function and I'm not sure why. It seems like global hotkeys only target pieces and not decks.
Bridger
 
Posts: 17
Joined: March 19th, 2015, 10:27 pm

Re: "Draw A Card" button; how to reshuffle discards automati

Postby Bridger » February 4th, 2020, 7:17 pm

Hmm, can't edit anymore: To clarify...

While using a GKC on a player hand window with property expression set to: {If(GetProperty("Main Deck_numPieces")==0,DeckName=="Discard",DeckName=="Main Deck")}

The result is that it will only shuffle a single card from the discard back into the main deck, even though I have it set to target 'all pieces' of a deck. This suggests that it's re-checking the 'if' statement for every piece, and I'm not sure hot to word the property match to get the result I want.
Bridger
 
Posts: 17
Joined: March 19th, 2015, 10:27 pm

Re: "Draw A Card" button; how to reshuffle discards automati

Postby JoelCFC25 » February 4th, 2020, 8:32 pm

I'll have to throw together a proof-of-concept to see if what I'm sketching out even works, otherwise I'll just be saying more stuff that might sow more confusion (and it might not even be right)!
JoelCFC25
 
Posts: 689
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: "Draw A Card" button; how to reshuffle discards automati

Postby JoelCFC25 » February 4th, 2020, 9:48 pm

Totally different tack here--can you not just use the "Send hotkey when empty?" feature of a deck? Namely, define a hotkey on the Discard pile using the "Include command to send entire deck to another deck" tickbox. Then on the Draw pile, specify that hotkey in the "Send hotkey when empty?" option.

So you have buttons to draw cards into player hands or draw cards into the discard as needed, but whenever the draw pile empties, it automatically fires the hotkey to return everything in the discard to the draw pile. I tested it just now and it seems to be ok.

You made mention of the Reshuffle function. It's there if you want that option, but really it comes down to whether or not the ordering of cards in your draw pile is important to retain. If you don't care about card ordering, you could use Reshuffle: Always, which means any time something is taken it's a random selection of what's there, i.e. it is not taking the "top card". It depends on the rules of your game whether that's acceptable or not.
JoelCFC25
 
Posts: 689
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: "Draw A Card" button; how to reshuffle discards automati

Postby Bridger » February 5th, 2020, 2:56 am

I had considered that option, but I was thinking there might be situations where reshuffling after a draw empties the pile results in different cards going back in compared to reshuffling while *trying* to draw from an empty pile (other cards may have been played in the meantime).

I just need to figure out how to get a GKC from a window into the main module. It seems like I might be able to create an invisible piece in that window which takes in the GKC and puts out an *actual* global key command which reaches into the other windows. It's just so bonkers that a thing called 'global' only works on the window it's in.
Bridger
 
Posts: 17
Joined: March 19th, 2015, 10:27 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 6 guests