Beispiel #1
0
    def tw_uti_tactic(self):
        def rutinaDatos(recno):
            dic = {}
            for clave in self.dbGames.liCamposBase:
                dic[clave] = self.dbGames.field(recno, clave)
            dic["PGN"] = self.dbGames.leePGNrecno(recno)
            return dic

        liRegistros = self.grid.recnosSeleccionados()
        if len(liRegistros) < 2:
            liRegistros = range(self.dbGames.reccount())

        PantallaPGN.crearTactic(self.procesador, self, liRegistros, rutinaDatos)
Beispiel #2
0
    def tw_uti_tactic(self):
        dbf = self.dbGamesFEN.dbf

        def rutinaDatos(recno):
            dic = {}
            dbf.goto(recno)
            for clave in dbf.liCampos:
                dic[clave] = getattr(dbf.reg, clave)
            dic["PGN"] = Util.blob2var(dic["PGN"])
            return dic

        liRegistros = self.grid.recnosSeleccionados()
        if len(liRegistros) < 2:
            liRegistros = range(dbf.reccount())

        PantallaPGN.crearTactic(self.procesador, self, liRegistros, rutinaDatos)
Beispiel #3
0
    def crearTactic(self):
        dbf = self.dbGames.dbf

        def rutinaDatos(recno):
            dic = {}
            dbf.goto(recno)
            for clave in dbf.liCampos:
                dic[clave] = getattr(dbf.reg, clave)
            dic["PGN"] = Util.blob2var(dic["PGN"])
            return dic

        liRegistros = self.grid.recnosSeleccionados()
        if len(liRegistros) < 2:
            liRegistros = range(dbf.reccount())

        PantallaPGN.crearTactic(self.procesador, self, liRegistros, rutinaDatos)
Beispiel #4
0
        def standard():
            w = PantallaPGN.WFiltrar(self, self.grid.oColumnas, self.liFiltro, self.dbGames.nomFichero)
            if w.exec_():
                self.liFiltro = w.liFiltro

                self.where = w.where()
                self.dbGames.filterPV(xpv, self.where)
                refresh()
Beispiel #5
0
 def raw_sql():
     w = PantallaPGN.WFiltrarRaw(self, self.grid.oColumnas, self.where)
     if w.exec_():
         self.where = w.where
         self.dbGames.filterPV(xpv, self.where)
         self.grid.refresh()
         self.grid.gotop()
         self.updateStatus()
Beispiel #6
0
 def nuevo(self):
     unpgn = PantallaPGN.eligePartida(self)
     if unpgn and unpgn.partida.numJugadas():
         reg = unpgn.dic
         unpgn.partida.siTerminada()
         reg["PARTIDA"] = unpgn.partida.guardaEnTexto()
         self.db.append(reg)
         self.grid.refresh()
         self.grid.gotop()
Beispiel #7
0
 def nuevo(self):
     unpgn = PantallaPGN.eligePartida(self)
     if unpgn and unpgn.partida.numJugadas():
         reg = unpgn.dic
         unpgn.partida.siTerminada()
         reg["PARTIDA"] = unpgn.partida.guardaEnTexto()
         self.db.append(reg)
         self.grid.refresh()
         self.grid.gotop()
Beispiel #8
0
 def raw_sql():
     w = PantallaPGN.WFiltrarRaw(self, self.grid.oColumnas, self.where)
     if w.exec_():
         self.where = w.where
         self.dbGames.filterPV(
             self.summaryActivo["pv"] if self.summaryActivo else None,
             self.where)
         self.grid.refresh()
         self.grid.gotop()
         self.updateStatus()
Beispiel #9
0
    def tw_filtrar(self):
        w = PantallaPGN.WFiltrar(self, self.grid.oColumnas, self.liFiltro)
        if w.exec_():
            self.liFiltro = w.liFiltro

            self.where = w.where()
            self.dbGames.filter(self.where)
            self.grid.refresh()
            self.grid.gotop()
            self.updateStatus()
