X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=qchess%2Fsrc%2Fgame.py;h=f1f48bb808f4ee3dfaf0e6f6a5aea33e44b45a43;hp=1aabe4aad760f53a6ab38601638907497ebb8bcf;hb=573931ea67fa99135eca781ff814933e04df4308;hpb=64978647120812a13948e2146de81281b38a54d5 diff --git a/qchess/src/game.py b/qchess/src/game.py index 1aabe4a..f1f48bb 100644 --- a/qchess/src/game.py +++ b/qchess/src/game.py @@ -33,6 +33,7 @@ class GameThread(StoppableThread): if True: [x,y] = p.select() # Player selects a square if self.stopped(): + #debug("Quitting in select") break if isinstance(p, NetworkPlayer): @@ -44,10 +45,18 @@ class GameThread(StoppableThread): else: result = self.board.select(x, y, colour = p.colour) - result = p.update(result) + result = p.update(result) + if self.stopped(): + break for p2 in self.players: - if p2 != p: - p2.update(result) # Inform players of what happened + if p2 == p: + continue + p2.update(result) # Inform players of what happened + if self.stopped(): + break + + if self.stopped(): + break log(result) @@ -77,6 +86,7 @@ class GameThread(StoppableThread): self.stop() if self.stopped(): + #debug("Quitting in get_move") break if isinstance(p, NetworkPlayer): @@ -90,10 +100,20 @@ class GameThread(StoppableThread): result = str(x) + " " + str(y) + " -> " + str(x2) + " " + str(y2) self.board.update_move(x, y, x2, y2) - result = p.update(result) + result = p.update(result) + if self.stopped(): + break for p2 in self.players: - if p2 != p: - p2.update(result) # Inform players of what happened + if p2 == p: + continue + p2.update(result) # Inform players of what happened + if self.stopped(): + break + + if self.stopped(): + break + + log(result)