]>
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
116 /* for getctrlseq() */
144 typedef signed char card_t
;
147 int z
; /* stock size */
148 int w
; /* waste; index into stock (occupied foundations in spider) */
149 card_t s
[MAX_STOCK
]; /* stock */
150 card_t f
[NUM_DECKS
*NUM_SUITS
][PILE_SIZE
]; /* foundation */
151 card_t t
[NUM_PILES
][PILE_SIZE
]; /* tableu piles */
153 int f
; /* pile cards were taken from */
154 int t
; /* pile cards were moved to */
155 int n
; /* if tableu: number of cards moved */
156 /* else: index into stock/foundation */
157 int o
; /* turn_over() fired? */
164 int m
; /* difficulty mode */
166 unsigned short w
[2]; /* terminal window rows/columns */
167 const struct scheme
* s
;
168 int h
; /* show active highlight? (disabled when mouse used) */
169 int v
; /* (simulated) visbell enabled? */
173 int opt
; /* klondike: foundation id; spider: move nth movable card */
175 const struct cursor no_hi
= {-1, -1};
178 struct undo undo_sentinel
;
181 #define SHORTHELP "%s [OPTIONS]\n"
183 #define LONGHELP_SPECIFIC ""
184 #define DIRECT_ADDR_KEYHELP \
185 " 1 .. 7: directly address tableu\n" \
186 " 8,9,0 : directly address stock/waste/foundation\n"
188 #define LONGHELP_SPECIFIC \
189 " -s(uits) <1, 2 or 4>\n"
190 #define DIRECT_ADDR_KEYHELP \
191 " 1 .. 0: directly address tableu\n"
196 " -b(land colorscheme)\n" \
197 " -c(olorful colorscheme)\n" \
198 " -m(iniature colorscheme)\n" \
199 " -V(isual bell disable; experimental)\n" \
204 " hjkl : move cursor (or cursor keys)\n" \
205 " H,M,L : move cursor to first/centre/last tableu pile (or home/ins/end)\n" \
206 " J : join to here (or right mouse click)\n" \
207 /*" K : show hint\n" */\
208 " space : select at cursor (or left mouse click)\n" \
209 " return: draw from stock\n" \
211 " :r : restart game\n" \
212 " :h : show keyboard help\n" \
219 int find_top(card_t
* pile
);
220 int first_movable(card_t
* pile
);
221 int turn_over(card_t
* pile
);
223 int rank_next (card_t a
, card_t b
);
224 int is_consecutive (card_t
* pile
, int pos
);
225 int is_movable(card_t
* pile
, int n
);
227 card_t
stack_take(void);
228 int t2f(int from
, int to
, int opt
);
229 int w2f(int from
, int to
, int opt
);
230 int s2w(int from
, int to
, int opt
);
231 int w2s(int from
, int to
, int opt
);
232 int f2t(int from
, int to
, int opt
);
233 int w2t(int from
, int to
, int opt
);
234 int t2t(int from
, int to
, int opt
);
236 int remove_if_complete (int pileno
);
237 int t2t(int from
, int to
, int opt
);
238 int s2t(int from
, int to
, int opt
);
239 int t2f(int from
, int to
, int opt
);
242 int nop(int from
, int to
, int opt
);
243 void cursor_left (struct cursor
* cursor
);
244 void cursor_down (struct cursor
* cursor
);
245 void cursor_up (struct cursor
* cursor
);
246 void cursor_right (struct cursor
* cursor
);
247 void cursor_to (struct cursor
* cursor
, int pile
);
248 int set_mouse(int pile
, int* main
, int* opt
);
249 int get_cmd (int* from
, int* to
, int* opt
);
250 int getctrlseq(unsigned char* buf
);
251 int term2pile(unsigned char *mouse
);
252 int wait_mouse_up(unsigned char* mouse
);
253 int getch(unsigned char* buf
);
254 void deal(long seed
);
255 void print_hi(int invert
, int grey_bg
, int bold
, char* str
);
256 void print_table(const struct cursor
* active
, const struct cursor
* inactive
);
259 void undo_push (int f
, int t
, int n
, int o
);
260 void undo_pop (struct undo
* u
);
261 void free_undo (struct undo
* u
);
262 void screen_setup (int enable
);
263 void raw_mode(int enable
);
264 void signal_handler (int signum
);
265 void signal_setup(void);