Exemple #1
0
def init_contest(contest_format, teams, fast=False, back_round=False,
                 num_turns=120):

    logging.info("#### INIT CONTEST")

    teams = _clean_dictionary(teams)

    progress_bar = pbs.ProgressBarDialog(None, _('Checking teams...'))
    progress_bar_dialog = progress_bar.progress_bar_dialog
    progress_bar.set_num_elements(len(teams))
    progress_bar_dialog.show()

    while gtk.events_pending():
        gtk.main_iteration(False)    

    bannedTeams = []
    for equipo in teams:
        logging.info("Probando equipo: %s", equipo)

        if (not filenames.comprobar_nombre_reglas(equipo[0]) or 
            not filenames.comprobar_nombre_formacion(equipo[1])):
            bannedTeams.append(equipo)
            logging.warning("Equipo baneado: %s", equipo)
            continue

        try:
            probar_equipo(equipo)
        except:
            progress_bar_dialog.hide()
            notificacion = notify_result.SimpleNotify(_("The rules file <b>\"%s\"</b> has errors. This team will be out of the competition.\n\nCheck \"<i>log_gsiege</i>\" log file for details.") % equipo[0])
            notificacion.dlg_result.run()
            progress_bar_dialog.show()
            bannedTeams.append(equipo)
            
        progress_bar.pulse()
        
        while gtk.events_pending():
            gtk.main_iteration(False)    

    progress_bar_dialog.hide()

    for t in bannedTeams:
        teams.remove(t)

    controlPartida.restaurarCampeonato()

    if len(teams) > 1:
        if contest_format == 'playoff':
            _init_playoff(teams, fast, num_turns, back_round)
        else:
            _init_game(contest_format, teams, fast, num_turns, back_round)
    else:
         notificacion = notify_result.SimpleNotify(_("Not enough teams to hold the competition. Aborting."))
         notificacion.dlg_result.run()

    logging.info("#### END CONTEST")
    def load_board(self):
        controlPartida.restaurarCampeonato()

        ambosEquipos = [(self.es_team_a, self.team_team_a), (self.es_team_b, self.team_team_b)]
        
        for equipo in ambosEquipos:
            if (not filenames.comprobar_nombre_reglas(equipo[0]) or 
                not filenames.comprobar_nombre_formacion(equipo[1])):

                return

            logging.info("Probando equipo: %s", equipo)
            try:
                probar_equipo(equipo)
            except Exception as e:
                #progress_bar_dialog.hide()
                logging.error("Algo ha fallado")
                logging.error(e)
                notificacion = notify_result.SimpleNotify(_("The rules file <b>\"%s\"</b> has errors. This quick game will be cancelled.\n\nCheck \"<i>log_gsiege</i>\" log file for details.") % equipo[0])
                notificacion.dlg_result.run()
                #progress_bar_dialog.show()

                return
            logging.info("Equipo probado")

        try:
            winner,kk = guada_board.run(
                ((self.es_team_a, self.team_team_a),
                 xdg.get_data_path('images/piece-orange.png')),
                ((self.es_team_b,self.team_team_b),
                 xdg.get_data_path('images/piece-violete.png')),

                self.fast_game, 
                self.dont_save_game,
                self.hidde_values, 
                str(int(self.num_turns))
                )
        except guada_board.GuadaFileError as e:
            raise guada_board.GuadaFileError(e.msg)
        
        # Se ha seleccionado mostrar sólo los resultados
        if self.fast_game:
            teamA = (self.es_team_a, self.team_team_a)
            teamB = (self.es_team_b, self.team_team_b)

            n = notify_result.notifyResult((teamA, teamB), winner)
            
            n.dlg_result.run()
    def load_board(self):
        controlPartida.restaurarCampeonato()

        ambosEquipos = [(self.es_team_a, self.team_team_a),
                        (self.es_team_b, self.team_team_b)]

        for equipo in ambosEquipos:
            if (not filenames.comprobar_nombre_reglas(equipo[0])
                    or not filenames.comprobar_nombre_formacion(equipo[1])):

                return

            logging.info("Probando equipo: %s", equipo)
            try:
                probar_equipo(equipo)
            except Exception as e:
                #progress_bar_dialog.hide()
                logging.error("Algo ha fallado")
                logging.error(e)
                notificacion = notify_result.SimpleNotify(
                    _("The rules file <b>\"%s\"</b> has errors. This quick game will be cancelled.\n\nCheck \"<i>log_gsiege</i>\" log file for details."
                      ) % equipo[0])
                notificacion.dlg_result.run()
                #progress_bar_dialog.show()

                return
            logging.info("Equipo probado")

        try:
            winner, kk = guada_board.run(
                ((self.es_team_a, self.team_team_a),
                 xdg.get_data_path('images/piece-orange.png')),
                ((self.es_team_b, self.team_team_b),
                 xdg.get_data_path('images/piece-violete.png')),
                self.fast_game, self.dont_save_game, self.hidde_values,
                str(int(self.num_turns)))
        except guada_board.GuadaFileError as e:
            raise guada_board.GuadaFileError(e.msg)

        # Se ha seleccionado mostrar sólo los resultados
        if self.fast_game:
            teamA = (self.es_team_a, self.team_team_a)
            teamB = (self.es_team_b, self.team_team_b)

            n = notify_result.notifyResult((teamA, teamB), winner)

            n.dlg_result.run()
Exemple #4
0
def init_contest(contest_format,
                 teams,
                 fast=False,
                 back_round=False,
                 num_turns=120):

    logging.info("#### INIT CONTEST")

    teams = _clean_dictionary(teams)

    progress_bar = pbs.ProgressBarDialog(None, _('Checking teams...'))
    progress_bar_dialog = progress_bar.progress_bar_dialog
    progress_bar.set_num_elements(len(teams))
    progress_bar_dialog.show()

    while gtk.events_pending():
        gtk.main_iteration(False)

    bannedTeams = []
    for equipo in teams:
        logging.info("Probando equipo: %s", equipo)

        if (not filenames.comprobar_nombre_reglas(equipo[0])
                or not filenames.comprobar_nombre_formacion(equipo[1])):
            bannedTeams.append(equipo)
            logging.warning("Equipo baneado: %s", equipo)
            continue

        try:
            probar_equipo(equipo)
        except:
            progress_bar_dialog.hide()
            notificacion = notify_result.SimpleNotify(
                _("The rules file <b>\"%s\"</b> has errors. This team will be out of the competition.\n\nCheck \"<i>log_gsiege</i>\" log file for details."
                  ) % equipo[0])
            notificacion.dlg_result.run()
            progress_bar_dialog.show()
            bannedTeams.append(equipo)

        progress_bar.pulse()

        while gtk.events_pending():
            gtk.main_iteration(False)

    progress_bar_dialog.hide()

    for t in bannedTeams:
        teams.remove(t)

    controlPartida.restaurarCampeonato()

    if len(teams) > 1:
        if contest_format == 'playoff':
            _init_playoff(teams, fast, num_turns, back_round)
        else:
            _init_game(contest_format, teams, fast, num_turns, back_round)
    else:
        notificacion = notify_result.SimpleNotify(
            _("Not enough teams to hold the competition. Aborting."))
        notificacion.dlg_result.run()

    logging.info("#### END CONTEST")