A user asked for the < signs in Unequal to be bolder.
[sgt-puzzles/ydirson.git] / nullgame.c
blob118cefe43bc30d64637d36c882c681e4be4fe6a6
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.
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <assert.h>
18 #include <ctype.h>
19 #include <math.h>
21 #include "puzzles.h"
23 enum {
24 COL_BACKGROUND,
25 NCOLOURS
28 struct game_params {
29 int FIXME;
32 struct game_state {
33 int FIXME;
36 static game_params *default_params(void)
38 game_params *ret = snew(game_params);
40 ret->FIXME = 0;
42 return ret;
45 static int game_fetch_preset(int i, char **name, game_params **params)
47 return FALSE;
50 static void free_params(game_params *params)
52 sfree(params);
55 static game_params *dup_params(game_params *params)
57 game_params *ret = snew(game_params);
58 *ret = *params; /* structure copy */
59 return ret;
62 static void decode_params(game_params *params, char const *string)
66 static char *encode_params(game_params *params, int full)
68 return dupstr("FIXME");
71 static config_item *game_configure(game_params *params)
73 return NULL;
76 static game_params *custom_params(config_item *cfg)
78 return NULL;
81 static char *validate_params(game_params *params, int full)
83 return NULL;
86 static char *new_game_desc(game_params *params, random_state *rs,
87 char **aux, int interactive)
89 return dupstr("FIXME");
92 static char *validate_desc(game_params *params, char *desc)
94 return NULL;
97 static game_state *new_game(midend *me, game_params *params, char *desc)
99 game_state *state = snew(game_state);
101 state->FIXME = 0;
103 return state;
106 static game_state *dup_game(game_state *state)
108 game_state *ret = snew(game_state);
110 ret->FIXME = state->FIXME;
112 return ret;
115 static void free_game(game_state *state)
117 sfree(state);
120 static char *solve_game(game_state *state, game_state *currstate,
121 char *aux, char **error)
123 return NULL;
126 static int game_can_format_as_text_now(game_params *params)
128 return TRUE;
131 static char *game_text_format(game_state *state)
133 return NULL;
136 static game_ui *new_ui(game_state *state)
138 return NULL;
141 static void free_ui(game_ui *ui)
145 static char *encode_ui(game_ui *ui)
147 return NULL;
150 static void decode_ui(game_ui *ui, char *encoding)
154 static void game_changed_state(game_ui *ui, game_state *oldstate,
155 game_state *newstate)
159 struct game_drawstate {
160 int tilesize;
161 int FIXME;
164 static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
165 int x, int y, int button)
167 return NULL;
170 static game_state *execute_move(game_state *state, char *move)
172 return NULL;
175 /* ----------------------------------------------------------------------
176 * Drawing routines.
179 static void game_compute_size(game_params *params, int tilesize,
180 int *x, int *y)
182 *x = *y = 10 * tilesize; /* FIXME */
185 static void game_set_size(drawing *dr, game_drawstate *ds,
186 game_params *params, int tilesize)
188 ds->tilesize = tilesize;
191 static float *game_colours(frontend *fe, int *ncolours)
193 float *ret = snewn(3 * NCOLOURS, float);
195 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
197 *ncolours = NCOLOURS;
198 return ret;
201 static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
203 struct game_drawstate *ds = snew(struct game_drawstate);
205 ds->tilesize = 0;
206 ds->FIXME = 0;
208 return ds;
211 static void game_free_drawstate(drawing *dr, game_drawstate *ds)
213 sfree(ds);
216 static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
217 game_state *state, int dir, game_ui *ui,
218 float animtime, float flashtime)
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.
226 draw_rect(dr, 0, 0, 10*ds->tilesize, 10*ds->tilesize, COL_BACKGROUND);
229 static float game_anim_length(game_state *oldstate, game_state *newstate,
230 int dir, game_ui *ui)
232 return 0.0F;
235 static float game_flash_length(game_state *oldstate, game_state *newstate,
236 int dir, game_ui *ui)
238 return 0.0F;
241 static int game_timing_state(game_state *state, game_ui *ui)
243 return TRUE;
246 static void game_print_size(game_params *params, float *x, float *y)
250 static void game_print(drawing *dr, game_state *state, int tilesize)
254 #ifdef COMBINED
255 #define thegame nullgame
256 #endif
258 const struct game thegame = {
259 "Null Game", NULL, NULL,
260 default_params,
261 game_fetch_preset,
262 decode_params,
263 encode_params,
264 free_params,
265 dup_params,
266 FALSE, game_configure, custom_params,
267 validate_params,
268 new_game_desc,
269 validate_desc,
270 new_game,
271 dup_game,
272 free_game,
273 FALSE, solve_game,
274 FALSE, game_can_format_as_text_now, game_text_format,
275 new_ui,
276 free_ui,
277 encode_ui,
278 decode_ui,
279 game_changed_state,
280 interpret_move,
281 execute_move,
282 20 /* FIXME */, game_compute_size, game_set_size,
283 game_colours,
284 game_new_drawstate,
285 game_free_drawstate,
286 game_redraw,
287 game_anim_length,
288 game_flash_length,
289 FALSE, FALSE, game_print_size, game_print,
290 FALSE, /* wants_statusbar */
291 FALSE, game_timing_state,
292 0, /* flags */