girst [Thu, 19 May 2022 13:16:03 +0000 (15:16 +0200)]
fix find-following
this bug manifested in freecell as the ace of clubs not recognized as
placable on the foundation (from the tableu) when all four free cells
were occupied.
due to us not checking that find_top() found a card at all, we
accidentally checked foundation[-1], which is the fourth free cell.
there are probably more bugs stemming from this misuse of find_top().
girst [Wed, 20 Apr 2022 17:18:08 +0000 (19:18 +0200)]
make 'no take from empty' more dry
oof, that's an awful macro.
girst [Wed, 20 Apr 2022 16:44:50 +0000 (18:44 +0200)]
prevent taking from empty foundation
a direct copy of the previous commit, but for the other non-tableu
piles.
girst [Wed, 20 Apr 2022 16:39:29 +0000 (18:39 +0200)]
freecell: fix direct addressing 'take from cell'
the 'no take from empty stock/cell' rule had a bug that only checked the
first cell when accessed with '9'. this is because with direct
addressing mode, active.opt stays at its initial value of 0. this check
was split in two parts:
- direct addressing: only abort when all cells are empty
- other: check that struct cursor active was actually modified.
a third test was then added to make this work with mouse addressing
also.
girst [Sun, 5 Sep 2021 15:48:51 +0000 (17:48 +0200)]
make freecell obey the 'no selecting of empty stock' rule
girst [Fri, 13 Mar 2020 15:18:52 +0000 (16:18 +0100)]
blink waste/cells
girst [Fri, 13 Mar 2020 14:22:54 +0000 (15:22 +0100)]
'.' implementation (ugly and not portable)
uses ungetc(3) twice, which "works on my machine"™
girst [Fri, 13 Mar 2020 14:05:21 +0000 (15:05 +0100)]
find and search commands prototypes
NOTE: both need a considerable amount of cleaning up
girst [Fri, 15 Nov 2019 13:32:52 +0000 (14:32 +0100)]
ifdef off inverted move logic
that proved to be more annoying than useful for me. pass -DINVERSE_MOVE
to the compiler to reenable.
girst [Sat, 23 Mar 2019 15:39:22 +0000 (16:39 +0100)]
fix freecell->free tableu
if only 1 free cell was occupied and moved to an empty tableu using
direct addressing the user was asked which cell to take from.
girst [Sat, 9 Mar 2019 20:50:11 +0000 (21:50 +0100)]
shuffle around TODOs
girst [Sat, 9 Mar 2019 20:43:35 +0000 (21:43 +0100)]
fix c2f() emtpy check
gah! function didn't check if the cell was empty. this caused extra
items on the undo list (and the wrong retval)
girst [Sat, 9 Mar 2019 20:23:20 +0000 (21:23 +0100)]
freecell: better join() cell->foundation fix
girst [Sat, 9 Mar 2019 20:07:55 +0000 (21:07 +0100)]
freecell: join() freecells->foundation
girst [Mon, 4 Mar 2019 20:31:10 +0000 (21:31 +0100)]
freecell: join() to foundation: fix fencepost error
girst [Mon, 25 Feb 2019 23:18:42 +0000 (00:18 +0100)]
update TODOs
smart card selector -> DONE
girst [Mon, 25 Feb 2019 22:45:27 +0000 (23:45 +0100)]
spider: fix undo stack-completed-pile bug
if the user draws from the stock and this completes a cascade, the
undo event for the stock deal _must_ be stored before the undo event for
the cascade removal. otherwise the undo history will be broken!!1
girst [Sun, 24 Feb 2019 17:56:18 +0000 (18:56 +0100)]
updated foundation placeholder
the braille characters are widely enough supported, and the placeholder
should still make sense even if they aren't on a system.
not commited: alternate "10" symbols. ⒑ (tofu in xterm), ⏨ (too small,
tofu in xterm), Ю, (cyrillic yu, not looking too good)
girst [Sun, 24 Feb 2019 17:54:43 +0000 (18:54 +0100)]
freecell: join to empty tableu
also removed redundant checks for join()-ability in get_cmd()
girst [Wed, 20 Feb 2019 19:59:54 +0000 (20:59 +0100)]
use color_ok macro everywhere
girst [Wed, 20 Feb 2019 19:51:23 +0000 (20:51 +0100)]
freecell: smart card selector, part 4
all done! \o\ /o/ \o/
nice test seed:
1550690183
also a new helper functoin color_ok(), yet to be used everywhere else
girst [Wed, 20 Feb 2019 18:26:42 +0000 (19:26 +0100)]
freecell: smart card selector, part 3
foundation -> tableu is the same as in klondike, so i reordered the code
to take advantage of this
note that the if inactive.opt check inside the klondike||freecell block
(sol.c:1169) is only correct for klondike, but freecell checks further
up the if/elseif branches for inactive.opt, so this is never executed.
girst [Wed, 20 Feb 2019 18:09:26 +0000 (19:09 +0100)]
freecell: smart card selector, part 2
also fixed wrong return value in spider's card selector dialog
girst [Wed, 20 Feb 2019 17:27:28 +0000 (18:27 +0100)]
freecell: smart card selector, part 1
implements smart move detector for foundation->freecell and
freecell->foundation. missing: *->tableu
girst [Wed, 20 Feb 2019 15:51:02 +0000 (16:51 +0100)]
implement join() for freecell
also fix the outstanding todo in klondike.join()
girst [Tue, 19 Feb 2019 19:17:55 +0000 (20:17 +0100)]
remove freecell backspace
girst [Tue, 19 Feb 2019 18:56:44 +0000 (19:56 +0100)]
freecell stable enough for default target
girst [Tue, 19 Feb 2019 18:51:48 +0000 (19:51 +0100)]
differentiate foundation from placeholder
alternative designs:
╭╌╌╌╮╭╌╌╌╮╭╌╌╌╮
╎ ╳ ╎╎▕▔▏╎╎▛▀▜╎
╎╱‾╲╎╎▕▔▏╎╎▛▀▜╎
╰╌╌╌╯╰╌╌╌╯╰╌╌╌╯
girst [Tue, 19 Feb 2019 18:10:23 +0000 (19:10 +0100)]
argh! a semicolon too many!
girst [Tue, 19 Feb 2019 18:06:14 +0000 (19:06 +0100)]
freecell: respect max_move() in cursor selection
girst [Tue, 19 Feb 2019 16:28:12 +0000 (17:28 +0100)]
swap win_anim width/height
girst [Tue, 19 Feb 2019 12:44:46 +0000 (13:44 +0100)]
fix fencepost in undo_pop, mouse-foundation also in klondike
girst [Tue, 19 Feb 2019 12:28:29 +0000 (13:28 +0100)]
fix fallthough at -V
thanks dax-dev
girst [Tue, 19 Feb 2019 12:27:58 +0000 (13:27 +0100)]
freecell: mouse select for cells/foundation
girst [Tue, 19 Feb 2019 11:35:49 +0000 (12:35 +0100)]
freecell: finished t2t, work on card selector dialog
playable, but clunky version of the get_cmd() post processing stage.
girst [Mon, 18 Feb 2019 20:49:32 +0000 (21:49 +0100)]
more work on freecell t2t()
it works now, although direct addressing still needs to be addressed
(ba-dum-tshhh) in get_cmd() and some new TODOs have to be DONE.
girst [Mon, 18 Feb 2019 20:15:09 +0000 (21:15 +0100)]
freecell: t2t(), calculate number of movable
see also: https://boardgames.stackexchange.com/a/45157/26498
girst [Sat, 16 Feb 2019 22:18:57 +0000 (23:18 +0100)]
win_anim: print everywhere on the terminal
girst [Sat, 16 Feb 2019 22:18:36 +0000 (23:18 +0100)]
merge freecell todos into readme
girst [Sat, 16 Feb 2019 21:23:38 +0000 (22:23 +0100)]
spider: fix move to empty tableu
"no of the additions affect klondike or spider, so its safe to commit"
my ass! this is the second bug I've found that I introduced with this.
girst [Sat, 16 Feb 2019 11:33:19 +0000 (12:33 +0100)]
remove debugging seed
that shouln't've been committed.
Feuerfuchs [Thu, 14 Feb 2019 09:09:39 +0000 (10:09 +0100)]
Add a colorful version of the mini colorscheme
girst [Thu, 14 Feb 2019 20:30:30 +0000 (21:30 +0100)]
WIP: freecell implementation (unfinished)
what's missing:
- t2t() and corresponding undo_pop()
- get_cmd() "select from which {cell,foundation}?" dialog
- some mouse details (term2pile, wait_mouse_up, set_mouse)
- join() for freecell
no of the additions affect klondike or spider, so its safe to commit.
girst [Thu, 14 Feb 2019 16:34:44 +0000 (17:34 +0100)]
join() fixes for w2t
you could join onto the waste and if the waste was -1.
girst [Wed, 13 Feb 2019 23:43:24 +0000 (00:43 +0100)]
remove stupid {1, ...} initialisation
girst [Wed, 13 Feb 2019 17:15:38 +0000 (18:15 +0100)]
new todo: freecell
girst [Wed, 13 Feb 2019 16:42:24 +0000 (17:42 +0100)]
allow disabling visual bell (might change)
thanks to github user mikezila for the idea. will be replaced by a
less-annoying visbell in the future
girst [Tue, 12 Feb 2019 20:04:42 +0000 (21:04 +0100)]
remove spider.c symlink
let's do the straight-forward thing and just spell out sol.c.
girst [Tue, 12 Feb 2019 19:59:55 +0000 (20:59 +0100)]
fix 80 columns, todo->done
girst [Tue, 12 Feb 2019 19:57:43 +0000 (20:57 +0100)]
finish active-cursor-hider
yeah, it's a hack.
girst [Tue, 12 Feb 2019 19:54:07 +0000 (20:54 +0100)]
WIP: hide active cursor when using mouse (/u/TooEarlyForMe)
girst [Tue, 12 Feb 2019 19:41:10 +0000 (20:41 +0100)]
`:help` to show keyhelp (/u/Valley6660)
girst [Tue, 12 Feb 2019 19:36:06 +0000 (20:36 +0100)]
allow using `10` instead of `X` on card face (/u/Valley6660)
girst [Tue, 12 Feb 2019 18:03:59 +0000 (19:03 +0100)]
hide old internal notes
girst [Tue, 12 Feb 2019 18:01:28 +0000 (19:01 +0100)]
add keybindings info
girst [Tue, 12 Feb 2019 18:00:38 +0000 (19:00 +0100)]
'join' with right mouse, update keybindings help
girst [Sun, 3 Feb 2019 16:54:57 +0000 (17:54 +0100)]
fix segfault when mouse-moving multiple cards to empty tableu
the "up to?" dialog calls getch(NULL), which caused a segfault.
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004030fb in getch (buf=0x0) at spider.c:940
> 940 if (buf[3]) {
> (gdb) bt
> #0 0x00000000004030fb in getch (buf=0x0) at spider.c:940
> #1 0x0000000000402c97 in get_cmd (from=0x7ffeba433bfc, to=0x7ffeba433bf8,
> opt=0x7ffeba433bf4) at spider.c:808
> #2 0x0000000000400ebf in sol () at spider.c:108
> #3 0x0000000000400e2f in main (argc=2, argv=0x7ffeba433d28) at spider.c:88
girst [Sat, 2 Feb 2019 18:39:47 +0000 (19:39 +0100)]
Add LICENSE
this is the first version covered by and released under the terms of the
GNU GPL version 3. Older versions are _not_ relicensed.
girst [Sat, 2 Feb 2019 18:39:40 +0000 (19:39 +0100)]
improve readme
girst [Sat, 2 Feb 2019 18:03:57 +0000 (19:03 +0100)]
friendly readme opening
elevator pitch of the controls
girst [Sat, 2 Feb 2019 17:57:04 +0000 (18:57 +0100)]
mouse: allow dragging
one can now drag the mouse cursor from one pile to another and it'll
register as two events and do the right thing.
girst [Sat, 26 Jan 2019 18:44:07 +0000 (19:44 +0100)]
handle SIGTSTP, fix mouse ctrlseq
girst [Tue, 22 Jan 2019 22:07:32 +0000 (23:07 +0100)]
cleanup mouse
still needs some features like dragging and 'if to is empty, how many
cards?'
girst [Tue, 22 Jan 2019 21:59:56 +0000 (22:59 +0100)]
mouse mode (needs cleanup)
girst [Tue, 22 Jan 2019 00:38:35 +0000 (01:38 +0100)]
fix overlong lines
girst [Tue, 22 Jan 2019 00:22:36 +0000 (01:22 +0100)]
fix spider foundation printing
girst [Mon, 21 Jan 2019 23:36:45 +0000 (00:36 +0100)]
clean up reworked join
girst [Mon, 21 Jan 2019 23:27:27 +0000 (00:27 +0100)]
rewrite join() prediction engine
girst [Mon, 21 Jan 2019 21:16:17 +0000 (22:16 +0100)]
fix 'make test'
symlink duplicated all TODOs in sol.c
girst [Mon, 21 Jan 2019 21:12:13 +0000 (22:12 +0100)]
join: in SPIDER, prefer completing a stack
girst [Mon, 21 Jan 2019 20:45:36 +0000 (21:45 +0100)]
better join for klondike
join to foundation, better to-tableu join
girst [Mon, 21 Jan 2019 19:59:36 +0000 (20:59 +0100)]
allow joining to foundation
girst [Mon, 21 Jan 2019 18:39:09 +0000 (19:39 +0100)]
allow inverted moves
girst [Mon, 21 Jan 2019 18:29:49 +0000 (19:29 +0100)]
use getch() everywhere
except for inside getch(), of course. where no mouse is needed, one can
pass NULL instead of a buffer; KEY_INVAL will then be returned if a
mouse click was received.
girst [Mon, 21 Jan 2019 18:19:16 +0000 (19:19 +0100)]
support 'real' cursor keys
keyhandling imported from minesviiper (minor changes); mouse support
stubbed.
girst [Mon, 21 Jan 2019 16:21:04 +0000 (17:21 +0100)]
make Makefile portable
apparently, the "prerequisite name != target rule name" only works in
GNU make. symlinking sol.c to spider.c and changing the makefile works.
girst [Sun, 20 Jan 2019 23:44:15 +0000 (00:44 +0100)]
implement restart same game, increase portability, update TODOs
* use rand() instead of random() to get in line with mines and viiper
* reorder playfield struct for better alignment
* remove ignore warnings pragma (not needed any more)
* remove _POSIX_C_SOURCE feture test (not needed and breaks freebsd)
girst [Sun, 20 Jan 2019 23:11:49 +0000 (00:11 +0100)]
fix off-by-one
cursor could 'escape' the playfield in KLONDIKE
girst [Sun, 20 Jan 2019 23:09:07 +0000 (00:09 +0100)]
actually useful CMD_JOIN implementation
girst [Sun, 20 Jan 2019 20:32:24 +0000 (21:32 +0100)]
first version of join() -- to be replaced
this version is very suboptimal. we shouldn't take from longest piles,
as that will rip apart already constructed piles. instead, take from
piles where the card we want to move has the least amount of movable
cards _above_ it. even better if the card above is closed. even better
yet if there is no card above (resulting in an empty pile)
girst [Sun, 20 Jan 2019 18:50:19 +0000 (19:50 +0100)]
automagic conserve space
only when the window size would be too small to display a pile
completely. still has the problem that sometimes the terminal is too
small for even the extreme overlap.
girst [Sun, 20 Jan 2019 18:00:02 +0000 (19:00 +0100)]
implement 'M' keybinding
moves active cursor to the centre pile
girst [Sun, 20 Jan 2019 17:15:37 +0000 (18:15 +0100)]
rework command line arguments
don't require long string arguments
girst [Sun, 20 Jan 2019 17:05:52 +0000 (18:05 +0100)]
fix BULCARD() padding
using ESC produces tofu on some terminal emulators. switching to SI
(Switch To Standard Charset) for padding seems to work better. (SI
should have no effect on Unicode terminal emulators). this also made
detecting the padded lines easier, as \017 (SI) is only appearing in
those.
girst [Sat, 19 Jan 2019 16:37:02 +0000 (17:37 +0100)]
fix foundation rendering (SPIDER)
by using a static int to store the foundation index, it couldn't be
reset when a new game was started. this caused the first pile to be e.g.
to end up on the second foundation if the game before had 1 completed.
girst [Fri, 11 Jan 2019 20:29:48 +0000 (21:29 +0100)]
fix bold hack; extreme overlap: always show top selected card
girst [Thu, 10 Jan 2019 14:16:31 +0000 (15:16 +0100)]
fix broken halfcard rendering
due to the faint hack, black cards were 1 byte shorter than red cards.
this meant, that the offset for halfcard was off for red colors (as it
has been adjusted for black cards), which caused printing errors in
spider's foundation for overlapping red cards. can't pad with zero bytes
(as that would end the string), but using an extra escape seems to be OK
for xterm and vte-based terminals.
girst [Tue, 8 Jan 2019 19:30:06 +0000 (20:30 +0100)]
update TODOs
girst [Tue, 8 Jan 2019 18:21:18 +0000 (19:21 +0100)]
assimilate remove_if_complete
so spider's "double-click" action has the same feedback as sol's.
girst [Mon, 7 Jan 2019 17:12:55 +0000 (18:12 +0100)]
awful hack that un-breaks faint+bold printing
bold and faint can bet set individually, but only reset both at once.
this causes the bold attribute (useful for determining with cards are
movable) to be reset when faint was. we are splitting the string at a
known-whitespace position only if we are at the faint printed lines
(str[n]==033).
girst [Mon, 7 Jan 2019 14:20:01 +0000 (15:20 +0100)]
fix turn over bug
girst [Mon, 7 Jan 2019 14:11:09 +0000 (15:11 +0100)]
undo for spider
note that there is a bug in turn-over-detection when to==FOUNDATATION[0]
girst [Mon, 7 Jan 2019 13:16:33 +0000 (14:16 +0100)]
properly free undo allocations
girst [Mon, 7 Jan 2019 13:03:38 +0000 (14:03 +0100)]
implement undo for KLONDIKE
for now, redo has been scrapped (would require an additional field in
f., and I don't see the need)
girst [Sun, 6 Jan 2019 00:14:45 +0000 (01:14 +0100)]
implement 'up to' space/return
girst [Sun, 6 Jan 2019 00:06:14 +0000 (01:06 +0100)]
remove redundant display calls
girst [Sat, 5 Jan 2019 23:58:25 +0000 (00:58 +0100)]
undo_pop pseudo implementation
girst [Sat, 5 Jan 2019 23:09:32 +0000 (00:09 +0100)]
move data structure definition into .h
can't declare functions otherwise :|
forward declarations are a mess!
girst [Sat, 5 Jan 2019 22:57:31 +0000 (23:57 +0100)]
rename append_undo to undo_push; subs for undo_pop, free_undo
girst [Sat, 5 Jan 2019 22:01:18 +0000 (23:01 +0100)]
squash another bug
what did that semicolon here!?
note that WASTE is not -1 but 0, as it is used as the second index into
action[][]