Deal every second card

Assume there is a deck of cards which is to be dealt to two different players. Each of players should be dealt every second card, starting from player A. Namely, there are two players, A and B and a deck of 52 cards = {1, 2, …, 52 }. Player A should be dealt odd numbered cards, player B these of even numbers.

I created a Global Property labelled NextHand of values 0 or 1. Each card of the deck has a trait of setting a global property, altering the NextHand value to 0 or 1 if its previous value was 1 or 0, respectively. There are also two Trigger Action traits, both triggered by the same key short cut:

Trigger Match: NextHand = 0,
Watch for the Keystrokes: CTRL 0
Perform Keystrokes:
ALT CTRL SHIFT 0 # alter NextHand
CTRL 1 # deal to player A

Trigger Match: NextHand = 1,
Watch for the Keystrokes: CTRL 0
Perform Keystrokes:
ALT CTRL SHIFT 0 # alter NextHand
CTRL 2 # deal to player B

On a map window there is a button is supposed to auto-deal cards:

Key Command: CTRL 0
Within a deck apply to Fixed number of cards: 4

The issue is, as you could have guessed, it does not work. The button doesn’t deal two cards to each of hands, instead it deals all four to one hand and then alters the NextHand value. It looks as if A-C-S-0 combo is triggered in the loop but only when the loop exits.

Any hints?

Is there a difference between being dealt every second card and being dealt
the first half of the cards if they’re shuffled?

Statistically, it doesn’t matter.

Just a thought.

  • m

On 20 May 2013 06:31, grouchysmurf lgrabun@gmail.com wrote:

Assume there is a deck of cards which is to be dealt to two different
players. Each of players should be dealt every second card, starting
from player A. Namely, there are two players, A and B and a deck of 52
cards = {1, 2, …, 52 }. Player A should be dealt odd numbered cards,
player B these of even numbers.

I created a Global Property labelled NextHand of values 0 or 1. Each
card of the deck has a trait of setting a global property, altering the
NextHand value to 0 or 1 if its previous value was 1 or 0, respectively.
There are also two Trigger Action traits, both triggered by the same key
short cut:

Trigger Match: NextHand = 0,
Watch for the Keystrokes: CTRL 0
Perform Keystrokes:
ALT CTRL SHIFT 0 # alter NextHand
CTRL 1 # deal to player A

Trigger Match: NextHand = 1,
Watch for the Keystrokes: CTRL 0
Perform Keystrokes:
ALT CTRL SHIFT 0 # alter NextHand
CTRL 2 # deal to player B

On a map window there is a button is supposed to auto-deal cards:

Key Command: CTRL 0
Within a deck apply to Fixed number of cards: 4

The issue is, as you could have guessed, it does not work. The button
doesn’t deal two cards to each of hands, instead it deals all four to
one hand and then alters the NextHand value. It looks as if A-C-S-0
combo is triggered in the loop but only when the loop exits.

Any hints?

_____________**
Read this topic online here:
vassalengine.org/**forum/vie … 4#**p40324<Deal every second card
_____________**
messages mailing list
messages@vassalengine.org
vassalengine.org/**mailman/listinfo/messageshttp://www.vassalengine.org/mailman/listinfo/messages

It does matter, actually. The situation is not as simply as I described it. There is a second deck added to the first one and there is a special card added on top of it before. This special card may go to one side or to the other, which does impact the game. The rulebook defines the sequence in which cards are dealt and I want to keep to it as closely as possible.

Think of it as of dealing cards in Twilight Struggle – who gets first card does impact how the middle war cards are dealt. And that definitely has an impact on the game.

Strange… Is the NextHand value altered each time you press the button? Are the 4 cards dealt to another player each time you press the button?

In my understanding, what happens is the following:
Suppose that NextHand==0, the first trigger receives ctrl+0 and triggers => NextHand=1 and the card is dealt to player A.
Now, NextHand==1, so the second trigger can trigger too! => NextHand=0 and the card is sent (from player A) to player B.
Repeat ad nauseam… all cards are sent to player B and NextHand is always 0.
If you reverse the order of the triggers in the prototype definition, then all cards will be sent to player A, and NextHand will always be 1.

=> Try to remove the “perform alt+ctrl+shift+0” from both your triggers, and add a new trigger: no matching conditions, watch for ctrl+0, perform alt+ctrl+shift+0.
Now both conditions (NextHand=0 / NextHand=1) are checked before NextHand is altered (and altered only once!), so the card are correctly dealt to both players in turns.

Note that it makes a difference whether this new trigger is before or after the other triggers (it could also work without new trigger, by using directly ctrl+0 for the “set global property” action, but in this case you can’t choose the order of the actions: the global property seems to be set always before the triggers).

Hi,

I found a simpler and more elegant way to do it. Instead of creating a somewhat superfluous property NextHand, now I have two GK, C-0 and C-1 which send the card respectively to hand 0 and hand 1. As the number of cards dealt each round is always even, I added a Multiaction Button which triggers C-0 C-1 combo required number of times, dealing the cards in a way I wanted.

Thanks for all the replies.