Exemplo n.º 1
0
    def __init__(self, wowner, configuration, path_lcbin):
        self.title = os.path.basename(path_lcbin)[:-6]
        QTVarios.WDialogo.__init__(self, wowner, self.title, Iconos.Book(), "polyglot")

        self.configuration = configuration
        self.path_lcbin = path_lcbin

        self.owner = wowner

        self.db_entries = DBPolyglot.DBPolyglot(path_lcbin)

        self.pol_import = PolyglotImportExports.PolyglotImport(self)
        self.pol_export = PolyglotImportExports.PolyglotExport(self)

        self.li_moves = []
        self.history = []

        conf_board = configuration.config_board("WPOLYGLOT", 48)
        self.board = Board.Board(self, conf_board)
        self.board.crea()
        self.board.set_dispatcher(self.mensajero)
        self.with_figurines = configuration.x_pgn_withfigurines

        o_columnas = Columnas.ListaColumnas()
        delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.configuration.x_pgn_withfigurines else None
        o_columnas.nueva("move", _("Move"), 80, centered=True, edicion=delegado, siEditable=False)
        o_columnas.nueva("%", "%", 60, siDerecha=True, siEditable=False)
        o_columnas.nueva("weight", _("Weight"), 60, siDerecha=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("score", _("Score"), 60, siDerecha=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("depth", _("Depth"), 60, siDerecha=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("learn", _("Learn"), 60, siDerecha=True, edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_moves = Grid.Grid(self, o_columnas, siEditable=True)
        self.grid_moves.setMinimumWidth(self.grid_moves.anchoColumnas() + 20)

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Takeback"), Iconos.Atras(), self.takeback),
            None,
            (_("Voyager"), Iconos.Voyager32(), self.voyager),
            None,
            (_("Import"), Iconos.Import8(), self.pol_import.importar),
            None,
            (_("Create book"), Iconos.BinBook(), self.pol_export.exportar),
            None,
        )
        self.tb = Controles.TBrutina(self, li_acciones)

        ly2 = Colocacion.V().control(self.tb).control(self.grid_moves)

        layout = Colocacion.H().control(self.board).otro(ly2)
        self.setLayout(layout)

        self.restore_video()

        self.position = None
        position = Position.Position()
        position.set_pos_initial()
        self.set_position(position, True)
Exemplo n.º 2
0
    def __init__(self, wparent, game):
        self.game = game

        self.wparent = wparent
        self.configuration = configuration = Code.configuration
        QtWidgets.QWidget.__init__(self, wparent)

        li_acciones = (
            (_("Save"), Iconos.Grabar(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.wparent.cancelar),
            None,
            (_("Start position"), Iconos.Datos(), self.inicial),
            None,
            (_("Clear"), Iconos.Borrar(), self.limpia),
            None,
            (_("Take back"), Iconos.Atras(), self.atras),
            None,
        )

        self.tb = Controles.TBrutina(self,
                                     li_acciones,
                                     with_text=False,
                                     icon_size=20)

        config_board = configuration.config_board("VOYAGERPGN", 24)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.set_dispatcher(self.player_has_moved)
        Delegados.generaPM(self.board.piezas)

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUMBER", _("N."), 35, centered=True)
        self.si_figurines_pgn = configuration.x_pgn_withfigurines
        nAnchoColor = (self.board.ancho - 35 - 20) // 2
        o_columns.nueva("WHITE",
                        _("White"),
                        nAnchoColor,
                        edicion=Delegados.EtiquetaPGN(
                            True if self.si_figurines_pgn else None))
        o_columns.nueva("BLACK",
                        _("Black"),
                        nAnchoColor,
                        edicion=Delegados.EtiquetaPGN(
                            False if self.si_figurines_pgn else None))
        self.pgn = Grid.Grid(self,
                             o_columns,
                             siCabeceraMovible=False,
                             siSelecFilas=True)
        self.pgn.setMinimumWidth(self.board.ancho)

        ly = Colocacion.V().control(self.tb).control(self.board)
        ly.control(self.pgn)
        ly.margen(1)
        self.setLayout(ly)

        self.board.set_position(self.game.last_position)
        self.play_next_move()
Exemplo n.º 3
0
    def __init__(self, wparent, partida):
        self.partida = partida

        self.wparent = wparent
        self.configuracion = configuracion = VarGen.configuracion
        QtGui.QWidget.__init__(self, wparent)

        liAcciones = (
            (_("Save"), Iconos.Grabar(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.wparent.cancelar),
            None,
            (_("Start position"), Iconos.Datos(), self.inicial),
            None,
            (_("Clear"), Iconos.Borrar(), self.limpia),
            None,
            (_("Take back"), Iconos.Atras(), self.atras),
            None,
        )

        self.tb = Controles.TBrutina(self,
                                     liAcciones,
                                     siTexto=False,
                                     tamIcon=20)

        confTablero = configuracion.confTablero("VOYAGERPGN", 24)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueveHumano)
        Delegados.generaPM(self.tablero.piezas)

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        self.siFigurinesPGN = configuracion.figurinesPGN
        nAnchoColor = (self.tablero.ancho - 35 - 20) / 2
        oColumnas.nueva("BLANCAS",
                        _("White"),
                        nAnchoColor,
                        edicion=Delegados.EtiquetaPGN(
                            True if self.siFigurinesPGN else None))
        oColumnas.nueva("NEGRAS",
                        _("Black"),
                        nAnchoColor,
                        edicion=Delegados.EtiquetaPGN(
                            False if self.siFigurinesPGN else None))
        self.pgn = Grid.Grid(self,
                             oColumnas,
                             siCabeceraMovible=False,
                             siSelecFilas=True)
        self.pgn.setMinimumWidth(self.tablero.ancho)

        ly = Colocacion.V().control(self.tb).control(self.tablero)
        ly.control(self.pgn)
        ly.margen(1)
        self.setLayout(ly)

        self.tablero.ponPosicion(self.partida.ultPosicion)
        self.siguienteJugada()
Exemplo n.º 4
0
    def player_has_moved(self, from_sq, to_sq, promotion=""):
        if not self.human_is_playing:
            return self.check_premove(from_sq, to_sq)
        move = self.check_human_move(from_sq, to_sq, promotion,
                                     not self.is_tutor_enabled)
        if not move:
            return False

        movimiento = move.movimiento()

        siAnalisis = False

        is_selected = False

        fen_base = self.last_fen()

        if self.bookR and self.bookMandatory:
            listaJugadas = self.bookR.get_list_moves(fen_base)
            if listaJugadas:
                li = []
                for apdesde, aphasta, appromotion, nada, nada1 in listaJugadas:
                    mx = apdesde + aphasta + appromotion
                    if mx.strip().lower() == movimiento:
                        is_selected = True
                        break
                    li.append((apdesde, aphasta, False))
                if not is_selected:
                    self.board.ponFlechasTmp(li)
                    self.sigueHumano()
                    return False

        if not is_selected and self.aperturaObl:
            if self.aperturaObl.check_human(fen_base, from_sq, to_sq):
                is_selected = True
            else:
                apdesde, aphasta = self.aperturaObl.from_to_active(fen_base)
                if apdesde is None:
                    self.aperturaObl = None
                else:
                    self.board.ponFlechasTmp(((apdesde, aphasta, False), ))
                    self.sigueHumano()
                    return False

        if not is_selected and self.aperturaStd:
            if self.aperturaStd.check_human(fen_base, from_sq, to_sq):
                is_selected = True
            else:
                if not self.aperturaStd.is_active(fen_base):
                    self.aperturaStd = None

        is_mate = move.is_mate
        self.analizaFinal(is_mate)  # tiene que acabar siempre
        if not is_mate and not is_selected and self.is_tutor_enabled:
            if not self.tutor_book.si_esta(fen_base, movimiento):
                rmUser, n = self.mrmTutor.buscaRM(movimiento)
                if not rmUser:
                    self.main_window.pensando_tutor(True)
                    rmUser = self.xtutor.valora(self.game.last_position,
                                                from_sq, to_sq, move.promotion)
                    self.main_window.pensando_tutor(False)
                    if not rmUser:
                        self.sigueHumanoAnalisis()
                        return False
                    self.mrmTutor.agregaRM(rmUser)
                siAnalisis = True
                pointsBest, pointsUser = self.mrmTutor.difPointsBest(
                    movimiento)
                self.setSummary("POINTSBEST", pointsBest)
                self.setSummary("POINTSUSER", pointsUser)
                difpts = self.configuration.x_tutor_difpoints
                difporc = self.configuration.x_tutor_difporc
                if self.mrmTutor.mejorRMQue(rmUser, difpts, difporc):
                    if not move.is_mate:
                        si_tutor = True
                        if self.chance:
                            num = self.mrmTutor.numMejorMovQue(movimiento)
                            if num:
                                rmTutor = self.mrmTutor.rmBest()
                                menu = QTVarios.LCMenu(self.main_window)
                                menu.opcion("None",
                                            _("There are %d best moves") % num,
                                            Iconos.Motor())
                                menu.separador()
                                resp = rmTutor.abrTextoBase()
                                if not resp:
                                    resp = _("Mate")
                                menu.opcion(
                                    "tutor",
                                    "&1. %s (%s)" % (_("Show tutor"), resp),
                                    Iconos.Tutor(),
                                )
                                menu.separador()
                                menu.opcion("try", "&2. %s" % _("Try again"),
                                            Iconos.Atras())
                                menu.separador()
                                menu.opcion(
                                    "user",
                                    "&3. %s (%s)" % (_("Select my move"),
                                                     rmUser.abrTextoBase()),
                                    Iconos.Player(),
                                )
                                self.main_window.cursorFueraBoard()
                                resp = menu.lanza()
                                if resp == "try":
                                    self.sigueHumanoAnalisis()
                                    return False
                                elif resp == "user":
                                    si_tutor = False
                                elif resp != "tutor":
                                    self.sigueHumanoAnalisis()
                                    return False
                        if si_tutor:
                            tutor = Tutor.Tutor(self, move, from_sq, to_sq,
                                                False)

                            if self.aperturaStd:
                                liApPosibles = self.listaOpeningsStd.list_possible_openings(
                                    self.game)
                            else:
                                liApPosibles = None

                            if tutor.elegir(self.hints > 0,
                                            liApPosibles=liApPosibles):
                                if self.hints > 0:  # doble entrada a tutor.
                                    self.set_piece_again(from_sq)
                                    self.hints -= 1
                                    self.tutor_con_flechas = self.nArrowsTt > 0 and self.hints > 0
                                    from_sq = tutor.from_sq
                                    to_sq = tutor.to_sq
                                    promotion = tutor.promotion
                                    ok, mens, jgTutor = Move.get_game_move(
                                        self.game, self.game.last_position,
                                        from_sq, to_sq, promotion)
                                    if ok:
                                        move = jgTutor
                                        self.setSummary("SELECTTUTOR", True)
                            if self.configuration.x_save_tutor_variations:
                                tutor.ponVariations(move,
                                                    1 + len(self.game) / 2)

                            del tutor

        self.setSummary("TIMEUSER", self.timekeeper.stop())
        self.reloj_stop(True)

        self.move_the_pieces(move.liMovs)

        if siAnalisis:
            rm, nPos = self.mrmTutor.buscaRM(move.movimiento())
            if rm:
                move.analysis = self.mrmTutor, nPos

        self.add_move(move, True)
        self.error = ""
        self.play_next_move()
        return True
Exemplo n.º 5
0
    def create_toolbar(self):
        self.tb = QtWidgets.QToolBar("BASIC", self)
        iconsTB = self.configuration.tipoIconos()
        self.tb.setToolButtonStyle(iconsTB)
        sz = 32 if iconsTB == QtCore.Qt.ToolButtonTextUnderIcon else 16
        self.tb.setIconSize(QtCore.QSize(sz, sz))
        style = "QToolBar {border-bottom: 1px solid gray; border-top: 1px solid gray;}"
        self.tb.setStyleSheet(style)
        # sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtGui, QtWidgets.QSizePolicy.Expanding)
        # self.tb.setSizePolicy(sp)
        self.tb.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.tb.customContextMenuRequested.connect(self.lanzaAtajos)

        self.dic_toolbar = {}

        dic_opciones = {
            TB_PLAY: (_("Play"), Iconos.Libre()),
            TB_COMPETE: (_("Compete"), Iconos.NuevaPartida()),
            TB_TRAIN: (_("Train"), Iconos.Entrenamiento()),
            TB_OPTIONS: (_("Options"), Iconos.Opciones()),
            TB_INFORMATION: (_("Information"), Iconos.Informacion()),
            TB_FILE: (_("File"), Iconos.File()),
            TB_SAVE: (_("Save"), Iconos.Grabar()),
            TB_SAVE_AS: (_("Save as"), Iconos.GrabarComo()),
            TB_OPEN: (_("Open"), Iconos.Recuperar()),
            TB_RESIGN: (_("Resign"), Iconos.Abandonar()),
            TB_REINIT: (_("Reinit"), Iconos.Reiniciar()),
            TB_TAKEBACK: (_("Takeback"), Iconos.Atras()),
            TB_ADJOURN: (_("Adjourn"), Iconos.Aplazar()),
            TB_Adjournments: (_("Adjournments"), Iconos.Aplazamientos()),
            TB_END_GAME: (_("End game"), Iconos.FinPartida()),
            TB_CLOSE: (_("Close"), Iconos.MainMenu()),
            TB_PREVIOUS: (_("Previous"), Iconos.Anterior()),
            TB_NEXT: (_("Next"), Iconos.Siguiente()),
            TB_QUIT: (_("Quit"), Iconos.FinPartida()),
            TB_PASTE_PGN: (_("Paste PGN"), Iconos.Pegar()),
            TB_READ_PGN: (_("Read PGN"), Iconos.Fichero()),
            TB_PGN_LABELS: (_("PGN Labels"), Iconos.InformacionPGN()),
            TB_OTHER_GAME: (_("Other game"), Iconos.FicheroRepite()),
            TB_MY_GAMES: (_("My games"), Iconos.NuestroFichero()),
            TB_DRAW: (_("Draw"), Iconos.Tablas()),
            TB_BOXROOMS_PGN: (_("Boxrooms PGN"), Iconos.BoxRooms()),
            TB_END: (_("End"), Iconos.MainMenu()),
            TB_SLOW: (_("Slow"), Iconos.Pelicula_Lento()),
            TB_PAUSE: (_("Pause"), Iconos.Pelicula_Pausa()),
            TB_CONTINUE: (_("Continue"), Iconos.Pelicula_Seguir()),
            TB_FAST: (_("Fast"), Iconos.Pelicula_Rapido()),
            TB_REPEAT: (_("Repeat"), Iconos.Pelicula_Repetir()),
            TB_PGN: (_("PGN"), Iconos.Pelicula_PGN()),
            TB_HELP: (_("Help"), Iconos.AyudaGR()),
            TB_LEVEL: (_("Level"), Iconos.Jugar()),
            TB_ACCEPT: (_("Accept"), Iconos.Aceptar()),
            TB_CANCEL: (_("Cancel"), Iconos.Cancelar()),
            TB_CONFIG: (_("Config"), Iconos.Configurar()),
            TB_UTILITIES: (_("Utilities"), Iconos.Utilidades()),
            TB_VARIATIONS: (_("Variations"), Iconos.VariationsG()),
            TB_TOOLS: (_("Tools"), Iconos.Tools()),
            TB_CHANGE: (_("Change"), Iconos.Cambiar()),
            TB_SHOW_TEXT: (_("Show text"), Iconos.Modificar()),
            TB_HELP_TO_MOVE: (_("Help to move"), Iconos.BotonAyuda()),
            TB_SEND: (_("Send"), Iconos.Enviar()),
            TB_STOP: (_("Play now"), Iconos.Stop()),
        }

        cf = self.manager.configuration
        peso = 75 if cf.x_tb_bold else 50
        puntos = cf.x_tb_fontpoints
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for key, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.key = key
            self.dic_toolbar[key] = accion
Exemplo n.º 6
0
    def __init__(self, owner, configuration, opening_block):
        icono = Iconos.Opening()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = OpeningsStd.apTrain
        self.configuration = configuration
        self.game = Game.Game()
        self.opening_block = opening_block
        self.liActivas = []

        # Board
        config_board = configuration.config_board("APERTURAS", 32)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.set_dispatcher(self.player_has_moved)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").set_wrap().ponTipoLetra(puntos=10, peso=75)

        # Movimiento
        self.is_moving_time = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, icon_size=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)
        tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida)
        tb.new(_("Takeback"), Iconos.Atras(), self.atras)
        tb.new(_("Remove"), Iconos.Borrar(), self.borrar)

        # Lista Openings
        o_columns = Columnas.ListaColumnas()
        dicTipos = {"b": Iconos.pmSun(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja()}
        o_columns.nueva("TYPE", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        o_columns.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, altoFila=32)
        self.register_grid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.board).otro(lyBM).control(self.lbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtWidgets.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.register_splitter(splitter, "splitter")

        # Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()

        dic = {"_SIZE_": "916,444", "SP_splitter": [356, 548]}
        self.restore_video(dicDef=dic)
Exemplo n.º 7
0
    def mueveHumano(self, desde, hasta, coronacion=None):
        jg = self.checkMueveHumano(desde, hasta, coronacion)
        if not jg:
            return False

        movimiento = jg.movimiento()

        siAnalisis = False

        siElegido = False

        if self.book and self.bookMandatory:
            fen = self.fenUltimo()
            listaJugadas = self.book.miraListaJugadas(fen)
            if listaJugadas:
                li = []
                for apdesde, aphasta, apcoronacion, nada, nada1 in listaJugadas:
                    mx = apdesde + aphasta + apcoronacion
                    if mx.strip().lower() == movimiento:
                        siElegido = True
                        break
                    li.append((apdesde, aphasta, False))
                if not siElegido:
                    self.tablero.ponFlechasTmp(li)
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaObl:
            fenBase = self.fenUltimo()
            if self.aperturaObl.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                apdesde, aphasta = self.aperturaObl.desdeHastaActual(fenBase)
                if apdesde is None:
                    self.aperturaObl = None
                else:
                    self.tablero.ponFlechasTmp(((apdesde, aphasta, False),))
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaStd:
            fenBase = self.fenUltimo()
            if self.aperturaStd.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                if not self.aperturaStd.isActive(fenBase):
                    self.aperturaStd = None

        if self.siTeclaPanico:
            self.sigueHumano()
            return False

        self.analizaFinal()  # tiene que acabar siempre
        if not siElegido and (self.siTutorActivado or self.childmode):
            rmUser, n = self.mrmTutor.buscaRM(movimiento)
            if not rmUser:
                rmUser = self.xtutor.valora(self.partida.ultPosicion, desde, hasta, jg.coronacion)
                if not rmUser:
                    self.sigueHumanoAnalisis()
                    return False
                self.mrmTutor.agregaRM(rmUser)
            siAnalisis = True
            pointsBest, pointsUser = self.mrmTutor.difPointsBest(movimiento)
            self.setSummary("POINTSBEST", pointsBest)
            self.setSummary("POINTSUSER", pointsUser)
            difpts = self.configuracion.tutorDifPts
            difporc = self.configuracion.tutorDifPorc
            if self.mrmTutor.mejorRMQue(rmUser, difpts, difporc):
                if not jg.siJaqueMate:
                    siTutor = not self.childmode
                    if self.chance:
                        num = self.mrmTutor.numMejorMovQue(movimiento)
                        if num:
                            rmTutor = self.mrmTutor.rmBest()
                            menu = QTVarios.LCMenu(self.pantalla)
                            menu.opcion("None", _("There are %d best moves") % num, Iconos.Motor())
                            menu.separador()
                            if siTutor:
                                menu.opcion("tutor", "&1. %s (%s)" % (_("Show tutor"), rmTutor.abrTextoBase()),
                                               Iconos.Tutor())
                                menu.separador()
                            menu.opcion("try", "&2. %s" % _("Try again"), Iconos.Atras())
                            menu.separador()
                            menu.opcion("user", "&3. %s (%s)" % (_("Select my move"), rmUser.abrTextoBase()),
                                           Iconos.Player())
                            self.pantalla.cursorFueraTablero()
                            resp = menu.lanza()
                            if resp == "try":
                                self.sigueHumanoAnalisis()
                                return False
                            elif resp == "user":
                                siTutor = False
                            elif resp != "tutor":
                                self.sigueHumanoAnalisis()
                                return False

                    if siTutor:
                        tutor = Tutor.Tutor(self, self, jg, desde, hasta, False)

                        if self.aperturaStd:
                            liApPosibles = self.listaAperturasStd.listaAperturasPosibles(self.partida)
                        else:
                            liApPosibles = None

                        if tutor.elegir(self.ayudas > 0, liApPosibles=liApPosibles):
                            if self.ayudas > 0:  # doble entrada a tutor.
                                self.reponPieza(desde)
                                self.ayudas -= 1
                                self.childmode = self.nArrowsTt > 0 and self.ayudas > 0
                                desde = tutor.desde
                                hasta = tutor.hasta
                                coronacion = tutor.coronacion
                                siBien, mens, jgTutor = Jugada.dameJugada(self.partida.ultPosicion, desde, hasta, coronacion)
                                if siBien:
                                    jg = jgTutor
                                    self.setSummary("SELECTTUTOR", True)
                        if self.configuracion.guardarVariantesTutor:
                            tutor.ponVariantes(jg, 1 + self.partida.numJugadas() / 2)

                        del tutor

        self.setSummary("TIMEUSER", self.timekeeper.stop())
        self.relojStop(True)

        self.movimientosPiezas(jg.liMovs)

        if siAnalisis:
            rm, nPos = self.mrmTutor.buscaRM(jg.movimiento())
            if rm:
                jg.analisis = self.mrmTutor, nPos

        self.partida.ultPosicion = jg.posicion
        self.masJugada(jg, True)
        self.error = ""
        self.siguienteJugada()
        return True
Exemplo n.º 8
0
    def __init__(self, owner, configuracion, bloqueApertura):
        icono = Iconos.Apertura()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = AperturasStd.ListaAperturasStd(configuracion, True, True)
        self.configuracion = configuracion
        self.partida = Partida.Partida()
        self.bloqueApertura = bloqueApertura
        self.liActivas = []

        # Tablero
        confTablero = configuracion.confTablero("APERTURAS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueveHumano)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").ponWrap().ponTipoLetra(puntos=10,
                                                                   peso=75)

        # Movimiento
        self.siMoviendoTiempo = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self,
                                                  "",
                                                  siLibre=False,
                                                  tamIcon=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)
        tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida)
        tb.new(_("Takeback"), Iconos.Atras(), self.atras)
        tb.new(_("Remove"), Iconos.Borrar(), self.borrar)

        # Lista Aperturas
        oColumnas = Columnas.ListaColumnas()
        dicTipos = {
            "b": Iconos.pmSun(),
            "n": Iconos.pmPuntoAzul(),
            "l": Iconos.pmNaranja()
        }
        oColumnas.nueva("TIPO",
                        "",
                        24,
                        edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        oColumnas.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, altoFila=32)
        self.registrarGrid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.tablero).otro(lyBM).control(
            self.lbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtGui.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.registrarSplitter(splitter, "splitter")

        # Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()

        dic = {'_SIZE_': '916,444', 'SP_splitter': [356, 548]}
        self.recuperarVideo(dicDef=dic)
Exemplo n.º 9
0
    def __init__(self, cpu):
        QtWidgets.QDialog.__init__(self)

        self.cpu = cpu
        self.kibitzer = cpu.kibitzer

        dicVideo = self.cpu.dic_video
        if not dicVideo:
            dicVideo = {}

        self.siTop = dicVideo.get("SITOP", True)
        self.show_board = dicVideo.get("SHOW_BOARD", True)
        self.history = []

        self.fen = ""
        self.liData = []

        self.setWindowTitle(cpu.titulo)
        self.setWindowIcon(Iconos.Motor())

        self.setWindowFlags(
            QtCore.Qt.WindowCloseButtonHint
            | QtCore.Qt.Dialog
            | QtCore.Qt.WindowTitleHint
            | QtCore.Qt.WindowMinimizeButtonHint
        )

        self.setBackgroundRole(QtGui.QPalette.Light)

        Code.configuration = cpu.configuration

        Code.todasPiezas = Piezas.TodasPiezas()
        config_board = cpu.configuration.config_board("kib" + cpu.kibitzer.huella, 24)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.set_dispatcher(self.mensajero)

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("titulo", "", 100, siDerecha=True)
        o_columns.nueva("valor", "", 100, centered=True)
        o_columns.nueva("info", "", 100)
        self.grid = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True, siCabeceraVisible=False)

        li_acciones = (
            (_("Continue"), Iconos.Kibitzer_Play(), self.play),
            (_("Pause"), Iconos.Kibitzer_Pause(), self.pause),
            (_("Takeback"), Iconos.Atras(), self.takeback),
            (_("Analyze only color"), Iconos.Kibitzer_Side(), self.color),
            (_("Show/hide board"), Iconos.Kibitzer_Board(), self.config_board),
            (_("Manual position"), Iconos.Voyager(), self.set_position),
            ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop),
            ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom),
        )
        self.tb = Controles.TBrutina(self, li_acciones, with_text=False, icon_size=16)
        self.tb.setAccionVisible(self.play, False)

        ly1 = Colocacion.H().control(self.tb).relleno()
        ly2 = Colocacion.V().otro(ly1).control(self.grid)

        layout = Colocacion.H().control(self.board).otro(ly2)
        self.setLayout(layout)

        self.siPlay = True
        self.is_white = True
        self.is_black = True

        if not self.show_board:
            self.board.hide()
        self.restore_video(dicVideo)
        self.ponFlags()

        self.engine = self.lanzaMotor()

        self.depth = 0
        self.veces = 0

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.compruebaInput)
        self.timer.start(200)
