From: Laurent Mazet Date: Thu, 4 Jul 2024 22:35:29 +0000 (+0200) Subject: add pet to queen transformation X-Git-Tag: v1.0~22 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=86082330081eafe4d77f26e7b3a368891a33d14e;p=checkers.git add pet to queen transformation --- diff --git a/c.chk b/c.chk new file mode 100644 index 0000000..c19f331 --- /dev/null +++ b/c.chk @@ -0,0 +1,4 @@ +width: 10 +height: 10 +tab: " . 0 0 0 01 0 0 0 0 0 0 0 0 .0 0 . . 0 . . 0 0 0. 1 1 1 . . 1 . . 11 1 1 1 . 1 1 1 1 01 1 1 1 . " +turn: 1 diff --git a/checkers.c b/checkers.c index 001c453..86b9759 100644 --- a/checkers.c +++ b/checkers.c @@ -344,6 +344,7 @@ int main (int argc, char *argv[]) player = (player == 0) ? 1 : 0; emptycache (cache); cleanafterjump (board); + pettoqueen (board); mode = 0; } break; diff --git a/function.c b/function.c index 75b3538..0d02412 100644 --- a/function.c +++ b/function.c @@ -340,6 +340,22 @@ void cleanafterjump (board_t *board) } } +void pettoqueen (board_t *board) +{ + int i; + char *cell = NULL; + for (i = 0; i < board->width; i++) { + cell = getcell (board, i, board->height - 1); + if (*cell == '0') { + *cell = '6'; + } + cell = getcell (board, i, 0); + if (*cell == '1') { + *cell = '7'; + } + } +} + int testjump (board_t *board, int x, int y, int mode) { int ret = 0; diff --git a/function.h b/function.h index 74f2ff9..f72e8ef 100644 --- a/function.h +++ b/function.h @@ -47,6 +47,8 @@ void dopetmove (board_t *board, int *x, int *y, int mode); void cleanafterjump (board_t *board); +void pettoqueen (board_t *board); + int testjump (board_t *board, int x, int y, int mode); int testalljumps (board_t *board, int x, int y);