Create account / Log in

Number of cards

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Number of cards

Postby packonn » January 26th, 2010, 7:02 pm

Hi friends,
I need to know the number of cards the players hold in their hands. The "text label" trait work on the map player hand, but no on the main map. How do it? Thanks for advance
User avatar
packonn
 
Posts: 58
Joined: November 5th, 2008, 4:13 pm
Location: Murcia (Spain)

Postby masterdinadan » January 28th, 2010, 1:50 am

The solution I used is fairly tricky.
Every map applies a keystroke to units ending their move there. For player hands, I use
ALT-1
ALT-2...
etc

And for other maps I use a different hotkey.

Every card has a set of trigger actions. One set for increasing hand count, and another set of decreasing (two trigger actions per card).

The increasing trigger watches for the keystroke ALT-1 (or whatever hand you are referring to) and checks the condition OldMap != $CurrentMap$ in order to prevent the count from incrementing when the card is moved around within the hand.

The decreasing triggers watches for all of the other keystrokes (if no cards are moving from hand to hand, just watch for the keystroke of your other maps), and checks the condition OldMap = p1hand or whatever you call the map.

The triggers each perform a keystroke. The cards also have Set Global Property, one for each players hand. The keystrokes that are performed by the trigger actions will either increment or decrement the Global Property.

Then you just need to make a text label that displays the global property!

This method is not fool-proof. Obviously, because you are relying on triggers, players can manually input the keyboard commands and bypass the trigger conditions altogether. Don't use anything that the players are likely to hit by mistake and you should be fine.

Another thing to watch out for is the "Send to Deck" property. It doesn't play nicely with the trigger conditions. The OldMap trait doesn't update properly when you send a card to a deck on another map. The card basically doesn't know where it came from, and it won't decrement the hand count.

Similarly, if you drag the card out of your hand, it will decrement the hand count. If you then send the card to a deck (without moving or deselecting it), the card's OldMap will still be your hand, and it will decrement the hand count AGAIN.

The easiest solution is not to rely on return to deck commands, but that's inconvenient. You can work around it by using triggers for your return to deck commands and having these triggers increment or decrement the hand count based on the current map rather than the old map. But things start to get a little complicated.

Because of all these issues, I included a Set Global Property on my text label pieces, which will prompt the user for the value for the property. Whenever a player's hand count is off due to a bug or an accidental keyboard shortcut, they can just right click the label and put in the correct number.

Hopefully that's enough to get you started.
masterdinadan
 
Posts: 15
Joined: November 13th, 2009, 10:14 pm

Postby packonn » January 29th, 2010, 4:57 pm

Thank you very much masterdinadan. I tried applying your explanations, but something goes wrong (maybe my limited knowledge of english, or my limited brain cells, sorry). I need a simple example. What are the text label instructions for the main map where the cards are not (the main map where you can see the numbers of the cards players have on private hand)? Thank you for advance :D
User avatar
packonn
 
Posts: 58
Joined: November 5th, 2008, 4:13 pm
Location: Murcia (Spain)

Postby masterdinadan » February 1st, 2010, 1:21 am

Alright, if I'm only doing this for player 1's hand, here's what I do:

I make a hand with map name p1hand. Open the properties window and use CTRL-F1 for "Key Command to apply to all units ending movement in this map"

In your main map area, and any other map that the card might be dragged into directly from somebody's hand, we need to apply a different key command for unit movement in the map. Let's use CTRL-F8.

You will also need to define a global property, let's call it Hand_1.

Now when you define the prototype for your cards, include the following traits:

Trigger action "Increment 1", when properties match "OldMap != $CurrentMap$". Watch for CTRL-F1, perform ALT-F1. (This trigger action causes ALT-F1 to be performed when the unit enters the map as long as it was previously in a different map.)

Trigger action "Decrement 1", when properties match "OldMap = p1hand". Watch for CTRL-F8, plus any other key you use for units entering maps. Perform SHIFT-F1. (This trigger action causes SHIFT-F1 to be performed when the unit enters ANOTHER map, as long as it was previously in the players hand)

Set global property, property name "Hand_1", Is Numeric. First key command is ALT-F1 and increments the value. Second key command is SHIFT-F1 and decrements the value.

Now you've got the players hand count stored as a global property that automatically updates (though it isn't perfect). Simply make a unit in the main map (or anywhere you want it really) with a text label, "Hand: $Hand_1$". If you use a property name in a label, it automatically updates when the property changes, so this label will constantly display the current value of the property.

Now, as I mentioned before, there are some problems with this approach. First of all, "Return to Deck" does not use the OldMap and CurrentMap properties like you would expect so if you rely on this trait it may not decrement the count (or sometimes will decrement it when it shouldn't). If you must use that trait, you need to apply some more trigger actions and it gets kind of complicated.

The other issue is of course that players may use the keyboard shortcuts to increment or decrement the global property without actually moving any cards around. Just like anything else in Vassal, it only works properly if the user uses it properly.

What I like to do is include a Set Global Property trait on the text label unit that prompts the user for a new value. If the global property should be off for any reason, you can just use that to correct it and keep going.
masterdinadan
 
Posts: 15
Joined: November 13th, 2009, 10:14 pm

Postby Tim M » February 1st, 2010, 1:54 am

masterdinadan wrote:Now you've got the players hand count stored as a global property that automatically updates (though it isn't perfect). Simply make a unit in the main map (or anywhere you want it really) with a text label, "Hand: $Hand_1$". If you use a property name in a label, it automatically updates when the property changes, so this label will constantly display the current value of the property

