GithubHelp home page GithubHelp logo

tty-solitaire's Introduction

tty-solitaire

Ncurses-based klondike solitaire game.

https://raw.github.com/mpereira/tty-solitaire/master/resources/ttysolitaire.gif

Dependencies

  • Terminal emulator with UTF-8 support
  • C library with multibyte locales support
  • Ncurses with wide-char/UTF-8 support

Install

https://repology.org/badge/vertical-allrepos/tty-solitaire.svg

Using package managers

Arch Linux

pacman -S tty-solitaire

macOS

brew install tty-solitaire

Debian testing

apt install tty-solitaire

Nix

nix-env --install tty-solitaire

Void Linux

xbps-install -S tty-solitaire

FreeBSD

pkg install tty-solitaire

Slackware

Via Slackbuilds.

ALT Linux

apt-get install tty-solitaire

We still need help making tty-solitaire available on Ubuntu, Fedora, Gentoo, and more. Please give us a hand at issue #29 if you think you can help.

From source

Install Ncurses

tty-solitaire depends on Ncurses. Some platforms provide it out of the box and some don’t, so you might need to install it yourself.

Ubuntu
sudo apt-get install libncurses5-dev libncursesw5-dev
macOS

macOS has Ncurses with wide character support out of the box, so there’s nothing you need to do.

If for some reason you want to use other Ncurses libraries (from Macports, Homebrew, etc.) you are able to do it by specifying LDLAGS in the make invocation. See this pull request for more information.

Install tty-solitaire

wget -O tty-solitaire-v1.3.1.tar.gz https://github.com/mpereira/tty-solitaire/archive/v1.3.1.tar.gz
tar xvf tty-solitaire-v1.3.1.tar.gz
cd tty-solitaire-1.3.1
make
sudo make install

Play

Run in your favorite shell:

ttysolitaire

Usage

usage: ./ttysolitaire [OPTIONS]
  -v, --version              Show version
  -h, --help                 Show this message
  -p, --passes               Number of passes through the deck  (default: 3)
      --four-color-deck      Draw unique card suit colors       (default: false)
      --no-background-color  Don't draw background color        (default: false)

Development

Get the code

git clone https://github.com/mpereira/tty-solitaire.git

Run the unit tests

make test

Author

Murilo Pereira

License

MIT

tty-solitaire's People

Contributors

amdmi3 avatar basxto avatar dolphywind avatar dseguin avatar dther avatar greno4ka avatar mimmyjau avatar mistydemeo avatar mpereira avatar phijor avatar porridge avatar saimen avatar siborgium avatar trofi avatar vaporup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tty-solitaire's Issues

Building fails in Fedora 32

linker seems to not like something when compiling in f32. Extract of build output below.
This is from the v1.1.1 tag but the same occurs on the building of HEAD.

cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.1.1\"   -c -o src/cursor.o src/cursor.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.1.1\"   -c -o src/keyboard.o src/keyboard.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.1.1\"   -c -o src/gui.o src/gui.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.1.1\"   -c -o src/game.o src/game.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.1.1\" src/ttysolitaire.c -o ttysolitaire src/common.o src/frame.o src/card.o src/stack.o src/deck.o src/cursor.o src/keyboard.o src/gui.o src/game.o  -lncursesw
/usr/bin/ld: src/cursor.o:(.bss+0x0): multiple definition of `deck'; /tmp/ccVwI7VH.o:(.bss+0x0): first defined here
/usr/bin/ld: src/cursor.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: multiple definition of `cursor'; /tmp/ccVwI7VH.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: first defined here
/usr/bin/ld: src/keyboard.o:(.bss+0x0): multiple definition of `deck'; /tmp/ccVwI7VH.o:(.bss+0x0): first defined here
/usr/bin/ld: src/keyboard.o:(.bss+0x8): multiple definition of `cursor'; /tmp/ccVwI7VH.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: first defined here
/usr/bin/ld: src/gui.o:(.bss+0x0): multiple definition of `deck'; /tmp/ccVwI7VH.o:(.bss+0x0): first defined here
/usr/bin/ld: src/gui.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: multiple definition of `cursor'; /tmp/ccVwI7VH.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: first defined here
/usr/bin/ld: src/game.o:(.bss+0x0): multiple definition of `deck'; /tmp/ccVwI7VH.o:(.bss+0x0): first defined here
/usr/bin/ld: src/game.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: multiple definition of `cursor'; /tmp/ccVwI7VH.o:/builddir/build/BUILD/tty-solitaire-1.1.1/src/game.h:38: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:48: ttysolitaire] Error 1
RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.92Pzdw (%build)
    Bad exit status from /var/tmp/rpm-tmp.92Pzdw (%build)
