Skip to content

Commit

Permalink
First
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy7 committed Dec 20, 2019
0 parents commit 3c6b9cf
Show file tree
Hide file tree
Showing 6 changed files with 919 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# cardpacks

```py

f = Deck() #Standard, uses standard Playing Card pack

#Also included is other packs (limited for now, more to come)

f = Deck(pack=FrenchStrippedPlayingPack) #0-9 numbered cards only
# Also available is TarotNouveauPack and TarotArcanaPack

# Once you have a deck, you can

f.shuffle()

#and

card = f.pull()
# card is now a randomly drawn card from the deck, it has various values based on the pack itself
# But the default packs try to be consistent, they have a .name, .value, and when represented as string, they show a format of "the VALUE of CLASS" or something similar.
1 change: 1 addition & 0 deletions cardpacks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from cardpacks.cardpacks import *
190 changes: 190 additions & 0 deletions cardpacks/cardpacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import itertools
import random

class TarotNouveauCard:
def __init__(self, *, number, icon, theme, group):
self.number = number
self.icon = icon
self.theme = theme
self.group = group

def __repr__(self):
return f"{self.icon} #{self.number} {self.group}, {self.theme}"

class MajorArcanaTarotCard:
def __init__(self, number):
self.number = number
self.faces = [
'the fool',
'the magician',
'the high priestess',
'the empress',
'the emperer',
'the hierophant',
'the lovers',
'chariot',
'justice',
'hermit',
'wheel of fortune',
'strength',
'the hanged man',
'death',
'temperance',
'the devil',
'the tower',
'the star',
'the moon',
'the sun',
'judgement',
'the world'
]
self.name = self.faces[number]

def __repr__(self):
return f"#{self.number} {self.name}"

class MinorArcanaTarotCard:
def __init__(self, suit, value):
self.suit = suit
self.value = value

if value == 0:
self.name = "ace"

elif value == 11:
self.name = "princess"

elif value == 12:
self.name = "prince"

elif value == 13:
self.name = "queen"

elif value == 14:
self.name = "king"
else:
self.name = str(self.value)

def __repr__(self):
return f"{self.name} of {self.suit}"


class PlayingCard:
def __init__(self, *, suit=None, icon=None, value=None):
self.suit = suit
self.icon = icon
self.value = value

if value == 0:
self.name = "ace"

elif value == 10:
self.name = "jack"

elif value == 11:
self.name = "queen"

elif value == 12:
self.name = "king"

else:
self.name = str(self.value)

def __repr__(self):
if self.suit:
return f"{self.name} of {self.suit}s"
else:
return self.name

class TarotArcanaPack:
@staticmethod
def get():
deck = []
for i in range(0, 14):
deck.append(MinorArcanaTarotCard('swords', i))
deck.append(MinorArcanaTarotCard('cups', i))
deck.append(MinorArcanaTarotCard('pentacles', i))
deck.append(MinorArcanaTarotCard('wands', i))
for i in range(0, 22):
deck.append(MajorArcanaTarotCard(i))
return deck

class TarotNouveauPack:
@staticmethod
def get():
deck = []
deck.append(TarotNouveauCard(number=1, icon="🃡", theme="individual", group="folly"))
deck.append(TarotNouveauCard(number=2, icon="🃢", theme="childhood", group="the four ages"))
deck.append(TarotNouveauCard(number=3, icon="🃣", theme="youth", group="the four ages"))
deck.append(TarotNouveauCard(number=4, icon="🃤", theme="maturity", group="the four ages"))
deck.append(TarotNouveauCard(number=5, icon="🃥", theme="old age", group="the four ages"))
deck.append(TarotNouveauCard(number=6, icon="🃦", theme="morning", group="the four times of day"))
deck.append(TarotNouveauCard(number=7, icon="🃧", theme="afternoon", group="the four times of day"))
deck.append(TarotNouveauCard(number=8, icon="🃨", theme="evening", group="the four times of day"))
deck.append(TarotNouveauCard(number=9, icon="🃩", theme="night", group="the four times of day"))
deck.append(TarotNouveauCard(number=10, icon="🃪", theme="earth", group="the four elements"))
deck.append(TarotNouveauCard(number=10, icon="🃪", theme="air", group="the four elements"))
deck.append(TarotNouveauCard(number=11, icon="🃫", theme="water", group="the four elements"))
deck.append(TarotNouveauCard(number=11, icon="🃫", theme="fire", group="the four elements"))
deck.append(TarotNouveauCard(number=12, icon="🃬", theme="dance", group="the four leisures"))
deck.append(TarotNouveauCard(number=13, icon="🃭", theme="shopping", group="the four leisures"))
deck.append(TarotNouveauCard(number=14, icon="🃮", theme="open air", group="the four leisures"))
deck.append(TarotNouveauCard(number=15, icon="🃯", theme="visual arts", group="the four leisures"))
deck.append(TarotNouveauCard(number=16, icon="🃰", theme="spring", group="the four seasons"))
deck.append(TarotNouveauCard(number=17, icon="🃱", theme="summer", group="the four seasons"))
deck.append(TarotNouveauCard(number=18, icon="🃲", theme="autumn", group="the four seasons"))
deck.append(TarotNouveauCard(number=19, icon="🃳", theme="winter", group="the four seasons"))
deck.append(TarotNouveauCard(number=20, icon="🃴", theme="the game", group="the game"))
deck.append(TarotNouveauCard(number=21, icon="🃵", theme="collective", group="folly"))
return deck

class StandardPlayingPack:
@staticmethod
def get():
deck = []
for i in range(0, 12):
deck.append(PlayingCard(suit='heart', icon='♥', value=i))
deck.append(PlayingCard(suit='spade', icon='♠', value=i))
deck.append(PlayingCard(suit='diamond', icon='♦', value=i))
deck.append(PlayingCard(suit='club', icon='♣', value=i))

for i in range(0, 6):
deck.append(PlayingCard(value='joker'))

return deck

class FrenchStrippedPlayingPack:
@staticmethod
def get():
deck = []
for i in range(0, 9):
deck.append(PlayingCard('heart', '♥', i))
deck.append(PlayingCard('spade', '♠', i))
deck.append(PlayingCard('diamond', '♦', i))
deck.append(PlayingCard('club', '♣', i))

return deck

class Deck:
def __init__(self, *, pack=StandardPlayingPack):
if type(pack) == list:
self.cards = pack
else:
self.cards = pack.get()

def shuffle(self, newpack = None):
if newpack:
if type(newpack) == list:
self.cards = newpack
else:
self.cards = newpack.get()

random.shuffle(self.cards)
return self.cards

def pull(self, shuffle=True):
if shuffle:
self.shuffle()
self.new_card = self.cards[0]
del self.cards[0]
return self.new_card
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from distutils.core import setup
setup(
name = 'cardpacks',
packages = ['cardpacks'],
version = '19.12.20',
license='gpl-3.0',
description = 'A collection of playing card classes..',
author = 'Kaiser',
author_email = 'technomancer@gmx.com',
url = 'https://github.com/Kaiz0r/cardpacks',
download_url = 'https://github.com/Kaiz0r/cardpacks/archive/19.12.20.tar.gz',
keywords = ['cards', 'packs', 'playing', 'tarot'],
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)

0 comments on commit 3c6b9cf

Please sign in to comment.