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 | |
be8d5aa1 |
62 | static game_params *decode_params(char const *string) |
b0e26073 |
63 | { |
64 | game_params *ret = snew(game_params); |
65 | |
66 | ret->FIXME = 0; |
67 | |
68 | return ret; |
69 | } |
70 | |
be8d5aa1 |
71 | static char *encode_params(game_params *params) |
b0e26073 |
72 | { |
73 | return dupstr("FIXME"); |
74 | } |
75 | |
be8d5aa1 |
76 | static config_item *game_configure(game_params *params) |
c8230524 |
77 | { |
78 | return NULL; |
79 | } |
80 | |
be8d5aa1 |
81 | static game_params *custom_params(config_item *cfg) |
c8230524 |
82 | { |
83 | return NULL; |
84 | } |
85 | |
be8d5aa1 |
86 | static char *validate_params(game_params *params) |
c8230524 |
87 | { |
88 | return NULL; |
89 | } |
90 | |
6f2d8d7c |
91 | static char *new_game_seed(game_params *params, random_state *rs, |
92 | game_aux_info **aux) |
699b896a |
93 | { |
94 | return dupstr("FIXME"); |
95 | } |
96 | |
2ac6d24e |
97 | static void game_free_aux_info(game_aux_info *aux) |
6f2d8d7c |
98 | { |
99 | assert(!"Shouldn't happen"); |
100 | } |
101 | |
be8d5aa1 |
102 | static char *validate_seed(game_params *params, char *seed) |
5928817c |
103 | { |
104 | return NULL; |
105 | } |
106 | |
be8d5aa1 |
107 | static game_state *new_game(game_params *params, char *seed) |
699b896a |
108 | { |
109 | game_state *state = snew(game_state); |
110 | |
111 | state->FIXME = 0; |
112 | |
113 | return state; |
114 | } |
115 | |
be8d5aa1 |
116 | static game_state *dup_game(game_state *state) |
699b896a |
117 | { |
118 | game_state *ret = snew(game_state); |
119 | |
120 | ret->FIXME = state->FIXME; |
121 | |
122 | return ret; |
123 | } |
124 | |
be8d5aa1 |
125 | static void free_game(game_state *state) |
699b896a |
126 | { |
127 | sfree(state); |
128 | } |
129 | |
2ac6d24e |
130 | static game_state *solve_game(game_state *state, game_aux_info *aux, |
131 | char **error) |
132 | { |
133 | return NULL; |
134 | } |
135 | |
9b4b03d3 |
136 | static char *game_text_format(game_state *state) |
137 | { |
138 | return NULL; |
139 | } |
140 | |
be8d5aa1 |
141 | static game_ui *new_ui(game_state *state) |
74a4e547 |
142 | { |
143 | return NULL; |
144 | } |
145 | |
be8d5aa1 |
146 | static void free_ui(game_ui *ui) |
74a4e547 |
147 | { |
148 | } |
149 | |
be8d5aa1 |
150 | static game_state *make_move(game_state *from, game_ui *ui, int x, int y, |
151 | int button) |
699b896a |
152 | { |
153 | return NULL; |
154 | } |
155 | |
156 | /* ---------------------------------------------------------------------- |
157 | * Drawing routines. |
158 | */ |
159 | |
160 | struct game_drawstate { |
161 | int FIXME; |
162 | }; |
163 | |
be8d5aa1 |
164 | static void game_size(game_params *params, int *x, int *y) |
699b896a |
165 | { |
166 | *x = *y = 200; /* FIXME */ |
167 | } |
168 | |
be8d5aa1 |
169 | static float *game_colours(frontend *fe, game_state *state, int *ncolours) |
699b896a |
170 | { |
171 | float *ret = snewn(3 * NCOLOURS, float); |
172 | |
173 | frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]); |
174 | |
175 | *ncolours = NCOLOURS; |
176 | return ret; |
177 | } |
178 | |
be8d5aa1 |
179 | static game_drawstate *game_new_drawstate(game_state *state) |
699b896a |
180 | { |
181 | struct game_drawstate *ds = snew(struct game_drawstate); |
182 | |
183 | ds->FIXME = 0; |
184 | |
185 | return ds; |
186 | } |
187 | |
be8d5aa1 |
188 | static void game_free_drawstate(game_drawstate *ds) |
699b896a |
189 | { |
190 | sfree(ds); |
191 | } |
192 | |
be8d5aa1 |
193 | static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, |
194 | game_state *state, int dir, game_ui *ui, |
195 | float animtime, float flashtime) |
699b896a |
196 | { |
1d30357e |
197 | /* |
198 | * The initial contents of the window are not guaranteed and |
199 | * can vary with front ends. To be on the safe side, all games |
200 | * should start by drawing a big background-colour rectangle |
201 | * covering the whole window. |
202 | */ |
203 | draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND); |
699b896a |
204 | } |
205 | |
be8d5aa1 |
206 | static float game_anim_length(game_state *oldstate, game_state *newstate, |
207 | int dir) |
699b896a |
208 | { |
209 | return 0.0F; |
210 | } |
211 | |
be8d5aa1 |
212 | static float game_flash_length(game_state *oldstate, game_state *newstate, |
213 | int dir) |
699b896a |
214 | { |
215 | return 0.0F; |
216 | } |
fd1a1a2b |
217 | |
be8d5aa1 |
218 | static int game_wants_statusbar(void) |
fd1a1a2b |
219 | { |
220 | return FALSE; |
221 | } |
be8d5aa1 |
222 | |
223 | #ifdef COMBINED |
224 | #define thegame nullgame |
225 | #endif |
226 | |
227 | const struct game thegame = { |
1d228b10 |
228 | "Null Game", NULL, |
be8d5aa1 |
229 | default_params, |
230 | game_fetch_preset, |
231 | decode_params, |
232 | encode_params, |
233 | free_params, |
234 | dup_params, |
1d228b10 |
235 | FALSE, game_configure, custom_params, |
be8d5aa1 |
236 | validate_params, |
237 | new_game_seed, |
6f2d8d7c |
238 | game_free_aux_info, |
be8d5aa1 |
239 | validate_seed, |
240 | new_game, |
241 | dup_game, |
242 | free_game, |
2ac6d24e |
243 | FALSE, solve_game, |
9b4b03d3 |
244 | FALSE, game_text_format, |
be8d5aa1 |
245 | new_ui, |
246 | free_ui, |
247 | make_move, |
248 | game_size, |
249 | game_colours, |
250 | game_new_drawstate, |
251 | game_free_drawstate, |
252 | game_redraw, |
253 | game_anim_length, |
254 | game_flash_length, |
255 | game_wants_statusbar, |
256 | }; |