Exemplo n.º 10
0
    def __init__(self, cpu):
        QtWidgets.QDialog.__init__(self)

        self.cpu = cpu

        self.kibitzer = cpu.kibitzer

        self.siCandidates = cpu.tipo == Kibitzers.KIB_CANDIDATES
        self.siThreats = cpu.tipo == Kibitzers.KIB_THREATS

        dicVideo = self.cpu.dic_video
        if not dicVideo:
            dicVideo = {}

        self.siTop = dicVideo.get("SITOP", True)
        self.siShowTablero = dicVideo.get("SHOW_TABLERO", True)
        self.nArrows = dicVideo.get("NARROWS", 2)

        self.fen = ""
        self.liData = []
        self.history = []

        self.setWindowTitle(cpu.titulo)
        self.setWindowIcon(Iconos.Motor())

        self.setWindowFlags(
            QtCore.Qt.WindowCloseButtonHint
            | QtCore.Qt.Dialog
            | QtCore.Qt.WindowTitleHint
            | QtCore.Qt.WindowMinimizeButtonHint
        )

        self.setBackgroundRole(QtGui.QPalette.Light)

        Code.configuracion = cpu.configuracion

        Code.todasPiezas = Piezas.TodasPiezas()
        config_board = cpu.configuracion.config_board("kib" + cpu.kibitzer.huella, 24)
        self.tablero = Tablero.Tablero(self, config_board)
        self.tablero.crea()
        self.tablero.set_dispatcher(self.mensajero)

        self.siFigurines = cpu.configuracion.x_pgn_withfigurines

        Delegados.generaPM(self.tablero.piezas)
        delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.siFigurines else None

        o_columns = Columnas.ListaColumnas()
        if not self.siCandidates:
            o_columns.nueva("DEPTH", "^", 40, centered=True)
        o_columns.nueva("BESTMOVE", _("Alternatives"), 80, centered=True, edicion=delegado)
        o_columns.nueva("EVALUATION", _("Evaluation"), 85, centered=True)
        o_columns.nueva("MAINLINE", _("Main line"), 400)
        self.grid = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True)

        self.lbDepth = Controles.LB(self)

        li_acciones = (
            (_("Quit"), Iconos.Kibitzer_Terminar(), self.terminar),
            (_("Continue"), Iconos.Kibitzer_Continuar(), self.play),
            (_("Pause"), Iconos.Kibitzer_Pausa(), self.pause),
            (_("Takeback"), Iconos.Atras(), self.takeback),
            (_("The line selected is saved on clipboard"), Iconos.MoverGrabar(), self.portapapelesJugSelected),
            (_("Analyze only color"), Iconos.P_16c(), self.color),
            (_("Show/hide board"), Iconos.Tablero(), self.config_board),
            (_("Manual position"), Iconos.Voyager(), self.set_position),
            ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop),
            ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom),
            (_("Options"), Iconos.Opciones(), self.change_options),
        )
        self.tb = Controles.TBrutina(self, li_acciones, siTexto=False, tamIcon=16)
        self.tb.setAccionVisible(self.play, False)

        ly1 = Colocacion.H().control(self.tb).relleno().control(self.lbDepth)
        ly2 = Colocacion.V().otro(ly1).control(self.grid)

        layout = Colocacion.H().control(self.tablero).otro(ly2)
        self.setLayout(layout)

        self.siPlay = True
        self.is_white = True
        self.siNegras = True

        if not self.siShowTablero:
            self.tablero.hide()
        self.restore_video(dicVideo)
        self.ponFlags()

        self.engine = self.lanzaMotor()

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.compruebaInput)
        self.timer.start(500)
        self.depth = 0
        self.veces = 0
