Skip to content

DeadFoxx1/python_solitaire

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

127 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Features:

  1. Dynamic resize of cards, spacing, and offset (works for any size screen!)
  2. All cards loaded from a sprite sheet for increased speed (generated using spright)
  3. Option for custom number of cards to draw (the default is 3 but you can change it to whatever you want)
  4. Optional debug output
  5. Web support using pygbag

About:

I started this project as soon as I learned about what a python class was. Also, I don't remember how I got the card assets. some I made myself (by coloring over others)
Also also (last one), This was originally a school project :p

TL;DR

Get the executable from the release page to run it!

Dependencies:

python
pygame
pygbag (optional for building web version)
docker (optional for building web version)

Setup:

1. Clone the repo and make a virtual environment:

git clone https://github.com/DeadFoxx1/python_solitaire
cd python_solitaire
python -m venv .venv

2. Activate the venv:

macOS/Linux:

source .venv/bin/activate

Windows:

.\.venv\Scripts\activate

3. Install dependencies:

pip install -r requirements.txt

4. Run it :3

Normal (no debug and draw 3):

python main.py

Extra options:

#see -h for help
python main.py -h
usage: main.py [-h] [-d DEBUG] [-c CARDSTODRAW]

options:
  -h, --help            show this help message and exit
  -d, --debug DEBUG     enables debug output
  -c, --cardstodraw CARDSTODRAW
                        number of cards to draw at a time (must be less then 24)
#easy mode
python  main.py -c=1

#debug mode
python main.py -d=True

#you can use both args at the same time
python main.py -d=True -c=1

DEBUG:

Run for debug output:

python main.py -d=True

Each card object _str_() is shown like this:

#5 of clubs that is face down:
5CFalse

Face cards are still their number value:

#king of clubs facing up:
13CTrue

Foundations and the very top of the columns are also card objects:

#all tops of the top columns are:
140True

#the foundations (specific to their suit):
0HTrue 

Other moves:

#valid move:
move 1STrue to 0STrue

#invalid move:
invalid move (3CTrue to 13HTrue)

#a card drawing:
draw

Build webapp using pygbag:

(Currently dosen't support the use of the extra options)

1. Get pygbag

pip install pygbag

2. build the webapp

There's a weird awaiting input screen so use --umn-block 0 to remove it

pygbag --ume_block 0 main.py

Find built files in /build
Test server runs on localhost:8000

3. build the docker image

In the root of the project directory

docker build -t solitaire .

uses port 80 by default

docker run -p 80:80 solitaire

License:

This game is released under the GNU GPLv3. It comes with absolutely no warranty. Please see LICENSE for license details.

About

Solitaire in python using pygame

Topics

Resources

License

Stars

Watchers

Forks

Contributors