Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/deck.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-01-03 16:30:55 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-01-03 16:30:55 (GMT)
commit0fe16c22d347dc0826a67f71c7aaa9b05d9c4b9c (patch)
tree15ad10e7713e1e246e1be4bc5de54fc81705cd27 /deck.py
parent15e45ab016df220803bccbf1ab7bae3cd407c44e (diff)
added easy/hard levels
Diffstat (limited to 'deck.py')
-rw-r--r--deck.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/deck.py b/deck.py
index 33616ba..f6918a4 100644
--- a/deck.py
+++ b/deck.py
@@ -32,18 +32,24 @@ from card import *
# class for defining deck of cards
#
class Deck:
- def __init__(self, sprites, path, cardtype, width, height):
- # create the deck of cards
+ def __init__(self, sprites, path, cardtype, width, height, level=HIGH):
+ # Create the deck of cards.
self.cards = {}
- # remember the position in the deck
+ # Remember the position in the deck.
self.index = 0
- # how many cards are in the deck?
+ # Track how many cards are in the deck.
self.count = 0
+ # If level is 'simple', only generate one fill type
+ if level == HIGH:
+ fill_range = FILLS
+ else:
+ fill_range = 1
+ print "fill range is %d" % (fill_range)
# Initialize the deck of cards by looping through all the patterns
for shape in range(0, SHAPES):
for color in range(0, COLORS):
for num in range(0, NUMBER):
- for fill in range(0, FILLS):
+ for fill in range(0, fill_range):
self.cards[self.count] = Card(sprites, path, cardtype,
width, height,
[shape,color,num,fill])
@@ -51,13 +57,14 @@ class Deck:
# shuffle the deck
def shuffle(self):
+ decksize = self.count
# hide all the cards
for c in self.cards:
self.cards[c].hide_card()
# randomize the deck
- for n in range(0, DECKSIZE*4):
- i = random.randrange(DECKSIZE)
- j = random.randrange(DECKSIZE)
+ for n in range(0, decksize*4):
+ i = random.randrange(decksize)
+ j = random.randrange(decksize)
self.swap_cards(i,j)
# reset the index to the beginning of the deck after a shuffle
self.index = 0