erkennt jetzt ob das spiel fertig ist master
authorjennifer.tesch <jennifer.tesch@gmx.de>
Sun, 3 Jun 2007 00:47:20 +0000 (00:47 +0000)
committerjennifer.tesch <jennifer.tesch@gmx.de>
Sun, 3 Jun 2007 00:47:20 +0000 (00:47 +0000)
engine.py

index 1022718..a625cfe 100644 (file)
--- a/engine.py
+++ b/engine.py
@@ -56,9 +56,17 @@ class BoardSlot(Slot):
     def can_drop_ship(self):
         if not self.is_reachable:
             return False
-        for neigh in self.adj:
-            if neigh and neigh.is_ocean and not neigh.card:
-                return True
+        if not self.is_ocean:
+            for  neigh in self.adj:
+                if neigh and neigh.is_ocean and not neigh.card:
+                    return True
+        else:
+            if not self.card:
+                return False
+            for dir in self.card.sea_conn():
+                neigh = self.adj[dir]
+                if neigh and neigh.is_ocean and not neigh.card:
+                    return True
         return False
         
     def can_drop_card(self, card):
@@ -268,6 +276,8 @@ class Pile(Slot):
     def can_drop_ship(self):
         return False
 
+    def is_empty(self):
+        return (len(self.cards) == 0)
 
     def rotate_right(self):
         if self.card:
@@ -439,8 +449,20 @@ class Board:
 
 
        self.points = points
+        print self.finished()
         #self.pd.set_points(points)
+    
+    def finished(self):
 
+        if (state == SHIPPING and self.pile.is_empty()):
+            return True
+        
+        for col in self.slots:
+            for slot in col:
+                if slot.can_drop_ship(): return False
+        
+        return True
+             
 
 
 # vim:ts=4:sw=4:sts=4:et