Ordinal - lcrocker/ojpoker GitHub Wiki
Ordinal
An ordinal is an integer type used to represent cards (in Dart that's int
, in Rust, u8
),
shown in the table below.
Note that using these values has several advantages: Suit can be computed with a simple
& 3
and Rank with a simple >> 2
if necessary, but it often won't be, because comparing
whole ordinals has the effect of comparing ranks. Also, the placement of these codes is such
that the rank of deuce is 2, trey is 3, etc. to simplify add-em-up games like baccarat and blackjack.
These ordinals are also in the same order as "high card by suit" order often used in Poker games to
determine dealer position, bring-ins, and other things.
Value | Card |
---|---|
1 | White/Blue third joker |
2 | Black/Uncolored second joker |
3 | Red/Colored default joker |
4 | Ace of clubs (low, see below) |
5 | Ace of diamonds (low) |
6 | Ace of hearts (low) |
7 | Ace of spades (low) |
8 | Deuce of clubs |
9 | Deuce of diamonds |
10 | Deuce of hearts |
11 | Deuce of spades |
12 | Trey of clubs |
13 | Trey of diamonds |
. . . | . . . |
46 | Jack of Hearts |
47 | Jack of spades |
48 | Knight / Cavalier of spades |
49 | Knight of diamonds |
50 | Knight of hearts |
51 | Knight of spades |
52 | Queen of clubs |
53 | Queen of diamonds |
54 | Queen of hearts |
55 | Queen of spades |
56 | King of clubs |
57 | King of diamonds |
58 | King of hearts |
59 | King of spades |
60 | Ace of clubs (high, see below) |
61 | Ace of diamonds (high) |
62 | Ace of hearts (high) |
63 | Ace of spades (high) |
64..47 | (TBD) Tarot Nouveau trumps |
48..71 | (TBD) Tarot de Marseilles trumps? |
Aces are high by default; hands being read from text files, for example, will put aces into the 60..63 slots. But many games play aces low, so I reserve the 1 rank for those games and put aces there to make comparisons faster. The library makes this nearly automatic for most games.
Knights complicate things a little bit. Most decks (even European ones) have only three face cards, but there are a few with all four (such as the Tarot de Marseilles), so I leave room for four.
Jokers and tarot trumps have neither rank nor suit. English/American decks of cards typically contain two jokers: one is drawn in plain black ink, and the other is more colorful. We call the former the #2 "black" joker, and the latter the #3 "red" joker, for games like Dou Dizhou which distinguish them. I don't know of any games requiring three distinguished jokers, but Unicode seems to think there is, so that's my joker #1. If there is just one joker, we use the red/colorful one.