Beispiel #10
0
        def standard():
            w = PantallaPGN.WFiltrar(self, self.grid.oColumnas, self.liFiltro)
            if w.exec_():
                self.liFiltro = w.liFiltro

                self.where = w.where()
                self.dbGames.filterPV(
                    self.summaryActivo["pv"] if self.summaryActivo else None,
                    self.where)
                self.grid.refresh()
                self.grid.gotop()
                self.updateStatus()
 def leerpgn(self, unpgn=None):
     if unpgn is None:
         unpgn = PantallaPGN.eligePartida(self.pantalla)
     if unpgn:
         self.bloqueApertura = None
         self.posicApertura = None
         self.fen = unpgn.dic.get("FEN", None)
         self.xfichero = None
         self.xpgn = None
         self.xjugadaInicial = None
         dic = self.creaDic()
         dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
         dic["liPGN"] = unpgn.listaCabeceras()
         dic["FEN"] = self.fen
         dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
         self.reiniciar(dic)
Beispiel #12
0
    def execMenuSP(self, tipo, siInsertar):
        if siInsertar:
            fila = self.g_guion.recno()
            filaIni = fila
        else:
            fila = -1
            filaIni = len(self.guion)

        if tipo == "PI":
            fen = self.tablero.fenActual()
            fen = WinPosition.editarPosicion(self, VarGen.configuracion, fen)
            if fen is None:
                return None

            nombre = self.editaNombre(_("Start position"))
            if nombre is None:
                return

            tarea = TabVisual.GT_Posicion()
            if not fen:
                fen = ControlPosicion.FEN_INICIAL
            tarea.fen(fen)
            tarea.nombre(nombre)
            self.guion.nuevaTarea(tarea, fila)
            self.gridPonValor(None, filaIni, None, True)

        elif tipo == "PP":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    nombre = self.editaNombre(_("Start position"))
                    if nombre is None:
                        return
                    cp.leeFen(str(texto))
                    tarea = TabVisual.GT_Posicion()
                    tarea.fen(cp.fen())
                    tarea.nombre(nombre)
                    self.guion.nuevaTarea(tarea, fila)
                    self.gridPonValor(None, filaIni, None, True)
                except:
                    return None
        elif tipo == "PA":
            nombre = self.editaNombre(_("Start position"))
            if nombre is None:
                return
            tarea = TabVisual.GT_Posicion()
            tarea.fen(self.tablero.fenActual())
            tarea.nombre(nombre)
            self.guion.nuevaTarea(tarea, fila)
        else:
            if tipo == "PGNF":
                unpgn = PantallaPGN.eligePartida(self)
                partida = unpgn.partida if unpgn else None
            else:
                pgn = QTUtil.traePortapapeles()
                partida = PantallaTabVPartidas.texto2partida(
                    self, pgn) if pgn else None
            if partida and partida.numJugadas():
                w = PantallaTabVPartidas.W_EligeMovimientos(self, partida)
                if w.exec_():
                    for jg in w.resultado:
                        tarea = TabVisual.GT_Jugada()
                        tarea.jugada(jg)
                        self.guion.nuevaTarea(tarea, fila)
                        if fila != -1:
                            fila += 1
                else:
                    return None
            else:
                return None

        self.g_guion.goto(filaIni, 0)
        self.g_guion.refresh()
Beispiel #13
0
    def execMenuSP(self, tipo, siInsertar):
        if siInsertar:
            fila = self.g_guion.recno()
            filaIni = fila
        else:
            fila = -1
            filaIni = len(self.guion)

        if tipo == "PI":
            fen = self.tablero.fenActual()
            fen = WinPosition.editarPosicion(self, VarGen.configuracion, fen)
            if fen is None:
                return None

            nombre = self.editaNombre(_("Start position"))
            if nombre is None:
                return

            tarea = TabVisual.GT_Posicion()
            if not fen:
                cp = ControlPosicion.FEN_INICIAL
            tarea.fen(fen)
            tarea.nombre(nombre)
            self.guion.nuevaTarea(tarea, fila)
            self.gridPonValor(None, filaIni, None, True)

        elif tipo == "PP":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    nombre = self.editaNombre(_("Start position"))
                    if nombre is None:
                        return
                    cp.leeFen(str(texto))
                    tarea = TabVisual.GT_Posicion()
                    tarea.fen(cp.fen())
                    tarea.nombre(nombre)
                    self.guion.nuevaTarea(tarea, fila)
                    self.gridPonValor(None, filaIni, None, True)
                except:
                    return None
        elif tipo == "PA":
            nombre = self.editaNombre(_("Start position"))
            if nombre is None:
                return
            tarea = TabVisual.GT_Posicion()
            tarea.fen(self.tablero.fenActual())
            tarea.nombre(nombre)
            self.guion.nuevaTarea(tarea, fila)
        else:
            if tipo == "PGNF":
                unpgn = PantallaPGN.eligePartida(self)
                partida = unpgn.partida if unpgn else None
            else:
                pgn = QTUtil.traePortapapeles()
                partida = PantallaTabVPartidas.texto2partida(self, pgn) if pgn else None
            if partida and partida.numJugadas():
                w = PantallaTabVPartidas.W_EligeMovimientos(self, partida)
                if w.exec_():
                    for jg in w.resultado:
                        tarea = TabVisual.GT_Jugada()
                        tarea.jugada(jg)
                        self.guion.nuevaTarea(tarea, fila)
                        if fila != -1:
                            fila += 1
                else:
                    return None
            else:
                return None

        self.g_guion.goto(filaIni, 0)
        self.g_guion.refresh()
