]> git.gir.st - solVItaire.git/blob - README.md
remove redundant display calls
[solVItaire.git] / README.md
1 # solVIItaire
2
3 play klondike and spider solitaire in your unicode terminal.
4
5 ## TODO
6
7 ### P1
8 * TODO: in direct addressing 'up to' dialog: make return/space select the lowest/highest option
9 ### P2
10 * TODO: undo:
11 - insert append_undo() in x2y() functions
12 - to encode stack position we need to overload `f.u.n` as index.
13 (similar for foundation: overload `f.u.n` as foundation id)
14 - w2f(): have to encode both stock index and foundation id <-XXX
15 don't want to add a struct field for this one case;
16 for the time being (i.e. forever) I'm ORing waste index and
17 (foundation id<<16). ugly but works :/
18 - turning over cards: this needs to be encoded, because the card might
19 be consecutive and there's no way to tell what its previous state was.
20 at least 3 methods possible:
21 * indicate that a card was turned (can be at most 1) by negating u.n
22 pros: no wasted space (it's just a boolean value), negation pattern
23 already used for closed cards
24 cons: dirty C hack, less obvious than in other places, no need to
25 conserve memory this tightly
26 - another flag in f.u (.c for was-closed?)
27 pros: a little bit more obvious
28 cons: seems like a clutch to me, won't do anything in most cases
29 - two undo structures (where .f == .t for example; auto-apply both)
30 pros: no need to modify structures
31 cons: more burden on changing x2y(), need to check if we need to
32 execute two undos (or redos) at once everytime
33 will use the starred method (negating), because a) the code is
34 hackish aleady b) further cements the idea that .n is not just a
35 'number of cards' but an argument that changes form depending on the
36 context. also, c) i don't like the other two options, because reasons.
37 * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise
38 when calculating legal moves, top cards, etc.
39 ### P3
40 * TODO: mouse mode
41 * TODO: screen size > stack height => rendering issues!
42 * TODO: suggest moves (`h` => hint)
43 ### P4
44 * TODO: scores, variants: draw 3, max. n overturns
45 * TODO: vt220 mode (problems: charset, slow baudrate and no differential drawing mode)
46 * TODO: ed(1) mode (solEDaire): playable on a line printer; ascii/ibm only?
47
48 ### DONE
49 * DONE: use `#ifdef`s to differentiate games (sol, spider, ed-sol, ed-spider)
50 * DONE: keyboard alias: twice same key == waste/pile -> foundation
51 * DONE: spider keyboard: `<from><to>` stacks; 1-9,0=tableu, return=draw
52 * DONE: spider: easy/medium difficulty: only deal 1/2 suits instead of 4 -> deal()
53 * DONE: patience: allow taking from 0(foundation)
54 * DONE: highlight `from` pile, so users can see at what input stage they are
55 * DONE: make piles 0-indexed in klondike as well
56 * HOLD: duplicate card ♠A found in tableu: added check at start to monitor this
57 Cannot reproduce, removed check
58 * HOLD: bugs in spider's t2t()
59 * once segfaulted on large column
60 * sometimes doesn't work (ERR when it should be OK)
61 Cannot reproduce
62 * DONE: some input functions are in `x2y()` -- move them to `get_cmd()` (req.
63 for mouse, hjkl modes)
64 * DONE: sigint, sigcont handler! atexit() to avoid inconsistent term state
65 * DONE: hjkl keyboard mode
66 * DONE: more vim mode keys (first/last tableu)
67 * DONE: online (key-)help `?`, `-h`, `-v` (NOTE: implemented -h, rest deemed
68 not usedul)
69 * DONE: extreme overlapping: if we are printing a sequence or multiple face down
70 cards, only print `.overlap` lines of the ends, and `1` line for the
71 middle cards
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