Exemplo n.º 11
0
    def __init__(self, cpu):
        QtWidgets.QDialog.__init__(self)

        self.cpu = cpu

        dicVideo = self.cpu.dic_video
        if not dicVideo:
            dicVideo = {}

        self.siTop = dicVideo.get("SITOP", True)
        self.siShowTablero = dicVideo.get("SHOW_TABLERO", True)
        self.position = Position.Position()

        self.fen = ""
        self.siPlay = True
        self.li_moves = []
        self.history = []

        self.setWindowTitle(cpu.titulo)
        self.setWindowIcon(Iconos.Finales())

        self.setWindowFlags(
            QtCore.Qt.WindowCloseButtonHint
            | QtCore.Qt.Dialog
            | QtCore.Qt.WindowTitleHint
            | QtCore.Qt.WindowMinimizeButtonHint
        )

        self.setBackgroundRole(QtGui.QPalette.Light)

        Code.configuracion = cpu.configuracion

        Code.todasPiezas = Piezas.TodasPiezas()
        config_board = cpu.configuracion.config_board("kib" + cpu.kibitzer.huella, 24)
        self.tablero = Tablero.Tablero(self, config_board)
        self.tablero.crea()
        self.tablero.set_dispatcher(self.mensajero)
        Delegados.generaPM(self.tablero.piezas)

        self.t4 = LibChess.T4(cpu.configuracion)

        self.siFigurines = cpu.configuracion.x_pgn_withfigurines

        o_columns = Columnas.ListaColumnas()
        delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.siFigurines else None
        o_columns.nueva("MOVE", _("Move"), 80, centered=True, edicion=delegado)
        o_columns.nueva("DTM", "DTM", 60, centered=True)
        self.grid_moves = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True)

        li_acciones = (
            (_("Quit"), Iconos.Kibitzer_Terminar(), self.terminar),
            (_("Continue"), Iconos.Kibitzer_Continuar(), self.play),
            (_("Pause"), Iconos.Kibitzer_Pausa(), self.pause),
            (_("Takeback"), Iconos.Atras(), self.takeback),
            (_("Manual position"), Iconos.Voyager(), self.set_position),
            (_("Show/hide board"), Iconos.Tablero(), self.config_board),
            ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop),
            ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom),
        )
        self.tb = Controles.TBrutina(self, li_acciones, siTexto=False, tamIcon=16)
        self.tb.setAccionVisible(self.play, False)

        ly1 = Colocacion.H().control(self.tb)
        ly2 = Colocacion.V().otro(ly1).control(self.grid_moves)

        layout = Colocacion.H().control(self.tablero).otro(ly2)
        self.setLayout(layout)

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.cpu.compruebaInput)
        self.timer.start(200)

        if not self.siShowTablero:
            self.tablero.hide()
        self.restore_video(dicVideo)
        self.ponFlags()
