Skip to content

Commit

Permalink
Add support for finding and highlighting arbitrary card rank.
Browse files Browse the repository at this point in the history
Sometimes you need to find a specific rank that doesn't get highlighted
by current highlighting options. This patch allows to find such cards by
typing their numerical rank and hitting "s", which will highlight all
occurences of specified rank, regardless of suit.

Signed-off-by: Vitaly Ostrosablin <[email protected]>
  • Loading branch information
ostrosablin committed Nov 23, 2022
1 parent 53ded57 commit dfb3373
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.2.3 Add support to find specific card rank by typing numeric rank,
followed by "s".

1.2.2 Add support to auto-skip unsolvable deals.

1.2.1 Add support for highlighting adjacent cards to current selection, too.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ And then, with following command, you'll be able to start with deal #0 and conti
* Improved formula for supermoves/metamoves. Original implementation considered each empty cascade as one more freecell, while more correct formula is (M^2)*(N+1), which allows to move much more cards at once as long as you have enough empty cascades and freecells. This allows to do fewer tedious explicit moves and most modern FreeCell implementations have this out-of-box.
* Step-by-step metamove animation. You can see exactly how metamoves are performed. If you don't want animations, though, you can specify -i (--instant) option. Also, you can adjust animation delay (in microseconds) via -d (--delay) option.
* Accidental quit protection. Now hitting "q" doesn't instantly terminate the game, instead it asks you to hit "q" again if you really meant to quit game.
* Option -H (--highlight) to highlight next card of a suit to move to foundation, so that you won't have hard time tracking down the aces at the beginning of game. Also add -a (--adjacent) option to highlight cards adjacent to current selection.
* Option -H (--highlight) to highlight next card of a suit to move to foundation, so that you won't have hard time tracking down the aces at the beginning of game. Also adds -a (--adjacent) option to highlight cards adjacent to current selection.
* Supports highlighting any specific card rank to help you finding a particular card's position. Just type in a numerical rank (for J, Q, K use 11, 12 and 13 respectively), followed by "s".
* Supports solvability check via fc-solve. Enable fc-solve support with -S (--solver) option. No more getting stuck with dead-end unsolvable configurations for hours. After each move, solver will check and report whether this board is still solvable, or if it is game over and it's time to undo or restart. You can also add -c (--solvable) to make sure game will never throw an unsolvable deal at you (implies -S).

This requires to install fc-solve. You can install it on Debian/Ubuntu based distros with following command.
Expand Down
8 changes: 4 additions & 4 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for freecell 1.2.2.
# Generated by GNU Autoconf 2.61 for freecell 1.2.3.
#
# Report bugs to <[email protected]>.
#
Expand Down Expand Up @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='freecell'
PACKAGE_TARNAME='freecell'
PACKAGE_VERSION='1.2.2'
PACKAGE_STRING='freecell 1.2.2'
PACKAGE_VERSION='1.2.3'
PACKAGE_STRING='freecell 1.2.3'
PACKAGE_BUGREPORT='[email protected]'

ac_default_prefix=/usr/games
Expand Down Expand Up @@ -2062,7 +2062,7 @@ fi
# Define the identity of the package.
PACKAGE='freecell'
VERSION='1.2.2'
VERSION='1.2.3'
cat >>confdefs.h <<_ACEOF
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

# AC_PREREQ(2.61)
AC_INIT([freecell],[1.2.2],[[email protected]])
AC_INIT([freecell],[1.2.3],[[email protected]])

AM_INIT_AUTOMAKE

Expand Down
5 changes: 5 additions & 0 deletions doc/freecell.6
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ By default, suites are represented with these characters:
.br

You may configure freecell to use other characters, using the --suites option.

If you have hard time finding a particular card's position, you may type in
it's numeric rank (for J, Q, K use 11, 12 and 13 respectively), followed by
"s" keypress, which will highlight the cards with specified rank.

.SH GAMEPLAY
The aim of the game is to move all cards to the foundations in the upper right
corner.
Expand Down
14 changes: 12 additions & 2 deletions src/freecell.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ int highlight = 0;
int adjacent = 0;
int animate = 1;
int skipdelay = 0;
int find = 0;
int solvable_check = 0;
int automove_delay = AUTOMOVE_DELAY;

Expand Down Expand Up @@ -145,14 +146,17 @@ void cardstr(struct card *c, int sel) {
}
}

if (highlight) {
if (highlight && !find) {
if ((!wselected && !selected) || !adjacent) {
int n = pile[c->kind] ? pile[c->kind]->value + 1 : 1;
if(c->value == n)
attron(A_BOLD | A_UNDERLINE);
}
}
if (adjacent) {
if (find && c->value == find) {
attron(A_BOLD | A_UNDERLINE);
}
if (adjacent && !find) {
if (wselected && (c->kind & 1) != (work[selcol]->kind & 1)) {
if (c->value == work[selcol]->value + 1 ||
c->value == work[selcol]->value - 1) {
Expand Down Expand Up @@ -254,6 +258,7 @@ void render() {
mvaddstr(7 + height, 0, buf);
}
move(5 + height, 43);
find = 0;
refresh();
}

Expand Down Expand Up @@ -903,6 +908,11 @@ int main(int argc, char **argv) {
} else if(c == 'u') {
popundo();
needssolving = 1;
} else if(c == 's') {
if (arg > 0 && arg <= 13) {
find = arg;
arg = 0;
}
} else if(c == '?') {
helpscreen();
} else if(c == 10 || c == 13 || c == KEY_ENTER) {
Expand Down

0 comments on commit dfb3373

Please sign in to comment.