def __init__(self, carpeta): dicTraining = TrListas.dicTraining() def trTraining(txt): return dicTraining.get(txt, txt) self.tr = trTraining self.name = trTraining(os.path.basename(carpeta)) self.read(carpeta)
def tacticas(self, tipo, name, carpeta, ini): dic_training = TrListas.dicTraining() um = self.procesador.unMomento() tacticas = Tactics.Tactics(tipo, name, carpeta, ini) liMenus = tacticas.listaMenus() if len(liMenus) == 0: um.final() return nico = QTVarios.rondoPuntos() if len(liMenus) > 1: menu = QTVarios.LCMenu(self.parent) menu.opcion(None, _SP(name), Iconos.Tacticas()) menu.separador() dmenu = {} for valor, lista in liMenus: actmenu = menu if len(lista) > 1: t = "" for x in range(len(lista) - 1): t += "|%s" % lista[x] if not (t in dmenu): v_trad = dic_training.get(lista[x], lista[x]) dmenu[t] = actmenu.submenu(v_trad, nico.otro()) actmenu.separador() actmenu = dmenu[t] actmenu.opcion(valor, dic_training.get(lista[-1], lista[-1]), nico.otro()) actmenu.separador() um.final() resp = menu.lanza() else: resp = liMenus[0][0] if not resp: um.final() return tactica = tacticas.eligeTactica(resp, self.configuration.carpeta_results) um.final() if tactica: self.entrenaTactica(tactica)
def create_menu_tactics(self, menu, xopcion): menu.separador() menu_tactics = menu.submenu(_("Tactics"), Iconos.Training_Tactics()) # Posiciones de entrenamiento -------------------------------------------------------------------------- self.menuFNS(menu_tactics, _("Training positions"), xopcion) menu_tactics.separador() # Tacticas --------------------------------------------------------------------------------------------- menu_t = menu_tactics.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()) menu_t.separador() lista.append((carpeta, name)) else: submenu1 = submenu.submenu(entry.name, nico.otro()) menu_tacticas(submenu1, tipo, carpeta, lista) return lista menu_tacticas(menu_t, TACTICS_BASIC, Code.path_resource("Tactics"), []) lista = [] carpetaTacticasP = self.configuration.folder_tactics() if os.path.isdir(carpetaTacticasP): submenu1 = menu_t.submenu(_("Personal tactics"), nico.otro()) lista = menu_tacticas(submenu1, TACTICS_PERSONAL, carpetaTacticasP, lista) if lista: ico = Iconos.Delete() menub = menu_t.submenu(_("Remove"), ico) for carpeta, name in lista: xopcion(menub, "remtactica|%s|%s" % (carpeta, name), trTraining(name), ico) menu_tactics.separador() xopcion(menu_tactics, "bmt", _("Find best move"), Iconos.BMT()) menu_tactics.separador() xopcion(menu_tactics, "dailytest", _("Your daily test"), Iconos.DailyTest()) menu_tactics.separador() xopcion(menu_tactics, "potencia", _("Determine your calculating power"), Iconos.Potencia()) menu_tactics.separador() # TOL menu_tactics.separador() menu2 = menu_tactics.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()) menu2.separador() xopcion(menu2, "tol_oneline", _("Turn on lights in one line"), Iconos.TOLline())
def start(self, pos_training, num_trainings, title_training, li_trainings, is_tutor_enabled=None, is_automatic_jump=False): if hasattr(self, "reiniciando"): if self.reiniciando: return self.reiniciando = True if is_tutor_enabled is None: is_tutor_enabled = (Code.dgtDispatch is None) and self.configuration.x_default_tutor_active self.pos_training = pos_training self.save_pos(pos_training) self.num_trainings = num_trainings self.title_training = title_training self.li_trainings = li_trainings self.is_automatic_jump = is_automatic_jump self.li_histo = [self.pos_training] self.hints = 99999 self.line_fns = FNSLine.FNSLine(self.li_trainings[self.pos_training - 1]) self.game_obj = self.line_fns.game_obj self.pos_obj = 0 self.is_rival_thinking = False cp = self.line_fns.position is_white = cp.is_white if self.line_fns.with_game_original(): self.game = self.line_fns.game_original else: self.game.set_position(cp) if self.game_obj: self.game.set_first_comment(self.game_obj.first_comment, True) self.game.pending_opening = False self.game_type = GT_POSITIONS self.human_is_playing = False self.state = ST_PLAYING self.plays_instead_of_me_option = True self.human_side = is_white self.is_engine_side_white = not is_white self.rm_rival = None self.is_tutor_enabled = is_tutor_enabled self.main_window.set_activate_tutor(self.is_tutor_enabled) self.ayudas_iniciales = 0 li_options = [TB_CLOSE, TB_HELP, TB_CHANGE, TB_REINIT, TB_TAKEBACK] li_options.append(TB_PGN_LABELS) li_options.extend((TB_CONFIG, TB_UTILITIES)) if self.num_trainings > 1: li_options.extend((TB_PREVIOUS, TB_NEXT)) self.li_options_toolbar = li_options self.main_window.pon_toolbar(li_options) self.main_window.activaJuego(True, False, siAyudas=False) self.main_window.remove_hints(False, False) self.set_dispatcher(self.player_has_moved) self.set_position(self.game.last_position) self.show_side_indicator(True) self.put_pieces_bottom(is_white) titulo = "<b>%s</b>" % TrListas.dicTraining().get(self.title_training, self.title_training) if self.line_fns.label: titulo += "<br>%s" % self.line_fns.label self.set_label1(titulo) self.set_label2("%d / %d" % (pos_training, num_trainings)) self.pgnRefresh(True) QTUtil.refresh_gui() if self.xrival is None: self.xrival = self.procesador.creaManagerMotor( self.configuration.tutor, self.configuration.x_tutor_mstime, self.configuration.x_tutor_depth ) player = self.configuration.nom_player() other = _("the engine") w, b = (player, other) if self.human_side else (other, player) self.game.set_tag("White", w) self.game.set_tag("Black", b) self.is_analyzed_by_tutor = False self.continueTt = not self.configuration.x_engine_notbackground self.check_boards_setposition() if self.line_fns.with_game_original(): self.repiteUltimaJugada() self.reiniciando = False self.is_rival_thinking = False self.is_analyzing = False self.play_next_move()