예제 #1
0
    def comprobar(self):
        self.paraReloj()
        self.ponToolBar([self.cancelar])
        for wm in self.liwm:
            wm.deshabilita()

        um = QTUtil2.analizando(self)

        self.liAnalisis = []
        cp = ControlPosicion.ControlPosicion()
        cp.leeFen(self.fen)
        jg = Jugada.Jugada()
        siError = False
        totalPuntos = 0
        factor = 1
        previo = 100
        for wm in self.liwm:
            desde, hasta, coronacion = wm.resultado()
            if desde:
                cpNue = cp.copia()
                siBien, mensaje = cpNue.mover(desde, hasta, coronacion)
                wm.siCorrecto(siBien)
                if not siBien:
                    wm.ponError(_("Invalid move"))
                    siError = True
                    break
                jg = Jugada.Jugada()
                jg.ponDatos(cp, cpNue, desde, hasta, coronacion)
                mrm, pos = self.xtutor.analizaJugada(jg, self.xtutor.motorTiempoJugada)
                jg.analisis = mrm, pos

                self.liAnalisis.append(jg)

                rm = mrm.liMultiPV[pos]
                rj = mrm.liMultiPV[0]
                dif = rj.puntosABS() - rm.puntosABS()
                if dif >= 100:
                    puntos = 0
                else:
                    puntos = 100 - dif
                wm.ponPuntos(puntos)
                cp = cpNue
                totalPuntos += int(puntos * factor * previo / 100)
                previo = puntos * previo / 100
                factor *= 2
            else:
                break

        um.final()
        self.btConsultar.show()

        if not siError:
            self.lbTiempo.ponTexto("<h2>%s: %d %s</h2>" % (_("Result"), totalPuntos, _("pts")))

            self.historico.append(Util.hoy(), totalPuntos, self.xtutor.clave, int(self.xtutor.motorTiempoJugada / 1000),
                                  self.min_min, self.min_max, self.linea, self.ref)

            self.ponToolBar([self.terminar])
예제 #2
0
 def recupera(self, reg):
     for atr in dir(reg):
         if atr.startswith("_") and not atr.startswith("__"):
             if atr == "_jg":
                 self._jg = Jugada.Jugada()
                 self._jg.recuperaDeTexto(reg._jg)
             else:
                 valor = getattr(reg, atr)
                 setattr(self, atr, valor)
예제 #3
0
 def recuperaDeTexto(self, txt):
     li = txt.split("|")
     self.iniPosicion = ControlPosicion.ControlPosicion().leeFen(li[0])
     self.ultPosicion = ControlPosicion.ControlPosicion().leeFen(li[1])
     nJG = int(li[2])
     self.liJugadas = []
     for n in range(nJG):
         jg = Jugada.Jugada()
         jg.recuperaDeTexto(li[n + 3])
         self.liJugadas.append(jg)
     if len(li) > nJG + 3:
         self.firstComment = li[nJG + 3]
     else:
         self.firstComment = ""
     self.siEmpiezaConNegras = not self.iniPosicion.siBlancas
예제 #4
0
    def leeTexto(self, texto):
        game = PGNreader.read1Game(texto)
        if game.erroneo:
            return False
        cp = ControlPosicion.ControlPosicion()
        cp.leeFen(game.fen)
        p = Partida.Partida(cp)
        p.firstComment = game.moves.firstComment

        for mv in game.moves.liMoves:
            cpBase = ControlPosicion.ControlPosicion()
            cpBase.leeFen(mv.fenPrev)
            cpActual = ControlPosicion.ControlPosicion()
            cpActual.leeFen(mv.fen)
            jg = Jugada.Jugada()
            jg.ponDatos(cpBase, cpActual, mv.desde, mv.hasta, mv.coronacion)

            if mv.criticas:
                li = []
                for una in mv.criticas:
                    if una:
                        if una.isdigit():
                            li.append(una)
                        elif una[0] == "$":
                            una = una[1:]
                            if una:
                                li.append(una)
                        elif una[0] in "?!":
                            jg.criticaDirecta = una
                jg.critica = " ".join(li)
            if mv.comentarios:
                jg.comentario = "\n".join(mv.comentarios)
            if mv.variantes:
                li = []
                for una in mv.variantes:
                    li.append(una.toPGN())
                jg.variantes = "\n\n".join(li)
            p.append_jg(jg)
        if game.moves:
            p.ultPosicion = cpActual if game.moves.liMoves else cp.copia()
        self.partida = p
        self.dic = game.labels
        self.siError = False
        self.texto = texto
        return True