Exemplo n.º 12
0
    def __init__(self, procesador):
        self.procesador = procesador
        self.configuration = procesador.configuration
        self.reinit = False
        self.db = EndingsGTB.DBendings(self.configuration)
        self.t4 = LibChess.T4(self.configuration)

        QTVarios.WDialogo.__init__(self, procesador.main_window,
                                   _("Endings with Gaviota Tablebases"),
                                   Iconos.Finales(), "endings_gtb")

        self.game = Game.Game()
        self.act_recno = -1

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Config"), Iconos.Configurar(), self.configurar),
            None,
            (_("Utilities"), Iconos.Utilidades(), self.utilidades),
            None,
        )
        tb = QTVarios.LCTB(self, li_acciones)

        ly_bt, self.bt_movs = QTVarios.lyBotonesMovimiento(
            self,
            "",
            siTiempo=True,
            siLibre=False,
            rutina=self.run_botones,
            icon_size=24)

        self.chb_help = Controles.CHB(self, _("Help mode"),
                                      False).capture_changes(
                                          self, self.help_changed)
        self.bt_back = Controles.PB(self,
                                    _("Takeback"),
                                    self.takeback,
                                    plano=False).ponIcono(Iconos.Atras())
        ly_bt.espacio(20).control(self.bt_back).control(self.chb_help)

        self.wpzs = QtWidgets.QWidget(self)
        self.wpzs.li_labels = []
        ly_wpzs = Colocacion.H()
        for x in range(6):
            lbl = Controles.LB(self.wpzs)
            self.wpzs.li_labels.append(lbl)
            ly_wpzs.control(lbl)
        self.wpzs.setLayout(ly_wpzs)
        self.wpzs.mousePressEvent = self.change

        self.color_done = QTUtil.qtColorRGB(213, 233, 250)

        li_acciones = (
            None,
            (" " + _("Restart"), Iconos.Reset(), self.restart),
            None,
            (" " + _("New"), Iconos.New1(), self.nuevo),
            None,
            (" " + _("Remove"), Iconos.Remove1(), self.remove),
            None,
        )
        self.tb_run = Controles.TBrutina(
            self,
            li_acciones,
            icon_size=32,
            puntos=self.configuration.x_tb_fontpoints)

        ly_top = Colocacion.H().control(tb).relleno().control(
            self.wpzs).relleno().control(self.tb_run)
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 50, centered=True)
        o_columns.nueva("XFEN", _("Position"), 140, centered=True)
        o_columns.nueva("MATE", _("Mate"), 60, centered=True)
        o_columns.nueva("TRIES", _("Tries"), 50, centered=True)
        o_columns.nueva("MOVES", _("Minimum moves"), 120, centered=True)
        o_columns.nueva("TIMEMS", _("Minimum time"), 120, centered=True)
        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True)
        self.grid.tipoLetra(puntos=self.configuration.x_pgn_fontpoints)
        self.grid.ponAltoFila(self.configuration.x_pgn_rowheight)
        self.grid.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        ly_pos = Colocacion.V().control(self.grid)

        config_board = self.configuration.config_board("ENDINGSGTB", 64)
        self.board = BoardEndings(self, config_board)
        self.board.set_startup_control(self.startup_control)
        self.board.crea()
        self.board.ponerPiezasAbajo(True)
        self.board.set_dispatcher(self.player_has_moved)

        self.pzs = self.board.piezas
        self.playing = False

        ly_left_bottom = Colocacion.V().control(
            self.board).otro(ly_bt).relleno().margen(0)
        w = QtWidgets.QWidget(self)
        w.setLayout(ly_left_bottom)
        w.setFixedWidth(self.board.ancho + 16)

        ly_bottom = Colocacion.H().control(w).otro(ly_pos)

        layout = Colocacion.V().otro(ly_top).otro(ly_bottom).margen(6)
        self.setLayout(layout)

        self.restore_video()

        dic = self.configuration.read_variables("endingsGTB")

        self.key = key = dic.get("KEY")
        if (not key) or len(key) > self.configuration.piezas_gaviota():
            key = "KPk"
        self.db.set_examples_auto(dic.get("EXAMPLES_AUTO", True))
        self.set_key(key)

        self.play_next_type = dic.get("PLAY_NEXT", PLAY_STOP)

        self.grid.gotop()
        self.pos_game = -1
        self.help_changed()
        self.restart()