Beispiel #14
0
    def configurarGS(self):
        sep = (None, None, None)

        liMasOpciones = [
            ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()),
            sep,
            ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()),
            sep,
            ("pastepgn", _("Paste PGN"), Iconos.Pegar16()),
            sep,
        ]
        if not self.siCompleta:
            liMasOpciones.extend([
                ("posicion", _("Start position"), Iconos.Datos()), sep,
                ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()),
                sep, ("voyager", _("Voyager 2"), Iconos.Voyager1())
            ])

        resp = self.configurar(liMasOpciones,
                               siCambioTutor=True,
                               siSonidos=True)

        if resp == "rotacion":
            self.siVolteoAutomatico = not self.siVolteoAutomatico
            siBlancas = self.partida.ultPosicion.siBlancas
            if self.siVolteoAutomatico:
                if siBlancas != self.tablero.siBlancasAbajo:
                    self.tablero.rotaTablero()

        elif resp == "posicion":
            ini_fen = self.partida.iniPosicion.fen()
            cur_fen = Voyager.voyagerFEN(self.pantalla, ini_fen)
            if cur_fen and cur_fen != ini_fen:
                self.partida.resetFEN(cur_fen)
                self.inicio(self.partida, self.siCompleta)

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    cp.leeFen(str(texto))
                    self.fen = cp.fen()
                    self.posicApertura = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            unpgn = PantallaPGN.eligePartida(self.pantalla)
            if unpgn:
                partida = unpgn.partida
                if self.siCompleta and not partida.siFenInicial():
                    return
                p = Partida.PartidaCompleta()
                p.leeOtra(partida)
                p.asignaApertura()
                p.setTags(unpgn.listaCabeceras())
                self.reinicio = p.save()
                self.reiniciar()

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                unpgn = PGN.UnPGN()
                unpgn.leeTexto(texto)
                if unpgn.siError:
                    QTUtil2.mensError(
                        self.pantalla,
                        _("The text from the clipboard does not contain a chess game in PGN format"
                          ))
                    return
                partida = unpgn.partida
                if self.siCompleta and not partida.siFenInicial():
                    return
                p = Partida.PartidaCompleta()
                p.leeOtra(partida)
                p.asignaApertura()
                p.setTags(unpgn.listaCabeceras())
                self.reinicio = p.save()
                self.reiniciar()

        elif resp == "voyager":
            ptxt = Voyager.voyagerPartida(self.pantalla, self.partida)
            if ptxt:
                dic = self.creaDic()
                dic["PARTIDA"] = ptxt
                p = self.partida.copia()
                p.recuperaDeTexto(ptxt)
                dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen()
                dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo
                self.reiniciar(dic)
