def __init__(self, wpantalla, liKibitzersActivas, xtutor, liEngines): self.liKibitzersActivas = liKibitzersActivas # self.configuracion = copy.deepcopy( VarGen.configuracion ) self.configuracion = VarGen.configuracion self.liOpcionesInicio = [ k_terminar, k_play, k_competicion, k_elo, k_entrenamiento, k_tools, k_opciones, k_informacion ] # Lo incluimos aqui porque sino no lo lee, en caso de aplazada self.siPresentacion = False self.pantalla = Pantalla.PantallaDialog(self, wpantalla) self.pantalla.ponGestor(self) self.tablero = self.pantalla.tablero self.teclaPanico = None self.xtutor = xtutor self.xrival = None self.xanalyzer = None self.replayBeep = None self.posicionInicial = None self.cpu = CPU.CPU(self.pantalla) self.liEngines = liEngines
def juegaAplazada(self, aplazamiento): self.cpu = CPU.CPU(self.pantalla) tipoJuego = aplazamiento["TIPOJUEGO"] siBlancas = aplazamiento["SIBLANCAS"] if tipoJuego == kJugNueva: categoria = self.configuracion.rival.categorias.segunClave(aplazamiento["CATEGORIA"]) nivel = aplazamiento["NIVEL"] puntos = aplazamiento["PUNTOS"] self.gestor = GestorCompeticion.GestorCompeticion(self) self.gestor.inicio(categoria, nivel, siBlancas, puntos, aplazamiento) elif tipoJuego == kJugEntMaq: if aplazamiento["MODO"] == "Basic": self.entrenaMaquina(None, aplazamiento) else: self.playPersonAplazada(aplazamiento) elif tipoJuego == kJugElo: self.gestor = GestorElo.GestorElo(self) self.gestor.inicio(None, aplazamiento["SICOMPETITIVO"], aplazamiento) elif tipoJuego == kJugMicElo: self.gestor = GestorMicElo.GestorMicElo(self) self.gestor.inicio(None, 0, 0, aplazamiento["SICOMPETITIVO"], aplazamiento) elif tipoJuego == kJugAlbum: self.gestor = GestorAlbum.GestorAlbum(self) self.gestor.inicio(None, None, aplazamiento) elif tipoJuego == kJugPGN: self.visorPGN("pgn_comandoExterno") elif tipoJuego == kJugSolo: self.jugarSolo(fichero=sys.argv[1]) elif tipoJuego in (kJugFics, kJugFide, kJugLichess): self.gestor = GestorFideFics.GestorFideFics(self) self.gestor.selecciona(tipoJuego) self.gestor.inicio(aplazamiento["IDGAME"], aplazamiento["SICOMPETITIVO"], aplazamiento=aplazamiento)
def juegaAplazada(self, aplazamiento): self.cpu = CPU.CPU(self.main_window) type_play = aplazamiento["TIPOJUEGO"] is_white = aplazamiento["ISWHITE"] if type_play == GT_COMPETITION_WITH_TUTOR: categoria = self.configuration.rival.categorias.segun_clave( aplazamiento["CATEGORIA"]) nivel = aplazamiento["LEVEL"] puntos = aplazamiento["PUNTOS"] self.manager = ManagerCompeticion.ManagerCompeticion(self) self.manager.start(categoria, nivel, is_white, puntos, aplazamiento) elif type_play == GT_AGAINST_ENGINE: if aplazamiento["MODO"] == "Basic": self.entrenaMaquina(aplazamiento) else: self.playPersonAplazada(aplazamiento) elif type_play == GT_ELO: self.manager = ManagerElo.ManagerElo(self) self.manager.start(aplazamiento) elif type_play == GT_MICELO: self.manager = ManagerMicElo.ManagerMicElo(self) self.manager.start(None, 0, 0, aplazamiento) elif type_play == GT_ALBUM: self.manager = ManagerAlbum.ManagerAlbum(self) self.manager.start(None, None, aplazamiento) elif type_play == GT_AGAINST_PGN: self.read_pgn(sys.argv[1]) elif type_play in (GT_FICS, GT_FIDE, GT_LICHESS): self.manager = ManagerFideFics.ManagerFideFics(self) self.manager.selecciona(type_play) self.manager.start(aplazamiento["IDGAME"], aplazamiento=aplazamiento)
def __init__(self, window, xtutor, is_competitive=False, kibitzers_manager=None): self.kibitzers_manager = kibitzers_manager self.is_competitive = is_competitive self.configuration = Code.configuration self.li_opciones_inicio = [ TB_QUIT, TB_PLAY, TB_TRAIN, TB_COMPETE, TB_TOOLS, TB_OPTIONS, TB_INFORMATION ] # Lo incluimos aqui porque sino no lo lee, en caso de aplazada self.siPresentacion = False self.main_window = MainWindow.MainWindow(self, window) self.main_window.set_manager_active(self) self.board = self.main_window.board self.xtutor = xtutor self.xrival = None self.xanalyzer = None self.replayBeep = None self.posicionInicial = None self.cpu = CPU.CPU(self.main_window)
def inicio(self): self.configuracion.limpiaTemporal() self.reset() if self.configuracion.siPrimeraVez: self.cambiaConfiguracionPrimeraVez() self.configuracion.siPrimeraVez = False self.pantalla.ponTitulo() if self.siPrimeraVez: self.siPrimeraVez = False self.cpu = CPU.CPU(self.pantalla) self.presentacion()
def iniciar_gui(self): if len(sys.argv) > 1: comando = sys.argv[1] if comando.lower().endswith(".pgn"): self.main_window = None self.read_pgn(comando) return self.main_window = MainWindow.MainWindow(self) self.main_window.set_manager_active(self) # antes que muestra self.main_window.muestra() self.kibitzers_manager = KibitzersManager.Manager(self) self.board = self.main_window.board self.cpu = CPU.CPU(self.main_window) self.entrenamientos = Trainings.Entrenamientos(self) if self.configuration.x_check_for_update: Update.test_update(self) if len(sys.argv) > 1: comando = sys.argv[1] comandoL = comando.lower() if comandoL.endswith(".pgn"): aplazamiento = {} aplazamiento["TIPOJUEGO"] = GT_AGAINST_PGN aplazamiento["ISWHITE"] = True # Compatibilidad self.juegaAplazada(aplazamiento) return elif comandoL.endswith(".lcsb"): aplazamiento = {} aplazamiento["TIPOJUEGO"] = GT_ALONE aplazamiento["ISWHITE"] = True # Compatibilidad self.juegaAplazada(aplazamiento) return elif comandoL.endswith(".lcdb"): self.externDatabase(comando) return elif comandoL.endswith(".bmt"): self.start() self.externBMT(comando) return elif comando == "-play": fich_tmp = sys.argv[2] self.juegaExterno(fich_tmp) return else: self.start()
def movimientosPiezasTV(self, liMovs, tablero): """ Hace los movimientos de piezas en el tablero """ if VarGen.configuracion.efectosVisuales: cpu = CPU.CPU(tablero.pantalla) segundos = None # primero los movimientos for movim in liMovs: if movim[0] == "m": if segundos is None: desde, hasta = movim[1], movim[2] dc = ord(desde[0]) - ord(hasta[0]) df = int(desde[1]) - int(hasta[1]) # Maxima distancia = 9.9 ( 9,89... sqrt(7**2+7**2)) = 4 segundos dist = (dc**2 + df**2)**0.5 segundos = 4.0 * dist / 9.9 cpu.muevePieza(movim[1], movim[2], siExclusiva=False, segundos=segundos) if segundos is None: segundos = 1.0 # segundo los borrados for movim in liMovs: if movim[0] == "b": n = cpu.duerme(segundos * 0.90) cpu.borraPieza(movim[1], padre=n) # tercero los cambios for movim in liMovs: if movim[0] == "c": cpu.cambiaPieza(movim[1], movim[2], siExclusiva=True) cpu.runLineal() else: for movim in liMovs: if movim[0] == "b": tablero.borraPieza(movim[1]) elif movim[0] == "m": tablero.muevePieza(movim[1], movim[2]) elif movim[0] == "c": tablero.cambiaPieza(movim[1], movim[2])
def inicio(self): Code.runSound.close() if self.gestor: del self.gestor self.gestor = None self.configuracion.limpiaTemporal() self.reset() if self.configuracion.siPrimeraVez: self.cambiaconfigurationPrimeraVez() self.configuracion.siPrimeraVez = False self.main_window.ponTitulo() if self.siPrimeraVez: self.siPrimeraVez = False self.cpu = CPU.CPU(self.main_window) self.presentacion() self.kibitzers_manager.stop()
def __init__(self, wpantalla, liKibitzersActivas, xtutor, liEngines): self.liKibitzersActivas = liKibitzersActivas # self.configuracion = copy.deepcopy( VarGen.configuracion ) self.configuracion = VarGen.configuracion self.pantalla = Pantalla.Pantalla(self, wpantalla) self.pantalla.ponGestor(self) self.tablero = self.pantalla.tablero self.teclaPanico = None self.xtutor = xtutor self.xrival = None self.replayBeep = None self.cpu = CPU.CPU(self.pantalla) self.liEngines = liEngines
def __init__(self, file_tournament, file_work): QtWidgets.QWidget.__init__(self) Code.list_engine_managers = EngineManager.ListEngineManagers() self.torneo = TournamentRun( file_tournament) # Tournament.Tournament(file_tournament) self.file_work = file_work self.db_work = UtilSQL.ListSQL(file_work) self.slow_pieces = self.torneo.slow_pieces() self.setWindowTitle( "%s - %s %d" % (self.torneo.name(), _("Worker"), int(file_work[-5:]))) self.setWindowIcon(Iconos.Torneos()) # Toolbar self.tb = Controles.TBrutina(self, icon_size=24) # Board conf_board = Code.configuration.config_board("TOURNEYPLAY", 36) self.board = Board.Board(self, conf_board) self.board.crea() Delegados.generaPM(self.board.piezas) # PGN self.configuration = Code.configuration self.game = Game.Game() self.pgn = ControlPGN.ControlPGN(self) ly_pgn = self.crea_bloque_informacion() self.is_closed = False self.state = None self.current_side = WHITE ly_tt = Colocacion.V().control(self.tb).control(self.board) layout = Colocacion.H().otro(ly_tt).otro(ly_pgn).relleno().margen(3) self.setLayout(layout) self.cpu = CPU.CPU(self) self.pon_estado(ST_WAITING)
def __init__(self, wpantalla, xtutor, siCompetitivo=False, kibitzers_manager=None): self.kibitzers_manager = kibitzers_manager self.siCompetitivo = siCompetitivo self.configuracion = Code.configuracion self.li_opciones_inicio = [ TB_QUIT, TB_PLAY, TB_TRAIN, TB_COMPETE, TB_TOOLS, TB_OPTIONS, TB_INFORMATION, ] # Lo incluimos aqui porque sino no lo lee, en caso de aplazada self.siPresentacion = False self.main_window = Pantalla.PantallaDialog(self, wpantalla) self.main_window.ponGestor(self) self.tablero = self.main_window.tablero self.xtutor = xtutor self.xrival = None self.xanalyzer = None self.replayBeep = None self.posicionInicial = None self.cpu = CPU.CPU(self.main_window)