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.
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.
36 static game_params
*default_params(void)
38 game_params
*ret
= snew(game_params
);
45 static int game_fetch_preset(int i
, char **name
, game_params
**params
)
50 static void free_params(game_params
*params
)
55 static game_params
*dup_params(const game_params
*params
)
57 game_params
*ret
= snew(game_params
);
58 *ret
= *params
; /* structure copy */
62 static void decode_params(game_params
*params
, char const *string
)
66 static char *encode_params(const game_params
*params
, int full
)
68 return dupstr("FIXME");
71 static config_item
*game_configure(const game_params
*params
)
76 static game_params
*custom_params(const config_item
*cfg
)
81 static char *validate_params(const game_params
*params
, int full
)
86 static char *new_game_desc(const game_params
*params
, random_state
*rs
,
87 char **aux
, int interactive
)
89 return dupstr("FIXME");
92 static char *validate_desc(const game_params
*params
, const char *desc
)
97 static game_state
*new_game(midend
*me
, const game_params
*params
,
100 game_state
*state
= snew(game_state
);
107 static game_state
*dup_game(const game_state
*state
)
109 game_state
*ret
= snew(game_state
);
111 ret
->FIXME
= state
->FIXME
;
116 static void free_game(game_state
*state
)
121 static char *solve_game(const game_state
*state
, const game_state
*currstate
,
122 const char *aux
, char **error
)
127 static int game_can_format_as_text_now(const game_params
*params
)
132 static char *game_text_format(const game_state
*state
)
137 static game_ui
*new_ui(const game_state
*state
)
142 static void free_ui(game_ui
*ui
)
146 static char *encode_ui(const game_ui
*ui
)
151 static void decode_ui(game_ui
*ui
, const char *encoding
)
155 static void game_changed_state(game_ui
*ui
, const game_state
*oldstate
,
156 const game_state
*newstate
)
160 struct game_drawstate
{
165 static char *interpret_move(const game_state
*state
, game_ui
*ui
,
166 const game_drawstate
*ds
,
167 int x
, int y
, int button
)
172 static game_state
*execute_move(const game_state
*state
, const char *move
)
177 /* ----------------------------------------------------------------------
181 static void game_compute_size(const game_params
*params
, int tilesize
,
184 *x
= *y
= 10 * tilesize
; /* FIXME */
187 static void game_set_size(drawing
*dr
, game_drawstate
*ds
,
188 const game_params
*params
, int tilesize
)
190 ds
->tilesize
= tilesize
;
193 static float *game_colours(frontend
*fe
, int *ncolours
)
195 float *ret
= snewn(3 * NCOLOURS
, float);
197 frontend_default_colour(fe
, &ret
[COL_BACKGROUND
* 3]);
199 *ncolours
= NCOLOURS
;
203 static game_drawstate
*game_new_drawstate(drawing
*dr
, const game_state
*state
)
205 struct game_drawstate
*ds
= snew(struct game_drawstate
);
213 static void game_free_drawstate(drawing
*dr
, game_drawstate
*ds
)
218 static void game_redraw(drawing
*dr
, game_drawstate
*ds
,
219 const game_state
*oldstate
, const game_state
*state
,
220 int dir
, const game_ui
*ui
,
221 float animtime
, float flashtime
)
224 * The initial contents of the window are not guaranteed and
225 * can vary with front ends. To be on the safe side, all games
226 * should start by drawing a big background-colour rectangle
227 * covering the whole window.
229 draw_rect(dr
, 0, 0, 10*ds
->tilesize
, 10*ds
->tilesize
, COL_BACKGROUND
);
230 draw_update(dr
, 0, 0, 10*ds
->tilesize
, 10*ds
->tilesize
);
233 static float game_anim_length(const game_state
*oldstate
,
234 const game_state
*newstate
, int dir
, game_ui
*ui
)
239 static float game_flash_length(const game_state
*oldstate
,
240 const game_state
*newstate
, int dir
, game_ui
*ui
)
245 static int game_status(const game_state
*state
)
250 static int game_timing_state(const game_state
*state
, game_ui
*ui
)
255 static void game_print_size(const game_params
*params
, float *x
, float *y
)
259 static void game_print(drawing
*dr
, const game_state
*state
, int tilesize
)
264 #define thegame nullgame
267 const struct game thegame
= {
268 "Null Game", NULL
, NULL
,
270 game_fetch_preset
, NULL
,
275 FALSE
, game_configure
, custom_params
,
283 FALSE
, game_can_format_as_text_now
, game_text_format
,
291 20 /* FIXME */, game_compute_size
, game_set_size
,
299 FALSE
, FALSE
, game_print_size
, game_print
,
300 FALSE
, /* wants_statusbar */
301 FALSE
, game_timing_state
,