Beispiel #15
0
    def tw_massive(self):
        liSeleccionadas = self.grid.recnosSeleccionados()
        nSeleccionadas = len(liSeleccionadas)

        alm = PantallaAnalisisParam.paramAnalisisMasivo(self, self.configuracion, nSeleccionadas > 1, siDatabase=True)
        if alm:

            if alm.siVariosSeleccionados:
                nregs = nSeleccionadas
            else:
                nregs = self.dbGames.reccount()

            tmpBP = QTUtil2.BarraProgreso2(self, _("Mass analysis"), formato2="%p%")
            tmpBP.ponTotal(1, nregs)
            tmpBP.ponRotulo(1, _("Game"))
            tmpBP.ponRotulo(2, _("Moves"))
            tmpBP.mostrar()

            ap = Analisis.AnalizaPartida(self.procesador, alm, True)

            for n in range(nregs):

                if tmpBP.siCancelado():
                    break

                tmpBP.pon(1, n + 1)

                if alm.siVariosSeleccionados:
                    n = liSeleccionadas[n]

                partida = self.dbGames.leePartidaRecno(n)
                self.grid.goto(n, 0)

                ap.xprocesa(partida.dicTags(), partida, tmpBP, partida.pgn())

                self.dbGames.guardaPartidaRecno(n, partida)

            if not tmpBP.siCancelado():
                ap.terminar(True)

                liCreados = []
                liNoCreados = []

                if alm.tacticblunders:
                    if ap.siTacticBlunders:
                        liCreados.append(alm.tacticblunders)
                    else:
                        liNoCreados.append(alm.tacticblunders)

                for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
                    if x:
                        if Util.existeFichero(x):
                            liCreados.append(x)
                        else:
                            liNoCreados.append(x)

                if alm.bmtblunders:
                    if ap.siBMTblunders:
                        liCreados.append(alm.bmtblunders)
                    else:
                        liNoCreados.append(alm.bmtblunders)
                if alm.bmtbrilliancies:
                    if ap.siBMTbrilliancies:
                        liCreados.append(alm.bmtbrilliancies)
                    else:
                        liNoCreados.append(alm.bmtbrilliancies)
                if liCreados:
                    PantallaPGN.mensajeEntrenamientos(self, liCreados, liNoCreados)

            else:
                ap.terminar(False)

            tmpBP.cerrar()
Beispiel #16
0
def analizaPartida(gestor):
    partida = gestor.partida
    procesador = gestor.procesador
    pantalla = gestor.pantalla
    pgn = gestor.pgn

    alm = PantallaParamAnalisis.paramAnalisis(pantalla, procesador.configuracion, True)

    if alm is None:
        return

    liJugadas = []
    lni = Util.ListaNumerosImpresion(alm.jugadas)
    numJugada = int(partida.primeraJugada())
    siBlancas = not partida.siEmpiezaConNegras
    for nRaw in range(partida.numJugadas()):
        siGrabar = lni.siEsta(numJugada)
        if siGrabar:
            if siBlancas:
                if not alm.blancas:
                    siGrabar = False
            elif not alm.negras:
                siGrabar = False
        if siGrabar:
            liJugadas.append(nRaw)
        siBlancas = not siBlancas
        if siBlancas:
            numJugada += 1

    mensaje = _("Analyzing the move....")
    numJugadas = len(liJugadas)
    tmpBP = QTUtil2.BarraProgreso(pantalla, _("Analysis"), mensaje, numJugadas).mostrarAD()

    ap = AnalizaPartida(procesador, alm, False, liJugadas)

    def dispatchBP(pos, ntotal, njg):
        tmpBP.mensaje(mensaje + " %d/%d" % ( pos + 1, ntotal))
        jg = partida.liJugadas[njg]
        gestor.ponPosicion(jg.posicion)
        gestor.pantalla.pgnColocate(njg / 2, (njg + 1) % 2)
        gestor.tablero.ponFlechaSC(jg.desde, jg.hasta)
        gestor.ponVista()

    ap.dispatchBP(dispatchBP)

    ap.xprocesa(pgn.dicCabeceraActual(), partida, tmpBP, pgn.actual())

    notCanceled = not tmpBP.siCancelado()
    ap.terminar(notCanceled)

    if notCanceled:
        liCreados = []
        liNoCreados = []

        if alm.tacticblunders:
            if ap.siTacticBlunders:
                liCreados.append(alm.tacticblunders)
            else:
                liNoCreados.append(alm.tacticblunders)

        for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
            if x:
                if Util.existeFichero(x):
                    liCreados.append(x)
                else:
                    liNoCreados.append(x)

        if alm.bmtblunders:
            if ap.siBMTblunders:
                liCreados.append(alm.bmtblunders)
            else:
                liNoCreados.append(alm.bmtblunders)
        if alm.bmtbrilliancies:
            if ap.siBMTbrilliancies:
                liCreados.append(alm.bmtbrilliancies)
            else:
                liNoCreados.append(alm.bmtbrilliancies)

        if liCreados or liNoCreados:
            PantallaPGN.mensajeEntrenamientos(pantalla, liCreados, liNoCreados)

    tmpBP.cerrar()

    gestor.ponteAlFinal()

    if notCanceled:
        if alm.showGraphs:
            gestor.showAnalisis()