Child return code was: 1
EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 776, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed: 

Add 4 color version

Diamonds is the only suit I can get working on tty, therefore I have trouble to distinguish suits who use the same color.
It would be nice to have an option to give each suit a unique color: (from German skat)
green ♠, yellow ♦, black ♣ and red ♥

There are also other color codes on https://en.wikipedia.org/wiki/Four-color_deck

ttysolitaire --colors

Doesn't work in Android

Hi! I tried to build your tty-solitaire on my phone. But sadly it doesn't work=( Just white screen and no more else. But, when i press 'q' it closes! So, I hope, that there is solution to run it on Android=))
I think it is rather interesting idea, what do you think?

screenshot_20171117-035808

Keys 'm' and 'M' start selecting cards without pressing 'space' first

Pressing space feels like an extra click when I plan on marking all cards in the stack anyways. Perhaps pressing Shift + M should mark all cards without having to first press space. As a corollary m should also mark the first card (like pressing space).

Alternatively, could make Shift + space does that.

Build issues

.
.
.
tty-solitaire-0.1.0/tests/test_helper_test.c
tty-solitaire-0.1.0/tests/ttysolitaire_test.c
tty-solitaire-0.1.0/tests/ttysolitaire_test.h
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/common.o src/common.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/frame.o src/frame.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/card.o src/card.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/stack.o src/stack.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/deck.o src/deck.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/cursor.o src/cursor.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/keyboard.o src/keyboard.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/gui.o src/gui.c
gcc -W -Wall -pedantic -ansi -std=c99 -g -c -o src/game.o src/game.c
gcc -W -Wall -pedantic -ansi -std=c99 -g src/ttysolitaire.c -o ttysolitaire src/common.o src/frame.o src/card.o src/stack.o src/deck.o src/cursor.o src/keyboard.o src/gui.o src/game.o -lncursesw
cp -pf ttysolitaire /tmp/SBo/package-tty-solitaire/usr/bin
cp: cannot create regular file ‘/tmp/SBo/package-tty-solitaire/usr/bin’: No such file or directory
make: *** [install] Error 1

Can't move cards?

I can pull cards off the deck, but it doesn't seem like I can move them around. Do you know about this?

select all cards in a stack by default

this might just be me, but i feel like when there is more than one card in a stack (face up), more often than not, i will want to move the whole stack instead of just the top card.

could you default the selection to "all face up cards in this stack" and then i can use m and n to decrease the number of selected cards if desired?

release

Please release your app !!!

Thanks...

Need help making tty-solitaire available in package repositories

It would be cool if tty-solitaire installation was more easily accessible to people. It seems like we already have some platforms covered:

These others still aren't:

  • Fedora
  • Gentoo
  • NetBSD
  • OpenBSD
  • RHEL/CentOS
  • Ubuntu

What platforms and/or distribution channels am I missing?

Are you a user of any of these and would like to make tty-solitaire available on it? Let me know how can I help!

About detecting failure

So I've noticed that an issue about this is open - this is odd because I was sure that the feature is already implemented. Specifically I'm talking about how the O on the stack changes to X. That's what this issue was supposed to be about - I'm in a situation where I'd expect this to happen but it doesn't. Here's a screenshot

