# A deck question

**URL:** <https://forum.vassalengine.org/t/a-deck-question/1476>\
**Category:** Module Design\
**Created:** [January 15, 2009, 5:25pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476 "2009-01-15T17:25:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 15, 2009, 5:25pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/1 "2009-01-15T17:25:49Z")

</div>

When the game starts, the cards of a deck (25 cards) should be distributed randomly on the main map forming a square of 5x5 cards. Is this possible? Is possible a button with this function? Thanks for advance.

---

<div class="post-metadata">

**Author:** ![mkiefte](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/mkiefte/32/25_2.png) [@mkiefte](https://forum.vassalengine.org/u/mkiefte)\
**Post date:** [January 15, 2009, 5:50pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/2 "2009-01-15T17:50:35Z")

</div>

What you want is a global key command and make sure “Within a deck apply to” is set to fixed number of pieces. You’re going to have to do this 25 times – one for each position in the 5x5 grid.

And make sure they’re shuffled before you do it.

- M.

2009/1/15 packonn \<[messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org) ([messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org))\>

> [@](#):
>
> When the game starts, the cards of one deck (25 cards) should be distributed randomly on the main map forming a square of 5x5 cards. Is this possible? Is possible a button with this function? Thanks for advance.

Post generated using Mail2Forum ([mail2forum.com](http://www.mail2forum.com))

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 15, 2009, 6:35pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/3 "2009-01-15T18:35:34Z")

</div>

Mmm… too much for me… but I will try. Thanks again, mkiefte

---

<div class="post-metadata">

**Author:** ![mkiefte](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/mkiefte/32/25_2.png) [@mkiefte](https://forum.vassalengine.org/u/mkiefte)\
**Post date:** [January 15, 2009, 6:45pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/4 "2009-01-15T18:45:13Z")

</div>

It’s tricky. I think you’re going to have 25 different commands for each card – one for each position.

And then you’re going to need 25 Global Key Commands to pick a card from the deck to go to one of each position.

I can’t immediately think of an easier way to do this.

- M.

2009/1/15 packonn \<[messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org) ([messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org))\>

> [@](#):
>
> :shock:Mmm… too much for me… but I will try. Thanks again, mkiefte

Post generated using Mail2Forum ([mail2forum.com](http://www.mail2forum.com))

---

<div class="post-metadata">

**Author:** ![Tim\_M](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/tim_m/32/2_2.png) [@Tim\_M](https://forum.vassalengine.org/u/Tim_M)\
**Post date:** [January 15, 2009, 7:13pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/5 "2009-01-15T19:13:10Z")

</div>

There is an easier way using a trigger loop using 1 GKC and 1 Send To Location that references a Global property to count.  
Essentially give your locations a name that includes a numeric value i.e 1 to 25.  
Set the GP to 0  
When the trigger starts it increases the GP by 1 with a Set Global property trait, executes a GKC on 1 card only (important) within the deck which tells 1 random card to be sent to the location by using a property match  
The trigger then fires off another trigger which checks the value of the GP - if less than desired number, loop back (rinse repeat)

In total you need only about 5/6 traits not 25

I don’t have the methodology immediately in front of me right now but it is in the To Be King 0.9.8beta module tiles setup

From: Michael Kiefte [mkiefte@dal.ca](mailto:mkiefte@dal.ca)  
To: VASSAL Engine Forums Mailing List [messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org)  
Sent: Thursday, January 15, 2009 12:45:08 PM  
Subject: Re: [Module Design]Re: A deck question

It’s tricky. I think you’re going to have 25 different commands for each card – one for each position.

And then you’re going to need 25 Global Key Commands to pick a card from the deck to go to one of each position.

I can’t immediately think of an easier way to do this.

- M.

2009/1/15 packonn \<[messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org) ([messages@forums.vassalengine.org](mailto:messages@forums.vassalengine.org))\>

> [@](#):
>
> :shock:Mmm… too much for me… but I will try. Thanks again, mkiefte

Post generated using Mail2Forum ([mail2forum.com](http://www.mail2forum.com))

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 15, 2009, 8:06pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/6 "2009-01-15T20:06:40Z")

</div>

Thank you Tim. I’m working on it

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 16, 2009, 6:51am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/7 "2009-01-16T06:51:07Z")

</div>

Here’s how I’m doing that in TBK.

Establish a region point (Irregular grid) for each of the 25 points where the cards need to go. Number the region points xx-1 to xx-25 …or just 1 to 25, if you want but I tend give my region points some sort of letter code.

Establish a Global Property. Something like:

Name: CardSpot  
Initial Value: 0  
Check “is numeric”  
Min value: 0  
Max value: 25

Create a prototype called CardSend and give this prototype to all of your cards. The prototype should have the following traits:

Trigger Action  
Description: Trigger Send Cards  
Trigger when properties match: CardSpot (“is less than” symbol) 25  
Keystroke: CTRL 2  
Perform these keystrokes: CTRL 3, CTRL 4

Set Global Property  
Description: Next Region Point  
Global Property Name: CardSpot  
check “is numeric”  
Min Value: 0  
Max Value: 25  
Key Command: CTRL 3  
Type: Increment Numeric Value  
Increment by: 1

Send to Location  
Description: Send Card to Board  
Keyboard Command: CTRL 4  
Destination: Region on Selected Map  
Map: (the map with the region points where the cards will be dealt)  
Region Name: xx-$CardSpot$

Now that your cards are ready to go, create an At Stack stack near your card layout and place a game piece there to use as a button …like “Deal Cards”

Give the button the following traits:

Action Button  
Description: Send Cards Button  
Invoke Key Command: CTRL 1

Global Key Command  
Description: Deal Cards  
Keyboard Command: CTRL 1  
Global Key Command: CTRL 2  
Matching Properties: CurrentMap = (the map where your deck is) && DeckName = (the name of the deck)  
Within a Deck, apply to: All pieces

Unless I’ve forgotten something, that should deal all your cards.

Take a look at my development forum for TBK to see the many variations I’ve done on this.

[To Be King Development Forum](http://tobeking.19.forumer.com/viewtopic.php?t=42)

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 16, 2009, 4:08pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/8 "2009-01-16T16:08:24Z")

</div>

Dr. Nostromo, only one (but critical) thing: Where to set a region point?  
A few days ago I discovered the incredible Vassal, and I have much to learn!  
Thank you very much for your detailed and magistral explanation.

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 16, 2009, 4:33pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/9 "2009-01-16T16:33:16Z")

</div>

The tree structure in the editor will look like this for the map you are using for your layout:

Map Window  
Map Boards  
Board

I’m assuming that you’ve added a Board at this point.

Right click the Board and select “Add Irregular Grid”

When you look at the Irregular Grid properties, you’ll see a button that says “Define Regions”. This will allow to your set your region points on the map.

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 16, 2009, 7:01pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/10 "2009-01-16T19:01:16Z")

</div>

Ok! 😃

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 17, 2009, 12:29am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/11 "2009-01-17T00:29:30Z")

</div>

Hi Dr. Nostromo.  
I followed your instructions step by step but does not work. I have some doubts:

1. Establish the Global Property in the “Global Properties” folder of the Module folder? Or in the “Global Properties” folder of the map (the map where I put the cards)?

2. In the Trigger Action trait you write: CardSpot (“is less than” symbol) 25.  
Is this Ok?: CardSpot\<25

3. In the trait Send to Location, Region Name, you write: xx-$CardSpot$  
What is “xx”?

4. I put the deck on the board with At Start Stack?

Thank you for advance

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 17, 2009, 1:58am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/12 "2009-01-17T01:58:05Z")

</div>

> [@](#):
>
> 1. Establish the Global Property in the “Global Properties” folder of the Module folder? Or in the “Global Properties” folder of the map (the map where I put the cards)?

The module level should work just fine.

> [@](#):
>
> 1. In the Trigger Action trait you write: CardSpot (“is less than” symbol) 25.  
> Is this Ok?: CardSpot\<25

Yeah. I just didn’t use the symbol in my post as the forum sometimes mistakes the “less than” and “greater than” symbols a HTML tags and it messes up the posting. I put spaces in my property lines but I don’t think it makes a difference.

> [@](#):
>
> 1. In the trait Send to Location, Region Name, you write: xx-$CardSpot$  
> What is “xx”?

I used xx to represent any lettering code you may have used. For example, if you named your region points CS-1, CS-2, etc., then the line above would read:

CS-$CardSpot$

If you just named your regions 1 to 25, then your line would simply be:

$CardSpot$

> [@](#):
>
> 1. I put the deck on the board with At Start Stack?

That shouldn’t be a problem.

I’ve attached a sample mod that has a deck and a deal button. Click the deal button and it distributes the 25 cards. I believe this is what you want to do. You should be able to break it down from there.

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 17, 2009, 2:17am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/13 "2009-01-17T02:17:12Z")

</div>

I have no words… Great Dr.!!!

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 17, 2009, 1:14pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/14 "2009-01-17T13:14:51Z")

</div>

Magic!  
I hit the button, the deck disappears, and all 25 cards are distributed on the map (5x5).  
Exactly what I wanted.

I noticed that this happens only once, at the game start. When the deck is recomposed, the button no work. Why?

Dr\_Nostromus: Thank you very very much!!

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 17, 2009, 3:58pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/15 "2009-01-17T15:58:54Z")

</div>

The button should work anytime it’s clicked as long as there are cards in the deck.

> [@](#):
>
> I noticed that this happens only once, at the game start. When the deck is recomposed, the button no work. Why?

How are you recomposing the deck?

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 17, 2009, 5:13pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/16 "2009-01-17T17:13:10Z")

</div>

> [@](#):
>
> How are you recomposing the deck?

Selecting all cards, right click on either card, and left click “Return to Deck” command text.

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 18, 2009, 6:51am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/17 "2009-01-18T06:51:38Z")

</div>

It took some thought but I know what the problem is.

The Trigger Action in the card prototype only works if the CardSpot Global Property is less than 25. After all the cards have been dealt, CardSpot has been left at 25. With nothing to adjust it, the Trigger Action will never work again.

A couple of extra traits need to be added to the “Deal” button to reset CardSpot. I’m using the sample mod I sent you as an example for the following:

Currently the “Deal” button has the traits:

Action Button  
Fires CTRL 1

## Global Key Command Accepts CTRL 1 to fire CTRL 2 at the card deck

This should be adjusted as follows

Action button  
Fires CTRL B

Trigger Action  
Accepts CTRL B to fire CTRL R, CTRL 1

Set Global Property  
Global Property Name: CardSpot  
“is numeric”  
Min: 0  
Max: 25  
Key Command: CTRL R  
Type: Set Value Directly  
New Value: 0

## Global Key Command (no change)

By doing it this way, when you click the “Deal” button, it resets the CardSpot Global Property back to zero before triggering the deal.

---

<div class="post-metadata">

**Author:** ![Brent\_Easton](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/brent_easton/32/10_2.png) [@Brent\_Easton](https://forum.vassalengine.org/u/Brent_Easton)\
**Post date:** [January 18, 2009, 8:30am UTC](https://forum.vassalengine.org/t/a-deck-question/1476/18 "2009-01-18T08:30:51Z")

</div>

> [@](#):
>
> By doing it this way, when you click the “Deal” button, it resets the  
> CardSpot Global Property back to zero before triggering the deal.

This thread would make an excellent addition to the Vassal HowTo pages at

[vassalengine.org/wiki/doku.p … ow\_to:main](http://www.vassalengine.org/wiki/doku.php?id=how_to:main)

🙂  
B.

* * *

Messages mailing list  
[Messages@forums.vassalengine.org](mailto:Messages@forums.vassalengine.org)  
[forums.vassalengine.org/mailman/ … engine.org](http://forums.vassalengine.org/mailman/listinfo/messages_forums.vassalengine.org)

Post generated using Mail2Forum ([mail2forum.com](http://www.mail2forum.com))

---

<div class="post-metadata">

**Author:** ![DrNostromo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/drnostromo/32/12593_2.png) [@DrNostromo](https://forum.vassalengine.org/u/DrNostromo)\
**Post date:** [January 18, 2009, 2:23pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/19 "2009-01-18T14:23:04Z")

</div>

Ok. I’ll put something together in the next couple days.

---

<div class="post-metadata">

**Author:** ![packonn](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/packonn/32/65_2.png) [@packonn](https://forum.vassalengine.org/u/packonn)\
**Post date:** [January 18, 2009, 3:37pm UTC](https://forum.vassalengine.org/t/a-deck-question/1476/20 "2009-01-18T15:37:08Z")

</div>

Perfect!  
Now the button always works.  
For me, It has been a great pleasure to have you as teacher.  
Dr\_Nostromo: I hope your next lesson with anxiety  
Greetings from Spain!

packonn

[Next page](https://forum.vassalengine.org/t/a-deck-question/1476.md?page=2)
