diff options
author | June McEnroe <programble@gmail.com> | 2018-01-23 21:52:53 -0500 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2018-01-23 21:52:53 -0500 |
commit | 39643f620a2c7196ab2ce3cf48f2ee479aa28597 (patch) | |
tree | 3fe0d3abae1af23b72e1190d40eb51711cc49d8d | |
parent | Add control to klon (diff) | |
download | src-39643f620a2c7196ab2ce3cf48f2ee479aa28597.tar.gz src-39643f620a2c7196ab2ce3cf48f2ee479aa28597.zip |
Add autoFound
Still messy though.
Diffstat (limited to '')
-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 49d04d5c..76c1e2dc 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(); |