def playerUndoMoves(self, movecount, gamemodel): timedLog.write("Human.playerUndoMoves_movecount=%s" % (movecount)) log.debug("Human.playerUndoMoves: movecount=%s self=%s" % (movecount, self)) # If the movecount is odd, the player has changed, and we have to interupt if movecount % 2 == 1: # If it is no longer us to move, we raise TurnInterruprt in order to # let GameModel continue the game. if gamemodel.curplayer != self: log.debug("Human.playerUndoMoves: putting TurnInterrupt into self.queue") self.queue.put("int") # If the movecount is even, we have to ensure the board is unlocked. # This is because it might have been locked by the game ending, but # perhaps we have now undone some moves, and it is no longer ended. elif movecount % 2 == 0 and gamemodel.curplayer == self: log.debug("Human.playerUndoMoves: self=%s: calling gmwidg.setLocked" % (self)) self.gmwidg.setLocked(False)
def makeMove(self, board1, move, board2): timedLog.write("Human.makeMove_attempt=%s" % (move)) log.debug("Human.makeMove: move=%s, board1=%s board2=%s" % (move, board1, board2)) if ( self.board.view.premovePiece and self.board.view.premove0 and self.board.view.premove1 and self.color == self.board.view.premovePiece.color ): if validate( board1, Move( self.board.view.premove0, self.board.view.premove1, board1, promotion=self.board.view.premovePromotion, ), ): timedLog.write("Human.makeMove_move=%s" % (move)) log.debug( "Human.makeMove: Setting move to premove %s %s" % (self.board.view.premove0, self.board.view.premove1) ) self.board.emit_move_signal( self.board.view.premove0, self.board.view.premove1, promotion=self.board.view.premovePromotion ) # reset premove self.board.view.setPremove(None, None, None, None) self.gmwidg.setLocked(False) item = self.queue.get(block=True) self.gmwidg.setLocked(True) if item == "del": raise PlayerIsDead("Killed by foreign forces") if item == "int": log.debug("Human.makeMove: %s: raise TurnInterrupt" % self) raise TurnInterrupt return item