diff options
author | June McEnroe <june@causal.agency> | 2018-01-23 21:52:53 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-01-23 21:52:53 -0500 |
commit | fe82240f95853426750fcd751e72f739d466b7d7 (patch) | |
tree | 458373ac77edd7645836462160e4a12eeadbf523 | |
parent | Add control to klon (diff) | |
download | src-fe82240f95853426750fcd751e72f739d466b7d7.tar.gz src-fe82240f95853426750fcd751e72f739d466b7d7.zip |
Add autoFound
Still messy though.
-rw-r--r-- | bin/klon.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bin/klon.c b/bin/klon.c index 8267b25a..0e0e3d4c 100644 --- a/bin/klon.c +++ b/bin/klon.c @@ -155,6 +155,13 @@ static bool canTable(const struct Stack *table, uint8_t card) { return (card & MASK_RANK) == (get(table, 0) & MASK_RANK) - 1; } +static struct Stack *autoFound(uint8_t card) { + for (int i = 0; i < 4; ++i) { + if (canFound(&g.found[i], card)) return &g.found[i]; + } + return NULL; +} + enum { PAIR_EMPTY = 1, PAIR_BACK, @@ -241,7 +248,7 @@ static void render(void) { x = 2; for (int i = 0; i < 7; ++i) { y = 5; - // FIXME: Render empty. + renderCard(y, x, 0); for (int j = len(&g.table[i]); j > 0; --j) { renderCard(y, x, get(&g.table[i], j - 1)); y++; @@ -275,8 +282,6 @@ static void cancel(void) { depth = 0; } -#define ESC (0x1B) - int main() { curse(); @@ -299,6 +304,15 @@ int main() { } else { cancel(); } + } else if ((c == 'f' || c == '\n') && depth == 1) { + struct Stack *found = autoFound(get(src, 0)); + if (found) { + transfer(found, src, depth); + src = NULL; + depth = 0; + } else { + cancel(); + } } else if (c >= '1' && c <= '7') { if (src == &g.table[c - '1']) { deepen(); |