return ret;
}
-static game_params *decode_params(char const *string)
+static void decode_params(game_params *ret, char const *string)
{
- game_params *ret = default_params();
-
switch (*string) {
case 't': ret->solid = TETRAHEDRON; string++; break;
case 'c': ret->solid = CUBE; string++; break;
string++;
ret->d2 = atoi(string);
}
-
- return ret;
}
-static char *encode_params(game_params *params)
+static char *encode_params(game_params *params, int full)
{
char data[256];
data->squareindex++;
}
-static char *new_game_seed(game_params *params, random_state *rs)
+static char *new_game_desc(game_params *params, random_state *rs,
+ game_aux_info **aux)
{
struct grid_data data;
int i, j, k, m, area, facesperclass;
int *flags;
- char *seed, *p;
+ char *desc, *p;
/*
* Enumerate the grid squares, dividing them into equivalence
* the non-blue squares into a list in the now-unused gridptrs
* array.
*/
- seed = snewn(area / 4 + 40, char);
- p = seed;
+ desc = snewn(area / 4 + 40, char);
+ p = desc;
j = 0;
k = 8;
m = 0;
sfree(data.gridptrs[0]);
sfree(flags);
- return seed;
+ return desc;
+}
+
+static void game_free_aux_info(game_aux_info *aux)
+{
+ assert(!"Shouldn't happen");
}
static void add_grid_square_callback(void *ctx, struct grid_square *sq)
return ret;
}
-static char *validate_seed(game_params *params, char *seed)
+static char *validate_desc(game_params *params, char *desc)
{
int area = grid_area(params->d1, params->d2, solids[params->solid]->order);
int i, j;
i = (area + 3) / 4;
for (j = 0; j < i; j++) {
- int c = seed[j];
+ int c = desc[j];
if (c >= '0' && c <= '9') continue;
if (c >= 'A' && c <= 'F') continue;
if (c >= 'a' && c <= 'f') continue;
return "Not enough hex digits at start of string";
- /* NB if seed[j]=='\0' that will also be caught here, so we're safe */
+ /* NB if desc[j]=='\0' that will also be caught here, so we're safe */
}
- if (seed[i] != ',')
+ if (desc[i] != ',')
return "Expected ',' after hex digits";
i++;
do {
- if (seed[i] < '0' || seed[i] > '9')
+ if (desc[i] < '0' || desc[i] > '9')
return "Expected decimal integer after ','";
i++;
- } while (seed[i]);
+ } while (desc[i]);
return NULL;
}
-static game_state *new_game(game_params *params, char *seed)
+static game_state *new_game(game_params *params, char *desc)
{
game_state *state = snew(game_state);
int area;
/*
* Set up the blue squares and polyhedron position according to
- * the game seed.
+ * the game description.
*/
{
- char *p = seed;
+ char *p = desc;
int i, j, v;
j = 8;
memcpy(ret->facecolours, state->facecolours,
ret->solid->nfaces * sizeof(int));
ret->nsquares = state->nsquares;
+ ret->current = state->current;
ret->squares = snewn(ret->nsquares, struct grid_square);
memcpy(ret->squares, state->squares,
ret->nsquares * sizeof(struct grid_square));
sfree(state);
}
+static game_state *solve_game(game_state *state, game_aux_info *aux,
+ char **error)
+{
+ return NULL;
+}
+
static char *game_text_format(game_state *state)
{
return NULL;
struct solid *poly;
/*
- * All moves are made with the cursor keys.
+ * All moves are made with the cursor keys or numeric keypad.
*/
- if (button == CURSOR_UP)
+ if (button == CURSOR_UP || button == (MOD_NUM_KEYPAD | '8'))
direction = UP;
- else if (button == CURSOR_DOWN)
+ else if (button == CURSOR_DOWN || button == (MOD_NUM_KEYPAD | '2'))
direction = DOWN;
- else if (button == CURSOR_LEFT)
+ else if (button == CURSOR_LEFT || button == (MOD_NUM_KEYPAD | '4'))
direction = LEFT;
- else if (button == CURSOR_RIGHT)
+ else if (button == CURSOR_RIGHT || button == (MOD_NUM_KEYPAD | '6'))
direction = RIGHT;
- else if (button == CURSOR_UP_LEFT)
+ else if (button == (MOD_NUM_KEYPAD | '7'))
direction = UP_LEFT;
- else if (button == CURSOR_DOWN_LEFT)
+ else if (button == (MOD_NUM_KEYPAD | '1'))
direction = DOWN_LEFT;
- else if (button == CURSOR_UP_RIGHT)
+ else if (button == (MOD_NUM_KEYPAD | '9'))
direction = UP_RIGHT;
- else if (button == CURSOR_DOWN_RIGHT)
+ else if (button == (MOD_NUM_KEYPAD | '3'))
direction = DOWN_RIGHT;
else
return NULL;
dup_params,
TRUE, game_configure, custom_params,
validate_params,
- new_game_seed,
- validate_seed,
+ new_game_desc,
+ game_free_aux_info,
+ validate_desc,
new_game,
dup_game,
free_game,
- NULL, game_text_format,
+ FALSE, solve_game,
+ FALSE, game_text_format,
new_ui,
free_ui,
make_move,