I’m trying to create modules using Vassal to prototype some boardgame designs, but I’m finding the Vassal model kind of confusing.
In particular, I clearly haven’t grasped the grid / stack / location / zone model for game components. When I drag in-game components from one place to another, it seems really difficult to make them behave the way I want.
For instance, I’d like players to have hands of cards which are laid out neatly in a row. So I make a Player Hand object. But this only lays the cards out neatly if they are in a single stack. Nothing stops me dragging cards to arbitrary locations in the window. So I add a Rectangular Grid child to the Player Hand. Now I can’t drag cards to arbitrary locations, but cards can be on top of each other in weird ways: there can be a stack of 2 cards in grid location 1, with the second of these cards visually overlapping a card on location 2.
I’d really like the whole of the Board in the Player Hand to have exactly one place that cards can be dragged, so that any card dragged there has to join the same stack. So I try making the Rectangular Grid have a cell size larger than the window. This works for the first couple of cards I drag, but the third one weirdly ends up in the first visual slot.
Then I try the same thing with movable “dice” (counters with multiple layers) in another window. I want to be able to drag the dice from one area to another, to indicate that the ones in the second area are to be re-rolled (I want this for several reasons). The problems are similar, except that it’s harder to select individual dice from the stack when I play - I seem to need some combination of double-clicking and single-clicking.
Then I try using the “Key Command to apply to units ending movement on this map” functionality. I set up a “Send to Location” property on the cards with key CTRL-K, which sends cards to a specific location on the player 1 hand board where (hopefully) they will stack. I set the player 1 hand map to apply this keystroke to all cards ending their movement on this map. This causes VASSAL to crash (I presume it’s causing the event to trigger endlessly?).
What’s more, even though the components I drag around the playing area are clearly clicking onto preset locations on my Rectangular Grid, the messages tell me they are being moved “offboard”. I don’t understand! They are on the named Board with the Rectangular Grid! Why is that “offboard”?
Can anyone help me out and explain what I’m doing wrong?
These are pretty advanced concerns for a ‘newbie’, so next time you can claim to be an ‘old hand’.
First, your ‘offboard’ issue. Yes, they are moving around on a grid, but you need to tell Vassal how you want those grid locations reported. Add a ‘grid numbering’ component to your rectangular grid, if you end up keeping the rectangular grid. I suspect there may be a better grid type for you, however, depending on how you want the piece movement reported. You can also change the autoreport format in the properties for the Map Window (or Private Window) component.
Second, your crash. Yes, this is an infinite loop. Instead of calling the Send To Location directly, you would need an intermediate Trigger Action to check that OldMap != $CurrentMap$, or OldBoard != $CurrentBoard$. What is happening is, you send the piece to the board, it is told to perform CTRL-K, which sends it to the location again, which triggers the CTRL-K again, etc.
Finally, about stacking: I hate it - I’m sure it’s useful for wargames, but it never seems to have any relevance for my Euro modules. So, first, I turn it off. Second, I write a deck organizer piece just to lay out the cards if I really think it’s a problem. But it’s complex, computationally expensive (in the current Vassal model), and at some point I think you’ve got to just trust your users. For reference, though, here’s a possible outline for what you want to do:
Decide on an absolute maximum number of cards in hand.
Create regions or zones for each possible card position, like ‘Position_1’, ‘Position_2’, …
Create a piece called, say, ‘HandOrganizer’ in an at-start stack on your hand board - give it no graphic.
Define a ‘this position is open’ property on your HandOrganizer for each possible position: positionIsOpen_1,positionIsOpen_2,…
When pieces enter the map, have them do the following:
(a) Set some kind of flag that they want to go to the next open position. They can set a dynamic property, they can go to a deck, a tiny zone, whatever.
(b) Signal the HandOrganizer.
The hand organizer loops through the PositionIsOpen properties to find the next open position; it stores this in, say, a global property called NextOpenPosition. It also sets PositionIsOpen to 0 or false, or whatever you prefer.
It then signals the flagged piece to Send To Location to the matching region or zone - Position_$NextOpenPosition$.
(a) If you’re using regions, you’ll also need a dynamic property like ‘myPosition’ to remember which position the piece belongs to.
To reopen the positions, you also need ‘ending movement on this map’ triggers on every other map you might drag those pieces to:
Check which position you just evacuated with OldZone or your dynamic property.
Set a global property at module level, ‘EvacuatedPosition’
Trigger your HandOrganizer to clear the positionIsOpen property.
I’ve never done it exactly this way, but it’s similar to other organizers I’ve made. As you can see, it’s a pain in the neck and it can end up being pretty slow. Also, it doesn’t (yet) deal with players manually moving cards from one position to another. You would need even more triggers to monitor for that - although not that many more. Personally, I’d recommend the Player Hand or just let the players lay out their cards however they want. Hopefully this can handled more gracefully in the future.
Thanks for your reply Seth! That’s very helpful to know.
I’m definitely a newbie, because I never used Vassal at all before yesterday.
I fixed the infinite loop crash by adding a Dynamic Property called “moving” to the cards, with CTRL M: moving=1, CTRL N: moving=0, and changing the “move onto hand” event to be a new triggered event CTRL H (trigger on moving=0) which triggers, in order, CTRL M, CTRL K and CTRL N. Now my hand does exactly what I want it to.
I’ve also changed CTRL K to be a “Send to Location” with the fields
X Position: 200
Y Position: 200
…this seems to make it work on every player hand. Of course, if someone hits CTRL-H or CTRL-K outside a hand, whoops!
Now to try and get the dice working…
The possibility of a player accidentally entering your ‘hidden’ keystrokes can be reduced by using more obscure ones (CTRL-ALT-K or CTRL-SHIFT-K), or, better, using named keystrokes in the 3.2 beta when it’s released (the test builds can be downloaded at vassalengine.org/~uckelman/builds/). The reason I recommended not using the stacks is that, as you said with the dice, I believe a player will need to use some combination of single- and double-clicks to access their cards, which I bet will get pretty frustrating.
Interestingly, the single / double-click issue with stacks does not seem to apply within Player Hand windows (as opposed to ordinary Map Windows). So by putting the whole darn thing in a Player Hand (belonging to all players), I’ve now got a nice Yahtzee style dice roller.
The functionality works as follows:
There are two boards (the rolling mat and the locked mat). Dragging a die onto either mat snaps it into place at the end of a row of dice there. A “roll” button transfers all dice from the rolling mat to the locked mat and randomises them.
I chose to have two mats because:
- It’s an intuitive interface for controlling which dice are to be re-rolled;
- Moving a die onto the locked mat shows unambiguously that it has been re-rolled (even if it comes up with the same face again).
Now… resource pools. I need each players to have pools of Resource X, Resource Y and Resource Z. Only the total number of resources in each pool matters. They get spent regularly and form a major part of the game, so it needs to be easy for a player to
- See how many resources of each type every player has (preferably without taking any mouse or keyboard action)
- Add resources of each type to your pool (and preferably you should be able to specify how many)
- Remove resources of each type from your pool (and preferably you should be able to specify how many)
What’s the best known way of implementing a resource pool in VASSAL? I don’t want stacks of counters cluttering up the board if I can avoid it.
Do the resources need to have a ‘physical’ representation? That is, are they passed around? If not, I would give each player a global variable, assign the text in a few text labels to, i.e., ‘$P1_Resources$’, and create a few controls (using action buttons, perhaps), one to increment and one to decrement:
a) Prompt for the amount to increment or decrement, and store:
b) Trigger an increment/decrement with value ‘$IncrementAmount$’ or whatever
If they do need a physical representation, I would give each player a tray of chips (or however they’re represented) of various denominations, one of each, and I would have the chips monitor a few things:
a) When a chip moves from a tray, it should signal a MoneyMaker piece, which creates a new chip and sends it to the tray. Also, decrement the resource pool of the player who owns the chip tray.
b) When a chip moves into the tray, it should delete itself. Also, increment the resource pool of the player who owns the chip tray.
I tried your Player Hand implementation just now and I am very impressed - it works exactly how I thought Player Hands ought to work out-of-the-box. As you noticed, they don’t, and I didn’t spend much time playing with them as a result. I still recommend using a hand organizer if you want more flexibility, but if what you want is a simple horizontal layout, your solution is quick, elegant, and apparently robust. Thanks!