From ff260d9c04a3aa68b2f873a17a881c6ea2712896 Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 6 Jan 2019 01:14:45 +0100 Subject: [PATCH] implement 'up to' space/return --- README.md | 2 +- sol.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c5900b0..8fccb92 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ play klondike and spider solitaire in your unicode terminal. ## TODO ### P1 - * TODO: in direct addressing 'up to' dialog: make return/space select the lowest/highest option ### P2 * TODO: undo: - insert append_undo() in x2y() functions @@ -69,6 +68,7 @@ play klondike and spider solitaire in your unicode terminal. * DONE: extreme overlapping: if we are printing a sequence or multiple face down cards, only print `.overlap` lines of the ends, and `1` line for the middle cards + * DONE: in direct addressing 'up to' dialog: make return/space select the lowest/highest option ## Notes diff --git a/sol.c b/sol.c index a4ed8cc..1a6d718 100644 --- a/sol.c +++ b/sol.c @@ -589,9 +589,9 @@ to_l: print_table(&active, &inactive); #elif defined SPIDER /* moving to empty tableu? */ if (is_tableu(*to) && f.t[*to][0] == NO_CARD) { + int bottom = first_movable(f.t[*from]); if (inactive.opt >= 0) { /*if from was cursor addressed: */ - int bottom = first_movable(f.t[*from]) + inactive.opt; - *opt = get_rank(f.t[*from][bottom]); + *opt = get_rank(f.t[*from][bottom + inactive.opt]); return CMD_MOVE; } int top = find_top(f.t[*from]); @@ -599,9 +599,11 @@ to_l: print_table(&active, &inactive); if (top >= 0 && !is_movable(f.t[*from], top-1)) { *opt = get_rank(f.t[*from][top]); } else { /* only ask the user if it's unclear: */ - printf ("\rup to (a23456789xjqk): "); + printf ("\rup to ([a23456789xjqk] or space/return): "); *opt = getchar(); switch (*opt) { + case ' ': *opt = get_rank(f.t[*from][top]); break; + case'\n': *opt = get_rank(f.t[*from][bottom]); break; case 'a': case 'A': *opt = RANK_A; break; case '0': /* fallthrough */ case 'x': case 'X': *opt = RANK_X; break; -- 2.39.3