From 86082330081eafe4d77f26e7b3a368891a33d14e Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Fri, 5 Jul 2024 00:35:29 +0200 Subject: [PATCH] add pet to queen transformation --- c.chk | 4 ++++ checkers.c | 1 + function.c | 16 ++++++++++++++++ function.h | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 c.chk 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); -- 2.30.2