Exemplo n.º 13
0
    def preparaTB(self):

        self.dicTB = {}

        liOpciones = (
            (_("Quit"), Iconos.Terminar(), k_terminar),
            (_("Play"), Iconos.Libre(), k_play),
            (_("Compete"), Iconos.NuevaPartida(), k_competir),
            (_("Train"), Iconos.Entrenamiento(), k_entrenamiento),
            (_("Options"), Iconos.Opciones(), k_opciones),
            (_("Information"), Iconos.Informacion(), k_informacion),
            (_("Save"), Iconos.Grabar(), k_grabar),
            (_("Save as"), Iconos.GrabarComo(), k_grabarComo),
            (_("Open"), Iconos.Recuperar(), k_recuperar),
            (_("Resign"), Iconos.Abandonar(), k_abandonar),
            (_("Reinit"), Iconos.Reiniciar(), k_reiniciar),
            (_("Takeback"), Iconos.Atras(), k_atras),
            (_("Adjourn"), Iconos.Aplazar(), k_aplazar),
            (_("End game"), Iconos.FinPartida(), k_finpartida),
            (_("Close"), Iconos.MainMenu(), k_mainmenu),
            (_("Reinit"), Iconos.Reiniciar(), k_ent_empezar),
            (_("Previous"), Iconos.Anterior(), k_anterior),
            (_("Next"), Iconos.Siguiente(), k_siguiente),
            (_("Quit"), Iconos.FinPartida(), k_pgnFin),
            (_("Paste PGN"), Iconos.Pegar(), k_pgnPaste),
            (_("Read PGN"), Iconos.Fichero(), k_pgnFichero),
            (_("PGN Labels"), Iconos.InformacionPGN(), k_pgnInformacion),
            (_("Other game"), Iconos.FicheroRepite(), k_pgnFicheroRepite),
            (_("My games"), Iconos.NuestroFichero(), k_pgnNuestroFichero),
            (_("Resign"), Iconos.Rendirse(), k_rendirse),
            (_("Draw"), Iconos.Tablas(), k_tablas),
            (_("Boxrooms PGN"), Iconos.Trasteros(), k_trasteros),
            (_("End"), Iconos.MainMenu(), k_peliculaTerminar),
            (_("Slow"), Iconos.Pelicula_Lento(), k_peliculaLento),
            (_("Pause"), Iconos.Pelicula_Pausa(), k_peliculaPausa),
            (_("Continue"), Iconos.Pelicula_Seguir(), k_peliculaSeguir),
            (_("Fast"), Iconos.Pelicula_Rapido(), k_peliculaRapido),
            (_("Repeat"), Iconos.Pelicula_Repetir(), k_peliculaRepetir),
            (_("PGN"), Iconos.Pelicula_PGN(), k_peliculaPGN),
            (_("Play"), Iconos.Jugar(), k_jugar),
            (_("Help"), Iconos.AyudaGR(), k_ayuda),
            (_("Level"), Iconos.Jugar(), k_mateNivel),
            (_("Accept"), Iconos.Aceptar(), k_aceptar),
            (_("Cancel"), Iconos.Cancelar(), k_cancelar),
            (_("Game of the day"), Iconos.LM(), k_jugadadia),
            (_("Config"), Iconos.Configurar(), k_configurar),
            (_("Utilities"), Iconos.Utilidades(), k_utilidades),
            (_("Variants"), Iconos.VariantesG(), k_variantes),
            (_("Tools"), Iconos.Tools(), k_tools),
            (_("Change"), Iconos.Cambiar(), k_cambiar),
            (_("Show text"), Iconos.Modificar(), k_showtext),
            (_("Help to move"), Iconos.BotonAyuda(), k_ayudaMover),
            (_("Send"), Iconos.Enviar(), k_enviar),
            # ( "Debug", Iconos.Camara(), 999),# Martin debug
        )

        cf = self.gestor.configuracion
        peso = 75 if cf.boldTB else 50
        puntos = cf.puntosTB
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for titulo, icono, clave in liOpciones:
            accion = QtGui.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            self.connect(accion, QtCore.SIGNAL("triggered()"),
                         self.procesarAccion)
            accion.clave = clave
            self.dicTB[clave] = accion
