def menu_run(self, resp): if resp: if type(resp) == str: if resp == "gm": self.entrenaGM() elif resp.startswith("mate"): self.jugarMate(int(resp[-1])) elif resp == "bmt": self.bmt() elif resp.startswith("resistance"): self.resistance(resp[10:]) elif resp in ["find_all_moves_rival", "find_all_moves_player"]: self.find_all_moves(resp == "find_all_moves_player") elif resp == "dailytest": self.dailyTest() elif resp == "potencia": self.potencia() elif resp == "visualiza": self.visualiza() elif resp == "anotar": self.anotar() elif resp == "endings_gtb": self.gaviota_endings() elif resp.startswith("tactica|"): nada, tipo, name, carpeta, ini = resp.split("|") self.tacticas(tipo, name, carpeta, ini) elif resp.startswith("remtactica|"): nada, carpeta, name = resp.split("|") self.tacticaRemove(carpeta, name) elif resp.startswith("puente_"): self.puente(int(resp[7:])) elif resp.startswith("horses_"): test = int(resp[7]) icl, icn, tit = self.horsesDef[test] icon = Code.todasPiezas.icono(icl, icn) self.horses(test, tit, icon) elif resp.startswith("ep_"): um = self.procesador.unMomento() entreno = os.path.realpath(resp[3:]) titentreno = Util.relative_path(entreno, Code.folder_root) # if "/" in entreno: # dicTraining = TrListas.dicTraining() # titentreno = "" # for x in entreno[:-4].split("/")[1:]: # titentreno += dicTraining.get(x, x) + "/" # titentreno = titentreno[:-1] with Util.OpenCodec(entreno) as f: todo = f.read().strip() liEntrenamientos = todo.split("\n") nPosiciones = len(liEntrenamientos) um.final() if nPosiciones == 0: return elif nPosiciones == 1: pos = 1 jump = False else: db = UtilSQL.DictSQL( self.configuracion.ficheroTrainings) data = db[entreno] jump = False tipo = "s" if data is None: posUltimo = 1 elif type(data) == int: posUltimo = data else: posUltimo = data["POSULTIMO"] jump = data["SALTA"] tipo = data["TIPO"] resp = WCompetitionWithTutor.numPosicion( self.procesador.main_window, titentreno, nPosiciones, posUltimo, jump, tipo) if resp is None: db.close() return pos, tipo, jump = resp db[entreno] = { "POSULTIMO": pos, "SALTA": jump, "TIPO": tipo } db.close() if tipo.startswith("r"): if tipo == "rk": random.seed(pos) random.shuffle(liEntrenamientos) self.procesador.entrenaPos(pos, nPosiciones, titentreno, liEntrenamientos, entreno, jump) elif resp == "learnPGN": self.learnPGN() elif resp == "playGame": self.procesador.play_game() elif resp.startswith("map_"): nada, mapa = resp.split("_") self.procesador.trainingMap(mapa) elif resp == "transsiberian": self.procesador.showRoute() elif resp == "everest": self.everest() elif resp.startswith("tol_"): self.turn_on_lights(resp[4:]) elif resp == "washing_machine": self.washing_machine() elif resp == "captures": self.captures() elif resp == "counts": self.counts() elif resp == "15mate": self.mate15() elif resp == "coordinates_blocks": self.coordinates_blocks() elif resp == "coordinates_basic": self.coordinates_basic() else: if resp <= -100: self.menu = None # ya que puede cambiar y la etiqueta es diferente mem = Memoria.Memoria(self.procesador) mem.lanza(abs(resp) - 100)
def creaMenu(self): dicMenu = {} menu = QTVarios.LCMenu(self.parent) talpha = Controles.TipoLetra("Chess Alpha 2", self.configuracion.x_menu_points + 4) def xopcion(menu, key, texto, icono, is_disabled=False): if "KP" in texto: k2 = texto.index("K", 2) texto = texto[:k2] + texto[k2:].lower() menu.opcion(key, texto, icono, is_disabled, tipoLetra=talpha) else: menu.opcion(key, texto, icono, is_disabled) dicMenu[key] = (self.menu_run, texto, icono, is_disabled) # Posiciones de entrenamiento -------------------------------------------------------------------------- self.menuFNS(menu, _("Training positions"), xopcion) menu.separador() # GM --------------------------------------------------------------------------------------------------- xopcion(menu, "gm", _("Play like a GrandMaster"), Iconos.GranMaestro()) menu.separador() # Mate -------------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Training mates"), Iconos.Mate()) for mate in range(1, 8): xopcion(menu1, "mate%d" % mate, _X(_("Mate in %1"), str(mate)), Iconos.PuntoAzul()) menu1.separador() menu.separador() # BMT ------------------------------------------------------------------------------------------- xopcion(menu, "bmt", _("Find best move"), Iconos.BMT()) menu.separador() # Resistencia ------------------------------------------------------------------------------------------ menu1 = menu.submenu(_("Resistance Test"), Iconos.Resistencia()) nico = Util.Rondo(Iconos.Verde(), Iconos.Azul(), Iconos.Amarillo(), Iconos.Naranja()) xopcion(menu1, "resistance", _("Normal"), nico.otro()) xopcion(menu1, "resistancec", _("Blindfold chess"), nico.otro()) xopcion(menu1, "resistancep1", _("Hide only our pieces"), nico.otro()) xopcion(menu1, "resistancep2", _("Hide only opponent pieces"), nico.otro()) menu.separador() # DailyTest ------------------------------------------------------------------------------------------------ xopcion(menu, "dailytest", _("Your daily test"), Iconos.DailyTest()) menu.separador() # Tacticas --------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Learn tactics by repetition"), Iconos.Tacticas()) nico = Util.Rondo(Iconos.Amarillo(), Iconos.Naranja(), Iconos.Verde(), Iconos.Azul(), Iconos.Magenta()) dicTraining = TrListas.dicTraining() def trTraining(txt): return dicTraining.get(txt, txt) def menu_tacticas(submenu, tipo, carpeta_base, lista): if os.path.isdir(carpeta_base): for entry in os.scandir(carpeta_base): if entry.is_dir(): carpeta = entry.path ini = os.path.join(carpeta, "Config.ini") if os.path.isfile(ini): name = entry.name xopcion( submenu, "tactica|%s|%s|%s|%s" % (tipo, name, carpeta, ini), trTraining(name), nico.otro(), ) menu1.separador() lista.append((carpeta, name)) else: submenu1 = submenu.submenu(entry.name, nico.otro()) menu_tacticas(submenu1, tipo, carpeta, lista) return lista menu_tacticas(menu1, TACTICS_BASIC, Code.path_resource("Tactics"), []) lista = [] carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining, "Tactics") if os.path.isdir(carpetaTacticasP): submenu1 = menu1.submenu(_("Personal tactics"), nico.otro()) lista = menu_tacticas(submenu1, TACTICS_PERSONAL, carpetaTacticasP, lista) if lista: ico = Iconos.Delete() menub = menu1.submenu(_("Remove"), ico) for carpeta, name in lista: xopcion(menub, "remtactica|%s|%s" % (carpeta, name), trTraining(name), ico) menu.separador() # Longs ---------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Long-term trainings"), Iconos.Longhaul()) # Maps menu2 = menu1.submenu(_("Training on a map"), Iconos.Maps()) xopcion(menu2, "map_Africa", _("Africa map"), Iconos.Africa()) menu2.separador() xopcion(menu2, "map_WorldMap", _("World map"), Iconos.WorldMap()) # Rail menu1.separador() xopcion(menu1, "transsiberian", _("Transsiberian Railway"), Iconos.Train()) # Everest menu1.separador() xopcion(menu1, "everest", _("Expeditions to the Everest"), Iconos.Trekking()) # TOL menu1.separador() menu2 = menu1.submenu(_("Turn on the lights"), Iconos.TOL()) menu.separador() menu3 = menu2.submenu(_("Memory mode"), Iconos.TOL()) xopcion(menu3, "tol_uned_easy", "%s (%s)" % (_("UNED chess school"), _("Initial")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uned", "%s (%s)" % (_("UNED chess school"), _("Complete")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uwe_easy", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe()) menu3.separador() xopcion(menu3, "tol_uwe", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe()) menu2.separador() menu3 = menu2.submenu(_("Calculation mode"), Iconos.Calculo()) xopcion(menu3, "tol_uned_easy_calc", "%s (%s)" % (_("UNED chess school"), _("Initial")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uned_calc", "%s (%s)" % (_("UNED chess school"), _("Complete")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uwe_easy_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe()) menu3.separador() xopcion(menu3, "tol_uwe_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe()) # Washing menu2.separador() xopcion(menu2, "tol_oneline", _("In one line"), Iconos.TOLline()) menu1.separador() xopcion(menu1, "washing_machine", _("The Washing Machine"), Iconos.WashingMachine()) # Cebras --------------------------------------------------------------------------------------------------- menu.separador() # menu1 = menu.submenu(_("Resources for zebras"), Iconos.Cebra()) menu2 = menu.submenu(_("Check your memory on a chessboard"), Iconos.Memoria()) mem = Memoria.Memoria(self.procesador) categorias = CompetitionWithTutor.Categorias() for x in range(6): cat = categorias.number(x) txt = cat.name() nm = mem.nivel(x) if nm >= 0: txt += " %s %d" % (_("Level"), nm + 1) xopcion(menu2, -100 - x, txt, cat.icono(), is_disabled=not mem.is_active(x)) menu.separador() menu2 = menu.submenu(_("Find all moves"), Iconos.FindAllMoves()) xopcion(menu2, "find_all_moves_rival", _("Opponent"), Iconos.PuntoNaranja()) xopcion(menu2, "find_all_moves_player", _("Player"), Iconos.PuntoAzul()) menu.separador() self.horsesDef = hd = { 1: ("N", "Alpha", _("Basic test")), 2: ("p", "Fantasy", _("Four pawns test")), 3: ("Q", "Pirat", _("Jonathan Levitt test")), 4: ("n", "Spatial", _("Basic test") + ": a1"), 5: ("N", "Cburnett", _("Basic test") + ": e4"), } menu2 = menu.submenu(_("Becoming a knight tamer"), Iconos.Knight()) vicon = Code.todasPiezas.icono icl, icn, tit = hd[1] menu3 = menu2.submenu(tit, vicon(icl, icn)) xopcion(menu3, "horses_1", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[4] xopcion(menu3, "horses_4", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[5] xopcion(menu3, "horses_5", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[2] xopcion(menu2, "horses_2", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[3] xopcion(menu2, "horses_3", tit, vicon(icl, icn)) menu.separador() menu2 = menu.submenu(_("Moves between two positions"), Iconos.Puente()) rp = QTVarios.rondoPuntos() for x in range(1, 11): xopcion(menu2, "puente_%d" % x, "%s %d" % (_("Level"), x), rp.otro()) menu.separador() xopcion(menu, "potencia", _("Determine your calculating power"), Iconos.Potencia()) menu.separador() menu2 = menu.submenu(_("Learn a game"), Iconos.School()) xopcion(menu2, "learnPGN", _("Memorizing their moves"), Iconos.LearnGame()) menu2.separador() xopcion(menu2, "playGame", _("Playing against"), Iconos.Law()) menu.separador() xopcion(menu, "visualiza", _("The board at a glance"), Iconos.Gafas()) menu.separador() menu2 = menu.submenu(_("Coordinates"), Iconos.Coordinates()) xopcion(menu2, "coordinates_basic", _("Basic"), Iconos.West()) menu2.separador() xopcion(menu2, "coordinates_blocks", _("By blocks"), Iconos.Blocks()) menu.separador() xopcion(menu, "anotar", _("Writing down moves of a game"), Iconos.Write()) menu.separador() xopcion(menu, "captures", _("Captures and threats in a game"), Iconos.Captures()) menu.separador() xopcion(menu, "counts", _("Count moves"), Iconos.Count()) menu.separador() xopcion(menu, "15mate", _("Mate in 1½"), Iconos.Mate15()) menu.separador() xopcion(menu, "endings_gtb", _("Endings with Gaviota Tablebases"), Iconos.Finales()) return menu, dicMenu
def lanza(self, siFavoritos=True): self.comprueba() liFavoritos = None if siFavoritos: liFav = self.procesador.configuracion.liFavoritos if liFav: li = [] for elem in liFav: if elem in self.dicMenu: li.append(self.dicMenu[elem]) liFavoritos = li if liFavoritos: menu = self.menuFavoritos(liFavoritos) else: menu = self.menu resp = menu.lanza() if resp: siStr = type(resp) == type("") if siStr: if resp == "menu_global": self.lanza(False) elif resp == "gm": self.entrenaGM() elif resp.startswith("mate"): self.jugarMate(int(resp[-1])) elif resp == "bmt": self.bmt() elif resp == "polyglot": self.entrenaBooks() elif resp.startswith("boxing"): self.boxing(resp[6:]) elif resp in ["j60_rival", "j60_jugador"]: self.jugar60(resp == "j60_jugador") elif resp == "aperturas": self.aperturas() elif resp == "dailytest": self.dailyTest() elif resp == "potencia": self.potencia() elif resp == "visualiza": self.visualiza() elif resp.startswith("tactica|"): nada, tipo, nombre, carpeta, ini = resp.split("|") self.tacticas(tipo, nombre, carpeta, ini) elif resp.startswith("remtactica|"): nada, carpeta, nombre = resp.split("|") self.tacticaRemove(carpeta, nombre) elif resp.startswith("puente_"): self.puente(int(resp[7:])) elif resp.startswith("horses_"): test = int(resp[7]) icl, icn, tit = self.horsesDef[test] icon = VarGen.todasPiezas.icono(icl, icn) self.horses(test, tit, icon) elif resp.startswith("ep_"): um = self.procesador.unMomento() entreno = resp[3:].replace("\\", "/") if "/" in entreno: dicTraining = TrListas.dicTraining() titentreno = "" for x in entreno[:-4].split("/")[1:]: titentreno += dicTraining.get(x, x) + "/" titentreno = titentreno[:-1] f = PGNreader.openCodec(entreno) todo = f.read().strip() f.close() liEntrenamientos = todo.split("\n") nPosiciones = len(liEntrenamientos) um.final() if nPosiciones == 0: return elif nPosiciones == 1: pos = 1 jump = False else: db = Util.DicSQL(self.configuracion.ficheroTrainings) posUltimo = db[entreno] if posUltimo is None: posUltimo = 1 resp = DatosNueva.numPosicion(self.procesador.pantalla, titentreno, nPosiciones, posUltimo) if resp is None: return pos, tipo, jump = resp db.close() if tipo.startswith("r"): if tipo == "rk": random.seed(pos) random.shuffle(liEntrenamientos) self.procesador.entrenaPos(pos, nPosiciones, titentreno, liEntrenamientos, entreno, jump) elif resp == "learnPGN": self.learnPGN() elif resp == "lucaselo": self.procesador.lucaselo(False) elif resp == "micelo": self.procesador.micelo(False) elif resp.startswith("fics"): self.procesador.ficselo(False, int(resp[4:])) elif resp.startswith("fide"): self.procesador.fideelo(False, int(resp[4:])) elif resp.startswith("map_"): nada, mapa = resp.split("_") self.procesador.trainingMap(mapa) else: if resp <= -100: self.menu = None # ya que puede cambiar y la etiqueta es diferente mem = Memoria.Memoria(self.procesador) mem.lanza(abs(resp) - 100)
def creaMenu(self): dicMenu = {} menu = QTVarios.LCMenu(self.parent) def xopcion(menu, clave, texto, icono, siDeshabilitado=False): menu.opcion(clave, texto, icono, siDeshabilitado) dicMenu[clave] = (clave, texto, icono, siDeshabilitado) # Posiciones de entrenamiento -------------------------------------------------------------------------- self.menuFNS(menu, _("Training positions"), xopcion) menu.separador() # GM --------------------------------------------------------------------------------------------------- xopcion(menu, "gm", _("Play like a grandmaster"), Iconos.GranMaestro()) menu.separador() # Mate -------------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Training mates"), Iconos.Mate()) for mate in range(1, 5): xopcion(menu1, "mate%d" % mate, _X(_("Mate in %1"), str(mate)), Iconos.PuntoAzul()) menu1.separador() menu.separador() # BMT ------------------------------------------------------------------------------------------- xopcion(menu, "bmt", _("Find best move"), Iconos.BMT()) menu.separador() # Openings ------------------------------------------------------------------------------------------------ menu1 = menu.submenu(_("Openings"), Iconos.Aperturas()) # # Aperturas -------------------------------------------------------------------------------------------- xopcion(menu1, "aperturas", _("Learn openings by repetition"), Iconos.Apertura()) menu1.separador() ## Books ------------------------------------------------------------------------------------------------ xopcion(menu1, "polyglot", _("Training with a book"), Iconos.Libros()) menu.separador() # DailyTest ------------------------------------------------------------------------------------------------ xopcion(menu, "dailytest", _("Your daily test"), Iconos.DailyTest()) menu.separador() # Resistencia ------------------------------------------------------------------------------------------ menu1 = menu.submenu(_("Resistance Test"), Iconos.Resistencia()) nico = Util.Rondo(Iconos.Verde(), Iconos.Azul(), Iconos.Amarillo(), Iconos.Naranja()) xopcion(menu1, "boxing", _("Normal"), nico.otro()) xopcion(menu1, "boxingc", _("Blindfold chess"), nico.otro()) xopcion(menu1, "boxingp1", _("Hide only our pieces"), nico.otro()) xopcion(menu1, "boxingp2", _("Hide only opponent pieces"), nico.otro()) menu.separador() # Tacticas --------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Learn tactics by repetition"), Iconos.Tacticas()) nico = Util.Rondo(Iconos.Amarillo(), Iconos.Naranja(), Iconos.Verde(), Iconos.Azul(), Iconos.Magenta()) dicTraining = TrListas.dicTraining() def trTraining(txt): return dicTraining.get(txt, txt) def menuTacticas(tipo, carpetaBase): lista = [] if os.path.isdir(carpetaBase): li = Util.listdir(carpetaBase) for nombre in li: carpeta = os.path.join(carpetaBase, nombre) ini = os.path.join(carpeta, "Config.ini") if os.path.isdir(carpeta) and os.path.isfile(ini): xopcion( menu1, "tactica|%s|%s|%s|%s" % (tipo, nombre, carpeta, ini), trTraining(nombre), nico.otro()) menu1.separador() lista.append((carpeta, nombre)) return lista menuTacticas("B", "Tactics") carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining, "Tactics") lista = menuTacticas("P", carpetaTacticasP) if lista: ico = Iconos.Delete() menub = menu1.submenu(_("Remove"), ico) for carpeta, nombre in lista: xopcion(menub, "remtactica|%s|%s" % (carpeta, nombre), trTraining(nombre), ico) menu.separador() # Maps ---------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Training on a map"), Iconos.Maps()) xopcion(menu1, "map_Africa", _("Africa map"), Iconos.Africa()) menu1.separador() xopcion(menu1, "map_WorldMap", _("World map"), Iconos.WorldMap()) # Cebras --------------------------------------------------------------------------------------------------- menu.separador() menu1 = menu.submenu(_("Resources for zebras"), Iconos.Cebra()) menu2 = menu1.submenu(_("Check your memory on a chessboard"), Iconos.Memoria()) rival = self.configuracion.rival mem = Memoria.Memoria(self.procesador) for x in range(6): cat = rival.categorias.numero(x) txt = cat.nombre() nm = mem.nivel(x) if nm > -1: txt += " %s %d" % (_("Level"), nm + 1) xopcion(menu2, -100 - x, txt, cat.icono(), siDeshabilitado=not mem.siActiva(x)) menu1.separador() menu2 = menu1.submenu(_("Find all moves"), Iconos.J60()) xopcion(menu2, "j60_rival", _("Opponent"), Iconos.PuntoNaranja()) xopcion(menu2, "j60_jugador", _("Player"), Iconos.PuntoAzul()) menu1.separador() self.horsesDef = hd = { 1: ("N", "Alpha", _("Basic test")), 2: ("p", "Fantasy", _("Four pawns test")), 3: ("Q", "Pirat", _("Jonathan Levitt test")), 4: ("n", "Spatial", _("Basic test") + ": a1"), 5: ("N", "Cburnett", _("Basic test") + ": e4") } menu2 = menu1.submenu(_("Becoming a knight tamer"), self.procesador.tablero.piezas.icono("N")) vicon = VarGen.todasPiezas.icono icl, icn, tit = hd[1] menu3 = menu2.submenu(tit, vicon(icl, icn)) xopcion(menu3, "horses_1", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[4] xopcion(menu3, "horses_4", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[5] xopcion(menu3, "horses_5", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[2] xopcion(menu2, "horses_2", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[3] xopcion(menu2, "horses_3", tit, vicon(icl, icn)) menu1.separador() menu2 = menu1.submenu(_("Moves between two positions"), Iconos.Puente()) rp = QTVarios.rondoPuntos() for x in range(1, 11): xopcion(menu2, "puente_%d" % x, "%s %d" % (_("Level"), x), rp.otro()) menu1.separador() xopcion(menu1, "potencia", _("Determine your calculating power"), Iconos.Potencia()) menu1.separador() xopcion(menu1, "learnPGN", _("Learn a game"), Iconos.PGN()) menu1.separador() xopcion(menu1, "visualiza", _("The board at a glance"), Iconos.Gafas()) # Ratings menu.separador() menu1 = menu.submenu(_("Training ratings"), Iconos.Elo()) xopcion(menu1, "lucaselo", "%s (%d)" % (_("Lucas-Elo"), self.configuracion.eloNC), Iconos.Elo()) menu1.separador() xopcion(menu1, "micelo", "%s (%d)" % (_("Tourney-Elo"), self.configuracion.micheloNC), Iconos.EloTimed()) menu1.separador() fics = self.configuracion.ficsNC menuf = menu1.submenu("%s (%d)" % (_("Fics-Elo"), fics), Iconos.Fics()) rp = QTVarios.rondoPuntos() for elo in range(900, 2800, 100): if (elo == 900) or (0 <= (elo + 99 - fics) <= 400 or 0 <= (fics - elo) <= 400): xopcion(menuf, "fics%d" % (elo / 100, ), "%d-%d" % (elo, elo + 99), rp.otro()) menu1.separador() fide = self.configuracion.fideNC menuf = menu1.submenu("%s (%d)" % (_("Fide-Elo"), fide), Iconos.Fide()) rp = QTVarios.rondoPuntos() for elo in range(1500, 2700, 100): if (elo == 1500) or (0 <= (elo + 99 - fide) <= 400 or 0 <= (fide - elo) <= 400): xopcion(menuf, "fide%d" % (elo / 100, ), "%d-%d" % (elo, elo + 99), rp.otro()) return menu, dicMenu
def menu_run(self, resp): if resp: if type(resp) == str: if resp == "gm": self.entrenaGM() elif resp == "wgm": self.entrenaWGM() elif resp.startswith("mate"): self.jugarMate(int(resp[-1])) elif resp == "bmt": self.bmt() elif resp == "polyglot": self.entrenaBooks() elif resp.startswith("resistance"): self.resistance(resp[10:]) elif resp in ["j60_rival", "j60_jugador"]: self.jugar60(resp == "j60_jugador") elif resp == "aperturas": self.aperturas() elif resp == "dailytest": self.dailyTest() elif resp == "potencia": self.potencia() elif resp == "visualiza": self.visualiza() elif resp.startswith("tactica|"): nada, tipo, nombre, carpeta, ini = resp.split("|") self.tacticas(tipo, nombre, carpeta, ini) elif resp.startswith("remtactica|"): nada, carpeta, nombre = resp.split("|") self.tacticaRemove(carpeta, nombre) elif resp.startswith("puente_"): self.puente(int(resp[7:])) elif resp.startswith("horses_"): test = int(resp[7]) icl, icn, tit = self.horsesDef[test] icon = VarGen.todasPiezas.icono(icl, icn) self.horses(test, tit, icon) elif resp.startswith("ep_"): um = self.procesador.unMomento() entreno = resp[3:].replace("\\", "/") if "/" in entreno: dicTraining = TrListas.dicTraining() titentreno = "" for x in entreno[:-4].split("/")[1:]: titentreno += dicTraining.get(x, x) + "/" titentreno = titentreno[:-1] with Util.OpenCodec(entreno) as f: todo = f.read().strip() liEntrenamientos = todo.split("\n") nPosiciones = len(liEntrenamientos) um.final() if nPosiciones == 0: return elif nPosiciones == 1: pos = 1 jump = False else: db = Util.DicSQL(self.configuracion.ficheroTrainings) data = db[entreno] jump = False tipo = "s" if data is None: posUltimo = 1 elif type(data) == int: posUltimo = data else: posUltimo = data["POSULTIMO"] jump = data["SALTA"] tipo = data["TIPO"] resp = DatosNueva.numPosicion(self.procesador.pantalla, titentreno, nPosiciones, posUltimo, jump, tipo) if resp is None: db.close() return pos, tipo, jump = resp db[entreno] = { "POSULTIMO": pos, "SALTA": jump, "TIPO": tipo } db.close() if tipo.startswith("r"): if tipo == "rk": random.seed(pos) random.shuffle(liEntrenamientos) self.procesador.entrenaPos(pos, nPosiciones, titentreno, liEntrenamientos, entreno, jump) elif resp == "learnPGN": self.learnPGN() elif resp == "playPGN": self.procesador.playPGN() elif resp == "lucaselo": self.procesador.lucaselo(False) elif resp == "micelo": self.procesador.micelo(False) elif resp.startswith("fics"): self.procesador.ficselo(False, int(resp[4:])) elif resp.startswith("fide"): self.procesador.fideelo(False, int(resp[4:])) elif resp.startswith("lichess"): self.procesador.lichesselo(False, int(resp[7:])) elif resp.startswith("map_"): nada, mapa = resp.split("_") self.procesador.trainingMap(mapa) elif resp == "transsiberian": self.procesador.showRoute() elif resp == "everest": self.everest() elif resp.startswith("tol_"): self.turn_on_lights(resp[4:]) elif resp == "washing_machine": self.washing_machine() else: if resp <= -100: self.menu = None # ya que puede cambiar y la etiqueta es diferente mem = Memoria.Memoria(self.procesador) mem.lanza(abs(resp) - 100)
def creaMenu(self): dicMenu = {} menu = QTVarios.LCMenu(self.parent) tpirat = Controles.TipoLetra("Chess Diagramm Pirat", self.configuracion.puntosMenu + 4) def xopcion(menu, clave, texto, icono, siDeshabilitado=False): if "KP" in texto: d = {"K": "r", "P": "w", "k": chr(126), "p": chr(134)} k2 = texto.index("K", 2) texto = texto[:k2] + texto[k2:].lower() texton = "" for c in texto: texton += d[c] menu.opcion(clave, texton, icono, siDeshabilitado, tipoLetra=tpirat) else: menu.opcion(clave, texto, icono, siDeshabilitado) dicMenu[clave] = (self.menu_run, texto, icono, siDeshabilitado) # Posiciones de entrenamiento -------------------------------------------------------------------------- self.menuFNS(menu, _("Training positions"), xopcion) menu.separador() # GM --------------------------------------------------------------------------------------------------- xopcion(menu, "gm", _("Play like a Grandmaster"), Iconos.GranMaestro()) menu.separador() xopcion(menu, "wgm", _("Play like a Woman Grandmaster"), Iconos.WGranMaestro()) menu.separador() # Mate -------------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Training mates"), Iconos.Mate()) for mate in range(1, 5): xopcion(menu1, "mate%d" % mate, _X(_("Mate in %1"), str(mate)), Iconos.PuntoAzul()) menu1.separador() menu.separador() # BMT ------------------------------------------------------------------------------------------- xopcion(menu, "bmt", _("Find best move"), Iconos.BMT()) menu.separador() # Resistencia ------------------------------------------------------------------------------------------ menu1 = menu.submenu(_("Resistance Test"), Iconos.Resistencia()) nico = Util.Rondo(Iconos.Verde(), Iconos.Azul(), Iconos.Amarillo(), Iconos.Naranja()) xopcion(menu1, "resistance", _("Normal"), nico.otro()) xopcion(menu1, "resistancec", _("Blindfold chess"), nico.otro()) xopcion(menu1, "resistancep1", _("Hide only our pieces"), nico.otro()) xopcion(menu1, "resistancep2", _("Hide only opponent pieces"), nico.otro()) menu.separador() # DailyTest ------------------------------------------------------------------------------------------------ xopcion(menu, "dailytest", _("Your daily test"), Iconos.DailyTest()) menu.separador() # Tacticas --------------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Learn tactics by repetition"), Iconos.Tacticas()) nico = Util.Rondo(Iconos.Amarillo(), Iconos.Naranja(), Iconos.Verde(), Iconos.Azul(), Iconos.Magenta()) dicTraining = TrListas.dicTraining() def trTraining(txt): return dicTraining.get(txt, txt) def menuTacticas(submenu, tipo, carpetaBase, lista): if os.path.isdir(carpetaBase): for entry in scandir.scandir(carpetaBase): if entry.is_dir(): carpeta = entry.path ini = os.path.join(carpeta, "Config.ini") if os.path.isfile(ini): nombre = entry.name xopcion( submenu, "tactica|%s|%s|%s|%s" % (tipo, nombre, carpeta, ini), trTraining(nombre), nico.otro()) menu1.separador() lista.append((carpeta, nombre)) else: submenu1 = submenu.submenu(entry.name, nico.otro()) menuTacticas(submenu1, tipo, carpeta, lista) return lista menuTacticas(menu1, "B", "Tactics", []) lista = [] carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining, "Tactics") if os.path.isdir(carpetaTacticasP): submenu1 = menu1.submenu(_("Personal tactics"), nico.otro()) lista = menuTacticas(submenu1, "P", carpetaTacticasP, lista) if lista: ico = Iconos.Delete() menub = menu1.submenu(_("Remove"), ico) for carpeta, nombre in lista: xopcion(menub, "remtactica|%s|%s" % (carpeta, nombre), trTraining(nombre), ico) menu.separador() # Openings ------------------------------------------------------------------------------------------------ menu1 = menu.submenu(_("Openings"), Iconos.Aperturas()) # # Aperturas -------------------------------------------------------------------------------------------- xopcion(menu1, "aperturas", _("Learn openings by repetition"), Iconos.Apertura()) menu1.separador() # Books ------------------------------------------------------------------------------------------------ xopcion(menu1, "polyglot", _("Training with a book"), Iconos.Libros()) # Ratings menu.separador() menu1 = menu.submenu(_("Training ratings"), Iconos.Elo()) xopcion(menu1, "lucaselo", "%s (%d)" % (_("Lucas-Elo"), self.configuracion.eloNC), Iconos.Elo()) menu1.separador() xopcion(menu1, "micelo", "%s (%d)" % (_("Tourney-Elo"), self.configuracion.micheloNC), Iconos.EloTimed()) menu1.separador() fics = self.configuracion.ficsNC menuf = menu1.submenu("%s (%d)" % (_("Fics-Elo"), fics), Iconos.Fics()) rp = QTVarios.rondoPuntos() for elo in range(900, 2800, 100): if (elo == 900) or (0 <= (elo + 99 - fics) <= 400 or 0 <= (fics - elo) <= 400): xopcion(menuf, "fics%d" % (elo / 100, ), "%d-%d" % (elo, elo + 99), rp.otro()) menu1.separador() fide = self.configuracion.fideNC menuf = menu1.submenu("%s (%d)" % (_("Fide-Elo"), fide), Iconos.Fide()) rp = QTVarios.rondoPuntos() for elo in range(1500, 2700, 100): if (elo == 1500) or (0 <= (elo + 99 - fide) <= 400 or 0 <= (fide - elo) <= 400): xopcion(menuf, "fide%d" % (elo / 100, ), "%d-%d" % (elo, elo + 99), rp.otro()) lichess = self.configuracion.lichessNC menuf = menu1.submenu("%s (%d)" % (_("Lichess-Elo"), fide), Iconos.Lichess()) rp = QTVarios.rondoPuntos() for elo in range(800, 2700, 100): if (elo == 800) or (0 <= (elo + 99 - lichess) <= 400 or 0 <= (lichess - elo) <= 400): xopcion(menuf, "fide%d" % (elo / 100, ), "%d-%d" % (elo, elo + 99), rp.otro()) menu.separador() # xopcion(menu, "tolday", _("Your daily turn on the lights"), Iconos.TOLday()) # menu.separador() # Longs ---------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Long-term trainings"), Iconos.Longhaul()) # Maps menu2 = menu1.submenu(_("Training on a map"), Iconos.Maps()) xopcion(menu2, "map_Africa", _("Africa map"), Iconos.Africa()) menu2.separador() xopcion(menu2, "map_WorldMap", _("World map"), Iconos.WorldMap()) # Rail menu1.separador() xopcion(menu1, "transsiberian", _("Transsiberian Railway"), Iconos.Train()) # Everest menu1.separador() xopcion(menu1, "everest", _("Expeditions to the Everest"), Iconos.Trekking()) # TOL menu1.separador() menu2 = menu1.submenu(_("Turn on the lights"), Iconos.TOL()) menu3 = menu2.submenu(_("Memory mode"), Iconos.TOL()) xopcion(menu3, "tol_uned_easy", "%s (%s)" % (_("UNED chess school"), _("Initial")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uned", "%s (%s)" % (_("UNED chess school"), _("Complete")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uwe_easy", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe()) menu3.separador() xopcion(menu3, "tol_uwe", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe()) menu2.separador() menu3 = menu2.submenu(_("Calculation mode"), Iconos.Calculo()) xopcion(menu3, "tol_uned_easy_calc", "%s (%s)" % (_("UNED chess school"), _("Initial")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uned_calc", "%s (%s)" % (_("UNED chess school"), _("Complete")), Iconos.Uned()) menu3.separador() xopcion(menu3, "tol_uwe_easy_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Initial")), Iconos.Uwe()) menu3.separador() xopcion(menu3, "tol_uwe_calc", "%s (%s)" % (_("Uwe Auerswald"), _("Complete")), Iconos.Uwe()) # Washing menu1.separador() xopcion(menu1, "washing_machine", _("The Washing Machine"), Iconos.WashingMachine()) # Cebras --------------------------------------------------------------------------------------------------- menu.separador() menu1 = menu.submenu(_("Resources for zebras"), Iconos.Cebra()) menu2 = menu1.submenu(_("Check your memory on a chessboard"), Iconos.Memoria()) rival = self.configuracion.rival mem = Memoria.Memoria(self.procesador) for x in range(6): cat = rival.categorias.numero(x) txt = cat.nombre() nm = mem.nivel(x) if nm >= 0: txt += " %s %d" % (_("Level"), nm + 1) xopcion(menu2, -100 - x, txt, cat.icono(), siDeshabilitado=not mem.siActiva(x)) menu1.separador() menu2 = menu1.submenu(_("Find all moves"), Iconos.J60()) xopcion(menu2, "j60_rival", _("Opponent"), Iconos.PuntoNaranja()) xopcion(menu2, "j60_jugador", _("Player"), Iconos.PuntoAzul()) menu1.separador() self.horsesDef = hd = { 1: ("N", "Alpha", _("Basic test")), 2: ("p", "Fantasy", _("Four pawns test")), 3: ("Q", "Pirat", _("Jonathan Levitt test")), 4: ("n", "Spatial", _("Basic test") + ": a1"), 5: ("N", "Cburnett", _("Basic test") + ": e4") } menu2 = menu1.submenu(_("Becoming a knight tamer"), self.procesador.tablero.piezas.icono("N")) vicon = VarGen.todasPiezas.icono icl, icn, tit = hd[1] menu3 = menu2.submenu(tit, vicon(icl, icn)) xopcion(menu3, "horses_1", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[4] xopcion(menu3, "horses_4", tit, vicon(icl, icn)) menu3.separador() icl, icn, tit = hd[5] xopcion(menu3, "horses_5", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[2] xopcion(menu2, "horses_2", tit, vicon(icl, icn)) menu2.separador() icl, icn, tit = hd[3] xopcion(menu2, "horses_3", tit, vicon(icl, icn)) menu1.separador() menu2 = menu1.submenu(_("Moves between two positions"), Iconos.Puente()) rp = QTVarios.rondoPuntos() for x in range(1, 11): xopcion(menu2, "puente_%d" % x, "%s %d" % (_("Level"), x), rp.otro()) menu1.separador() xopcion(menu1, "potencia", _("Determine your calculating power"), Iconos.Potencia()) menu1.separador() menu2 = menu1.submenu(_("Learn a game"), Iconos.School()) xopcion(menu2, "learnPGN", _("Memorizing their moves"), Iconos.LearnGame()) menu2.separador() xopcion(menu2, "playPGN", _("Playing against"), Iconos.Law()) menu1.separador() xopcion(menu1, "visualiza", _("The board at a glance"), Iconos.Gafas()) # menu2 = menu1.submenu(_("Endings with 3/4 pieces"), Iconos.Puente()) # xopcion(menu2, "end_t4-1", "%s %d"%(_("Level"), 1), Iconos.PuntoAzul()) # xopcion(menu2, "end_t4-2", "%s %d"%(_("Level"), 2), Iconos.PuntoMagenta()) return menu, dicMenu