Beispiel #17
0
    def configurarGS(self):
        sep = (None, None, None)

        liMasOpciones = [
            ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep,
            ("apertura", _("Opening"), Iconos.Apertura()), sep,
            ("posicion", _("Start position"), Iconos.Datos()), sep,
            ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()), sep,
            ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()), sep,
            ("pastepgn", _("Paste PGN"), Iconos.Pegar16()), sep,
            ("voyager", _("Voyager 2"), Iconos.Voyager1()),
        ]
        resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True)

        if resp == "rotacion":
            self.siVolteoAutomatico = not self.siVolteoAutomatico
            siBlancas = self.partida.ultPosicion.siBlancas
            if self.siVolteoAutomatico:
                if siBlancas != self.tablero.siBlancasAbajo:
                    self.tablero.rotaTablero()
        elif resp == "apertura":
            bl, ps = PantallaAperturas.dameApertura(self.pantalla, self.configuracion, self.bloqueApertura,
                                                    self.posicApertura)
            if bl:
                self.bloqueApertura = bl
                self.posicApertura = ps
                self.fen = None
                self.reiniciar()

        elif resp == "posicion":
            resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen)
            if resp is not None:
                self.fen = resp
                self.bloqueApertura = None
                self.posicApertura = None

                if self.xpgn:
                    siInicio = self.fen == ControlPosicion.FEN_INICIAL
                    li = self.xpgn.split("\n")
                    lin = []
                    siFen = False
                    for linea in li:
                        if linea.startswith("["):
                            if "FEN " in linea:
                                siFen = True
                                if siInicio:
                                    continue
                                linea = '[FEN "%s"]' % self.fen
                            lin.append(linea)
                        else:
                            break
                    if not siFen:
                        linea = '[FEN "%s"]' % self.fen
                        lin.append(linea)
                    self.liPGN = lin
                    self.xpgn = "\n".join(lin) + "\n\n*"

                self.reiniciar()

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    cp.leeFen(str(texto))
                    self.fen = cp.fen()
                    self.bloqueApertura = None
                    self.posicApertura = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            unpgn = PantallaPGN.eligePartida(self.pantalla)
            if unpgn:
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                unpgn = PGN.UnPGN()
                unpgn.leeTexto(texto)
                if unpgn.siError:
                    QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format"))
                    return
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "voyager":
            ptxt = XVoyager.xVoyager(self.pantalla, self.configuracion, partida=self.partida)
            if ptxt:
                dic = self.creaDic()
                dic["PARTIDA"] = ptxt
                p = self.partida.copia()
                p.recuperaDeTexto(ptxt)
                dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen()
                dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo
                self.reiniciar(dic)
 def dropPGN(self, pgn):
     unpgn = PantallaPGN.eligePartida(self.pantalla, pgn)
     if unpgn:
         self.leerpgn(unpgn)
