699b896a |
1 | /* |
2 | * nullgame.c [FIXME]: Template defining the null game (in which no |
3 | * moves are permitted and nothing is ever drawn). This file exists |
4 | * solely as a basis for constructing new game definitions - it |
5 | * helps to have something which will compile from the word go and |
6 | * merely doesn't _do_ very much yet. |
7 | * |
8 | * Parts labelled FIXME actually want _removing_ (e.g. the dummy |
9 | * field in each of the required data structures, and this entire |
10 | * comment itself) when converting this source file into one |
11 | * describing a real game. |
12 | */ |
13 | |
14 | #include <stdio.h> |
15 | #include <stdlib.h> |
16 | #include <string.h> |
17 | #include <assert.h> |
b0e26073 |
18 | #include <ctype.h> |
699b896a |
19 | #include <math.h> |
20 | |
21 | #include "puzzles.h" |
22 | |
699b896a |
23 | enum { |
24 | COL_BACKGROUND, |
25 | NCOLOURS |
26 | }; |
27 | |
28 | struct game_params { |
29 | int FIXME; |
30 | }; |
31 | |
32 | struct game_state { |
33 | int FIXME; |
34 | }; |
35 | |
be8d5aa1 |
36 | static game_params *default_params(void) |
699b896a |
37 | { |
38 | game_params *ret = snew(game_params); |
39 | |
40 | ret->FIXME = 0; |
41 | |
42 | return ret; |
43 | } |
44 | |
be8d5aa1 |
45 | static int game_fetch_preset(int i, char **name, game_params **params) |
699b896a |
46 | { |
47 | return FALSE; |
48 | } |
49 | |
be8d5aa1 |
50 | static void free_params(game_params *params) |
699b896a |
51 | { |
52 | sfree(params); |
53 | } |
54 | |
be8d5aa1 |
55 | static game_params *dup_params(game_params *params) |
699b896a |
56 | { |
57 | game_params *ret = snew(game_params); |
58 | *ret = *params; /* structure copy */ |
59 | return ret; |
60 | } |
61 | |
1185e3c5 |
62 | static void decode_params(game_params *params, char const *string) |
b0e26073 |
63 | { |
b0e26073 |
64 | } |
65 | |
1185e3c5 |
66 | static char *encode_params(game_params *params, int full) |
b0e26073 |
67 | { |
68 | return dupstr("FIXME"); |
69 | } |
70 | |
be8d5aa1 |
71 | static config_item *game_configure(game_params *params) |
c8230524 |
72 | { |
73 | return NULL; |
74 | } |
75 | |
be8d5aa1 |
76 | static game_params *custom_params(config_item *cfg) |
c8230524 |
77 | { |
78 | return NULL; |
79 | } |
80 | |
3ff276f2 |
81 | static char *validate_params(game_params *params, int full) |
c8230524 |
82 | { |
83 | return NULL; |
84 | } |
85 | |
1185e3c5 |
86 | static char *new_game_desc(game_params *params, random_state *rs, |
c566778e |
87 | char **aux, int interactive) |
699b896a |
88 | { |
89 | return dupstr("FIXME"); |
90 | } |
91 | |
1185e3c5 |
92 | static char *validate_desc(game_params *params, char *desc) |
5928817c |
93 | { |
94 | return NULL; |
95 | } |
96 | |
dafd6cf6 |
97 | static game_state *new_game(midend *me, game_params *params, char *desc) |
699b896a |
98 | { |
99 | game_state *state = snew(game_state); |
100 | |
101 | state->FIXME = 0; |
102 | |
103 | return state; |
104 | } |
105 | |
be8d5aa1 |
106 | static game_state *dup_game(game_state *state) |
699b896a |
107 | { |
108 | game_state *ret = snew(game_state); |
109 | |
110 | ret->FIXME = state->FIXME; |
111 | |
112 | return ret; |
113 | } |
114 | |
be8d5aa1 |
115 | static void free_game(game_state *state) |
699b896a |
116 | { |
117 | sfree(state); |
118 | } |
119 | |
df11cd4e |
120 | static char *solve_game(game_state *state, game_state *currstate, |
c566778e |
121 | char *aux, char **error) |
2ac6d24e |
122 | { |
123 | return NULL; |
124 | } |
125 | |
fa3abef5 |
126 | static int game_can_format_as_text_now(game_params *params) |
127 | { |
128 | return TRUE; |
129 | } |
130 | |
9b4b03d3 |
131 | static char *game_text_format(game_state *state) |
132 | { |
133 | return NULL; |
134 | } |
135 | |
be8d5aa1 |
136 | static game_ui *new_ui(game_state *state) |
74a4e547 |
137 | { |
138 | return NULL; |
139 | } |
140 | |
be8d5aa1 |
141 | static void free_ui(game_ui *ui) |
74a4e547 |
142 | { |
143 | } |
144 | |
844f605f |
145 | static char *encode_ui(game_ui *ui) |
ae8290c6 |
146 | { |
147 | return NULL; |
148 | } |
149 | |
844f605f |
150 | static void decode_ui(game_ui *ui, char *encoding) |
ae8290c6 |
151 | { |
152 | } |
153 | |
07dfb697 |
154 | static void game_changed_state(game_ui *ui, game_state *oldstate, |
155 | game_state *newstate) |
156 | { |
157 | } |
158 | |
1e3e152d |
159 | struct game_drawstate { |
1f3ee4ee |
160 | int tilesize; |
1e3e152d |
161 | int FIXME; |
162 | }; |
163 | |
df11cd4e |
164 | static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, |
165 | int x, int y, int button) |
166 | { |
167 | return NULL; |
168 | } |
169 | |
170 | static game_state *execute_move(game_state *state, char *move) |
699b896a |
171 | { |
172 | return NULL; |
173 | } |
174 | |
175 | /* ---------------------------------------------------------------------- |
176 | * Drawing routines. |
177 | */ |
178 | |
1f3ee4ee |
179 | static void game_compute_size(game_params *params, int tilesize, |
180 | int *x, int *y) |
699b896a |
181 | { |
1f3ee4ee |
182 | *x = *y = 10 * tilesize; /* FIXME */ |
183 | } |
184 | |
dafd6cf6 |
185 | static void game_set_size(drawing *dr, game_drawstate *ds, |
186 | game_params *params, int tilesize) |
1f3ee4ee |
187 | { |
188 | ds->tilesize = tilesize; |
699b896a |
189 | } |
190 | |
8266f3fc |
191 | static float *game_colours(frontend *fe, int *ncolours) |
699b896a |
192 | { |
193 | float *ret = snewn(3 * NCOLOURS, float); |
194 | |
195 | frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]); |
196 | |
197 | *ncolours = NCOLOURS; |
198 | return ret; |
199 | } |
200 | |
dafd6cf6 |
201 | static game_drawstate *game_new_drawstate(drawing *dr, game_state *state) |
699b896a |
202 | { |
203 | struct game_drawstate *ds = snew(struct game_drawstate); |
204 | |
1f3ee4ee |
205 | ds->tilesize = 0; |
699b896a |
206 | ds->FIXME = 0; |
207 | |
208 | return ds; |
209 | } |
210 | |
dafd6cf6 |
211 | static void game_free_drawstate(drawing *dr, game_drawstate *ds) |
699b896a |
212 | { |
213 | sfree(ds); |
214 | } |
215 | |
dafd6cf6 |
216 | static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, |
be8d5aa1 |
217 | game_state *state, int dir, game_ui *ui, |
218 | float animtime, float flashtime) |
699b896a |
219 | { |
1d30357e |
220 | /* |
221 | * The initial contents of the window are not guaranteed and |
222 | * can vary with front ends. To be on the safe side, all games |
223 | * should start by drawing a big background-colour rectangle |
224 | * covering the whole window. |
225 | */ |
dafd6cf6 |
226 | draw_rect(dr, 0, 0, 10*ds->tilesize, 10*ds->tilesize, COL_BACKGROUND); |
699b896a |
227 | } |
228 | |
be8d5aa1 |
229 | static float game_anim_length(game_state *oldstate, game_state *newstate, |
e3f21163 |
230 | int dir, game_ui *ui) |
699b896a |
231 | { |
232 | return 0.0F; |
233 | } |
234 | |
be8d5aa1 |
235 | static float game_flash_length(game_state *oldstate, game_state *newstate, |
e3f21163 |
236 | int dir, game_ui *ui) |
699b896a |
237 | { |
238 | return 0.0F; |
239 | } |
fd1a1a2b |
240 | |
4496362f |
241 | static int game_is_solved(game_state *state) |
242 | { |
243 | return FALSE; |
244 | } |
245 | |
4d08de49 |
246 | static int game_timing_state(game_state *state, game_ui *ui) |
48dcdd62 |
247 | { |
248 | return TRUE; |
249 | } |
250 | |
dafd6cf6 |
251 | static void game_print_size(game_params *params, float *x, float *y) |
252 | { |
253 | } |
254 | |
255 | static void game_print(drawing *dr, game_state *state, int tilesize) |
256 | { |
257 | } |
258 | |
be8d5aa1 |
259 | #ifdef COMBINED |
260 | #define thegame nullgame |
261 | #endif |
262 | |
263 | const struct game thegame = { |
750037d7 |
264 | "Null Game", NULL, NULL, |
be8d5aa1 |
265 | default_params, |
266 | game_fetch_preset, |
267 | decode_params, |
268 | encode_params, |
269 | free_params, |
270 | dup_params, |
1d228b10 |
271 | FALSE, game_configure, custom_params, |
be8d5aa1 |
272 | validate_params, |
1185e3c5 |
273 | new_game_desc, |
1185e3c5 |
274 | validate_desc, |
be8d5aa1 |
275 | new_game, |
276 | dup_game, |
277 | free_game, |
2ac6d24e |
278 | FALSE, solve_game, |
fa3abef5 |
279 | FALSE, game_can_format_as_text_now, game_text_format, |
be8d5aa1 |
280 | new_ui, |
281 | free_ui, |
ae8290c6 |
282 | encode_ui, |
283 | decode_ui, |
07dfb697 |
284 | game_changed_state, |
df11cd4e |
285 | interpret_move, |
286 | execute_move, |
1f3ee4ee |
287 | 20 /* FIXME */, game_compute_size, game_set_size, |
be8d5aa1 |
288 | game_colours, |
289 | game_new_drawstate, |
290 | game_free_drawstate, |
291 | game_redraw, |
292 | game_anim_length, |
293 | game_flash_length, |
4496362f |
294 | game_is_solved, |
dafd6cf6 |
295 | FALSE, FALSE, game_print_size, game_print, |
ac9f41c4 |
296 | FALSE, /* wants_statusbar */ |
48dcdd62 |
297 | FALSE, game_timing_state, |
2705d374 |
298 | 0, /* flags */ |
be8d5aa1 |
299 | }; |