3 Play klondike and spider solitaire in your unicode terminal.
5 Supports `vi` style keybindings (hjkl), cursor keys and the mouse. Press `J` to
6 'join' a well-suited pile to the cursor. `Return` pulls cards from the stack in
7 spider solitaire. Piles can also be *directly addressed* by the number below
8 them (or 8, 9, 0 for stack, waste and foundation in klondike).
9 See `$PROGNAME -h` for details.
16 * TODO: suggest moves (`h` => hint)
17 * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise
18 when calculating legal moves, top cards, etc.
20 * TODO: differential drawing mode (at least for highlighting cards)
21 * TODO: `.` command (repeat last action)
23 * TODO: mouse mode improvements:
24 - spider: detect how many cards to move to empty pile
25 (must find exact position despite `extreme_overlap`)
26 * TODO: scores, variants: draw 3, max. n overturns
27 * TODO: vt220 mode (problems: charset, slow baudrate and no differential drawing mode)
28 * TODO: ed(1) mode (solEDaire): playable on a line printer; ascii/ibm only?
31 * DONE: use `#ifdef`s to differentiate games (sol, spider, ed-sol, ed-spider)
32 * DONE: keyboard alias: twice same key == waste/pile -> foundation
33 * DONE: spider keyboard: `<from><to>` stacks; 1-9,0=tableu, return=draw
34 * DONE: spider: easy/medium difficulty: only deal 1/2 suits instead of 4 -> deal()
35 * DONE: patience: allow taking from 0(foundation)
36 * DONE: highlight `from` pile, so users can see at what input stage they are
37 * DONE: make piles 0-indexed in klondike as well
38 * DONE: duplicate card ♠A found in tableu: added check at start to monitor this
39 Cannot reproduce, removed check
40 * DONE: bugs in spider's t2t()
41 * once segfaulted on large column
42 * sometimes doesn't work (ERR when it should be OK)
44 * DONE: some input functions are in `x2y()` -- move them to `get_cmd()` (req.
45 for mouse, hjkl modes)
46 * DONE: sigint, sigcont handler! atexit() to avoid inconsistent term state
47 * DONE: hjkl keyboard mode
48 * DONE: more vim mode keys (first/last tableu)
49 * DONE: online (key-)help `?`, `-h`, `-v` (NOTE: implemented -h, rest deemed
51 * DONE: extreme overlapping: if we are printing a sequence or multiple face down
52 cards, only print `.overlap` lines of the ends, and `1` line for the
54 * DONE: in direct addressing 'up to' dialog: make return/space select the lowest/highest option
56 - insert append_undo() in x2y() functions
57 - to encode stack position we need to overload `f.u.n` as index.
58 (similar for foundation: overload `f.u.n` as foundation id)
59 - w2f(): have to encode both stock index and foundation id
60 don't want to add a struct field for this one case;
61 for the time being (i.e. forever) I'm ORing waste index and
62 (foundation id<<16). ugly but works :/
63 - turning over cards: this needs to be encoded, because the card might
64 be consecutive and there's no way to tell what its previous state was.
65 * indicate that a card was turned (can be at most 1) by negating u.n
66 pros: no wasted space (it's just a boolean value), negation pattern
67 already used for closed cards
68 cons: dirty C hack, less obvious than in other places, no need to
69 conserve memory this tightly
70 * DONE: screen size > stack height => rendering issues!
71 as good as it's going to get, since we can't just not draw cards at all
72 * DONE: 'join to here' command (should take longest chain available)
73 * DONE: expose deal() seed for restarting the game
74 * DONE: make portable (clang on FreeBSD)
75 makefile's `$<` refuses to work if prequisite name != target name
78 sed -i 's/^spider: sol.c/spider: spider.c/' Makefile
79 * DONE: escape sequences (for real cursor keys)
80 * DONE: inverted moves (if A->B doesn't work, try B->A)
81 * DONE: - allow dragging the mouse
87 {stock}[waste] [4*foundation]
90 [] (tableu piles) {} {}
98 - enum for each card (e.g. `SPADES_ACE`, `HEARTS_10`)
99 - each pile is an array holding (13 open cards + up to 6 closed)
100 [0] is the "northmost"/bottom-most card; unoccupied are NULL/NO_CARD
101 - a single card is represented in the 'cards' enum; if it is closed, it is negated.
102 - the foundation are 4 arrays of size 13
103 - the stock pile is an array holding n cards and an index to the one to display
104 when removing, decrement stack size and move all cards above index 1 over
105 - previous states array: where to move which cards to get back to the state before
107 double-linked list (follow `.prev` to undo, `.next` to redo)
108 "N cards were moved from X to Y" (do Y->X to undo)
109 allows jumping forwards in time as well (by repeating X->Y)
110 warn: when appending state, must check if `.next` was non-NULL and free rest of chain if so.
111 - multiple card sizes: schemes.h will store cards like below. if we want to draw a card
112 that has one or more other cards below it, we only draw the first `.overlap` lines,
113 otherwise if it is the last one, we draw the whole one.
114 this will give a look like in `~/solitaire-tests`
116 .grid=7, /*vertical alignment*/
133 "closed": face down card