Now, as I mentioned before, there are some problems with this approach. First of all, "Return to Deck" does not use the OldMap and CurrentMap properties like you would expect so if you rely on this trait it may not decrement the count (or sometimes will decrement it when it shouldn't). If you must use that trait, you need to apply some more trigger actions and it gets kind of complicated.


This is why I was suggesting changing to use STL instead till I realized you wanted to use RTD

masterdinadan wrote:The other issue is of course that players may use the keyboard shortcuts to increment or decrement the global property without actually moving any cards around. Just like anything else in Vassal, it only works properly if the user uses it properly.


Not if you use an obscure key combo a user is very very unlikely to ever press and is kept hidden
such as Alt Ctrl Shift Back_Quote or Alt Ctrl Clear (find that on your keyboard - I used it once and for the life of me spent ages trying to find it again lol! :shock: :) )

masterdinadan wrote:What I like to do is include a Set Global Property trait on the text label unit that prompts the user for a new value. If the global property should be off for any reason, you can just use that to correct it and keep going.


Here on the text label piece I would be cleaner and add a plus / minus action button. Action buttons are a lot quicker to interact with and user is very familiar with the operation if you make the button obvious (single mouse click).
As an interface option a single mouse button click on a piece from Action button trait is a lot quicker and easier than : select piece (left mouse click), open menu (right mouse click), select command (left mouse click), input value.

Either way, it works though :)
Tim,
Vassal Uber Geek/Guru

Problems? post your OS, Physical Mem, version of Vassal and Java plus the Module in question.
No developer can help with out that info, thx!
User avatar
Tim M
 
Posts: 1762
Joined: December 8th, 2007, 12:22 pm
Location: Earth

Postby packonn » February 1st, 2010, 3:21 pm

Well, I'm halfway to the solution. I deal five cards to each player, and now I see on the main map number “5” for the Hand_1. All players know that Hand_1 has five cards in his hand. Perfect. But when the Hand_1 discard one card to the discard deck (on the main map), the number “5” for the Hand_1 remains, does not change the number “4”. Why? I reviewed one to one all the commands, and I see no error.
I have changed the KeyStroke in the two Trigger Action, one key for increment and another key for decrement, but unsuccessfully.
The two Types in the Set Global Property (one for ALT -F1, and one for SHIFT -F1), what are they? Increment numeric value by ..., or Set value directly by ...?
The increment work no problem, but the decrement is frozen...
Thanks
User avatar
packonn
 
Posts: 58
Joined: November 5th, 2008, 4:13 pm
Location: Murcia (Spain)

Postby masterdinadan » February 2nd, 2010, 10:08 am

Tim M wrote:Here on the text label piece I would be cleaner and add a plus / minus action button. Action buttons are a lot quicker to interact with and user is very familiar with the operation if you make the button obvious (single mouse click).
As an interface option a single mouse button click on a piece from Action button trait is a lot quicker and easier than : select piece (left mouse click), open menu (right mouse click), select command (left mouse click), input value.

Either way, it works though :)


A matter of preference I suppose. As far as I'm concerned, the hand count should rarely be off if it's properly designed. In my module, it's hard to use rare shortcuts, because I have 7 players with their own set of hotkeys for incrementing and decrementing counts, as well as countless other hotkeys that I use in trigger actions to send to all sorts of decks (I have a lot of GCKs that move pieces around... big fan of automating tasks).

As for the RTD trait resulting in problems, I've found a very easy and effective fix for it. The cause of the problem is that RTD does not change the OldMap property on the piece. The property is only updated when a user drags and drops the piece (Maybe STL, I didn't try using it). However, I just added in a dynamic variable trait for OldMap and have a keyboard shortcut that changes the value to $CurrentMap$. I just use this keyboard shortcut in any trigger action that performs a Send to Deck, which causes OldMap to be set to the current map before sending the card off to some other map. It single-handedly solved all of my woes.

packonn, I'm sorry to hear that it isn't working properly, but it sounds like you are getting the idea.
"Increment numeric value by..." is definitely the one you want to use. To decrement the count, you just use Increment and type -1 as the value instead of 1. If it still doesn't work, do some trouble shooting. Select a card and manually perform Shift-F1 and see if it decrements. If it does, your problem is in the trigger action somewhere. I would start by double checking the conditions match field.
masterdinadan
 
Posts: 15
Joined: November 13th, 2009, 10:14 pm

Re: Number of cards

Postby fcolmenarez » January 22nd, 2016, 7:44 pm

The RTD Trait bug not updating the OldMap property seems to have been fixed in the latest VASSAL I'm using 3.2.15. (Probably fixed even earlier)

Also Key Commands can be given full names now, this ensures you can absolutely create a command no one can trigger by accident or design.
fcolmenarez
 
Posts: 4
Joined: June 28th, 2012, 3:59 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 4 guests