Add comments everywhere
This commit is contained in:
15
deck.py
15
deck.py
@ -1,33 +1,37 @@
|
||||
from random import shuffle
|
||||
import card
|
||||
import card as c
|
||||
from card import Card
|
||||
import logging
|
||||
|
||||
|
||||
class Deck(object):
|
||||
""" This class represents a deck of cards """
|
||||
|
||||
def __init__(self):
|
||||
self.cards = list()
|
||||
self.graveyard = list()
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
for color in card.COLORS:
|
||||
for value in card.VALUES:
|
||||
# Fill deck
|
||||
for color in c.COLORS:
|
||||
for value in c.VALUES:
|
||||
self.cards.append(Card(color, value))
|
||||
if not value == card.ZERO:
|
||||
if not value == c.ZERO:
|
||||
self.cards.append(Card(color, value))
|
||||
|
||||
for special in card.SPECIALS * 4:
|
||||
for special in c.SPECIALS * 4:
|
||||
self.cards.append(Card(None, None, special=special))
|
||||
|
||||
self.logger.debug(self.cards)
|
||||
self.shuffle()
|
||||
|
||||
def shuffle(self):
|
||||
""" Shuffle the deck """
|
||||
self.logger.debug("Shuffling Deck")
|
||||
shuffle(self.cards)
|
||||
|
||||
def draw(self):
|
||||
""" Draw a card from this deck """
|
||||
try:
|
||||
card = self.cards.pop()
|
||||
self.logger.debug("Drawing card " + str(card))
|
||||
@ -39,4 +43,5 @@ class Deck(object):
|
||||
return self.draw()
|
||||
|
||||
def dismiss(self, card):
|
||||
""" All played cards should be returned into the deck """
|
||||
self.graveyard.append(card)
|
||||
|
Reference in New Issue
Block a user