]> git.gir.st - solVItaire.git/blob - README.md
comments on the undo feature
[solVItaire.git] / README.md
1 # solVIItaire
2
3 play klondike and spider solitaire in your unicode terminal.
4
5 ## TODO
6
7 ### P1
8 ### P2
9 * TODO: undo:
10 - insert append_undo() in x2y() functions
11 - to encode stack position we need to overload `f.u.n` as index.
12 (similar for foundation: overload `f.u.n` as foundation id)
13 - turning over cards: this needs to be encoded, because the card might
14 be consecutive and there's no way to tell what its previous state was.
15 at least 3 methods possible:
16 * indicate that a card was turned (can be at most 1) by negating u.n
17 pros: no wasted space, negation pattern already used for closed cards
18 cons: dirty C hack, less obvious than in other places, no need to
19 conserve memory this tightly
20 - another flag in f.u (.c for was-closed?)
21 pros: a little bit more obvious
22 cons: seems like a clutch to me, won't do anything in most cases
23 - two undo structures (where .f == .t for example; auto-apply both)
24 pros: no need to modify structures
25 cons: more burden on changing x2y(), need to check if we need to
26 execute two undos (or redos) at once everytime
27 will use the starred method (negating), because a) the code is
28 hackish aleady b) further cements the idea that .n is not just a
29 'number of cards' but an argument that changes form depending on the
30 context. also, c) i don't like the other two options, because reasons.
31 * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise
32 when calculating legal moves, top cards, etc.
33 ### P3
34 * TODO: mouse mode
35 * TODO: screen size > stack height => rendering issues!
36 * TODO: suggest moves (`h` => hint)
37 ### P4
38 * TODO: scores, variants: draw 3, max. n overturns
39 * TODO: vt220 mode (problems: charset, slow baudrate and no differential drawing mode)
40 * TODO: ed(1) mode (solEDaire): playable on a line printer; ascii/ibm only?
41
42 ### DONE
43 * DONE: use `#ifdef`s to differentiate games (sol, spider, ed-sol, ed-spider)
44 * DONE: keyboard alias: twice same key == waste/pile -> foundation
45 * DONE: spider keyboard: `<from><to>` stacks; 1-9,0=tableu, return=draw
46 * DONE: spider: easy/medium difficulty: only deal 1/2 suits instead of 4 -> deal()
47 * DONE: patience: allow taking from 0(foundation)
48 * DONE: highlight `from` pile, so users can see at what input stage they are
49 * DONE: make piles 0-indexed in klondike as well
50 * HOLD: duplicate card ♠A found in tableu: added check at start to monitor this
51 Cannot reproduce, removed check
52 * HOLD: bugs in spider's t2t()
53 * once segfaulted on large column
54 * sometimes doesn't work (ERR when it should be OK)
55 Cannot reproduce
56 * DONE: some input functions are in `x2y()` -- move them to `get_cmd()` (req.
57 for mouse, hjkl modes)
58 * DONE: sigint, sigcont handler! atexit() to avoid inconsistent term state
59 * DONE: hjkl keyboard mode
60 * DONE: more vim mode keys (first/last tableu)
61 * DONE: online (key-)help `?`, `-h`, `-v` (NOTE: implemented -h, rest deemed
62 not usedul)
63 * DONE: extreme overlapping: if we are printing a sequence or multiple face down
64 cards, only print `.overlap` lines of the ends, and `1` line for the
65 middle cards
66
67 ## Notes
68
69 - terminology:
70 ```
71 {stock}[waste] [4*foundation]
72
73 [] {} {} {} {} {} {}
74 [] (tableu piles) {} {}
75 [] {} {} {} {}
76 [] {} {} {}
77 [] {} {}
78 [] {}
79 []
80 ```
81 - data structures:
82 - enum for each card (e.g. `SPADES_ACE`, `HEARTS_10`)
83 - each pile is an array holding (13 open cards + up to 6 closed)
84 [0] is the "northmost"/bottom-most card; unoccupied are NULL/NO_CARD
85 - a single card is represented in the 'cards' enum; if it is closed, it is negated.
86 - the foundation are 4 arrays of size 13
87 - the stock pile is an array holding n cards and an index to the one to display
88 when removing, decrement stack size and move all cards above index 1 over
89 - previous states array: where to move which cards to get back to the state before
90 - undo:
91 double-linked list (follow `.prev` to undo, `.next` to redo)
92 "N cards were moved from X to Y" (do Y->X to undo)
93 allows jumping forwards in time as well (by repeating X->Y)
94 warn: when appending state, must check if `.next` was non-NULL and free rest of chain if so.
95 - multiple card sizes: schemes.h will store cards like below. if we want to draw a card
96 that has one or more other cards below it, we only draw the first `.overlap` lines,
97 otherwise if it is the last one, we draw the whole one.
98 this will give a look like in `~/solitaire-tests`
99 ```
100 .grid=7, /*vertical alignment*/
101 .overlap=2,
102 .cards = [
103 ["╭───╮",
104 "│♠ X│",
105 "│ ♠ │",
106 "╰───╯",
107 NULL],
108 ]
109 /*or:*/
110 .grid=2,
111 .overlap=1,
112 .cards = [
113 [ "🃖 ", NULL ],
114 ]
115 ```
116 "open": face up card
117 "closed": face down card
Imprint / Impressum