Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CardsMarkup

Summary: Markup suitable for displaying playing card games (e.g., contract bridge)
Version: 2007-04-22
Prerequisites: pmwiki-2
Status: Stable
Maintainer: Pm
Categories: Markup

Questions answered by this recipe

  • How can I easily display information about card games such as contract bridge?

Description

The cards.zipΔ recipe provides markups to make it easy to display playing card suits and players' hands in a variety of layout formats. For example, with this recipe one can easily write things such as:

s 6 2 
h K Q 9 4 
d Q 5 
c A 8 5 4 2
s A Q J 10 3 
h 8 7 3 
d J 10 2 
c Q 7
s 9 8 7 5 
h 5 
d K 9 8 7 4 
c J 9 3
s K 4 
h A J 10 6 2 
d A 6 3 
c K 10 6
SouthWestNorthEast
1 h1 s2 c2 s
PassPass3 hPass
4 hAll Pass

Opening Lead: d J

Displaying card suits

This recipe defines the markups " s ", " h ", " d ", and " c " as shortcut notations for card suits like spades ( s ), hearts ( h ), diamonds ( d ), and clubs ( c ). The spaces around each of s, h, d, and c are required. With this, one can easily create things such as:

Inline suit markers

Bid 1 h , the suit below the doubleton.  If partner bids 2 c , your rebid
is 2 d , permitting partner to return to 2 h cheaply.

Bid 1 h , the suit below the doubleton. If partner bids 2 c , your rebid is 2 d , permitting partner to return to 2 h cheaply.

Displaying a hand

Display of hands is performed using the (:cards:) directive. Hands are specified by entering the cards of each suit separated by dots. The ten may be specified as either "T" or "10". To display an empty (void) suit, simply omit cards from that suit. Thus a specification of (:cards k487.ajt62..kt65:) results in:

s K 4 8 7 
h A J 10 6 2 
d 
c K 10 6 5

To display several players' hands at once, simply combine the hands separated by spaces. By default the first hand given is "North", but a hand's position may be specified by prefixing it with one of "N:", "E:", "S:", or "W:". Subsequent hands are taken as being the next position clockwise from the previous position.


(:cards "W:.63.AKQ987.A9732 A8654.KQ5.T.QJT6 J973.J98742.3.K4
KQT2.AT.J6542.85" :)

s A 8 6 5 4 
h K Q 5 
d 10 
c Q J 10 6
s 
h 6 3 
d A K Q 9 8 7 
c A 9 7 3 2
s J 9 7 3 
h J 9 8 7 4 2 
d 3 
c K 4
s K Q 10 2 
h A 10 
d J 6 5 4 2 
c 8 5

To suppress the display of one or more of the hands, use a hyphen:

Displaying only West and East hands

(:cards "W:.63.AKQ987.A9732 - J973.J98742.3.K4 -" :)

s 
h 6 3 
d A K Q 9 8 7 
c A 9 7 3 2
s J 9 7 3 
h J 9 8 7 4 2 
d 3 
c K 4

Similarly, use a hyphen to suppress the display of a suit altogether (as opposed to simply showing an empty or void suit):

Distribution of hearts

(:cards "W:-.63.-.- -.KQ5.-.- -.J98742.-.- -.AT.-.-" :)

 
h K Q 5
 
h 6 3
 
h J 9 8 7 4 2
 
h A 10

Notes

  • The notation used for representing cards is based on Portable Bridge Notation (PBN).
    Homepage of PBN

Release Notes

Comments

PKHG speaking: To make the recipe even more superb one needs some more possibilities: On a series on hands at the top left edge one would like to add some information:

Nr.: ?<-- some info of which hand
N/-<-- dealer/vulnarability

And if all 4 hands are shown, one would like to see (for clarity) North, East, South, West (in the language of the country).

See Also

Contributors

Sandbox

Feel free to experiment with the card markups below.

Edit - History - Print - Recent Changes - Search
Page last modified on May 06, 2007, at 01:48 AM