Beispiel #19
0
def analizaPartida(gestor):
    partida = gestor.partida
    procesador = gestor.procesador
    pantalla = gestor.pantalla
    pgn = gestor.pgn

    alm = PantallaAnalisisParam.paramAnalisis(pantalla,
                                              procesador.configuracion, True)

    if alm is None:
        return

    liJugadas = []
    lni = Util.ListaNumerosImpresion(alm.jugadas)
    numJugada = int(partida.primeraJugada())
    siBlancas = not partida.siEmpiezaConNegras
    for nRaw in range(partida.numJugadas()):
        siGrabar = lni.siEsta(numJugada)
        if siGrabar:
            if siBlancas:
                if not alm.blancas:
                    siGrabar = False
            elif not alm.negras:
                siGrabar = False
        if siGrabar:
            liJugadas.append(nRaw)
        siBlancas = not siBlancas
        if siBlancas:
            numJugada += 1

    mensaje = _("Analyzing the move....")
    numJugadas = len(liJugadas)
    tmpBP = QTUtil2.BarraProgreso(pantalla, _("Analysis"), mensaje,
                                  numJugadas).mostrarAD()

    ap = AnalizaPartida(procesador, alm, False, liJugadas)

    def dispatchBP(pos, ntotal, njg):
        tmpBP.mensaje(mensaje + " %d/%d" % (pos + 1, ntotal))
        jg = partida.jugada(njg)
        gestor.ponPosicion(jg.posicion)
        gestor.pantalla.pgnColocate(njg / 2, (njg + 1) % 2)
        gestor.tablero.ponFlechaSC(jg.desde, jg.hasta)
        gestor.ponVista()

    ap.dispatchBP(dispatchBP)

    ap.xprocesa(pgn.dicCabeceraActual(), partida, tmpBP, pgn.actual())

    notCanceled = not tmpBP.siCancelado()
    ap.terminar(notCanceled)

    if notCanceled:
        liCreados = []
        liNoCreados = []

        if alm.tacticblunders:
            if ap.siTacticBlunders:
                liCreados.append(alm.tacticblunders)
            else:
                liNoCreados.append(alm.tacticblunders)

        for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
            if x:
                if Util.existeFichero(x):
                    liCreados.append(x)
                else:
                    liNoCreados.append(x)

        if alm.bmtblunders:
            if ap.siBMTblunders:
                liCreados.append(alm.bmtblunders)
            else:
                liNoCreados.append(alm.bmtblunders)
        if alm.bmtbrilliancies:
            if ap.siBMTbrilliancies:
                liCreados.append(alm.bmtbrilliancies)
            else:
                liNoCreados.append(alm.bmtbrilliancies)

        if liCreados or liNoCreados:
            PantallaPGN.mensajeEntrenamientos(pantalla, liCreados, liNoCreados)

    tmpBP.cerrar()

    gestor.ponteAlFinal()

    if notCanceled:
        if alm.showGraphs:
            gestor.showAnalisis()
Beispiel #20
0
    def configurarGS(self):
        mt = _("Engine").lower()
        mt = _X(_("Disable %1"), mt) if self.siJuegaMotor else _X(_("Enable %1"), mt)

        sep = (None, None, None)

        liMasOpciones = [
            ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep,
            ("apertura", _("Opening"), Iconos.Apertura()), sep,
            ("posicion", _("Start position"), Iconos.Datos()), sep,
            ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()), sep,
            ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()), sep,
            ("pastepgn", _("Paste PGN"), Iconos.Pegar16()), sep,
            ("motor", mt, Iconos.Motores()), sep,
            ("voyager", _("Voyager 2"), Iconos.Voyager1()),
        ]
        resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True)

        if resp == "rotacion":
            self.siVolteoAutomatico = not self.siVolteoAutomatico
            siBlancas = self.partida.ultPosicion.siBlancas
            if self.siVolteoAutomatico:
                if siBlancas != self.tablero.siBlancasAbajo:
                    self.tablero.rotaTablero()
        elif resp == "apertura":
            me = self.unMomento()
            w = PantallaAperturas.WAperturas(self.pantalla, self.configuracion, self.bloqueApertura)
            me.final()
            if w.exec_():
                self.bloqueApertura = w.resultado()
                # self.posicApertura = ps
                self.fen = None
                self.reiniciar()

        elif resp == "posicion":
            self.startPosition()

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    cp.leeFen(str(texto))
                    self.fen = cp.fen()
                    self.bloqueApertura = None
                    self.posicApertura = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            unpgn = PantallaPGN.eligePartida(self.pantalla)
            if unpgn:
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                unpgn = PGN.UnPGN()
                unpgn.leeTexto(texto)
                if unpgn.siError:
                    QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format"))
                    return
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "motor":
            self.ponRotulo1("")
            if self.siJuegaMotor:
                if self.xrival:
                    self.xrival.terminar()
                    self.xrival = None
                self.siJuegaMotor = False
            else:
                self.cambioRival()

        elif resp == "voyager":
            ptxt = Voyager.voyagerPartida(self.pantalla, self.partida)
            if ptxt:
                dic = self.creaDic()
                dic["PARTIDA"] = ptxt
                p = self.partida.copia()
                p.recuperaDeTexto(ptxt)
                dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen()
                dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo
                self.reiniciar(dic)
