Card Game Tutorial

=Card Game Tutorial=

Besides traditional board games, VASSAL can be used to play card-based games, or games that are a mix of both. In this tutorial, we will go through the steps for making a VASSAL module for a pure card game called Raj. Data for this module is in the file.

Raj is a bidding game. Each player maintains a hand of cards with values 1-15 and bids for a set of tiles that are revealed one at a time. We will make one map window for the main playing area. This will be where the tiles are revealed and each players bid cards are placed. In addition, we will make one window for each player to hold his current hand of cards in.

The Playing Area
Since each module begins with a map window by default, we'll make that one into the playing area. Double-click on the Map Window node and name it "Playing Area." We'll make the playing area blank, but with a definite size. Right-click on the Map Boards node and select "Add Board." Set the size to 800x800 and set the background color to a greyish blue. The name of the board doesn't matter in this case. Also delete the Image Capture Tool from the Map Window, since that's not really necessary for a card game.

Defining the Sides
Now we need to specify what sides are available for players in the game. Right-click on the Module node and select "Define Available Sides." In the box at the bottom, type "Red" and hit return (or the Add button). Do the same for "Green," "Blue," and "Purple." When players load a saved game or join one on the live server, they'll be prompted which side they want to take, or whether they just want to be an observer.



Windows for Player Hands

Now for each side, we'll create a window for that player's hand of cards. Right-click on the Module node and select "Add Player Hand." For the name, enter "Red's Hand." For the owning side, enter "Red." This will mean that only the player playing Red will be able to change the contents of this window. Also leave the "visible to other players" box unchecked. This will mean that other players won't even see the window. Leave the rest of the fields blank. It's possible to give these windows an image for a background by specifying a board, but we'll simply leave the background blank.

Right-click on the "Red's Hand" node and clone it three times. Then double-click on each node. Rename one "Green's Hand" and set the owning player to "Green" and do the same for Blue and Purple. This completes the setup for each player's hand.

Making the Cards

VASSAL board games draw counters from the Game Piece Palette, with an unlimited supply of each counter. This is not appropriate for card games. Right-click on the Game Piece Palette node and delete it.

Decks of cards are added directly to a Map Window in VASSAL. Cards added to a deck in the Configuration Window will be in the deck when a game is begun. Players click on a deck to drag the top card to their hands or a playing area. Right-clicking on a deck lets players turn it face-up or face-down, shuffle it, or reverse the order of cards in it.

For this module we will create one deck that contains the tiles the players are bidding for and one deck for each player's set of cards.

The deck of tiles goes in the middle of the playing area. Right-click on the Playing Area map node and select "Add Deck." Put the position in the middle of the map, at 400,400. The size is only used when the deck is empty, so that players can place cards back into the deck. We'll use the size of one of our tiles, 70x94. Now right-click on the Tile Deck node and select "Add Card" to add the first card to the deck.

Cards in VASSAL are built the same way as counters. The simplest card is a Basic Piece with the Mask trait. The image of the Basic Piece will be the front of the card and the image for the Mask will be the reverse of the card. Select "tile1.gif" in the rajData directory for the front and "tileBack.gif" for the back. If we needed more features for our cards, such as the ability to rotate them sideways or place markers on them, that could be done by adding more traits (they should go before the Mask trait if you want them to only show when the card is face up. We only need simple cards for this tutorial.

Now right-click on the tile you just made and clone it. Double-click on the clone and edit the Basic Piece properties. Select "tile2.gif" for the front of this card. Repeat this until you've created cards for tile1.gif through tile10.gif and tile_1.gif through tile_5.gif.

For the tiles we needed a different image for every card. We can save some steps when creating the players' decks. The players' cards are simply numbered 1-15 on the front, so we'll use a Text Label trait to write the number on a common background image.

Right-click on the Playing Area node to create another Deck. We'll make this the deck of Red's cards and put it at 400,150 with size 150x240. Right-click to add a new Card. Use FrontRed.gif for the front and RedBack.gif for the back. Now select "Text Label" from the list on the left and hit "Add." This will be a permanent label so set the Text to "1" and make the Menu Command blank. Set the font size to 52. Set the Text color to black and the background color to white. Set the vertical and horizontal position and the vertical and horizontal justifications all to "Center." Now with the "Text Label" selected in the list on the right, hit the "Move Up" button. This will ensure that the number is not showing when the card is face down.Now clone the card until you have 15 of them. Edit each one and set the text of the label to run from "1" to "15."

Having made the Red deck, the others follow quickly. Right-click on the node for the Red Deck and clone it. This will become the Green deck. Double-click on the Green Deck node and set its position to 700,400. VASSAL provides a convenient feature to edit many pieces at one. Right-click on the Green deck and select "Edit all contained Pieces". You'll see the properties window for the first card, but all changes you make in this window will apply to all cards in the deck. Set the front image to FrontGreen.gif and the back to GreenBack.gif. Voila! Do the same for the Blue and Purple decks.

During Play

To play, one of the players turns the first tile in the deck face up. Then each player selects a card from their hand, turns it face down, and drags it to the playing area. All players then reveal their cards simultaneously. The highest card wins the tile, but cards of the same value cancel each other out. For example, if the players play 12,6,8,12, the 8 wins. The playing buying the tile moves it to his area in the playing area and the used cards are deleted. After all tiles have been bought, the player with the highest tile total wins.