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