So how is the state of failure detection? Is it partially implemented? Or does that X mean something completely different? Also, is my situation from the screenshot actually a game over or I'm missing something?

Feature Request: Undo command (among a few other items)

I really like this game. Played it on Manjaro ARM Linux (which is basically an Arch Linux distro).

A few ideas for improvement:

  • Undo moves: more than likely undo as a tree of states. (Might use u as that command.)
  • Redo (Might use U (<Shift-U>) for that command.
  • Start over: return to the initial state of the game (Might use r as that command)
  • Press F2 for a new game
  • Allow m to select a column (Space does this, but using m seems to work better.)
  • Allow M (<Shift-M>) to select all the cards in the column.
  • Allow N (<Shift-N>) to deselect all the cards in the column that were selected.
  • Three card mode
  • Invert the colors of the BORDER of the card when the cursor is over it. (or use another color)
  • Invert the colors of the CARDS that are selected (or use another color)
  • Timer (show how long the game is going)
  • Points (Not sure how M$ does it, but that's been a classic feature.)
  • If Points is added, add a scoreboard? Or see who can do this the fastest?
  • man file (man ttysolitare)
  • Change the color of the deck
  • Change the color of the background (if the background is enabled)
  • 256 color support for those last two items. (that's popular lately.)
  • Auto-flip (When moving a card from a column that has cards unflipped underneath it, flip the next card automatically.)
  • Game Over screen for Wins (The game feels like it crashes upon a winning scenario. Rather than quit the game for the user, upon a possible winning scenario, either let the user complete the deck, have a button that allows for the deck to auto complete, or auto complete when a winning scenario is detected. Congratulate the user and ask if they want to play another game or quit.)
  • Game Over screen for Losses (The user has run out of moves. Ask if they want to start a new game or this game over.)
  • Hints (After a short delay, highlight some suggestions. (Might require a bit of AI?)

That's a pretty big list, so if anyone else contributes, it might be helpful towards this project.

make test fails on Debian Bullseye

~/Downloads/tty-solitaire-1.1.1 $ make test

ttysolitaire_test: tests/game_test.c:133: test_valid_move_from_waste_pile_to_foundation_stacks: Assertion `valid_move(waste_pile, foundation_stacks[i])' failed.
make: *** [Makefile:52: test] Aborted

Error, while make test

Hello, I made "make test" and got error:

ttysolitaire_test: tests/game_test.c:132: test_valid_move_from_waste_pile_to_foundation_stacks: Assertion `valid_move(waste_pile, foundation_stacks[i])' failed.
make: *** [test] Aborted

New features

This game is awesome! But I found some possible enhancements.

  • When I win, I want a big window with great letters, that are saying, that I WIN!!! Simple text in terminal "You won." is a little bit boring.
  • Game can advise to play another game, when current ends (especially when you lost).
  • Game can detect win and lost situations. (detecting of lost situations can be little bit difficult, but win situations are obvious: there no cards in stack and no hidden cards) For example in this position is very boring to drag cards up.
    _2017-10-27_14-17-14

Please, dont stop development!

Correct changelog

First of all I want to ask, why changelog has so unusual name with .org - suffix? Don't you want to rename it in just CHANGELOG?
Second ask is to add changelog entries for previous releases (before 1.0.0) For example you wrote in changelog that 1.0.0 is "Initial release.", but in releases I can see, that 0.1.0 was "Initial release.". It's confusing me. Which release was initial in fact?

Automatically detect "fail" scenario

I think it's rather complex, but cool idea - to detect situations, when there is no solution to win the game. And program can draw a beautiful window with text "You're loser, lol, hahaha" or just "You lost"=)) But it will require some artificial intelligence.

Missing LICENSE file

Hi,

I would like to create a package for Void linux.
According to the README the license is MIT, but there's no LICENSE file.
Please add it.

Thanks.

could not compile on Gentoo

I tried to compile this game on Gentoo without success.
Maybe it's a simple bug, but I'm not a programmer.

$ uname -a
Linux jeany 5.15.16-gentoo-x86_64 #1 SMP Sun Jan 23 14:12:47 CET 2022 x86_64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz GenuineIntel GNU/Linux
$
$
$ make test
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/common.o src/common.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/frame.o src/frame.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/card.o src/card.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/stack.o src/stack.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/deck.o src/deck.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/cursor.o src/cursor.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/keyboard.o src/keyboard.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/gui.o src/gui.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o src/game.o src/game.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/frame_test.o tests/frame_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/card_test.o tests/card_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/stack_test.o tests/stack_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/deck_test.o tests/deck_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/cursor_test.o tests/cursor_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/keyboard_test.o tests/keyboard_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/gui_test.o tests/gui_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/game_test.o tests/game_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/test_helper.o tests/test_helper.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon   -c -o tests/test_helper_test.o tests/test_helper_test.c
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon tests/ttysolitaire_test.c -o ttysolitaire_test tests/frame_test.o tests/card_test.o tests/stack_test.o tests/deck_test.o tests/cursor_test.o tests/keyboard_test.o tests/gui_test.o tests/game_test.o tests/test_helper.o tests/test_helper_test.o  src/common.o src/frame.o src/card.o src/stack.o src/deck.o src/cursor.o src/keyboard.o src/gui.o src/game.o  -lncursesw
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: src/common.o: undefined reference to symbol 'stdscr'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:52: test] Error 1
$
$
$ make
cc -g -W -Wall -pedantic -ansi -std=c99 -DVERSION=\"1.3.1\" -fcommon src/ttysolitaire.c -o ttysolitaire src/common.o src/frame.o src/card.o src/stack.o src/deck.o src/cursor.o src/keyboard.o src/gui.o src/game.o  -lncursesw
src/ttysolitaire.c: In function 'main':
src/ttysolitaire.c:55:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
   55 |       if (options[option_index].flag != 0)
      |          ^
src/ttysolitaire.c:57:5: note: here
   57 |     default:
      |     ^~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/cc0ZlrDT.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:49: ttysolitaire] Error 1
$

More efficient game controls

Just found this! Great that someone made a Terminal Solitaire, but there are some immediate issues:

  1. Most importantly: Too many keystrokes for common tasks. Look at Solitaire on the iPod Nano 3rd generation for how to improve this. Like, if you click a red 3, and there is a black 4 somewhere, automatically move the 3 there.

  2. For clarity, while moving a card, actually move the card visually, not just the cursor. Actually, get rid of the cursor, and instead highlight the focused card using bright ANSI colors.

  3. Let the Enter key do the same as Space.

  4. When on last column in lower area and pressing "right", move focus to first column in upper area. (And vice versa for similar situations.)

  5. I know this is not part of the original game design, but rather than having a deck where you pick cards one after the other, you could just lay out that deck in the bottom, cards side by side, where you could see all of them at once and cursor between them to pick a card. (This is not cheating, just saves you from having to pass through the whole deck to get around to a particular card.)

Any interest in fixing any of this?

Version issue

$ ttysolitaire -v
ttysolitaire: No such file or directory (src/ttysolitaire.c:128)

Feature request - just use keyboard to play

I am working on another solitaire here which do not use the mark key to move cards. It is much faster. Not to go the mouse way, really keyboard based.

The idea is that there are piles and hence why not just use

w-waste
s-stock

foundation f1 f2 f3 f3
piles 1 2 3 4 5 6 7

move can be

a) w1 for w to 1, c1f1 ...
b) the original programmer use above but I think it could be just use alternative so that you do not even need to leave the home keys mostly (except s/w and other "menu" command")

w-waste
s-stock

piles asdfghk
foundation kl;'

now to move is
-wa for waste to pile a
-wk for waste to foundation k
-ak for piles a to foundation k
-# e.g. 12 detect or "collect via keyboard event" then it will mark 12 cards

That would be much faster. Not that windows based. What you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.