]>
git.gir.st - solVItaire.git/blob - sol.h
4 // enums and constants {{{
8 #define MAX_HIDDEN 6 /*how many cards are turned over at most in a tableu pile*/
9 #define MAX_STOCK 24 /*how many cards can be in the stock at most (=@start)*/
11 #define PILE_SIZE MAX_HIDDEN+NUM_RANKS
15 #define MAX_STOCK 50 /*how many cards can be dealt onto the piles*/
17 #define PILE_SIZE DECK_SIZE*NUM_DECKS /* no maximum stack size in spider :/ */
22 CLU_A
, DIA_A
, HEA_A
, SPA_A
,
23 CLU_2
, DIA_2
, HEA_2
, SPA_2
,
24 CLU_3
, DIA_3
, HEA_3
, SPA_3
,
25 CLU_4
, DIA_4
, HEA_4
, SPA_4
,
26 CLU_5
, DIA_5
, HEA_5
, SPA_5
,
27 CLU_6
, DIA_6
, HEA_6
, SPA_6
,
28 CLU_7
, DIA_7
, HEA_7
, SPA_7
,
29 CLU_8
, DIA_8
, HEA_8
, SPA_8
,
30 CLU_9
, DIA_9
, HEA_9
, SPA_9
,
31 CLU_X
, DIA_X
, HEA_X
, SPA_X
,
32 CLU_J
, DIA_J
, HEA_J
, SPA_J
,
33 CLU_Q
, DIA_Q
, HEA_Q
, SPA_Q
,
34 CLU_K
, DIA_K
, HEA_K
, SPA_K
,
67 OK
, /*move successful*/
77 /* WARN: stock must always follow immediately after `TAB_*`! */
78 #define TAB_MAX (STOCK-1)
92 #define WASTE 0 /* for action[][10] (must be valid index) */
93 #define TABLEU STOCK+1 /* for undo{.t} (value never read) */
94 #define FOUNDATION STOCK+2 /* for undo{.t} (must be unique) */
95 #elif defined KLONDIKE
121 typedef signed char card_t
;
124 card_t s
[MAX_STOCK
]; /* stock */
125 int z
; /* stock size */
126 int w
; /* waste; index into stock (occupied foundations in spider) */
127 card_t f
[NUM_DECKS
*NUM_SUITS
][PILE_SIZE
]; /* foundation */
128 card_t t
[NUM_PILES
][PILE_SIZE
]; /* tableu piles */
130 int f
; /* pile cards were taken from */
131 int t
; /* pile cards were moved to */
132 int n
; /* if tableu: number of cards moved */
133 /* else: index into stock/foundation */
134 int o
; /* turn_over() fired? */
141 int m
; /* difficulty mode */
143 unsigned short w
[2]; /* terminal window rows/columns */
144 const struct scheme
* s
;
148 int opt
; /* klondike: foundation id; spider: move nth movable card */
150 const struct cursor no_hi
= {-1, -1};
153 struct undo undo_sentinel
;
156 #define SHORTHELP "%s [OPTIONS]\n"
158 #define LONGHELP_SPECIFIC ""
159 #define DIRECT_ADDR_KEYHELP \
160 " 1 .. 7: directly address tableu\n" \
161 " 8,9,0 : directly address stock/waste/foundation\n"
163 #define LONGHELP_SPECIFIC \
164 " -s(uits) <1, 2 or 4>\n"
165 #define DIRECT_ADDR_KEYHELP \
166 " 1 .. 0: directly address tableu\n"
171 " -b(land colorscheme)\n" \
172 " -c(olorful colorscheme)\n" \
173 " -m(iniature colorscheme)\n" \
178 " hjkl : move cursor\n" \
179 " H,M,L : move cursor to first/centre/last tableu pile\n" \
180 /*" J, K : join to here, show hint\n" */\
181 " space : select at cursor\n" \
182 " return: draw from stock\n" \
190 int find_top(card_t
* pile
);
191 int first_movable(card_t
* pile
);
192 int turn_over(card_t
* pile
);
194 int rank_next (card_t a
, card_t b
);
195 int is_consecutive (card_t
* pile
, int pos
);
196 int is_movable(card_t
* pile
, int n
);
198 card_t
stack_take(void);
199 int t2f(int from
, int to
, int opt
);
200 int w2f(int from
, int to
, int opt
);
201 int s2w(int from
, int to
, int opt
);
202 int w2s(int from
, int to
, int opt
);
203 int f2t(int from
, int to
, int opt
);
204 int w2t(int from
, int to
, int opt
);
205 int t2t(int from
, int to
, int opt
);
207 int remove_if_complete (int pileno
);
208 int t2t(int from
, int to
, int opt
);
209 int s2t(int from
, int to
, int opt
);
210 int t2f(int from
, int to
, int opt
);
212 int nop(int from
, int to
, int opt
);
213 void cursor_left (struct cursor
* cursor
);
214 void cursor_down (struct cursor
* cursor
);
215 void cursor_up (struct cursor
* cursor
);
216 void cursor_right (struct cursor
* cursor
);
217 int get_cmd (int* from
, int* to
, int* opt
);
219 void print_hi(int invert
, int grey_bg
, int bold
, char* str
);
220 void print_table(const struct cursor
* active
, const struct cursor
* inactive
);
223 void undo_push (int f
, int t
, int n
, int o
);
224 void undo_pop (struct undo
* u
);
225 void free_undo (struct undo
* u
);
226 void screen_setup (int enable
);
227 void raw_mode(int enable
);
228 void signal_handler (int signum
);
229 void signal_setup(void);