A deck question

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.

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 (messages@forums.vassalengine.org)>

Post generated using Mail2Forum (mail2forum.com)

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

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 (messages@forums.vassalengine.org)>

Post generated using Mail2Forum (mail2forum.com)

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
To: VASSAL Engine Forums Mailing List 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 (messages@forums.vassalengine.org)>

Post generated using Mail2Forum (mail2forum.com)

Thank you Tim. I’m working on it

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

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.

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.

Ok! :smiley:

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

The module level should work just fine.

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.

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$

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.

I have no words… Great Dr.!!!

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!!

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

How are you recomposing the deck?

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

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.

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

vassalengine.org/wiki/doku.p … ow_to:main

:slight_smile:
B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

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

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