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@walter-laptop.(none)>2009-10-04 18:04:19 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-10-04 18:04:19 (GMT)
commitb361fd5355714467794bbb48252829468c94e122 (patch)
treee035adf1f5e0a405520cd780fda49e16be3956f3 /grid.py
parent4f6a5d5cab10af39e3ba81a5dc6e66aabcc51efc (diff)
old-style toolbars enabled
Diffstat (limited to 'grid.py')
-rw-r--r--grid.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/grid.py b/grid.py
index 8cc45b4..6565a68 100644
--- a/grid.py
+++ b/grid.py
@@ -36,9 +36,10 @@ CARD_DEFS = ((1,3,-2,-3),(2,3,-3,-2),(2,3,-4,-4),\
# class for defining 3x3 matrix of cards
#
class Grid:
- # 123
- # 456
- # 789
+ # 012
+ # 345
+ # 678
+ # 9 is an extra (blank) card that matches everything
def __init__(self,tw):
self.grid = [0,1,2,3,4,5,6,7,8,9]
self.card_table = {}
@@ -57,9 +58,12 @@ class Grid:
if i == 9: # put the extra (blank) card off the screen
y = tw.height
+ # swap in/out the blank card
def toggle_blank(self):
self.swap(6,9)
+ # swap card a and card b
+ # swap their entries in the grid and the position of their sprites
def swap(self,a,b):
# swap grid elements and x,y positions of sprites
# print "swapping cards " + str(a) + " and " + str(b)
@@ -74,12 +78,15 @@ class Grid:
self.card_table[b].spr.x = x
self.card_table[b].spr.y = y
+ # print the grid
def print_grid(self):
- print self.grid
+ print self.grid[0:2]
+ print self.grid[3:5]
+ print self.grid[6:8]
return
+ # test all relevant borders, ignoring borders on the blank card
def test(self):
- # self.print_grid()
for i in (0,1,3,4,6,7):
if self.card_table[self.grid[i]].east != 0 and \
self.card_table[self.grid[i+1]].west != 0 and \