Create account / Log in

Deck with single card only

Talk about module design ideas and techniques.

Moderators: uckelman, Tim M

Deck with single card only

Postby dawg » November 30th, 2012, 8:11 am

Hi all,
I'm new in this forum, my name is Riccardo and I'm from Italy.

I'm trying to create a cardgame with Vassal.
The game have some cards players can choose from to create theyr deck.
I need a check, for both players deck, to verify that deck don't have more than one copy of a single card.

Can someone halp me?? Thanks :wink:
My works -> Warage GCC <-
User avatar
dawg
 
Posts: 30
Joined: November 30th, 2012, 7:54 am

Re: Deck with single card only

Postby DrNostromo » November 30th, 2012, 3:44 pm

Without going into details, one method that comes to mind would be to create a temporary deck. Whenever a card is drawn from the deck, you would have a command sent to the deck to send all duplicate cards to the temporary deck. Once all the cards are drawn, you can have the cards in the temporary deck returned back to the original deck.
User avatar
DrNostromo
 
Posts: 1061
Joined: December 21st, 2007, 3:54 am
Location: Wine Country, Cal. USA

Re: Deck with single card only

Postby dawg » November 30th, 2012, 5:12 pm

DrNostromo wrote:Without going into details, one method that comes to mind would be to create a temporary deck. Whenever a card is drawn from the deck, you would have a command sent to the deck to send all duplicate cards to the temporary deck. Once all the cards are drawn, you can have the cards in the temporary deck returned back to the original deck.


I'll try to explain better my project.
I'm working on a module called "Deck Builder" with a Main Map that have 1 empty deck inside.
Have created a "Cards" Game Piece Palette with 4 Scrollable Lists (one for any tipe of card) and also 4 Prototype Definition.
In the Prototype Definition have put the Trait Return to Deck so the player can right click the card from the scrollable list and send it to the deck, when the deck is complete player can save it and then load it in the Module for the game.

A Deck must have only one copy of a single card and more than 30 cards.
I would like to put a Message, visible by all players, that say "Deck Player 1 - Ok" or "....not Ok" when player load it for play.

Thanks.....and sorry for my english 8)
My works -> Warage GCC <-
User avatar
dawg
 
Posts: 30
Joined: November 30th, 2012, 7:54 am

Re: Deck with single card only

Postby barbanera » November 30th, 2012, 5:44 pm

If your pool of cards is not too big you could allow counting of property expression in your deck and have a property expression to match every single one of your cards. This is the hard/boring part. Then you would need to add a single DYNAMIC PROPERTY and a single RESTRICT COMMAND on your cards prototype.

This makes for N+2 things/traits to edit, where N is the number of cards in your pool. Hence I spare you the details unless you are willing to do the grunt work.
barbanera
 
Posts: 384
Joined: January 12th, 2012, 2:27 pm

Re: Deck with single card only

Postby dawg » December 1st, 2012, 2:55 pm

barbanera wrote:If your pool of cards is not too big you could allow counting of property expression in your deck and have a property expression to match every single one of your cards. This is the hard/boring part. Then you would need to add a single DYNAMIC PROPERTY and a single RESTRICT COMMAND on your cards prototype.

This makes for N+2 things/traits to edit, where N is the number of cards in your pool. Hence I spare you the details unless you are willing to do the grunt work.


Hi Barbanera,
the cards pool is supposed to be around 100 cards.
I really appreciate if you can write me an example with the code supposing a card name is Supergunner and the prototype Rifle :)

Is it possible to do an expression that check if a card name is already inside the deck any time a card enter the deck?

Thanks for your help :wink:
My works -> Warage GCC <-
User avatar
dawg
 
Posts: 30
Joined: November 30th, 2012, 7:54 am

Re: Deck with single card only

Postby barbanera » December 1st, 2012, 4:28 pm

1) Edit your empty deck to "allow counting of property expressions" and add the following expression:

Supergunner: cardname=Supergunner

(for the other 99 cards you would need other 99 expressions such as
Superpistol: cardname=Superpistol
Superbongo: cardname=Superbongo
Superdude: cardname=Superdude
etc)

STRONG DISCLAIMER: Vassal should work with 100 such expressions but I never personally tried it with so many expressions, use at your own risk!

