Logo Search packages:      
Sourcecode: uligo version File versions  Download package

def uligo::App::nextMove (   self,
  p 
)

React to mouse-click, in 'normal mode', i.e. answering a problem
    (as opposed to 'show solution' or 'try variation' mode). 

Definition at line 470 of file uligo.py.

00470                          :
        """ React to mouse-click, in 'normal mode', i.e. answering a problem
            (as opposed to 'show solution' or 'try variation' mode). """

        self.board.play(p)  # put the stone on the board
        x, y = p

        if (self.inputColor == 'B' and not self.invertColor) or \
           (self.inputColor == 'W' and self.invertColor):
            nM = 'B'
            nnM = 'W'
        else:
            nM = 'W'
            nnM = 'B'

        nnMove = self.board.invert(self.inputColor)

        try:
       
            # look for the move in the SGF file
            done = 0 
            for i in range(self.cursor.noChildren()):
                c = self.cursor.next(i) # try i-th variation
                if c.has_key(nM) and self.convCoord(c[nM][0], self.orientation)==(x,y): # found the move
                    done = 1
                    if self.cursor.wrongVariation == 1:        # just entered wrong variation
                        if self.creditAvailable:
                            self.pbmRec.store(0)
                            self.creditAvailable = 0
                        if self.options.wrongVar.get() == 1:
                            self.statusbar.set('wrong')
                            if self.clock.running: self.clock.stop()
                        if self.options.wrongVar.get() == 2:
                            self.cursor.previous()
                            self.statusbar.set('wrong')
                            if self.clock.running: self.clock.stop()
                            time.sleep(0.5 * self.options.replaySpeedVar.get() + 0.5) # show the move for a short time,
                            self.board.undo()                                         # then delete it
                            self.statusbar.set('empty')
                            break

                    if not self.cursor.atEnd:                  # respond to the move
                        c = self.cursor.next(randint(0,self.cursor.noChildren()-1))
                        pos = self.convCoord(c[nnM][0], self.orientation)
                        self.board.play(pos, nnMove)
                        self.noMovesMade = self.noMovesMade + 2
                    else:
                        self.noMovesMade = self.noMovesMade + 1
                    if self.cursor.atEnd:                      # problem solved / end of wrong var.
                        if self.clock.running: self.clock.stop()
                        if self.cursor.wrongVariation:
                            self.statusbar.set('wrong')
                        else:
                            if self.creditAvailable:
                                self.statusbar.set('solved1')
                                self.pbmRec.store(1)
                                self.creditAvailable = 0
                            else:
                                self.statusbar.set('solved2') 
                            self.showSolutionButton.config(state=DISABLED)                        

                        self.board.state('disabled')
                    break
            
                else:
                    self.cursor.previous()
            
            if not done:                                  # not found the move in the SGF file, so it's wrong
                self.statusbar.set('wrong')
                if self.clock.running: self.clock.stop()
                if self.creditAvailable:
                    self.pbmRec.store(0)
                    self.creditAvailable = 0
                time.sleep(0.5 * self.options.replaySpeedVar.get() + 0.5) # show the move for a short time,
                self.board.undo()                                         # then delete it
                self.statusbar.set('empty')

        except SGFError:
            showwarning('SGF Error', 'Error in SGF file!')
            return


    def markRightWrong(self):


Generated by  Doxygen 1.6.0   Back to index