def competicion(self):
        options = WCompetitionWithTutor.datos(self.main_window,
                                              self.configuration, self)
        if options:
            # self.game_type = GT_COMPETITION_WITH_TUTOR
            categorias, categoria, nivel, is_white, puntos = options

            self.manager = ManagerCompeticion.ManagerCompeticion(self)
            self.manager.start(categorias, categoria, nivel, is_white, puntos)
示例#2
0
    def competicion(self):
        opciones = WCompetitionWithTutor.datos(self.main_window,
                                               self.configuracion, self)
        if opciones:
            # self.game_type = GT_COMPETITION_WITH_TUTOR
            categorias, categoria, nivel, is_white, puntos = opciones

            self.gestor = GestorCompeticion.GestorCompeticion(self)
            self.gestor.inicio(categorias, categoria, nivel, is_white, puntos)
示例#3
0
 def ent_otro(self):
     pos = WCompetitionWithTutor.edit_training_position(
         self.main_window,
         self.title_training,
         self.num_trainings,
         pos=self.pos_training)
     if pos is not None:
         self.pos_training = pos
         self.reiniciar()
示例#4
0
    def cambiar(self):
        if self.tactic.w_next_position >= 0:
            pos = WCompetitionWithTutor.edit_training_position(
                self.main_window,
                self.tactic.title_extended(),
                self.tactic.w_next_position,
                pos=self.tactic.w_next_position,
            )
            if pos is not None:
                self.tactic.w_next_position = pos - 1
                self.tactic.work_set_current_position(self.tactic.w_next_position)

                self.ent_siguiente()
    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 == "train_book":
                    self.train_book()

                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 = os.path.basename(entreno)[:-4]
                    # 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.configuration.ficheroTrainings)
                        data = db[entreno]
                        if type(data) != dict:
                            data = {}
                        posUltimo = data.get("POSULTIMO", 1)
                        jump = data.get("SALTA", False)
                        tipo = data.get("TYPE", "s")
                        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,
                            "TYPE": 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 = Memory.Memoria(self.procesador)
                    mem.lanza(abs(resp) - 100)
    def jugar(self, number=None):

        if self.state == ST_PLAYING:
            self.state = ST_ENDGAME
            self.disable_all()

        if number is None:
            pos = self.pgn.primeroSinHacer() + 1
            number = WCompetitionWithTutor.edit_training_position(
                self.main_window,
                _("Find all moves"),
                pos,
                etiqueta=_("Level"),
                pos=pos,
                mensAdicional="<b>"
                + _("Movements must be indicated in the following order: King, Queen, Rook, Bishop, Knight and Pawn.")
                + "</b>",
            )
            if number is None:
                return
            number -= 1

        fen = self.pgn.dame(number)
        self.number = number
        cp = Position.Position()
        cp.read_fen(fen)
        self.human_side = self.is_white = cp.is_white
        if self.is_white:
            siP = self.siJugador
        else:
            siP = not self.siJugador
        self.put_pieces_bottom(siP)
        self.set_position(cp)
        self.cp = cp
        self.refresh()

        FasterCode.set_fen(fen)
        self.liMovs = FasterCode.get_exmoves()

        # Creamos un avariable para controlar que se mueven en orden
        d = {}
        fchs = "KQRBNP"
        if not cp.is_white:
            fchs = fchs.lower()
        for k in fchs:
            d[k] = ""
        for mov in self.liMovs:
            mov.is_selected = False
            pz = mov.piece()
            d[pz] += pz
        self.ordenPZ = ""
        for k in fchs:
            self.ordenPZ += d[k]

        self.errores = 0
        self.iniTiempo = time.time()
        self.pendientes = len(self.liMovs)
        self.state = ST_PLAYING

        self.board.remove_arrows()

        mens = ""
        if cp.castles:
            if ("K" if cp.is_white else "k") in cp.castles:
                mens = "O-O"
            if ("Q" if cp.is_white else "q") in cp.castles:
                if mens:
                    mens += " + "
                mens += "O-O-O"
            if mens:
                mens = _("Castling moves possible") + ": " + mens
        if cp.en_passant != "-":
            mens += " " + _("En passant") + ": " + cp.en_passant

        self.main_window.set_label1(mens)

        self.nivel = number
        self.is_white = cp.is_white
        self.ponRotulo2n()

        self.main_window.pon_toolbar((TB_RESIGN,))
        self.main_window.base.pgn.goto(number, 0)
        self.activate_side(self.is_white)