def voyager2(self, game): ptxt = Voyager.voyagerPartida(self, game) if ptxt: game = Game.Game() game.restore(ptxt) self.addPartida(game) self.show_lines()
def voyager2(self, partida): ptxt = Voyager.voyagerPartida(self, partida) if ptxt: partida = Partida.Partida() partida.recuperaDeTexto(ptxt) self.addPartida(partida) self.show_lines()
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)
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.is_complete: liMasOpciones.extend([ ("position", _("Edit start position"), Iconos.Datos()), sep, ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager()), ]) resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.auto_rotate = not self.auto_rotate is_white = self.game.last_position.is_white if self.auto_rotate: if is_white != self.board.is_white_bottom: self.board.rotaBoard() elif resp == "position": ini_position = self.game.first_position new_position = Voyager.voyager_position(self.main_window, ini_position) if new_position and new_position != ini_position: self.game.set_position(new_position) self.start(self.game, self.is_complete, self.only_consult, self.with_previous_next, self.save_routine) self.changed = True self.put_toolbar() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: new_position = Position.Position() try: new_position.read_fen(str(texto)) ini_position = self.game.first_position if new_position and new_position != ini_position: self.game.set_position(new_position) self.start(self.game, self.is_complete, self.only_consult, self.with_previous_next, self.save_routine) self.changed = True self.put_toolbar() except: pass elif resp == "leerpgn": game = self.procesador.select_1_pgn(self.main_window) self.replace_game(game) elif resp == "pastepgn": self.paste_pgn() elif resp == "voyager": game = Voyager.voyagerPartida(self.main_window, self.game) self.replace_game(game)
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([ ("position", _("Edit 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.auto_rotate = not self.auto_rotate is_white = self.game.last_position.is_white if self.auto_rotate: if is_white != self.tablero.is_white_bottom: self.tablero.rotaTablero() elif resp == "position": ini_position = self.game.first_position new_position = Voyager.voyager_position(self.main_window, ini_position) if new_position and new_position != ini_position: self.game.set_position(new_position) self.inicio(self.game, self.siCompleta) elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = Position.Position() try: cp.read_fen(str(texto)) self.fen = cp.fen() self.posicApertura = None self.reiniciar() except: pass elif resp == "leerpgn": game = self.procesador.select_1_pgn(self.main_window) if game: if self.siCompleta and not game.siFenInicial(): return p = Game.Game() p.leeOtra(game) p.assign_opening() self.reinicio = p.save() self.reiniciar() elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: ok, game = Game.pgn_game(texto) if not ok: QTUtil2.message_error( self.main_window, _("The text from the clipboard does not contain a chess game in PGN format" )) return if self.siCompleta and not game.siFenInicial(): return self.reinicio = game.save() self.reiniciar() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.main_window, self.game) if ptxt: dic = self.creaDic() dic["GAME"] = ptxt.save() dic["FEN"] = None if ptxt.siFenInicial( ) else ptxt.first_position.fen() dic["WHITEBOTTOM"] = self.tablero.is_white_bottom self.reiniciar(dic)
def configurarGS(self): mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.play_against_engine else _X( _("Enable %1"), mt) sep = (None, None, None) liMasOpciones = [ ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep, ("opening", _("Opening"), Iconos.Apertura()), sep, ("position", _("Edit 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, ("engine", mt, Iconos.Motores()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager1()), ] resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.auto_rotate = not self.auto_rotate is_white = self.game.last_position.is_white if self.auto_rotate: if is_white != self.tablero.is_white_bottom: self.tablero.rotaTablero() elif resp == "opening": me = self.unMomento() w = PantallaOpenings.WAperturas(self.main_window, self.configuracion, self.bloqueApertura) me.final() if w.exec_(): self.bloqueApertura = w.resultado() self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.reiniciar() elif resp == "position": self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = Position.Position() try: cp.read_fen(str(texto)) self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.new_game() self.game.set_position(first_position=cp) self.bloqueApertura = None self.reiniciar() except: pass elif resp == "leerpgn": self.leerpgn() elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: ok, game = Game.pgn_game(texto) if not ok: QTUtil2.message_error( self.main_window, _("The text from the clipboard does not contain a chess game in PGN format" )) return self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.bloqueApertura = None dic = self.creaDic() dic["GAME"] = game.save() dic["WHITEBOTTOM"] = game.last_position.is_white self.reiniciar(dic) elif resp == "engine": self.ponRotulo1("") if self.play_against_engine: if self.xrival: self.xrival.terminar() self.xrival = None self.play_against_engine = False else: self.cambioRival() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.main_window, self.game) if ptxt: self.xfichero = None self.xpgn = None self.xjugadaInicial = None dic = self.creaDic() dic["GAME"] = ptxt.save() dic["WHITEBOTTOM"] = self.tablero.is_white_bottom self.reiniciar(dic)
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)
def utilities_gs(self): sep = (None, None, None) li_mas_opciones = [ (None, _("Change the initial position"), Iconos.PGN()), sep, ("leerpgn", _("Read PGN file"), Iconos.PGN_Importar()), sep, ("pastepgn", _("Paste PGN"), Iconos.Pegar16()), sep, ] if not self.is_complete: li_mas_opciones.extend([ ("position", _("Edit start position"), Iconos.Datos()), sep, ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager()), ]) li_mas_opciones.extend([(None, None, True), sep, ("books", _("Consult a book"), Iconos.Libros()) ]) resp = self.utilidades(li_mas_opciones) if resp == "books": liMovs = self.librosConsulta(True) if liMovs: for x in range(len(liMovs) - 1, -1, -1): from_sq, to_sq, promotion = liMovs[x] self.player_has_moved(from_sq, to_sq, promotion) elif resp == "position": ini_position = self.game.first_position new_position = Voyager.voyager_position(self.main_window, ini_position) if new_position and new_position != ini_position: self.game.set_position(new_position) self.start(self.game, self.is_complete, self.only_consult, self.with_previous_next, self.save_routine) self.changed = True self.put_toolbar() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: new_position = Position.Position() try: new_position.read_fen(str(texto)) ini_position = self.game.first_position if new_position and new_position != ini_position: self.game.set_position(new_position) self.start(self.game, self.is_complete, self.only_consult, self.with_previous_next, self.save_routine) self.changed = True self.put_toolbar() except: pass elif resp == "leerpgn": game = self.procesador.select_1_pgn(self.main_window) self.replace_game(game) elif resp == "pastepgn": self.paste_pgn() elif resp == "voyager": game = Voyager.voyagerPartida(self.main_window, self.game) self.replace_game(game)
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": resp = Voyager.voyagerFEN(self.pantalla, self.fen) if resp is not None: self.fen = resp 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.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) if self.siCompleta: p.asignaApertura(self.configuracion) 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) if self.siCompleta: p.asignaApertura(self.configuracion) 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)
def utilities_gs(self): mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.play_against_engine else _X( _("Enable %1"), mt) sep = (None, None, None) liMasOpciones = ( (None, _("Change the initial position"), Iconos.PGN()), sep, ("position", _("Edit start position") + " [S]", Iconos.Datos()), sep, ("initial", _("Basic position") + " [B]", Iconos.Board()), sep, ("opening", _("Opening"), Iconos.Opening()), sep, ("pasteposicion", _("Paste FEN position") + " [V]", Iconos.Pegar16()), sep, ("leerpgn", _("Read PGN file"), Iconos.PGN_Importar()), sep, ("pastepgn", _("Paste PGN") + " [V]", Iconos.Pegar16()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager()), (None, None, True), sep, ("books", _("Consult a book"), Iconos.Libros()), sep, ("engine", mt, Iconos.Motores()), sep, ) resp = self.utilidades(liMasOpciones) if resp == "books": liMovs = self.librosConsulta(True) if liMovs: for x in range(len(liMovs) - 1, -1, -1): from_sq, to_sq, promotion = liMovs[x] self.player_has_moved(from_sq, to_sq, promotion) elif resp == "initial": self.basic_initial_position() elif resp == "opening": me = self.unMomento() w = WindowOpenings.WOpenings(self.main_window, self.configuration, self.opening_block) me.final() if w.exec_(): self.opening_block = w.resultado() self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.reiniciar() elif resp == "position": self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = Position.Position() try: cp.read_fen(str(texto)) self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.new_game() self.game.set_position(first_position=cp) self.opening_block = None self.reiniciar() except: pass elif resp == "leerpgn": self.leerpgn() elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: ok, game = Game.pgn_game(texto) if not ok: QTUtil2.message_error( self.main_window, _("The text from the clipboard does not contain a chess game in PGN format" )) return self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.opening_block = None dic = self.creaDic() dic["GAME"] = game.save() dic["WHITEBOTTOM"] = game.first_position.is_white self.reiniciar(dic) elif resp == "engine": self.set_label1("") if self.play_against_engine: if self.xrival: self.xrival.terminar() self.xrival = None self.play_against_engine = False else: self.cambioRival() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.main_window, self.game) if ptxt: self.xfichero = None self.xpgn = None self.xjugadaInicial = None dic = self.creaDic() dic["GAME"] = ptxt dic["WHITEBOTTOM"] = self.board.is_white_bottom self.reiniciar(dic)