2) In your Rifle prototype add a Dynamic Property called "cardname" with a command key (e.g. CTRL-V)
to set it to $BasicName$

3) In your Rifle prototype add a Restrict Command trait to "Hide" the command key associated to your Return to Deck trait (the one sending the card to the empty deck) when "<empty deck name>_$cardname$ > 0" (substitute the string <empty deck name> with the exact name of your empty deck).

4) You will also need some "start/setup" global hotkey in your toolbar or on your map itself to issue CTRL-V to all cards in the pool when you start editing; alternatively, you can do without this final step, but then step (2) above rather than a Dynamic Property in the Rifle prototype should be a Marker trait on each individual card (with name "cardname" and value the exact name of the card).

P.S. You can also use the property "<empty deck name>_numPieces" to check when at least 30 cards have been added and take appropriate action (like showing a green light or happy smiley or something..).
barbanera
 
Posts: 384
Joined: January 12th, 2012, 2:27 pm

Re: Deck with single card only

Postby dawg » December 3rd, 2012, 12:18 pm

barbanera wrote:1) Edit your empty deck to "allow counting of property expressions" and add the following expression:

Supergunner: cardname=Supergunner

(for the other 99 cards you would need other 99 expressions such as
Superpistol: cardname=Superpistol
Superbongo: cardname=Superbongo
Superdude: cardname=Superdude
etc)

STRONG DISCLAIMER: Vassal should work with 100 such expressions but I never personally tried it with so many expressions, use at your own risk!

2) In your Rifle prototype add a Dynamic Property called "cardname" with a command key (e.g. CTRL-V)
to set it to $BasicName$

3) In your Rifle prototype add a Restrict Command trait to "Hide" the command key associated to your Return to Deck trait (the one sending the card to the empty deck) when "<empty deck name>_$cardname$ > 0" (substitute the string <empty deck name> with the exact name of your empty deck).

4) You will also need some "start/setup" global hotkey in your toolbar or on your map itself to issue CTRL-V to all cards in the pool when you start editing; alternatively, you can do without this final step, but then step (2) above rather than a Dynamic Property in the Rifle prototype should be a Marker trait on each individual card (with name "cardname" and value the exact name of the card).

P.S. You can also use the property "<empty deck name>_numPieces" to check when at least 30 cards have been added and take appropriate action (like showing a green light or happy smiley or something..).


Hello, I tried your suggestions with 2 cards and they works :)
Have also made some changes: now cards are created in the main map at the start of the game with At Start Stack and if a card called X is inside the deck the card X in the map loose the Send To Deck option (it works also when you load a saved deck).

I have only one problem left: how can I prevent player from manually drag and drop cards into the deck?

Again...thanks!!!!
Attachments
deckbuilder.vmod
My Deck Builder
(7.16 KiB) Downloaded 99 times
My works -> Warage GCC <-
User avatar
dawg
 
Posts: 30
Joined: November 30th, 2012, 7:54 am

Re: Deck with single card only

Postby barbanera » December 3rd, 2012, 2:09 pm

dawg wrote:I have only one problem left: how can I prevent player from manually drag and drop cards into the deck?


In an ideal world Vassal 3.2.0 would have included a way to have stacking but unmovable pieces, thus you would just had to give the DOES NOT MOVE (or something) trait to your card to avoid drag and drop. You can give the DOES NOT STACK (with move set to "never") trait to your cards, but that might look ugly/unusable if you need your cards to actually stack (like in your empty deck).

However, nothing of the sort was implemented (Tim M who was doing work on that line seems to have given up on it) and we can only hope for Vassal 4 ;-)

In the meanwhile, I guess the pedestrian way to achieve what you want is to define a command at map level (=map properties) to be issued to pieces ending movement on the map, say CTRL-A. Then add a trigger on your cards to fire on CTRL-A when "DeckName=<empty deck name> && <empty deck name>_$cardname$ > 1 and issue, say, CTRL-B. Then add a return to deck or send to location firing on CTRL-B to return the card to the original pool. Make sure that any other piece/card elsewhere on the same map won't respond to CTRL-A doing something unexpected.
barbanera
 
Posts: 384
Joined: January 12th, 2012, 2:27 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 3 guests