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(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(game_params
*params
, int full
)
68 return dupstr("FIXME");
71 static config_item
*game_configure(game_params
*params
)
76 static game_params
*custom_params(config_item
*cfg
)
81 static char *validate_params(game_params
*params
)
86 static char *new_game_desc(game_params
*params
, random_state
*rs
,
87 game_aux_info
**aux
, int interactive
)
89 return dupstr("FIXME");
92 static void game_free_aux_info(game_aux_info
*aux
)
94 assert(!"Shouldn't happen");
97 static char *validate_desc(game_params
*params
, char *desc
)
102 static game_state
*new_game(midend_data
*me
, game_params
*params
, char *desc
)
104 game_state
*state
= snew(game_state
);
111 static game_state
*dup_game(game_state
*state
)
113 game_state
*ret
= snew(game_state
);
115 ret
->FIXME
= state
->FIXME
;
120 static void free_game(game_state
*state
)
125 static game_state
*solve_game(game_state
*state
, game_state
*currstate
,
126 game_aux_info
*aux
, char **error
)
131 static char *game_text_format(game_state
*state
)
136 static game_ui
*new_ui(game_state
*state
)
141 static void free_ui(game_ui
*ui
)
145 static void game_changed_state(game_ui
*ui
, game_state
*oldstate
,
146 game_state
*newstate
)
150 struct game_drawstate
{
154 static game_state
*make_move(game_state
*from
, game_ui
*ui
, game_drawstate
*ds
,
155 int x
, int y
, int button
)
160 /* ----------------------------------------------------------------------
164 static void game_size(game_params
*params
, game_drawstate
*ds
,
165 int *x
, int *y
, int expand
)
167 *x
= *y
= 200; /* FIXME */
170 static float *game_colours(frontend
*fe
, game_state
*state
, int *ncolours
)
172 float *ret
= snewn(3 * NCOLOURS
, float);
174 frontend_default_colour(fe
, &ret
[COL_BACKGROUND
* 3]);
176 *ncolours
= NCOLOURS
;
180 static game_drawstate
*game_new_drawstate(game_state
*state
)
182 struct game_drawstate
*ds
= snew(struct game_drawstate
);
189 static void game_free_drawstate(game_drawstate
*ds
)
194 static void game_redraw(frontend
*fe
, game_drawstate
*ds
, game_state
*oldstate
,
195 game_state
*state
, int dir
, game_ui
*ui
,
196 float animtime
, float flashtime
)
199 * The initial contents of the window are not guaranteed and
200 * can vary with front ends. To be on the safe side, all games
201 * should start by drawing a big background-colour rectangle
202 * covering the whole window.
204 draw_rect(fe
, 0, 0, 200, 200, COL_BACKGROUND
);
207 static float game_anim_length(game_state
*oldstate
, game_state
*newstate
,
208 int dir
, game_ui
*ui
)
213 static float game_flash_length(game_state
*oldstate
, game_state
*newstate
,
214 int dir
, game_ui
*ui
)
219 static int game_wants_statusbar(void)
224 static int game_timing_state(game_state
*state
)
230 #define thegame nullgame
233 const struct game thegame
= {
241 FALSE
, game_configure
, custom_params
,
250 FALSE
, game_text_format
,
262 game_wants_statusbar
,
263 FALSE
, game_timing_state
,
264 0, /* mouse_priorities */