mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Dominosa
The only tricky bit is whether clicking precisely on the diagonal of a square (which never has any effect on the game) is MOVE_UNUSED or MOVE_NO_EFFECT. I decided that having single-pixel lines in the middle of the grid causing events to be passed back to the environment would be very confusing, so they're MOVE_NO_EFFECT. Clicking entirely outside the grid, on the other hand, returns MOVE_UNUSED.
This commit is contained in:
16
dominosa.c
16
dominosa.c
@ -2799,7 +2799,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
int d1, d2;
|
int d1, d2;
|
||||||
|
|
||||||
if (tx < 0 || tx >= w || ty < 0 || ty >= h)
|
if (tx < 0 || tx >= w || ty < 0 || ty >= h)
|
||||||
return NULL;
|
return MOVE_UNUSED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we know which square the click was in, decide which
|
* Now we know which square the click was in, decide which
|
||||||
@ -2817,14 +2817,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
else if (abs(dy) > abs(dx) && dy > 0 && ty+1 < h)
|
else if (abs(dy) > abs(dx) && dy > 0 && ty+1 < h)
|
||||||
d1 = t, d2 = t + w; /* clicked in top half of domino */
|
d1 = t, d2 = t + w; /* clicked in top half of domino */
|
||||||
else
|
else
|
||||||
return NULL;
|
return MOVE_NO_EFFECT; /* clicked precisely on a diagonal */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't mark an edge next to any domino.
|
* We can't mark an edge next to any domino.
|
||||||
*/
|
*/
|
||||||
if (button == RIGHT_BUTTON &&
|
if (button == RIGHT_BUTTON &&
|
||||||
(state->grid[d1] != d1 || state->grid[d2] != d2))
|
(state->grid[d1] != d1 || state->grid[d2] != d2))
|
||||||
return NULL;
|
return MOVE_NO_EFFECT;
|
||||||
|
|
||||||
ui->cur_visible = false;
|
ui->cur_visible = false;
|
||||||
sprintf(buf, "%c%d,%d", (int)(button == RIGHT_BUTTON ? 'E' : 'D'), d1, d2);
|
sprintf(buf, "%c%d,%d", (int)(button == RIGHT_BUTTON ? 'E' : 'D'), d1, d2);
|
||||||
@ -2839,7 +2839,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
int d1, d2;
|
int d1, d2;
|
||||||
|
|
||||||
if (!((ui->cur_x ^ ui->cur_y) & 1))
|
if (!((ui->cur_x ^ ui->cur_y) & 1))
|
||||||
return NULL; /* must have exactly one dimension odd */
|
return MOVE_NO_EFFECT; /* must have exactly one dimension odd */
|
||||||
d1 = (ui->cur_y / 2) * w + (ui->cur_x / 2);
|
d1 = (ui->cur_y / 2) * w + (ui->cur_x / 2);
|
||||||
d2 = ((ui->cur_y+1) / 2) * w + ((ui->cur_x+1) / 2);
|
d2 = ((ui->cur_y+1) / 2) * w + ((ui->cur_x+1) / 2);
|
||||||
|
|
||||||
@ -2848,14 +2848,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
*/
|
*/
|
||||||
if (button == CURSOR_SELECT2 &&
|
if (button == CURSOR_SELECT2 &&
|
||||||
(state->grid[d1] != d1 || state->grid[d2] != d2))
|
(state->grid[d1] != d1 || state->grid[d2] != d2))
|
||||||
return NULL;
|
return MOVE_NO_EFFECT;
|
||||||
|
|
||||||
sprintf(buf, "%c%d,%d", (int)(button == CURSOR_SELECT2 ? 'E' : 'D'), d1, d2);
|
sprintf(buf, "%c%d,%d", (int)(button == CURSOR_SELECT2 ? 'E' : 'D'), d1, d2);
|
||||||
return dupstr(buf);
|
return dupstr(buf);
|
||||||
} else if (isdigit(button)) {
|
} else if (isdigit(button)) {
|
||||||
int n = state->params.n, num = button - '0';
|
int n = state->params.n, num = button - '0';
|
||||||
if (num > n) {
|
if (num > n) {
|
||||||
return NULL;
|
return MOVE_UNUSED;
|
||||||
} else if (ui->highlight_1 == num) {
|
} else if (ui->highlight_1 == num) {
|
||||||
ui->highlight_1 = -1;
|
ui->highlight_1 = -1;
|
||||||
} else if (ui->highlight_2 == num) {
|
} else if (ui->highlight_2 == num) {
|
||||||
@ -2865,12 +2865,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
} else if (ui->highlight_2 == -1) {
|
} else if (ui->highlight_2 == -1) {
|
||||||
ui->highlight_2 = num;
|
ui->highlight_2 = num;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return MOVE_NO_EFFECT;
|
||||||
}
|
}
|
||||||
return MOVE_UI_UPDATE;
|
return MOVE_UI_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return MOVE_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static game_state *execute_move(const game_state *state, const char *move)
|
static game_state *execute_move(const game_state *state, const char *move)
|
||||||
|
Reference in New Issue
Block a user