Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/grid.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-03-06 23:25:12 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-03-06 23:25:12 (GMT)
commitdc3f5cff94cdb655e95db19d8daf600f97118d90 (patch)
tree0b7cf10029eefe36cccaa7b84e185da550547802 /grid.py
parent1ea8fbaba89c1045d5eba54d6f62baab0ad667af (diff)
first pass at robot player support
Diffstat (limited to 'grid.py')
-rw-r--r--grid.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/grid.py b/grid.py
index 6de9a8b..235ca8b 100644
--- a/grid.py
+++ b/grid.py
@@ -29,12 +29,15 @@ class Grid:
# the tiles in your hand
self.hand = []
+ self.robot_hand = []
+ self.robot_status = False
for i in range(ROW * COL):
self.grid.append(None)
for i in range(COL):
self.hand.append(None)
+ self.robot_hand.append(None)
# card spacing
self.left_hand = int(card_width / 2)
@@ -47,14 +50,19 @@ class Grid:
self.blanks.append(blank_card(sprites, scale))
self.blanks[i].move(self.grid_to_xy(i))
+ def set_robot_status(self, status=False):
+ self.robot_status = status
+
def deal(self, deck):
''' Deal an initial set of cards to the hand '''
for i in range(COL):
self.hand[i] = deck.deal_next_card()
self.place_a_card(self.hand[i], self.hand_to_xy(i)[0],
self.hand_to_xy(i)[1])
+ if self.robot_status:
+ self.robot_hand[i] = deck.deal_next_card()
- # and empty the grid
+ # ...and empty the grid.
for i in range(ROW * COL):
self.grid[i] = None
@@ -64,6 +72,8 @@ class Grid:
self.hand[i] = deck.deal_next_card()
self.place_a_card(self.hand[i], self.hand_to_xy(i)[0],
self.hand_to_xy(i)[1])
+ if self.robot_status:
+ self.robot_hand[i] = deck.deal_next_card()
def find_empty_slot(self):
''' Is there an empty slot in the hand? '''
@@ -76,6 +86,10 @@ class Grid:
''' How many cards are in the hand? '''
return COL - self.hand.count(None)
+ def cards_in_robot_hand(self):
+ ''' How many cards are in the robot hand? '''
+ return COL - self.robot_hand.count(None)
+
def cards_in_grid(self):
''' How many cards are on the grid? '''
return ROW * COL - self.grid.count(None)
@@ -125,6 +139,10 @@ class Grid:
''' Return the sprite in hand-position i. '''
return self.hand[i].spr
+ def robot_hand_to_spr(self, i):
+ ''' Return the sprite in robot-hand-position i. '''
+ return self.robot_hand[i].spr
+
def spr_to_grid(self, spr):
''' Return the index of a sprite in grid. '''
for i in range(ROW * COL):