A small module for creating a card deck, used for making card games

Overview

card-deck

This module can be used to create small card games such as BlackJack etc..

To initialize the deck, use:

Deck()

To shuffle the deck, use:

Deck().shuffle()

To restart/renew the deck, use:

Deck().restart()

To draw a card from the deck, use:

Deck().draw()

This returns a list[tuple[str, int]], it could look something like [("Hearts", 5)].

Classes Methods/Properties Paremeters/Arguments
Deck Method: shuffle, draw, restart optional: draw(amount=1), restart(shuffle=True)
Card Properties: name, value, suit required: Card(tuple[str, int])

Try to except EmptyDeckError and CardAmountError when drawing a card since the deck can end up being empty at some point or you maybe try to draw more cards than what the deck has.

Examples

from card_deck import Deck, Card, EmptyDeck

# Instantiating and initializing the deck
deck = Deck()

# Shuffling the deck so it becomes in random orders when drawing a card
deck.shuffle()

# Creating the hand of a player
player_hand = []

while True:
    # Asking if the user wants to draw a card
    inp = input("Do you wanna draw a card? (yes/no): ")
    
    if inp == "yes":
        try:
            player_hand.append(deck.draw())
        except EmptyDeckError: # If the Deck is empty, deck.draw() will raise a EmptyDeckError
            break
    else:
        break

# Lets say we draw a card two times, player_hand would look like: [[("Hearts", 5)], [("Spades", 10)]]
# So what we can do to pretty print it is to iterate through player_hand
for cards in player_hand:
    card = Card(cards[0]) # Since Cards only takes a tuple of str and int, we need to do cards[0]
    print(card.suit, card.name, card.value)
Owner
Hi, I'm 17 (soon 18) and I'm a Python develeoper, currently learning Rust and also working on small Python scripts. Wann be a software engineer in the future :)
Creating Tetris with Pygame

Tetris 🤝 Contributing Contributions, issues and feature requests are welcome! Feel free to check issues page. Show your support Give a ⭐️ if this pro

Gavin Capriola 0 Mar 01, 2022
A converter for the .BMR / .RLE bitmap files used in some Neversoft PS1 games.

Requirements python3 pyqt5 - can be installed with pip install PyQt5 pypng - Included Usage Instructions This program can be running py main.py in the

4 Jul 30, 2022
A little python script for finding the best word choice in a Wordle game

A little python script for finding the best word choice in a Wordle game, by assuming that at each step you want to minimise the average number of possible answers left after guessing that word (note

zeb 26 Mar 16, 2022
A small module for creating a card deck, used for making card games

card-deck This module can be used to create small card games such as BlackJack etc.. To initialize the deck, use: Deck() To shuffle the deck, use: Dec

4 Dec 31, 2021
Pyxel is a retro game engine for Python.

Pyxel is open source and free to use. Let's start making a retro game with Pyxel!

Takashi Kitao 11.2k Jan 09, 2023
Rock Paper Scissors Games with Python

This is a classic Rock, Paper, Scissors game with some ASCII aesthetics. After the welcome message, the game asks you to choose between the three choices. Then it let the computer choose its choice.

p.katekomol 1 Jan 24, 2022
2D Minecraft Clone made with Python & Pygame & OpenGL

2D Minecraft Clone This is a 2D clone of the well-known game Minecraft made in Python using Pygame and ModernGL I started this mostly as a self-improv

Kadir Aksoy 2 Sep 25, 2022
Minecraft-Bedrock-Modpack-Maker - Simple tool to combine multiple addons into one. Not finished

Minecraft-Bedrock-Modpack-Maker Simple tool to combine multiple addons into one. Not finished! Any contributing is welcome. How to use: Move all .mcpa

MivianCoin 1 Jan 06, 2022
Automatic game data translator for RPGMaker-MV

RPGMaker-MV Translator 🕹️ 🎮 Use AI to translate all the dialogs and texts of your RPGMaker automatically. 👊 You worked hard to make your game, now

Davide Liu 11 Dec 26, 2022
Implementation of the Spider-Man Game

Projeto FPRO FPRO/LEIC, 2021/22 Francisco Campos (up202108735) 1LEIC08 Objetivo Criar um clone do clássico Spider-Man em Pygame... Repositório de códi

1 Dec 24, 2021
This is a good project to train your logic game with python language

JO-KEN-PÔ!!! | Description | basic. I make this game only to train. This is a good project to train your logic game with python language. This game is

Elianderson Silva 1 Jan 24, 2022
Code and outputs from analysis determining that the wordle game can always be won in six moves.

wordle_worst_case_analysis Code and outputs from analysis determining that the wordle game can always be won in six moves. This is for the general cas

2 Aug 19, 2022
Guess The Random Number - A sample Random Number Guessing Game Python Program

Guess_The_Random_Number This repo contains a simple "Random Number Guessing Game

Pramod Kumar 3 Feb 09, 2022
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

11 Oct 11, 2022
General Crossy Road Game using Python code

Python-Game General Crossy Road Game using Python code Using code such as function and while using turtle, I was able to recreate a beginner version o

Jacob Paquette 1 Dec 19, 2021
🐥Flappy Birds🐤 Video game. With your help I can go through🚀 the pipes. All UI is made with 🐍Pygame🐍

🐠 Flappy Fish 🐢 I am Flappy Fish 🐟 . With your help I can jump through the pipes and experience an interesting and exciting flight deep into the fi

MohammadReza 2 Jan 14, 2022
This is a simple rock paper scissor game created with python.

This is a simple rock paper scissor game created with python.

Fayas Noushad 3 Feb 04, 2022
Rudimentary CMD based implementation of the Tic Tac Toe game

Packages used: questionary random os (Requires Python 3.8 as walrus operators are used in the script) Contains the .py file (tictactoe.py) and an exe

Ashwin 1 Oct 15, 2021
Easily manage wine prefixes in a new way. Run Windows software and games on Linux

Bottles Easily manage wineprefix using environments Documentation · Forums · Telegram group · Funding 📚 Documentation Before opening a new issue, che

Bottles 4.1k Jan 09, 2023
An automation bot to play Myuu Discord game

Auto selfbot Myuu is a self Discordbot, meaning it will use your TOKEN to logged as your account and take commands from yourself to play the game.

6 Dec 15, 2022