Added a help file, mostly thanks to Jacob.
[sgt/puzzles] / nullgame.c
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>
18 #include <ctype.h>
19 #include <math.h>
20
21 #include "puzzles.h"
22
23 const char *const game_name = "Null Game";
24 const char *const game_winhelp_topic = NULL;
25 const int game_can_configure = FALSE;
26
27 enum {
28 COL_BACKGROUND,
29 NCOLOURS
30 };
31
32 struct game_params {
33 int FIXME;
34 };
35
36 struct game_state {
37 int FIXME;
38 };
39
40 game_params *default_params(void)
41 {
42 game_params *ret = snew(game_params);
43
44 ret->FIXME = 0;
45
46 return ret;
47 }
48
49 int game_fetch_preset(int i, char **name, game_params **params)
50 {
51 return FALSE;
52 }
53
54 void free_params(game_params *params)
55 {
56 sfree(params);
57 }
58
59 game_params *dup_params(game_params *params)
60 {
61 game_params *ret = snew(game_params);
62 *ret = *params; /* structure copy */
63 return ret;
64 }
65
66 game_params *decode_params(char const *string)
67 {
68 game_params *ret = snew(game_params);
69
70 ret->FIXME = 0;
71
72 return ret;
73 }
74
75 char *encode_params(game_params *params)
76 {
77 return dupstr("FIXME");
78 }
79
80 config_item *game_configure(game_params *params)
81 {
82 return NULL;
83 }
84
85 game_params *custom_params(config_item *cfg)
86 {
87 return NULL;
88 }
89
90 char *validate_params(game_params *params)
91 {
92 return NULL;
93 }
94
95 char *new_game_seed(game_params *params, random_state *rs)
96 {
97 return dupstr("FIXME");
98 }
99
100 char *validate_seed(game_params *params, char *seed)
101 {
102 return NULL;
103 }
104
105 game_state *new_game(game_params *params, char *seed)
106 {
107 game_state *state = snew(game_state);
108
109 state->FIXME = 0;
110
111 return state;
112 }
113
114 game_state *dup_game(game_state *state)
115 {
116 game_state *ret = snew(game_state);
117
118 ret->FIXME = state->FIXME;
119
120 return ret;
121 }
122
123 void free_game(game_state *state)
124 {
125 sfree(state);
126 }
127
128 game_ui *new_ui(game_state *state)
129 {
130 return NULL;
131 }
132
133 void free_ui(game_ui *ui)
134 {
135 }
136
137 game_state *make_move(game_state *from, game_ui *ui, int x, int y, int button)
138 {
139 return NULL;
140 }
141
142 /* ----------------------------------------------------------------------
143 * Drawing routines.
144 */
145
146 struct game_drawstate {
147 int FIXME;
148 };
149
150 void game_size(game_params *params, int *x, int *y)
151 {
152 *x = *y = 200; /* FIXME */
153 }
154
155 float *game_colours(frontend *fe, game_state *state, int *ncolours)
156 {
157 float *ret = snewn(3 * NCOLOURS, float);
158
159 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
160
161 *ncolours = NCOLOURS;
162 return ret;
163 }
164
165 game_drawstate *game_new_drawstate(game_state *state)
166 {
167 struct game_drawstate *ds = snew(struct game_drawstate);
168
169 ds->FIXME = 0;
170
171 return ds;
172 }
173
174 void game_free_drawstate(game_drawstate *ds)
175 {
176 sfree(ds);
177 }
178
179 void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
180 game_state *state, game_ui *ui,
181 float animtime, float flashtime)
182 {
183 /*
184 * The initial contents of the window are not guaranteed and
185 * can vary with front ends. To be on the safe side, all games
186 * should start by drawing a big background-colour rectangle
187 * covering the whole window.
188 */
189 draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND);
190 }
191
192 float game_anim_length(game_state *oldstate, game_state *newstate)
193 {
194 return 0.0F;
195 }
196
197 float game_flash_length(game_state *oldstate, game_state *newstate)
198 {
199 return 0.0F;
200 }
201
202 int game_wants_statusbar(void)
203 {
204 return FALSE;
205 }