Beispiel #21
0
    def ficheroMostrar(self, dicDB, siRepite, siAnterior=False, siSiguiente=False):

        bd = SQLBase.DBBase(dicDB["PATHDB"])

        if (not siRepite) and self.siFicheroNuestro:
            orden = "ROWID DESC"
        else:
            orden = ""

        dClavesTam = dicDB["DCLAVES"]
        dbf = bd.dbf("GAMES", ",".join(dClavesTam.keys()),
                     orden=orden)  # La lectura se hace en la pantalla, para que la haga en el mismo sitio tanto siRepite como si no

        estadoWpgn = dicDB["ESTADOWPGN"] if siRepite else None

        if siAnterior or siSiguiente:
            siSeguir = True
            siSeHaBorradoAlgo = False
            dbf.leer()
            recno = estadoWpgn.recno
            if siAnterior:
                if recno > 0:
                    recno -= 1
            elif siSiguiente:
                if recno < dbf.reccount() - 1:
                    recno += 1
            dbf.goto(recno)
            estadoWpgn.recno = recno
        else:
            siSeguir, estadoWpgn, siSeHaBorradoAlgo = PantallaPGN.elegirPGN(self.pantalla, dbf, dClavesTam, self,
                                                                            estadoWpgn)

        if siSeguir:
            self.pensando(True)
            rid = dbf.rowid(dbf.recno)
            self.dicDB = dicDB
            dicDB["ESTADOWPGN"] = estadoWpgn
            dbf.cerrar()
            dbf = bd.dbfT("GAMES", ",".join(dClavesTam.keys()) + ",PGN", condicion="ROWID=%d" % rid)
            dbf.leer()
            dbf.gotop()
            dicDatos = dbf.dicValores()
            self.pgnPaste = dicDatos["PGN"]

            dbf.cerrar()
            pgn = PGN.UnPGN()
            pgn.leeTexto(dicDatos["PGN"])
            siMostrar = not pgn.siError
            self.pensando(False)
            if not siMostrar:
                QTUtil2.mensError(self.pantalla, _("This is not a valid PGN file"))

        else:
            siMostrar = False

        bd.cerrar()

        if siSeHaBorradoAlgo:
            fpgn = PGN.PGN()
            fpgn.borraReferenciaA(dicDB["FICHERO"])

        if siMostrar:
            self.mostrar(pgn, True)
        elif self.muestraInicial or self.finExit:
            self.finPartida()
Beispiel #22
0
    def ficheroMostrar(self,
                       dicDB,
                       siRepite,
                       siAnterior=False,
                       siSiguiente=False):

        bd = SQLBase.DBBase(dicDB["PATHDB"])

        if (not siRepite) and self.siFicheroNuestro:
            orden = "ROWID DESC"
        else:
            orden = ""

        dClavesTam = dicDB["DCLAVES"]
        dbf = bd.dbf(
            "GAMES", ",".join(dClavesTam.keys()), orden=orden
        )  # La lectura se hace en la pantalla, para que la haga en el mismo sitio tanto siRepite como si no

        estadoWpgn = dicDB["ESTADOWPGN"] if siRepite else None

        if siAnterior or siSiguiente:
            siSeguir = True
            siSeHaBorradoAlgo = False
            dbf.leer()
            recno = estadoWpgn.recno
            if siAnterior:
                if recno > 0:
                    recno -= 1
            elif siSiguiente:
                if recno < dbf.reccount() - 1:
                    recno += 1
            dbf.goto(recno)
            estadoWpgn.recno = recno
        else:
            siSeguir, estadoWpgn, siSeHaBorradoAlgo = PantallaPGN.elegirPGN(
                self.pantalla, dbf, dClavesTam, self, estadoWpgn)

        if siSeguir:
            self.pensando(True)
            rid = dbf.rowid(dbf.recno)
            self.dicDB = dicDB
            dicDB["ESTADOWPGN"] = estadoWpgn
            dbf.cerrar()
            dbf = bd.dbfT("GAMES",
                          ",".join(dClavesTam.keys()) + ",PGN",
                          condicion="ROWID=%d" % rid)
            dbf.leer()
            dbf.gotop()
            dicDatos = dbf.dicValores()
            self.pgnPaste = dicDatos["PGN"]

            dbf.cerrar()
            pgn = PGN.UnPGN()
            pgn.leeTexto(self.pgnPaste)
            siMostrar = not pgn.siError
            self.pensando(False)
            if not siMostrar:
                QTUtil2.mensError(self.pantalla,
                                  _("This is not a valid PGN file"))

        else:
            siMostrar = False

        bd.cerrar()

        if siSeHaBorradoAlgo:
            fpgn = PGN.PGN()
            fpgn.borraReferenciaA(dicDB["FICHERO"])

        if siMostrar:
            self.mostrar(pgn, True)
        elif self.muestraInicial or self.finExit:
            self.finPartida()
