nmak

makao card game
git clone git://git.kocotian.pl/nmak.git
Log | Files | Refs | README | LICENSE

commit d60fe67f33853fc0887eb43d514b71e313abe0d5
parent 95a4c80c06561892f39135f02fbeeac715a8d75c
Author: kocotian <kocotian@kocotian.pl>
Date:   Thu, 18 Feb 2021 10:03:42 +0100

taking card back

Diffstat:
Dnmak | 0
Mnmak.c | 15++++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/nmak b/nmak Binary files differ. diff --git a/nmak.c b/nmak.c @@ -152,9 +152,15 @@ static int8_t * getcardbyindex(int8_t *stack, int8_t index) { int i, j; - for (i = 0, j = -1; i < 52; ++i) - if (stack[i] != -1 && ++j == index) - return stack + i; + if (index >= 0) { + for (i = 0, j = -1; i < 52; ++i) + if (stack[i] != -1 && ++j == index) + return stack + i; + } else { + for (i = 51; i > -1; --i) + if (stack[i] != -1) + return stack + i; + } return NULL; } @@ -454,6 +460,9 @@ main(int argc, char *argv[]) } else if (COMMAND(line, "sort")) { sort(stacks, 52, line); sendupdate(stacks, *chost); + } else if (COMMAND(line, "take")) { + movecard(stacks + (52 * (color + 2)), stacks + 52, -1); + sendupdate(stacks, *chost); } else if (COMMAND(line, "quit") || COMMAND(line, "exit") || COMMAND(line, "bye")) break;