Lots of stuff happened
[progcomp2013.git] / qchess / game.py
index 1b568a0..efca0f8 100644 (file)
@@ -18,13 +18,18 @@ class GameThread(StoppableThread):
                        
                        for p in self.players:
                                with self.lock:
-                                       self.state["turn"] = p # "turn" contains the player who's turn it is
-                               #try:
-                               if True:
+                                       if isinstance(p, NetworkSender):
+                                               self.state["turn"] = p.base_player # "turn" contains the player who's turn it is
+                                       else:
+                                               self.state["turn"] = p
+                               try:
                                        [x,y] = p.select() # Player selects a square
                                        if self.stopped():
                                                break
 
+                                       
+                                               
+
                                        result = self.board.select(x, y, colour = p.colour)                             
                                        for p2 in self.players:
                                                p2.update(result) # Inform players of what happened
@@ -75,18 +80,18 @@ class GameThread(StoppableThread):
                                                        graphics.state["moves"] = None
 
                        # Commented out exception stuff for now, because it makes it impossible to tell if I made an IndentationError somewhere
-                               #except Exception,e:
-                                       #result = "ILLEGAL " + e.message
+                               except Exception,e:
+                                       result = e.message
                                        #sys.stderr.write(result + "\n")
                                        
-                                       #self.stop()
-                                       #with self.lock:
-                                       #       self.final_result = self.state["turn"].colour + " " + "ILLEGAL"
+                                       self.stop()
+                                       with self.lock:
+                                               self.final_result = self.state["turn"].colour + " " + e.message
 
                                if self.board.king["black"] == None:
                                        if self.board.king["white"] == None:
                                                with self.lock:
-                                                       self.final_result = "DRAW"
+                                                       self.final_result = self.state["turn"].colour + " DRAW"
                                        else:
                                                with self.lock:
                                                        self.final_result = "white"

UCC git Repository :: git.ucc.asn.au