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