Beispiel #23
0
    def configurarGS(self):
        # self.test()
        # return

        mt = _("Engine").lower()
        mt = _X(_("Disable %1"), mt) if self.siJuegaMotor else _X(_("Enable %1"), mt)

        sep = ( None, None, None )

        liMasOpciones = [
            ( "rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion() ), sep,
            ( "apertura", _("Opening"), Iconos.Apertura() ), sep,
            ( "posicion", _("Start position"), Iconos.Datos() ), sep,
            ( "pasteposicion", _("Paste FEN position"), Iconos.Pegar16() ), sep,
            ( "leerpgn", _("Read PGN"), Iconos.PGN_Importar() ), sep,
            ( "pastepgn", _("Paste PGN"), Iconos.Pegar16() ), sep,
            ( "motor", mt, Iconos.Motores() ), sep,
            ( "voyager", _("Voyager 2").replace("2", "1"), Iconos.Voyager1() ),
        ]
        if self.configuracion.voice:
            liMasOpciones.append(sep)
            if self.activeVoice:
                liMasOpciones.append(( "desvoice", _("Deactivate voice"), Iconos.X_Microfono() ))
            else:
                liMasOpciones.append(( "actvoice", _("Activate voice"), Iconos.S_Microfono() ))
        resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True)

        if resp == "rotacion":
            self.siVolteoAutomatico = not self.siVolteoAutomatico
            siBlancas = self.partida.ultPosicion.siBlancas
            if self.siVolteoAutomatico:
                if siBlancas != self.tablero.siBlancasAbajo:
                    self.tablero.rotaTablero()
        elif resp == "apertura":
            bl, ps = PantallaAperturas.dameApertura(self.pantalla, self.configuracion, self.bloqueApertura,
                                                    self.posicApertura)
            if bl:
                self.bloqueApertura = bl
                self.posicApertura = ps
                self.fen = None
                self.reiniciar()

        elif resp == "posicion":
            resp = WinPosition.editarPosicion(self.pantalla, self.configuracion, self.fen)
            if resp is not None:
                self.fen = resp
                self.bloqueApertura = None
                self.posicApertura = None

                if self.xpgn:
                    siInicio = self.fen == ControlPosicion.FEN_INICIAL
                    li = self.xpgn.split("\n")
                    lin = []
                    siFen = False
                    for linea in li:
                        if linea.startswith("["):
                            if "FEN " in linea:
                                siFen = True
                                if siInicio:
                                    continue
                                linea = '[FEN "%s"]' % self.fen
                            lin.append(linea)
                        else:
                            break
                    if not siFen:
                        linea = '[FEN "%s"]' % self.fen
                        lin.append(linea)
                    self.liPGN = lin
                    self.xpgn = "\n".join(lin) + "\n\n*"

                self.reiniciar()

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    cp.leeFen(str(texto))
                    self.fen = cp.fen()
                    self.bloqueApertura = None
                    self.posicApertura = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            unpgn = PantallaPGN.eligePartida(self.pantalla)
            if unpgn:
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                unpgn = PGN.UnPGN()
                unpgn.leeTexto(texto)
                if unpgn.siError:
                    QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format"))
                    return
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "motor":
            self.ponRotulo1("")
            if self.siJuegaMotor:
                self.xrival.terminar()
                self.xrival = None
                self.siJuegaMotor = False
            else:
                self.cambioRival()

        elif resp == "voyager":
            ptxt = XVoyager.xVoyager(self.pantalla, self.configuracion, self.partida)
            if ptxt:
                dic = self.creaDic()
                dic["PARTIDA"] = ptxt
                p = self.partida.copia()
                p.recuperaDeTexto(ptxt)
                dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen()
                dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo
                self.reiniciar(dic)

        elif resp == "actvoice":
            self.setVoice( True )

        elif resp == "desvoice":
            self.setVoice( False )