Exemplo n.º 14
0
    def __init__(self, wowner, configuracion, path_dbbin):
        title = os.path.basename(path_dbbin)[:-6]
        QTVarios.WDialogo.__init__(self, wowner, title, Iconos.Book(),
                                   "polyglot")

        self.configuracion = configuracion
        self.path_dbbin = path_dbbin
        self.path_mkbin = self.path_dbbin[:-6] + ".mkbin"

        self.owner = wowner
        self.key = None
        self.key_str10 = None

        self.db_entries = UtilSQL.DictSQL(self.path_dbbin)
        if Util.filesize(self.path_mkbin) < 0:
            f = open(self.path_mkbin, "wb")
            f.close()
        self.pol_mkbin = FasterCode.Polyglot(self.path_mkbin)

        self.li_moves = []
        self.history = []

        self.pol_imports = PolyglotImports.PolyglotImports(self)

        conf_tablero = configuracion.config_board("WPOLYGLOT", 48)
        self.tablero = Tablero.Tablero(self, conf_tablero)
        self.tablero.crea()
        self.tablero.set_dispatcher(self.mensajero)
        self.siFigurines = configuracion.x_pgn_withfigurines

        o_columnas = Columnas.ListaColumnas()
        delegado = Delegados.EtiquetaPOS(
            True,
            siLineas=False) if self.configuracion.x_pgn_withfigurines else None
        o_columnas.nueva("move",
                         _("Move"),
                         80,
                         centered=True,
                         edicion=delegado,
                         siEditable=False)
        o_columnas.nueva("%", "%", 60, siDerecha=True, siEditable=False)
        o_columnas.nueva("weight",
                         _("weight"),
                         60,
                         siDerecha=True,
                         edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("score",
                         _("Score"),
                         60,
                         siDerecha=True,
                         edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("depth",
                         _("Depth"),
                         60,
                         siDerecha=True,
                         edicion=Delegados.LineaTexto(siEntero=True))
        o_columnas.nueva("learn",
                         _("Learn"),
                         60,
                         siDerecha=True,
                         edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_moves = Grid.Grid(self, o_columnas, siEditable=True)
        self.grid_moves.setMinimumWidth(self.grid_moves.anchoColumnas() + 20)

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Takeback"), Iconos.Atras(), self.takeback),
            None,
            (_("Voyager"), Iconos.Voyager(), self.voyager),
            None,
            (_("Import"), Iconos.Import8(), self.pol_imports.importar),
            None,
            (_("Export"), Iconos.Export8(), self.pol_imports.exportar),
            None,
        )
        self.tb = Controles.TBrutina(self, li_acciones)

        ly2 = Colocacion.V().control(self.tb).control(self.grid_moves)

        layout = Colocacion.H().control(self.tablero).otro(ly2)
        self.setLayout(layout)

        self.restore_video()

        self.position = None
        position = Position.Position()
        position.set_pos_initial()
        self.set_position(position, True)
Exemplo n.º 15
0
    def preparaTB(self):
        self.dicTB = {}

        dic_opciones = {
            TB_PLAY: (_("Play"), Iconos.Libre()),
            TB_COMPETE: (_("Compete"), Iconos.NuevaPartida()),
            TB_TRAIN: (_("Train"), Iconos.Entrenamiento()),
            TB_OPTIONS: (_("Options"), Iconos.Opciones()),
            TB_INFORMATION: (_("Information"), Iconos.Informacion()),
            TB_FILE: (_("File"), Iconos.File()),
            TB_SAVE: (_("Save"), Iconos.Grabar()),
            TB_SAVE_AS: (_("Save as"), Iconos.GrabarComo()),
            TB_OPEN: (_("Open"), Iconos.Recuperar()),
            TB_RESIGN: (_("Resign"), Iconos.Abandonar()),
            TB_REINIT: (_("Reinit"), Iconos.Reiniciar()),
            TB_TAKEBACK: (_("Takeback"), Iconos.Atras()),
            TB_ADJOURN: (_("Adjourn"), Iconos.Aplazar()),
            TB_ADJOURNS: (_("Adjourns"), Iconos.Aplazamientos()),
            TB_END_GAME: (_("End game"), Iconos.FinPartida()),
            TB_CLOSE: (_("Close"), Iconos.MainMenu()),
            TB_PREVIOUS: (_("Previous"), Iconos.Anterior()),
            TB_NEXT: (_("Next"), Iconos.Siguiente()),
            TB_QUIT: (_("Quit"), Iconos.FinPartida()),
            TB_PASTE_PGN: (_("Paste PGN"), Iconos.Pegar()),
            TB_READ_PGN: (_("Read PGN"), Iconos.Fichero()),
            TB_PGN_LABELS: (_("PGN Labels"), Iconos.InformacionPGN()),
            TB_OTHER_GAME: (_("Other game"), Iconos.FicheroRepite()),
            TB_MY_GAMES: (_("My games"), Iconos.NuestroFichero()),
            TB_DRAW: (_("Draw"), Iconos.Tablas()),
            TB_BOXROOMS_PGN: (_("Boxrooms PGN"), Iconos.BoxRooms()),
            TB_END: (_("End"), Iconos.MainMenu()),
            TB_SLOW: (_("Slow"), Iconos.Pelicula_Lento()),
            TB_PAUSE: (_("Pause"), Iconos.Pelicula_Pausa()),
            TB_CONTINUE: (_("Continue"), Iconos.Pelicula_Seguir()),
            TB_FAST: (_("Fast"), Iconos.Pelicula_Rapido()),
            TB_REPEAT: (_("Repeat"), Iconos.Pelicula_Repetir()),
            TB_PGN: (_("PGN"), Iconos.Pelicula_PGN()),
            TB_HELP: (_("Help"), Iconos.AyudaGR()),
            TB_LEVEL: (_("Level"), Iconos.Jugar()),
            TB_ACCEPT: (_("Accept"), Iconos.Aceptar()),
            TB_CANCEL: (_("Cancel"), Iconos.Cancelar()),
            # TB_GAME_OF_THE_DAY: (_("Game of the day"), Iconos.LM()),
            TB_CONFIG: (_("Config"), Iconos.Configurar()),
            TB_UTILITIES: (_("Utilities"), Iconos.Utilidades()),
            TB_VARIATIONS: (_("Variations"), Iconos.VariantesG()),
            TB_TOOLS: (_("Tools"), Iconos.Tools()),
            TB_CHANGE: (_("Change"), Iconos.Cambiar()),
            TB_SHOW_TEXT: (_("Show text"), Iconos.Modificar()),
            TB_HELP_TO_MOVE: (_("Help to move"), Iconos.BotonAyuda()),
            TB_SEND: (_("Send"), Iconos.Enviar()),
            TB_STOP: (_("Play now"), Iconos.Stop()),
        }

        cf = self.gestor.configuracion
        peso = 75 if cf.x_tb_bold else 50
        puntos = cf.x_tb_fontpoints
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for clave, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.clave = clave
            self.dicTB[clave] = accion
Exemplo n.º 16
0
    def mueveHumano(self, desde, hasta, coronacion=None):
        if self.siJuegaHumano:
            self.paraHumano()
        else:
            self.sigueHumano()
            return False

        movimiento = desde + hasta

        # Peon coronando
        if not coronacion and self.partida.ultPosicion.siPeonCoronando(
                desde, hasta):
            coronacion = self.tablero.peonCoronando(
                self.partida.ultPosicion.siBlancas)
            if coronacion is None:
                self.sigueHumano()
                return False
        if coronacion:
            movimiento += coronacion

        siBien, mens, jg = Jugada.dameJugada(self.partida.ultPosicion, desde,
                                             hasta, coronacion)

        siAnalisis = False

        if self.siTeclaPanico:
            self.sigueHumano()
            return False

        if siBien:
            siElegido = False

            if self.book and self.bookMandatory:
                fen = self.fenUltimo()
                listaJugadas = self.book.miraListaJugadas(fen)
                if listaJugadas:
                    li = []
                    for apdesde, aphasta, apcoronacion, nada, nada1 in listaJugadas:
                        mx = apdesde + aphasta + apcoronacion
                        if mx.strip().lower() == movimiento:
                            siElegido = True
                            break
                        li.append((apdesde, aphasta, False))
                    if not siElegido:
                        self.tablero.ponFlechasTmp(li)
                        self.sigueHumano()
                        return False

            if not siElegido and self.siApertura:
                fenBase = self.fenUltimo()
                if self.siAperturaStd:
                    if self.apertura.compruebaHumano(fenBase, desde, hasta):
                        siElegido = True
                    else:
                        if self.apertura.activa:
                            apdesde, aphasta = self.apertura.desdeHastaActual(
                                fenBase)

                            self.tablero.ponFlechasTmp(
                                ((apdesde, aphasta, False), ))
                            self.sigueHumano()
                            return False
                if not siElegido and self.apertura and self.apertura.compruebaHumano(
                        fenBase, desde, hasta):
                    siElegido = True

            if self.siTeclaPanico:
                self.sigueHumano()
                return False

            if not siElegido and self.siTutorActivado:
                self.analizaTutorFinal()
                rmUser, n = self.mrmTutor.buscaRM(movimiento)
                if not rmUser:
                    rmUser = self.xtutor.valora(self.partida.ultPosicion,
                                                desde, hasta, coronacion)
                    if not rmUser:
                        return False
                    self.mrmTutor.agregaRM(rmUser)
                siAnalisis = True
                pointsBest, pointsUser = self.mrmTutor.difPointsBest(
                    movimiento)
                self.setSummary("POINTSBEST", pointsBest)
                self.setSummary("POINTSUSER", pointsUser)
                if (pointsBest - pointsUser) > 0:
                    if not jg.siJaqueMate:
                        siTutor = True
                        if self.chance:
                            num = self.mrmTutor.numMejorMovQue(movimiento)
                            if num:
                                rmTutor = self.mrmTutor.rmBest()
                                rmUser, n = self.mrmTutor.buscaRM(movimiento)
                                menu = QTVarios.LCMenu(self.pantalla)
                                submenu = menu.submenu(
                                    _("There are %d best moves") % num,
                                    Iconos.Motor())
                                submenu.opcion(
                                    "tutor", "%s (%s)" %
                                    (_("Show tutor"), rmTutor.abrTextoBase()),
                                    Iconos.Tutor())
                                submenu.separador()
                                submenu.opcion("try", _("Try again"),
                                               Iconos.Atras())
                                submenu.separador()
                                submenu.opcion(
                                    "user",
                                    "%s (%s)" % (_("Select my move"),
                                                 rmUser.abrTextoBase()),
                                    Iconos.Player())
                                self.pantalla.cursorFueraTablero()
                                resp = menu.lanza()
                                if resp == "try":
                                    self.sigueHumano()
                                    return False
                                elif resp == "user":
                                    siTutor = False
                        if siTutor:
                            tutor = Tutor.Tutor(self, self, jg, desde, hasta,
                                                False)

                            if self.siApertura:
                                liApPosibles = self.listaAperturasStd.listaAperturasPosibles(
                                    self.partida)
                            else:
                                liApPosibles = None

                            if tutor.elegir(self.ayudas > 0,
                                            liApPosibles=liApPosibles):
                                if self.ayudas > 0:  # doble entrada a tutor.
                                    self.reponPieza(desde)
                                    self.ayudas -= 1
                                    desde = tutor.desde
                                    hasta = tutor.hasta
                                    coronacion = tutor.coronacion
                                    siBien, mens, jgTutor = Jugada.dameJugada(
                                        self.partida.ultPosicion, desde, hasta,
                                        coronacion)
                                    if siBien:
                                        jg = jgTutor
                                        self.setSummary("SELECTTUTOR", True)
                            if self.configuracion.guardarVariantesTutor:
                                tutor.ponVariantes(
                                    jg, 1 + self.partida.numJugadas() / 2)

                            del tutor

            if self.siTeclaPanico:
                self.sigueHumano()
                return False

            self.setSummary("TIMEUSER", self.timekeeper.stop())
            self.relojStop(True)

            if self.siApertura and self.siAperturaStd:
                self.siApertura = self.apertura.activa

            self.movimientosPiezas(jg.liMovs)

            if siAnalisis:
                rm, nPos = self.mrmTutor.buscaRM(jg.movimiento())
                if rm:
                    jg.analisis = self.mrmTutor, nPos

            self.partida.ultPosicion = jg.posicion
            self.masJugada(jg, True)
            self.error = ""
            self.siguienteJugada()
            return True
        else:
            self.error = mens
            self.sigueHumano()
            return False