Exemplo n.º 1
0
    def __init__(self, parent):
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/settingsDialog.glade'))

        self.settings = builder.get_object("settingsDialog")
        self.settings.set_transient_for(parent)

        self.file_chooser_games = builder.get_object("file_chs_prev_games")
        self.file_chooser_teams = builder.get_object("file_chs_se")
        self.check_active_music = builder.get_object("check_active_music")

        self.label_subfolders = builder.get_object("label_subfolders")
        self.label_logfolder = builder.get_object("label_logfolder")

        config_vars = configure.load_configuration()

        games_current_folder = config_vars['games_path'] + '..'
        teams_current_folder = config_vars['se_path'] + '..'
        
        self.file_chooser_games.set_current_folder(games_current_folder)
        self.file_chooser_games.set_filename(config_vars['games_path'])
        self.file_chooser_teams.set_current_folder(teams_current_folder)
        self.file_chooser_teams.set_filename(config_vars['se_path'])

        active = False
        if config_vars['music_active'] == '1':
            active = True
        self.check_active_music.set_active(active)

        self.scale_intervalo = builder.get_object("scale_intervalo")
        self.scale_intervalo.set_range(100, 2000)
        self.scale_intervalo.set_value(config_vars['auto_interval_time'])
        
        builder.connect_signals(self)
Exemplo n.º 2
0
    def __init__(self, parent):
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/contest.glade'))
        
        self.contest_dialog = builder.get_object("contest_dialog")
        self.contest_dialog.set_transient_for(parent)

        self.files = {}
        self.teams = {}

        #---------------------------
        self.cName = 0
        self.cRules = 1
        self.cFormation = 2
        
        self.sName = _("Name")
        self.sRules = _("Rules")
        self.sFormation = _("Formation")
        
        self.list_view = builder.get_object("list_es_view")
        self.list_view.set_reorderable(False)

        self.addColumn(self.sName, self.cName)
        self.addColumn(self.sRules, self.cRules)
        self.addColumn(self.sFormation, self.cFormation)

        self.list_store = builder.get_object("list_expert_system")
        #-----------------------------

        self.file_chooser_rules = builder.get_object('file_chooser_rules')
        #self.file_chooser_rules.set_transient_for(self.players_selector)
        self.file_chooser_formation = builder.get_object('file_chooser_formation')
        #self.file_chooser_formation.set_transient_for(self.players_selector)

        self.format_contest = 'league'
        self.radio_league = builder.get_object('radio_league')
        self.radio_cup = builder.get_object('radio_cup')
        self.radio_groups = builder.get_object('radio_groups')
        self.radio_playoff = builder.get_object('radio_playoff')
        self.check_backround = builder.get_object('check_backround')
        self.check_fast = builder.get_object('check_onlyresults')

        self.back_round = False
        self.fast = False
        self.all_teams = False
        
        def_path = configure.load_configuration()['se_path']
        self.file_chooser_rules.set_current_folder(def_path + '/rules')
        self.file_chooser_formation.set_current_folder(def_path + '/formations')

        self.start_button = builder.get_object('btn_start')
        self.frame_selection_teams = builder.get_object('box_selection')
        
        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50,300)
        self.spin_turns.set_increments(2,10)
        self.spin_turns.set_value(self.num_turns)
        
        builder.connect_signals(self)
Exemplo n.º 3
0
def _init_playoff(teams, fast, num_turns, back_round):
    logging.info("##### INIT PLAYOFF")

    log_base_folder = configure.load_configuration()['games_path'] + '/'
    log_base_folder += "Mixto-" + filenames.generate_isodate() + "/"

    os.mkdir(log_base_folder)

    band, classifications = _init_game('league',
                                       teams,
                                       fast,
                                       num_turns,
                                       back_round,
                                       log_base_folder=log_base_folder)

    if not band and not controlPartida.flagCancelarCampeonato:
        band = False
        teams = _get_teams_next_round(
            teams, _extract_classifications(classifications))
        _init_game('cup',
                   teams,
                   fast,
                   num_turns,
                   log_base_folder=log_base_folder)

    logging.info("##### END PLAYOFF")
Exemplo n.º 4
0
    def __init__(self, teams, num_turns, pairings_done=False):
        self.matchs = []
        self.teams = []
        self.round_winners = []
        self.num_turns = num_turns
        if pairings_done:
            self.matchs.append(teams)
            self.teams = _extract_teams_from_pairing(self.matchs)
        else:
            self.teams = teams

        self.translator = contest.generate_key_names(self.teams)
        self.keys = []
        
        for t in self.translator:
            self.keys.append(t)

        if not pairings_done:
            self.matchs.append(_auto_pairings(self.keys))

        self.round_number = 0
        self.rounds = []
        
        base_path = configure.load_configuration()['games_path'] + '/'
        self.tournament_file_name = base_path + filenames.generate_filename('tournament')
        
        self.rounds.append(round.Round(self.matchs[self.round_number],
                                       self.translator,
                                       self.tournament_file_name,
                                       self.num_turns))

        self.number_of_rounds = int(math.ceil(math.log(len(self.teams),2)))
        self.tournament_completed = False
Exemplo n.º 5
0
def _load_game_from_file(src_file, team_a, team_b, path_piece_def, xml_file,
                         hidden=False, cant_draw=False):
                         

    entire_game, winner = file_parser.parse_file(src_file)
    if cant_draw:
        winner,kk = _handle_draw(entire_game, winner)

    music = False
    if configure.load_configuration()['music_active'] == '1':
        music = True

    if type(team_a[0]) == str:
        name_team_a = team_a[0]
        name_team_b = team_b[0]
    else:
        name_team_a = filenames.extract_name_expert_system(team_a[0])
        name_team_b = filenames.extract_name_expert_system(team_b[0]) 

    c_team_a = (name_team_a, team_a[1])
    c_team_b = (name_team_b, team_b[1])

    P = pintarPartida.PintarPartida(src_file, c_team_a, c_team_b, music, hidden, cant_draw)
    P.run()

    show_dialog_result((team_a[0], team_b[0]), winner)
Exemplo n.º 6
0
    def __init__(self, main_team, teams, rounds_number, num_turns):
        self.main_team = main_team
        self.teams = teams
        self.num_turns = num_turns
        
        self.translator_teams = _generate_key_names(teams)
        self.translator_main_team = _generate_key_names([main_team])

        self.keys_teams = []
        self.key_main_team = []

        self.rounds_number = rounds_number

        base_path = configure.load_configuration()['games_path'] + '/'
        base_path += filenames.generate_filename('labdir', main_team) +'/'

        os.mkdir(base_path)

        

        self.filename = base_path + filenames.generate_filename('stats',
                                                                main_team)

        
        for _team in self.translator_teams:
            self.keys_teams.append(_team)

        for _team in self.translator_main_team:
            self.key_main_team.append(_team)

        self.translator = self.translator_teams.copy()
        for k in self.translator_main_team:
            self.translator[k] = self.translator_main_team[k]

        self.rounds = []
        stats_writer = csv.writer(open(self.filename, 'w'), delimiter=',',
                                  quotechar='|', quoting=csv.QUOTE_MINIMAL)
        stats_writer.writerow([_('Opponent'), _('As team'),
                               _('Result'), _("Number of turns"),
                               _('Number of pieces'), _("Value of the pieces"),
                               _('Turn when max value piece died')])

        for i in range(self.rounds_number):
            round_games = pairing.test_pairing(self.key_main_team[0],
                                               self.keys_teams, i%2)
            self.rounds.append(test_round.TestRound((round_games,
                                                    self.translator),
                                                    num_turns = self.num_turns,
                                                    log_file=self.filename,
                                                    player=i%2, logFolder = base_path))

        self.total_stats = {}
        self.total_stats['wins'] = 0
        self.total_stats['looses'] = 0
        self.total_stats['draws'] = 0
        self.total_stats['turns_winning'] = 0
        self.total_stats['turns_losing'] = 0
        self.total_stats['num_pieces'] = 0
        self.total_stats['val_pieces'] = 0
        self.total_stats['max_death'] = 0
Exemplo n.º 7
0
def _load_game_from_file(src_file,
                         team_a,
                         team_b,
                         path_piece_def,
                         xml_file,
                         hidden=False,
                         cant_draw=False):

    entire_game, winner = file_parser.parse_file(src_file)
    if cant_draw:
        winner, kk = _handle_draw(entire_game, winner)

    music = False
    if configure.load_configuration()['music_active'] == '1':
        music = True

    if type(team_a[0]) == str:
        name_team_a = team_a[0]
        name_team_b = team_b[0]
    else:
        name_team_a = filenames.extract_name_expert_system(team_a[0])
        name_team_b = filenames.extract_name_expert_system(team_b[0])

    c_team_a = (name_team_a, team_a[1])
    c_team_b = (name_team_b, team_b[1])

    P = pintarPartida.PintarPartida(src_file, c_team_a, c_team_b, music,
                                    hidden, cant_draw)
    P.run()

    show_dialog_result((team_a[0], team_b[0]), winner)
Exemplo n.º 8
0
    def __init__(self, teams, num_turns, back_round=False):
        self.teams = teams
        self.translator = contest.generate_key_names(teams)
        self.keys = []
        self.num_turns = num_turns

        for t in self.translator:
            self.keys.append(t)

        self.matchs = pairing.make_pairings(self.keys, back_round)

        self.rounds = []
        base_path = configure.load_configuration()['games_path'] + '/'
        self.tournament_file_name = base_path + filenames.generate_filename('league')
        print self.tournament_file_name
        
        for jorn in self.matchs:
            self.rounds.append(round.Round(jorn, self.translator,
                                           self.tournament_file_name,
                                           self.num_turns))

        self.puntuations_by_round = []
        self.puntuations = {}
        for key in self.keys:
            self.puntuations[key] = 0

        self.number_of_rounds = len(self.rounds)
        self.actual_round = 0
        self.league_completed = False
Exemplo n.º 9
0
    def __init__(self):
        "Constructor of the object"

        # gtk.Builder es un objeto que lee una interfaz de glade e instancia los
        # widgets descritos en el fichero
        builder = gtk.Builder()

        # Carga el fichero con la interfaz principal
        builder.add_from_file(xdg.get_data_path('glade/main.glade')) 
        
        # Guarda referencias a cada uno de los diálogos
        self.window = builder.get_object("mainWindow")
        self.about = builder.get_object("aboutdialog1")
        self.previous_games_chooser = builder.get_object("filechooserdialog1")
        self.games_chooser_warning = builder.get_object("messagedialog1")

        # Conecta el evento response a una lambda-función que oculta el cuadro
        # de diálogo
        self.games_chooser_warning.connect('response', lambda d, r: d.hide())

        # Indica que ese diálogo es un subdiálogo (sort of) de
        # previous_game_chooser
        self.games_chooser_warning.set_transient_for(self.previous_games_chooser)

        # Lo mismo, pero de la ventana principal
        self.previous_games_chooser.set_transient_for(self.window)

        # Lo mismo, pero de la ventana principal también
        self.about.set_transient_for(self.window)
        
        def_path = configure.load_configuration()['games_path']
        self.previous_games_chooser.set_current_folder(def_path)
        builder.connect_signals(self)
Exemplo n.º 10
0
def get_installed_teams():
    """
    Return a list of the installed teams. We consider a installed team some
    of the way 'data/teams/formations/equipoXX.clp',
    'data/teams/rules/reglasYYYY.clp' where XX == YYYY
    """
    base_path = configure.load_configuration()['se_path']
    rules_path = base_path + '/rules'
    formations_path = base_path + '/formations'

    list_rules = os.listdir(rules_path)
    list_formations = os.listdir(formations_path)

    for i in range(len(list_rules)):
        list_rules[i] = list_rules[i].replace('reglas','')
        list_rules[i] = list_rules[i].replace('.clp','')

    for i in range(len(list_formations)):
        list_formations[i] = list_formations[i].replace('equipo', '')
        list_formations[i] = list_formations[i].replace('.clp', '')

    set_rules = set(list_rules)
    set_formations = set(list_formations)

    set_final = set_rules.intersection(set_formations)
    list_final = list(set_final)

    res = []

    for i in range(len(list_final)):
        _rules = rules_path + '/reglas' + list_final[i] + '.clp'
        _form = formations_path + '/equipo' + list_final[i] + '.clp'
        res.append((_rules, _form))

    return res
Exemplo n.º 11
0
    def on_btn_apply_clicked(self, widget, data=None):
        config_vars = configure.load_configuration()
        #current_games_path = self.file_chooser_games.get_current_folder()
        #current_teams_path = self.file_chooser_teams.get_current_folder()
        
        current_games_path = self.file_chooser_games.get_filename()
        current_teams_path = self.file_chooser_teams.get_filename()
        current_active_music = ''
        if self.check_active_music.get_active():
            current_active_music = "1"
        else:
            current_active_music = "0"

        current_interval_time = self.scale_intervalo.get_value()
        
        if current_games_path != config_vars['games_path']:
            configure.set_games_path(current_games_path)

        if self.comprobarDirectorios() and current_teams_path != config_vars['se_path']:
            configure.set_se_path(current_teams_path)

        if current_active_music != config_vars['music_active']:
            configure.set_active_music(current_active_music)

        if current_interval_time != config_vars['auto_interval_time']:
            configure.set_interval_time(current_interval_time)

        self.settings.hide()
    def __init__(self, parent):
        self.es_team_a = ''
        self.team_team_a = ''
        self.es_team_b = ''
        self.team_team_b = ''
        
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/quickGame.glade'))

        def_path = configure.load_configuration()['se_path']
        def_rules_path = def_path + '/rules'
        def_formations_path = def_path + '/formations'
        builder.get_object('file_chooser_es_a').set_current_folder(def_rules_path)
        builder.get_object('file_chooser_team_a').set_current_folder(def_formations_path)
        builder.get_object('file_chooser_es_b').set_current_folder(def_rules_path)
        builder.get_object('file_chooser_team_b').set_current_folder(def_formations_path)

        self.quick_game = builder.get_object("quick_game_dialog")
        self.quick_game.set_transient_for(parent)
        #---- Initialation for the dialogs
        self.error_es_a = builder.get_object("error_no_es_a")
        self.error_es_a.connect('response', lambda d, r: d.hide())
        self.error_es_a.set_transient_for(self.quick_game)
        
        self.error_team_a = builder.get_object("error_no_team_a")
        self.error_team_a.connect('response', lambda d, r: d.hide())
        self.error_team_a.set_transient_for(self.quick_game)
        
        self.error_es_b = builder.get_object("error_no_es_b")
        self.error_es_b.connect('response', lambda d, r: d.hide())
        self.error_es_b.set_transient_for(self.quick_game)
        
        self.error_team_b = builder.get_object("error_no_team_b")
        self.error_team_b.connect('response', lambda d, r: d.hide())
        self.error_team_b.set_transient_for(self.quick_game)

        #self.result_dialog = builder.get_object("dlg_result")
        #self.result_dialog.connect('response', lambda d, r: d.hide())
        #self.result_dialog.set_transient_for(self.quick_game)

        self.dlg_bad_file = builder.get_object('dlg_bad_file')
        self.dlg_bad_file.connect('response', lambda d, r: d.hide())
        self.dlg_bad_file.set_transient_for(self.quick_game)
        

        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50,300)
        self.spin_turns.set_increments(2,10)
        self.spin_turns.set_value(self.num_turns)
        #---------------
        self.fast_game = False
        self.dont_save_game = False
        self.hidde_values = False
        
        builder.connect_signals(self)
def _generate_file_name(team_a, team_b):
    """This function generate a proper filename for the game log

    Return a string like 'game_YYYY-MM-DD_hh:mm:ss_team_a-vs-team_b.txt'
    """
    des = filenames.generate_filename_keys('game', (team_a, team_b))

    base_path = configure.load_configuration()['games_path']

    return '%s/%s' % (base_path, des)
Exemplo n.º 14
0
    def __generateFileName(self):
        """This function generates a proper filename for the game log

        Returns a string like 'game_YYYY-MM-DD_hh:mm:ss_teamA-vs-teamB.txt'
        """
        des = filenames.generate_filename('game', (self.teamA, self.teamB))

        base_path = configure.load_configuration()['games_path']

        return os.path.join(base_path, des)
    def __init__(self, parent):
        self.rules_computer = ''
        self.formation_computer = ''
        self.formation_player = ''

        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/humanEsDialog.glade'))

        def_path = configure.load_configuration()['se_path']
        def_rules_path = def_path + '/rules'
        def_formations_path = def_path + '/formations'

        self.human_ia_dialog = builder.get_object('human_ia_dialog')
        self.human_ia_dialog.set_transient_for(parent)

        builder.get_object('file_chooser_es_ia').set_current_folder(
            def_rules_path)
        builder.get_object('file_chooser_team_ia').set_current_folder(
            def_formations_path)
        builder.get_object('file_chooser_team').set_current_folder(
            def_formations_path)

        self.file_chooser_team_ia = builder.get_object('file_chooser_team_ia')

        self.file_chooser_es_ia = builder.get_object('file_chooser_es_ia')
        self.file_chooser_team_ia = builder.get_object('file_chooser_team_ia')

        self.error_es_ia = builder.get_object("error_no_es_ia")
        self.error_es_ia.connect('response', lambda d, r: d.hide())
        self.error_es_ia.set_transient_for(self.human_ia_dialog)

        self.error_team_ia = builder.get_object("error_no_team_ia")
        self.error_team_ia.connect('response', lambda d, r: d.hide())
        self.error_team_ia.set_transient_for(self.human_ia_dialog)

        self.error_team = builder.get_object("error_no_team")
        self.error_team.connect('response', lambda d, r: d.hide())
        self.error_team.set_transient_for(self.human_ia_dialog)

        self.dlg_bad_file = builder.get_object('dlg_bad_file')
        self.dlg_bad_file.connect('response', lambda d, r: d.hide())
        self.dlg_bad_file.set_transient_for(self.human_ia_dialog)

        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50, 300)
        self.spin_turns.set_increments(1, 10)
        self.spin_turns.set_value(self.num_turns)

        self.dont_save_game = False
        self.human_team = 'A'
        self.random_computer = False
        self.label_description = builder.get_object('label_description')

        builder.connect_signals(self)
Exemplo n.º 16
0
    def __generateFileName(self):
        """This function generates a proper filename for the game log

        Returns a string like 'game_YYYY-MM-DD_hh:mm:ss_teamA-vs-teamB.txt'
        """
        des = filenames.generate_filename('game',
                                          (self.teamA, self.teamB))

        base_path = configure.load_configuration()['games_path']

        return os.path.join(base_path, des)
def _generate_file_name(team_a, team_b):
    """This function generate a proper filename for the game log

    Return a string like 'game_YYYY-MM-DD_hh:mm:ss_team_a-vs-team_b.txt'
    """
    des = filenames.generate_filename_keys('game',
                                           (team_a, team_b))

    base_path = configure.load_configuration()['games_path']

    return '%s/%s' % (base_path, des)
    def __init__(self, parent):
        self.rules_computer = ''
        self.formation_computer = ''
        self.formation_player = ''

        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/humanEsDialog.glade'))

        def_path = configure.load_configuration()['se_path']
        def_rules_path = def_path + '/rules'
        def_formations_path = def_path + '/formations'

        self.human_ia_dialog = builder.get_object('human_ia_dialog')
        self.human_ia_dialog.set_transient_for(parent)
        
        builder.get_object('file_chooser_es_ia').set_current_folder(def_rules_path)
        builder.get_object('file_chooser_team_ia').set_current_folder(def_formations_path)
        builder.get_object('file_chooser_team').set_current_folder(def_formations_path)
        
        self.file_chooser_team_ia = builder.get_object('file_chooser_team_ia')

        self.file_chooser_es_ia = builder.get_object('file_chooser_es_ia')
        self.file_chooser_team_ia = builder.get_object('file_chooser_team_ia')
        
        self.error_es_ia = builder.get_object("error_no_es_ia")
        self.error_es_ia.connect('response', lambda d, r: d.hide())
        self.error_es_ia.set_transient_for(self.human_ia_dialog)
        
        self.error_team_ia = builder.get_object("error_no_team_ia")
        self.error_team_ia.connect('response', lambda d, r: d.hide())
        self.error_team_ia.set_transient_for(self.human_ia_dialog)
        
        self.error_team = builder.get_object("error_no_team")
        self.error_team.connect('response', lambda d, r: d.hide())
        self.error_team.set_transient_for(self.human_ia_dialog)
        
        self.dlg_bad_file = builder.get_object('dlg_bad_file')
        self.dlg_bad_file.connect('response', lambda d, r: d.hide())
        self.dlg_bad_file.set_transient_for(self.human_ia_dialog)
        
        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50,300)
        self.spin_turns.set_increments(1,10)
        self.spin_turns.set_value(self.num_turns)

        self.dont_save_game = False
        self.human_team = 'A'
        self.random_computer = False
        self.label_description = builder.get_object('label_description')

        builder.connect_signals(self)
Exemplo n.º 19
0
    def __init__(self,
                 team_a,
                 team_b,
                 default_piece,
                 xml_file,
                 piece_size=60,
                 board_size=8,
                 player=0):
        self.turn = 0

        self.team_a_piece = team_a[1]
        self.team_b_piece = team_b[1]
        self.default_piece = default_piece
        self.piece_size = piece_size
        self.board_size = board_size

        self.srfc_board_size = (self.board_size * self.piece_size, ) * 2
        self.player = player

        self.music = False
        if configure.load_configuration()['music_active'] == '1':
            self.music = True

        pygame.init()
        self.xml_layout = layout.Layout(xml_file, True)
        self.screen = pygame.display.set_mode(
            self.xml_layout.get_window_size())
        pygame.display.set_caption(self.xml_layout.get_window_title())
        self.srfc_board = pygame.Surface(self.srfc_board_size)

        self.xml_layout.init((team_a[1], team_a[0]), (team_b[1], team_b[0]),
                             self.srfc_board)
        self.rects = self.xml_layout.get_buttons_rects()
        self.offset = self.xml_layout.get_board_position()
        pygame.display.set_icon(self.xml_layout.get_favicon())

        self.screen.blit(self.xml_layout.get_surface(), (0, 0))
        pygame.display.flip()

        if self.music:
            music_path = xdg.get_data_path('music/walking_on_old_stones.ogg')
            pygame.mixer.music.load(music_path)
            pygame.mixer.music.play()

        img_piece_slct_path = xdg.get_data_path('images/piece-selection.png')
        img_possible_move_path = xdg.get_data_path('images/posible-move.png')

        self.piece_selected = pygame.image.load(img_piece_slct_path)
        self.possible_move = pygame.image.load(img_possible_move_path)
Exemplo n.º 20
0
def _init_playoff(teams, fast, num_turns, back_round):
    logging.info("##### INIT PLAYOFF")

    log_base_folder = configure.load_configuration()['games_path'] + '/'
    log_base_folder += "Mixto-" + filenames.generate_isodate() + "/"

    os.mkdir(log_base_folder)

    band, classifications = _init_game('league', teams, fast, num_turns, back_round, log_base_folder = log_base_folder)

    if not band and not controlPartida.flagCancelarCampeonato:
        band = False
        teams = _get_teams_next_round(teams, _extract_classifications(classifications))
        _init_game('cup', teams, fast, num_turns, log_base_folder = log_base_folder)

    logging.info("##### END PLAYOFF")
Exemplo n.º 21
0
    def __init__(self, team_a, team_b, default_piece, xml_file,
                 piece_size=60, board_size=8, player=0):
        self.turn = 0

        self.team_a_piece = team_a[1]
        self.team_b_piece = team_b[1]
        self.default_piece = default_piece
        self.piece_size = piece_size
        self.board_size = board_size

        self.srfc_board_size = (self.board_size * self.piece_size, ) * 2
        self.player = player

        self.music = False
        if configure.load_configuration()['music_active'] == '1':
            self.music = True

        pygame.init()
        self.xml_layout = layout.Layout(xml_file, True)
        self.screen = pygame.display.set_mode(
            self.xml_layout.get_window_size())
        pygame.display.set_caption(self.xml_layout.get_window_title())
        self.srfc_board = pygame.Surface(self.srfc_board_size)

        self.xml_layout.init((team_a[1], team_a[0]), (team_b[1], team_b[0]),
                             self.srfc_board)
        self.rects = self.xml_layout.get_buttons_rects()
        self.offset = self.xml_layout.get_board_position()
        pygame.display.set_icon(self.xml_layout.get_favicon())

        self.screen.blit(self.xml_layout.get_surface(), (0, 0))
        pygame.display.flip()

        if self.music:
            music_path = xdg.get_data_path('music/walking_on_old_stones.ogg')
            pygame.mixer.music.load(music_path)
            pygame.mixer.music.play()

        img_piece_slct_path = xdg.get_data_path('images/piece-selection.png')
        img_possible_move_path = xdg.get_data_path('images/posible-move.png')
        print img_piece_slct_path
        self.piece_selected = pygame.image.load(img_piece_slct_path)
        self.possible_move = pygame.image.load(img_possible_move_path)
Exemplo n.º 22
0
    def __init__(self):
        "Constructor of the object"
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/main.glade')) 
        
        self.window = builder.get_object("mainWindow")
        self.about = builder.get_object("aboutdialog1")
        self.previous_games_chooser = builder.get_object("filechooserdialog1")
        self.games_chooser_warning = builder.get_object("messagedialog1")

        
        self.games_chooser_warning.connect('response', lambda d, r: d.hide())
        self.games_chooser_warning.set_transient_for(self.previous_games_chooser)

        self.previous_games_chooser.set_transient_for(self.window)
        self.about.set_transient_for(self.window)
        
        def_path = configure.load_configuration()['games_path']
        self.previous_games_chooser.set_current_folder(def_path)
        builder.connect_signals(self)
Exemplo n.º 23
0
def get_installed_teams():
    """
    Return a list of the installed teams. We consider a installed team some
    of the way 'data/teams/formations/equipoXX.form',
    'data/teams/rules/reglasYYYY.clp' where XX == YYYY
    """
    base_path = configure.load_configuration()['se_path']
    rules_path = os.path.join(base_path, 'rules')

    ficheros_reglas = browse_dir_rules(rules_path)
    conjuntoTotal = []
    for this_regla in ficheros_reglas:
        this_formacion = filenames.devolverFormacionAsociada(this_regla, True)
        if this_formacion != "":
            conjuntoTotal.append((this_regla, this_formacion))
        else:
            logging.error("ATENCIÓN: no se encontró el fichero de formación para el fichero de reglas <%s>", this_regla)

    logging.info("* %i equipos instalados en el sistema", len(conjuntoTotal))
    return conjuntoTotal
Exemplo n.º 24
0
 def on_btn_apply_clicked(self, widget, data=None):
     config_vars = configure.load_configuration()
     #current_games_path = self.file_chooser_games.get_current_folder()
     #current_teams_path = self.file_chooser_teams.get_current_folder()
     
     current_games_path = self.file_chooser_games.get_filename()
     current_teams_path = self.file_chooser_teams.get_filename()
     current_active_music = ''
     if self.check_active_music.get_active():
         current_active_music = "1"
     else:
         current_active_music = "0"
     
     if current_games_path != config_vars['games_path']:
         configure.set_games_path(current_games_path)
     if current_teams_path != config_vars['se_path']:
         configure.set_se_path(current_teams_path)
     if current_active_music != config_vars['music_active']:
         configure.set_active_music(current_active_music)
         
     self.settings.hide()
Exemplo n.º 25
0
def get_installed_teams():
    """
    Return a list of the installed teams. We consider a installed team some
    of the way 'data/teams/formations/equipoXX.form',
    'data/teams/rules/reglasYYYY.clp' where XX == YYYY
    """
    base_path = configure.load_configuration()['se_path']
    rules_path = os.path.join(base_path, 'rules')

    ficheros_reglas = browse_dir_rules(rules_path)
    conjuntoTotal = []
    for this_regla in ficheros_reglas:
        this_formacion = filenames.devolverFormacionAsociada(this_regla, True)
        if this_formacion != "":
            conjuntoTotal.append((this_regla, this_formacion))
        else:
            logging.error(
                "ATENCIÓN: no se encontró el fichero de formación para el fichero de reglas <%s>",
                this_regla)

    logging.info("* %i equipos instalados en el sistema", len(conjuntoTotal))
    return conjuntoTotal
Exemplo n.º 26
0
    def __init__(self, parent):
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/tree.glade'))

        self.players_selector = builder.get_object("players_selector")
        self.players_selector.set_transient_for(parent)

        #---------------------------
        self.cName = 0
        self.cRules = 1
        self.cFormation = 2

        self.sName = "Name"
        self.sRules = "Rules"
        self.sFormation = "Formation"

        self.list_view = builder.get_object("list_es_view")
        self.list_view.set_reorderable(False)

        self.addColumn(self.sName, self.cName)
        self.addColumn(self.sRules, self.cRules)
        self.addColumn(self.sFormation, self.cFormation)

        self.list_store = builder.get_object("list_expert_system")
        #-----------------------------

        self.file_chooser_rules = builder.get_object('file_chooser_rules')
        #self.file_chooser_rules.set_transient_for(self.players_selector)
        self.file_chooser_formation = builder.get_object(
            'file_chooser_formation')
        #self.file_chooser_formation.set_transient_for(self.players_selector)

        def_path = configure.load_configuration()['se_path']
        self.file_chooser_rules.set_current_folder(def_path + '/rules')
        self.file_chooser_formation.set_current_folder(def_path +
                                                       '/formations')

        builder.connect_signals(self)
    def __init__ (self, parent):
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/tree.glade'))

        self.players_selector = builder.get_object('players_selector')
        self.players_selector.set_transient_for(parent)

        self.files = {}
        self.teams = {}

        # ---- Building the table
        self.cName = 0
        self.cRules = 1
        self.cFormation = 2

        self.sName = 'Name'
        self.sRules = 'Rules'
        self.sFormation = 'Formation'
        
        self.list_view = builder.get_object("list_es_view")
        self.list_view.set_reorderable(False)

        self.add_column(self.sName, self.cName)
        self.add_column(self.sRules, self.cRules)
        self.add_column(self.sFormation, self.cFormation)

        self.list_store = builder.get_object('list_expert_system')
        # -----
        
        self.file_chooser_rules = builder.get_object('file_chooser_rules')
        self.file_chooser_formation = builder.get_object('file_chooser_formation')
        
        def_path = configure.load_configuration()['se_path']
        self.file_chooser_rules.set_current_folder(def_path + '/rules')
        self.file_chooser_formation.set_current_folder(def_path + '/formations')
        
        builder.connect_signals(self)
Exemplo n.º 28
0
    def __init__(self, parent):
        self.rules_main_team = ''
        self.formation_main_team = ''
        self.files = {}
        self.teams = {}

        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/testDialog.glade'))

        self.tests_dialog = builder.get_object('tests_dialog')
        self.tests_dialog.set_transient_for(parent)

        # ---- Init file chooser buttons
        default_path = configure.load_configuration()['se_path']
        default_rules_path = default_path + '/rules'
        default_formations_path = default_path + '/formations'
        builder.get_object('btn_filechooser_rules').set_current_folder(default_rules_path)
        builder.get_object('btn_filechooser_formation').set_current_folder(default_formations_path)
        # ----

        self.num_rounds = 2
        self.spin_rounds = builder.get_object('spin_rounds')
        self.spin_rounds.set_range(2, 100)
        self.spin_rounds.set_increments(2,10)
        self.spin_rounds.set_value(self.num_rounds)
        
        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50,300)
        self.spin_turns.set_increments(2,10)
        self.spin_turns.set_value(self.num_turns)

        self.all_teams = False
        self.frame_selection_teams = builder.get_object('frame_es_selection')

        self.start_button = builder.get_object('btn_apply')
        self.start_button.set_sensitive(False)
        
        #---------------------------
        self.cName = 0
        self.cRules = 1
        self.cFormation = 2
        
        self.sName = _("Name")
        self.sRules = _("Rules")
        self.sFormation = _("Formation")
        
        self.list_view = builder.get_object("list_es_view")
        self.list_view.set_reorderable(False)

        self.addColumn(self.sName, self.cName)
        self.addColumn(self.sRules, self.cRules)
        self.addColumn(self.sFormation, self.cFormation)

        self.list_store = builder.get_object("list_expert_system")
        #-----------------------------
        self.file_chooser_rules = builder.get_object('file_chooser_rules')
        self.file_chooser_formation = builder.get_object('file_chooser_formation')
        self.file_chooser_rules.set_current_folder(default_rules_path)
        self.file_chooser_formation.set_current_folder(default_formations_path)

        
        self.error_es = builder.get_object("error_no_es")
        self.error_es.connect('response', lambda d, r: d.hide())
        self.error_es.set_transient_for(self.tests_dialog)
        
        self.error_team = builder.get_object("error_no_team")
        self.error_team.connect('response', lambda d, r: d.hide())
        self.error_team.set_transient_for(self.tests_dialog)

        self.progress_bar = pbs.ProgressBarDialog(self.tests_dialog,
                                                  _('Running the test'))
        self.progress_bar_dialog = self.progress_bar.progress_bar_dialog
        
        builder.connect_signals(self)
Exemplo n.º 29
0
    def run(self):
        logging.info("## INICIANDO Pintado de partida")
        # Inicializando pygame..."
        pygame.init()

        if self.musica:
            _music_path = xdg_data_path('music/walking_on_old_stones.ogg')
            pygame.mixer.music.load(_music_path)
            pygame.mixer.music.play()

        tamanoVentana = (760,560)
        
        # Estableciendo el modo de pantalla..."
        self.pantalla = pygame.display.set_mode(tamanoVentana)

        # Estableciendo el título de la ventana..."
        pygame.display.set_caption("Reproduciendo partida")

        # Cargando imagen de fondo..."
        self.imagenFondoTemp = pygame.image.load(xdg_data_path("images/fondo.png"))

        # Convirtiendo la imagen de fondo al formato adecuado..."
        self.imagenFondo = self.imagenFondoTemp.convert()

        # Parseando el estado inicial..."
        organizacionInicial = self.parseador.esteTurno()

        # Cargamos la imagen de los marcos con los nombres..."
        imagenMarco = pygame.image.load(xdg_data_path("images/marco.png"))
        imagenMarco = imagenMarco.convert()

        # Posición inicial de los marcos con los nombres de los equipos
        self.posMarcoSuperior = 10 
        self.posMarcoInferior = 190

        # Bliteamos el marco en el fondo
        self.imagenFondo.blit(imagenMarco, (510, self.posMarcoSuperior))
        self.imagenFondo.blit(imagenMarco, (510, self.posMarcoInferior))

        self.obstaculos = parsear_obstaculos()
        self.imagenObstaculo = pygame.image.load(xdg_data_path("images/stone.png"))
        self.imagenObstaculo = self.imagenObstaculo.convert()

        # Cargamos la fuente para el rótulo con el valor de la ficha
        fuenteEquipos = pygame.font.Font(xdg_data_path("fonts/zektonbi.ttf"), 18)
        
        # Renderizamos los textos en superficies
        textoEquipoA = fuenteEquipos.render(self.name_team_a[:16], 1, (255,255,255))
        sombraTextoEquipoA = fuenteEquipos.render(self.name_team_a[:16], 1, (0,0,0))
        self.imagenEquipoA = pygame.transform.scale(pygame.image.load(self.team_a[1]), (30,30))

        textoEquipoB = fuenteEquipos.render(self.name_team_b[:16], 1, (255,255,255))
        sombraTextoEquipoB = fuenteEquipos.render(self.name_team_b[:16], 1, (0,0,0))
        self.imagenEquipoB = pygame.transform.scale(pygame.image.load(self.team_b[1]), (30,30))

        # Bliteamos las superficies de los marcadores
        self.imagenFondo.blit(self.imagenEquipoA, (515, self.posMarcoSuperior + 9))
        self.imagenFondo.blit(sombraTextoEquipoA, (552, self.posMarcoSuperior + 11))
        self.imagenFondo.blit(textoEquipoA, (550, self.posMarcoSuperior + 9))

        self.imagenFondo.blit(self.imagenEquipoB, (515, self.posMarcoInferior + 9))
        self.imagenFondo.blit(sombraTextoEquipoB, (552, self.posMarcoInferior + 11))
        self.imagenFondo.blit(textoEquipoB, (550, self.posMarcoInferior + 9))

        posBloqueTurnoActual = 367
        self.imagenFondo.blit(imagenMarco, (510, posBloqueTurnoActual))

        posBloqueTurnosRestantes = 420
        self.imagenFondo.blit(imagenMarco, (510, posBloqueTurnosRestantes))

        # Cargamos la fuente para el texto de las fichas muertas
        self.fuenteFichasMuertas = pygame.font.Font(xdg_data_path("fonts/LiberationMono-Bold.ttf"), 19)

        # Pintamos las fichas blancas del fondo
        fichaBlanca = pygame.image.load(xdg_data_path("images/piece-default.png"))
        fichaBlanca = fichaBlanca.convert()

        for i in range(8):
            for j in range (8):
                self.imagenFondo.blit(fichaBlanca, (10 + 60 * i, 10 + 60 * j))

        # Cargando las fichas iniciales..."
        for keyFicha in organizacionInicial.keys():
            ficha = organizacionInicial[keyFicha];
            self.fichas[keyFicha] = Ficha(ficha[0], ficha[1], ficha[2], 
                                       ficha[3], ficha[4], ficha[5], self.hidden)

        # Pintamos los botones
        botonesInterfaz = []
        botonesInterfaz.append(Boton(700, 500, "images/salir", self.callSalir))
        botonesInterfaz.append(Boton(120, 500, "images/flecha_izquierda2", self.callRetrocederInicio))
        botonesInterfaz.append(Boton(190, 500, "images/flecha_izquierda1", self.callRetrocederTurno))
        botonesInterfaz.append(Boton(260, 500, "images/flecha_derecha1", self.callAvanzarTurno))
        botonesInterfaz.append(Boton(330, 500, "images/flecha_derecha2", self.callAvanzarFinal))
        botonesInterfaz.append(Boton(630, 500, "images/btnAbortar", self.callAbortar, False))
        botonesInterfaz.append(Interruptor(560, 500, "images/btnAvanceAutomatico", self.callToggleAvanceAutomatico))

        self.salir = False
        self.avanceAutomatico = False

        # Leemos del fichero de configuración la velocidad del avance automático
        config_vars = configure.load_configuration()
        self.intervaloAvanceAutomatico = config_vars['auto_interval_time']

        # Comienza el game loop
        while not self.salir and not controlPartida.flagCancelarCampeonato:

            # Comprobación del avance automático
            if self.avanceAutomatico:
                # Si el tiempo que ha pasado desde el último avance supera el intervalo
                if pygame.time.get_ticks() - self.ultimoAvance > self.intervaloAvanceAutomatico:

                    # Avanzamos el turno
                    self.callAvanzarTurno()

                    # Actualizamos la variable con el tiempo del último avance
                    self.ultimoAvance = pygame.time.get_ticks()

            # Gestión de eventos
            for eventos in pygame.event.get():
                
                # Si se ha pulsado ALT+F4 o el botón de cerrar ventana
                if eventos.type == QUIT:
                    # Activamos el flag de salir
                    self.salir = True

                # Cuando se pulsa el botón el ratón
                elif eventos.type == MOUSEBUTTONDOWN:

                    # Informamos a cada botón de la interfaz
                    for btn in botonesInterfaz:
                        btn.informarClick(eventos.pos)

                # Cuando se mueve el ratón
                elif eventos.type == MOUSEMOTION:

                    # Informamos a cada botón de la interfaz
                    for btn in botonesInterfaz:
                        btn.informarHover(eventos.pos)

                # Podemos avanzar turno con la flecha derecha del teclado
                elif eventos.type == KEYDOWN and eventos.key == 275:
                    self.callAvanzarTurno()

                # También podemos retroceder turno con las flechas del teclado
                elif eventos.type == KEYDOWN and eventos.key == 276:
                    self.callRetrocederTurno()


            # Pintamos el fondo
            self.pantalla.blit(self.imagenFondo, (0, 0))

            # Pintamos las fichas
            for keyFicha in self.fichas:
                self.fichas[keyFicha].pintar(self.pantalla)

            for obs in self.obstaculos:
                self.pantalla.blit(self.imagenObstaculo, (float(10 + (obs[0] - 1) * 60),
                                                          float(10 + (obs[1] - 1) * 60)))

            # Pintamos los botones
            for btn in botonesInterfaz:
                btn.pintar(self.pantalla)

            # Pintamos las fichas muertas
            self.pintarFichasMuertas()

            self.pantalla.blit(fuenteEquipos.render("Turno actual: %d" % self.parseador.getNumTurnoActual(), 1, (0,0,0)), (517, posBloqueTurnoActual + 11))
            self.pantalla.blit(fuenteEquipos.render("Turno actual: %d" % self.parseador.getNumTurnoActual(), 1, (255,255,255)), (515, posBloqueTurnoActual + 9))

            self.pantalla.blit(fuenteEquipos.render("Turnos restantes: %d" % (self.parseador.getNumTurnoMax() - self.parseador.getNumTurnoActual()), 1, (0,0,0)), (517, posBloqueTurnosRestantes + 11))
            self.pantalla.blit(fuenteEquipos.render("Turnos restantes: %d" % (self.parseador.getNumTurnoMax() - self.parseador.getNumTurnoActual()), 1, (255,255,255)), (515, posBloqueTurnosRestantes + 9))

            # Volcamos la pantalla a la gráfica
            pygame.display.flip()

            ##############################
            # GESTIÓN DE LOS FPS

            # Cogemos los ticks actuales
            ticksActual = pygame.time.get_ticks()

            espera = self.intervalo - (ticksActual - self.ticksAnterior)

            if espera > 0:
                # Esperamos el tiempo necesario para mantener los FPS
                pygame.time.delay(int(espera))

            # Actualizamos los ticks anteriores
            self.ticksAnterior = ticksActual

        # Fin del game loop"

        # Cortamos la música
        pygame.mixer.music.stop()

        # Cerramos el subsistema gráfica (no es necesario)
        pygame.display.quit()
        logging.info("## FINALIZADO Pintado de partida")
        return 0
Exemplo n.º 30
0
    def __init__(self, parent):
        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/contest.glade'))

        self.contest_dialog = builder.get_object("contest_dialog")
        self.contest_dialog.set_transient_for(parent)

        self.files = {}
        self.teams = {}

        #---------------------------
        self.cName = 0
        self.cRules = 1
        self.cFormation = 2

        self.sName = _("Name")
        self.sRules = _("Rules")
        self.sFormation = _("Formation")

        self.list_view = builder.get_object("list_es_view")
        self.list_view.set_reorderable(False)

        self.addColumn(self.sName, self.cName)
        self.addColumn(self.sRules, self.cRules)
        self.addColumn(self.sFormation, self.cFormation)
        self.addColumn(_("Description"), 3)

        self.list_store = builder.get_object("list_expert_system")
        #-----------------------------

        self.file_chooser_rules = builder.get_object('file_chooser_rules')
        #self.file_chooser_rules.set_transient_for(self.players_selector)
        self.file_chooser_formation = builder.get_object(
            'file_chooser_formation')
        #self.file_chooser_formation.set_transient_for(self.players_selector)

        self.format_contest = 'league'
        self.radio_league = builder.get_object('radio_league')
        self.radio_cup = builder.get_object('radio_cup')
        self.radio_groups = builder.get_object('radio_groups')
        self.radio_playoff = builder.get_object('radio_playoff')
        self.check_backround = builder.get_object('check_backround')
        self.check_fast = builder.get_object('check_onlyresults')

        self.back_round = False
        self.fast = False
        self.all_teams = False

        self.def_path = configure.load_configuration()['se_path']
        self.file_chooser_rules.set_current_folder(self.def_path + '/rules')
        self.file_chooser_formation.set_current_folder(self.def_path +
                                                       '/formations')

        self.start_button = builder.get_object('btn_start')
        self.frame_selection_teams = builder.get_object('box_selection')

        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50, 300)
        self.spin_turns.set_increments(2, 10)
        self.spin_turns.set_value(self.num_turns)

        self.check_default_formations = builder.get_object(
            'check_default_formations')

        builder.connect_signals(self)
Exemplo n.º 31
0
def _init_game(game_type, teams, fast, num_turns, back_round = False, log_base_folder = None):

    logging.info(">>>> INIT GAME")

    if log_base_folder == None:
        log_base_folder = configure.load_configuration()['games_path'] + '/'


    # Generamos el nombre del fichero de log según el tipo de juego
    log_base_name = filenames.generate_filename(game_type, noExtension = True)
    log_folder_name = log_base_folder + log_base_name
    log_file_name = log_folder_name + "/" + game_type + ".txt"

    logging.info("Fichero de log: %s", log_file_name)
    logging.info("Carpeta de log: %s", log_folder_name)

    os.mkdir(log_folder_name)
    
    # Lanzamos el tipo de juego apropiado
    if game_type == 'cup':
        game = tournament.Tournament(teams, num_turns, log_folder = log_folder_name)
    else:
        game = league.League(teams, num_turns, back_round, log_folder = log_folder_name)

    band = False

    # Contenedor para clasificaciones
    classifications = {}

    results = None

    # Cada elemento tendrá una tupla de 3: ganadas, empatadas y perdidas
    estadisticas = {"aux_ghost_team": {"ganadas":0, "empatadas":0, "perdidas":0}}

    for equipo in contest.generate_key_names(teams).keys():
        estadisticas[equipo] = {"ganadas":0, "empatadas":0, "perdidas":0};

    # Mientras no se haya completado el juego
    while not game.completed() and not band and not controlPartida.flagCancelarCampeonato:

        logging.info("---- START OF THE ROUND")

        if results != None:

            # Cargamos el diálogo de resultados
            R = round_results.roundResults(classifications, results,
                                           game.get_prev_round_number() + 1,
                                           game.get_number_of_rounds(),
                                           show_classifications = (game_type != 'cup'),
                                           stats = estadisticas,
                                           show_top_teams = True,
                                           next_matches = game.matchs[game.get_round_number()])

        # Mostramos el diálogo de resultados
            button_pressed = R.result_dialog.run()
        
            while gtk.events_pending():
                gtk.main_iteration(False)
            
            if button_pressed == -4 or button_pressed == 0:
                band = True
                continue


        # Guardamos el número de la ronda
        roundNumber = game.get_round_number()

        if roundNumber == 0:
            show_round_matches(game)

        # Por defecto que la barra de progreso no exista
        progress_bar = None

        # Si no mostramos el progreso del juego, que salga la barra
        if fast:
            progress_bar = pbs.ProgressBarDialog(None, _('Running the contest'))
            progress_bar_dialog = progress_bar.progress_bar_dialog
            progress_bar.set_num_elements(game.get_round(roundNumber).number_games)
            progress_bar_dialog.show()

            while gtk.events_pending():
                gtk.main_iteration(False)
    
        # Jugamos esta ronda
        game.play_round(progress_bar, fast)

        if controlPartida.flagCancelarCampeonato:
            return
        
        # Guardamos en r la ronda actual, con sus resultados y tal
        r = game.get_round(roundNumber)
        
        # Resultados de la ronda
        results = r.get_round_results()

        # Actualizamos el fichero del log
        update_log_round(log_file_name, results, roundNumber)

        for partido in results:
            if partido[1] == 1:
                estadisticas[partido[0][0]]["ganadas"] += 1
                estadisticas[partido[0][1]]["perdidas"] += 1
            elif partido[1] == -1:
                estadisticas[partido[0][1]]["ganadas"] += 1
                estadisticas[partido[0][0]]["perdidas"] += 1                    
            else:
                estadisticas[partido[0][0]]["empatadas"] += 1
                estadisticas[partido[0][1]]["empatadas"] += 1

        if game_type == 'cup':
            pass
        else:
            # "Puntuations" es una palabra que no existe
            classifications = game.get_actual_puntuations()

        # Ocultamos la barra de progreso (que ya habrá acabado)
        if fast:
            progress_bar_dialog.hide()

        logging.info("---- END OF THE ROUND")

    if not band:
        # Mostramos los resultados FINALES
        R = round_results.roundResults(classifications, results,
                                       game.get_prev_round_number() + 1,
                                       game.get_number_of_rounds(),
                                       show_classifications = (game_type != 'cup'),
                                       show_top_teams = True,
                                       stats = estadisticas)

        # Mostramos el diálogo de resultados
        button_pressed = R.result_dialog.run()
        
        while gtk.events_pending():
            gtk.main_iteration(False)
            
    if not band and not controlPartida.flagCancelarCampeonato:
        if game_type == 'cup':
            update_log_ending_tournament(log_file_name, estadisticas)
            dibujoClasificacion = dibujo_clasificacion.DibujoClasificacion(game)
        else:        
            update_log_ending_league(log_file_name, classifications)
        
    logging.info(">>>> END INIT GAME")
    return (band, classifications)
    def __init__(self, parent):
        self.es_team_a = ''
        self.team_team_a = ''
        self.es_team_b = ''
        self.team_team_b = ''

        builder = gtk.Builder()
        builder.add_from_file(xdg.get_data_path('glade/quickGame.glade'))

        def_path = configure.load_configuration()['se_path']
        def_rules_path = def_path + '/rules'
        def_formations_path = def_path + '/formations'
        builder.get_object('file_chooser_es_a').set_current_folder(
            def_rules_path)
        builder.get_object('file_chooser_team_a').set_current_folder(
            def_formations_path)
        builder.get_object('file_chooser_es_b').set_current_folder(
            def_rules_path)
        builder.get_object('file_chooser_team_b').set_current_folder(
            def_formations_path)

        self.file_chooser_team_a = builder.get_object('file_chooser_team_a')
        self.file_chooser_team_b = builder.get_object('file_chooser_team_b')

        self.quick_game = builder.get_object("quick_game_dialog")
        self.quick_game.set_transient_for(parent)

        #---- Initialation for the dialogs
        self.error_es_a = builder.get_object("error_no_es_a")
        self.error_es_a.connect('response', lambda d, r: d.hide())
        self.error_es_a.set_transient_for(self.quick_game)

        self.error_team_a = builder.get_object("error_no_team_a")
        self.error_team_a.connect('response', lambda d, r: d.hide())
        self.error_team_a.set_transient_for(self.quick_game)

        self.error_es_b = builder.get_object("error_no_es_b")
        self.error_es_b.connect('response', lambda d, r: d.hide())
        self.error_es_b.set_transient_for(self.quick_game)

        self.error_team_b = builder.get_object("error_no_team_b")
        self.error_team_b.connect('response', lambda d, r: d.hide())
        self.error_team_b.set_transient_for(self.quick_game)

        #self.result_dialog = builder.get_object("dlg_result")
        #self.result_dialog.connect('response', lambda d, r: d.hide())
        #self.result_dialog.set_transient_for(self.quick_game)

        self.dlg_bad_file = builder.get_object('dlg_bad_file')
        self.dlg_bad_file.connect('response', lambda d, r: d.hide())
        self.dlg_bad_file.set_transient_for(self.quick_game)

        self.num_turns = 120
        self.spin_turns = builder.get_object("spin_num_turns")
        self.spin_turns.set_range(50, 300)
        self.spin_turns.set_increments(2, 10)
        self.spin_turns.set_value(self.num_turns)
        #---------------
        self.fast_game = False
        self.dont_save_game = False
        self.hidde_values = False

        self.label_desc_A = builder.get_object("label_desc_A")
        self.label_desc_B = builder.get_object("label_desc_B")

        builder.connect_signals(self)
Exemplo n.º 33
0
    def run(self):
        logging.info("## INICIANDO Pintado de partida")
        # Inicializando pygame..."
        pygame.init()

        if self.musica:
            _music_path = xdg_data_path("music/walking_on_old_stones.ogg")
            pygame.mixer.music.load(_music_path)
            pygame.mixer.music.play()

        tamanoVentana = (760, 560)

        # Estableciendo el modo de pantalla..."
        self.pantalla = pygame.display.set_mode(tamanoVentana)

        # Estableciendo el título de la ventana..."
        pygame.display.set_caption("Reproduciendo partida")

        # Cargando imagen de fondo..."
        self.imagenFondoTemp = pygame.image.load(xdg_data_path("images/fondo.png"))

        # Convirtiendo la imagen de fondo al formato adecuado..."
        self.imagenFondo = self.imagenFondoTemp.convert()

        # Parseando el estado inicial..."
        organizacionInicial = self.parseador.esteTurno()

        # Cargamos la imagen de los marcos con los nombres..."
        imagenMarco = pygame.image.load(xdg_data_path("images/marco.png"))
        imagenMarco = imagenMarco.convert()

        # Posición inicial de los marcos con los nombres de los equipos
        self.posMarcoSuperior = 10
        self.posMarcoInferior = 190

        # Bliteamos el marco en el fondo
        self.imagenFondo.blit(imagenMarco, (510, self.posMarcoSuperior))
        self.imagenFondo.blit(imagenMarco, (510, self.posMarcoInferior))

        self.obstaculos = parsear_obstaculos()
        self.imagenObstaculo = pygame.image.load(xdg_data_path("images/stone.png"))
        self.imagenObstaculo = self.imagenObstaculo.convert()

        # Cargamos la fuente para el rótulo con el valor de la ficha
        fuenteEquipos = pygame.font.Font(xdg_data_path("fonts/zektonbi.ttf"), 18)

        # Renderizamos los textos en superficies
        textoEquipoA = fuenteEquipos.render(self.name_team_a[:16], 1, (255, 255, 255))
        sombraTextoEquipoA = fuenteEquipos.render(self.name_team_a[:16], 1, (0, 0, 0))
        self.imagenEquipoA = pygame.transform.scale(pygame.image.load(self.team_a[1]), (30, 30))

        textoEquipoB = fuenteEquipos.render(self.name_team_b[:16], 1, (255, 255, 255))
        sombraTextoEquipoB = fuenteEquipos.render(self.name_team_b[:16], 1, (0, 0, 0))
        self.imagenEquipoB = pygame.transform.scale(pygame.image.load(self.team_b[1]), (30, 30))

        # Bliteamos las superficies de los marcadores
        self.imagenFondo.blit(self.imagenEquipoA, (515, self.posMarcoSuperior + 9))
        self.imagenFondo.blit(sombraTextoEquipoA, (552, self.posMarcoSuperior + 11))
        self.imagenFondo.blit(textoEquipoA, (550, self.posMarcoSuperior + 9))

        self.imagenFondo.blit(self.imagenEquipoB, (515, self.posMarcoInferior + 9))
        self.imagenFondo.blit(sombraTextoEquipoB, (552, self.posMarcoInferior + 11))
        self.imagenFondo.blit(textoEquipoB, (550, self.posMarcoInferior + 9))

        posBloqueTurnoActual = 367
        self.imagenFondo.blit(imagenMarco, (510, posBloqueTurnoActual))

        posBloqueTurnosRestantes = 420
        self.imagenFondo.blit(imagenMarco, (510, posBloqueTurnosRestantes))

        # Cargamos la fuente para el texto de las fichas muertas
        self.fuenteFichasMuertas = pygame.font.Font(xdg_data_path("fonts/LiberationMono-Bold.ttf"), 19)

        # Pintamos las fichas blancas del fondo
        fichaBlanca = pygame.image.load(xdg_data_path("images/piece-default.png"))
        fichaBlanca = fichaBlanca.convert()

        for i in range(8):
            for j in range(8):
                self.imagenFondo.blit(fichaBlanca, (10 + 60 * i, 10 + 60 * j))

        # Cargando las fichas iniciales..."
        for keyFicha in organizacionInicial.keys():
            ficha = organizacionInicial[keyFicha]
            self.fichas[keyFicha] = Ficha(ficha[0], ficha[1], ficha[2], ficha[3], ficha[4], ficha[5], self.hidden)

        # Pintamos los botones
        botonesInterfaz = []
        botonesInterfaz.append(Boton(700, 500, "images/salir", self.callSalir))
        botonesInterfaz.append(Boton(120, 500, "images/flecha_izquierda2", self.callRetrocederInicio))
        botonesInterfaz.append(Boton(190, 500, "images/flecha_izquierda1", self.callRetrocederTurno))
        botonesInterfaz.append(Boton(260, 500, "images/flecha_derecha1", self.callAvanzarTurno))
        botonesInterfaz.append(Boton(330, 500, "images/flecha_derecha2", self.callAvanzarFinal))
        botonesInterfaz.append(Boton(630, 500, "images/btnAbortar", self.callAbortar, False))
        botonesInterfaz.append(Interruptor(560, 500, "images/btnAvanceAutomatico", self.callToggleAvanceAutomatico))

        self.salir = False
        self.avanceAutomatico = False

        # Leemos del fichero de configuración la velocidad del avance automático
        config_vars = configure.load_configuration()
        self.intervaloAvanceAutomatico = config_vars["auto_interval_time"]

        # Comienza el game loop
        while not self.salir and not controlPartida.flagCancelarCampeonato:

            # Comprobación del avance automático
            if self.avanceAutomatico:
                # Si el tiempo que ha pasado desde el último avance supera el intervalo
                if pygame.time.get_ticks() - self.ultimoAvance > self.intervaloAvanceAutomatico:

                    # Avanzamos el turno
                    self.callAvanzarTurno()

                    # Actualizamos la variable con el tiempo del último avance
                    self.ultimoAvance = pygame.time.get_ticks()

            # Gestión de eventos
            for eventos in pygame.event.get():

                # Si se ha pulsado ALT+F4 o el botón de cerrar ventana
                if eventos.type == QUIT:
                    # Activamos el flag de salir
                    self.salir = True

                # Cuando se pulsa el botón el ratón
                elif eventos.type == MOUSEBUTTONDOWN:

                    # Informamos a cada botón de la interfaz
                    for btn in botonesInterfaz:
                        btn.informarClick(eventos.pos)

                # Cuando se mueve el ratón
                elif eventos.type == MOUSEMOTION:

                    # Informamos a cada botón de la interfaz
                    for btn in botonesInterfaz:
                        btn.informarHover(eventos.pos)

                # Podemos avanzar turno con la flecha derecha del teclado
                elif eventos.type == KEYDOWN and eventos.key == 275:
                    self.callAvanzarTurno()

                # También podemos retroceder turno con las flechas del teclado
                elif eventos.type == KEYDOWN and eventos.key == 276:
                    self.callRetrocederTurno()

            # Pintamos el fondo
            self.pantalla.blit(self.imagenFondo, (0, 0))

            # Pintamos las fichas
            for keyFicha in self.fichas:
                self.fichas[keyFicha].pintar(self.pantalla)

            for obs in self.obstaculos:
                self.pantalla.blit(self.imagenObstaculo, (float(10 + (obs[0] - 1) * 60), float(10 + (obs[1] - 1) * 60)))

            # Pintamos los botones
            for btn in botonesInterfaz:
                btn.pintar(self.pantalla)

            # Pintamos las fichas muertas
            self.pintarFichasMuertas()

            self.pantalla.blit(
                fuenteEquipos.render("Turno actual: %d" % self.parseador.getNumTurnoActual(), 1, (0, 0, 0)),
                (517, posBloqueTurnoActual + 11),
            )
            self.pantalla.blit(
                fuenteEquipos.render("Turno actual: %d" % self.parseador.getNumTurnoActual(), 1, (255, 255, 255)),
                (515, posBloqueTurnoActual + 9),
            )

            self.pantalla.blit(
                fuenteEquipos.render(
                    "Turnos restantes: %d" % (self.parseador.getNumTurnoMax() - self.parseador.getNumTurnoActual()),
                    1,
                    (0, 0, 0),
                ),
                (517, posBloqueTurnosRestantes + 11),
            )
            self.pantalla.blit(
                fuenteEquipos.render(
                    "Turnos restantes: %d" % (self.parseador.getNumTurnoMax() - self.parseador.getNumTurnoActual()),
                    1,
                    (255, 255, 255),
                ),
                (515, posBloqueTurnosRestantes + 9),
            )

            # Volcamos la pantalla a la gráfica
            pygame.display.flip()

            ##############################
            # GESTIÓN DE LOS FPS

            # Cogemos los ticks actuales
            ticksActual = pygame.time.get_ticks()

            espera = self.intervalo - (ticksActual - self.ticksAnterior)

            if espera > 0:
                # Esperamos el tiempo necesario para mantener los FPS
                pygame.time.delay(int(espera))

            # Actualizamos los ticks anteriores
            self.ticksAnterior = ticksActual

        # Fin del game loop"

        # Cortamos la música
        pygame.mixer.music.stop()

        # Cerramos el subsistema gráfica (no es necesario)
        pygame.display.quit()
        logging.info("## FINALIZADO Pintado de partida")
        return 0
Exemplo n.º 34
0
gtk.glade.textdomain(APP)
gtk.glade.bindtextdomain(APP, DIR)


# set the locale to LANG, or the user's default
locale.setlocale(locale.LC_ALL, '')

# this installs _ into python's global namespace, so we don't have to
# explicitly import it elsewhere

from resistencia.nls import gettext as _

from resistencia.gui import main_window
import resistencia.configure as configure

configure.load_configuration()
  
def main():
    "Main function"

    logging.basicConfig(format='[%(levelname)s] [%(filename)s (%(lineno)d) %(funcName)s] %(message)s', filename='log_gsiege', level=logging.DEBUG)
    logging.info("#" * 40)
    logging.info("Init logging")
    # Crea una nueva instancia de la clase Resistencia, que guarda todos los
    # cuadros de diálogo
    editor = main_window.Resistencia()

    # Muestra el cuadro de diálogo principal
    editor.window.show()

    # Lanza el bucle de GTK (?)
Exemplo n.º 35
0
    def __init__(self, main_team, teams, rounds_number, num_turns):
        self.main_team = main_team
        self.teams = teams
        self.num_turns = num_turns

        self.translator_teams = _generate_key_names(teams)
        self.translator_main_team = _generate_key_names([main_team])

        self.keys_teams = []
        self.key_main_team = []

        self.rounds_number = rounds_number

        base_path = configure.load_configuration()['games_path'] + '/'
        base_path += filenames.generate_filename('labdir', main_team) + '/'

        os.mkdir(base_path)

        self.filename = base_path + filenames.generate_filename(
            'stats', main_team)

        for _team in self.translator_teams:
            self.keys_teams.append(_team)

        for _team in self.translator_main_team:
            self.key_main_team.append(_team)

        self.translator = self.translator_teams.copy()
        for k in self.translator_main_team:
            self.translator[k] = self.translator_main_team[k]

        self.rounds = []
        stats_writer = csv.writer(open(self.filename, 'w'),
                                  delimiter=',',
                                  quotechar='|',
                                  quoting=csv.QUOTE_MINIMAL)
        stats_writer.writerow([
            _('Opponent'),
            _('As team'),
            _('Result'),
            _("Number of turns"),
            _('Number of pieces'),
            _("Value of the pieces"),
            _('Turn when max value piece died')
        ])

        for i in range(self.rounds_number):
            round_games = pairing.test_pairing(self.key_main_team[0],
                                               self.keys_teams, i % 2)
            self.rounds.append(
                test_round.TestRound((round_games, self.translator),
                                     num_turns=self.num_turns,
                                     log_file=self.filename,
                                     player=i % 2,
                                     logFolder=base_path))

        self.total_stats = {}
        self.total_stats['wins'] = 0
        self.total_stats['looses'] = 0
        self.total_stats['draws'] = 0
        self.total_stats['turns_winning'] = 0
        self.total_stats['turns_losing'] = 0
        self.total_stats['num_pieces'] = 0
        self.total_stats['val_pieces'] = 0
        self.total_stats['max_death'] = 0
Exemplo n.º 36
0
def generate_log_folder_name(prefix='pachanga', base_path = None):
    if base_path == None:
        base_path = configure.load_configuration()['games_path'] + '/'

    return base_path + filenames.generate_filename(prefix, noExtension = True)
Exemplo n.º 37
0
def generate_log_folder_name(prefix='pachanga', base_path=None):
    if base_path == None:
        base_path = configure.load_configuration()['games_path'] + '/'

    return base_path + filenames.generate_filename(prefix, noExtension=True)
Exemplo n.º 38
0
def _load_game_from_file(src_file, team_a, team_b, path_piece_def, xml_file,
                         hidden=False, cant_draw=False):
    entire_game, winner = file_parser.parse_file(src_file)
    if cant_draw:
        winner = _handle_draw(src_file)

    if winner == 0:
        print u'Empate'
    elif winner == 1:
        print u'Ganó %s' % team_a[0]
    else:
        print u'Ganó %s' % team_b[0]

    music = False
    if configure.load_configuration()['music_active'] == '1':
        music = True

    pygame.init()

    xml_layout = layout.Layout(xml_file)

    screen = pygame.display.set_mode(xml_layout.get_window_size())
    pygame.display.set_caption(xml_layout.get_window_title())

    if music:
        _music_path = xdg_data_path('music/walking_on_old_stones.ogg')
        mixer.music.load(_music_path)
        mixer.music.play()

    res_game = game.Game(entire_game, team_a[1],
                         team_b[1], path_piece_def, hidden=hidden)

    img_board = res_game.draw_board().convert()

    xml_layout.init((team_a[1], team_a[0]), (team_b[1], team_b[0]), img_board)
    rects = xml_layout.get_buttons_rects()

    pygame.display.set_icon(xml_layout.get_favicon())

    screen.blit(xml_layout.get_surface(), (0, 0))
    pygame.display.flip()

    band_pos = False
    clock = pygame.time.Clock()
    while True:
        clock.tick(50)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                if music:
                    mixer.music.stop()
                pygame.display.quit()
                show_dialog_result((team_a[0], team_b[0]), winner)
                return winner
            elif event.type == pygame.KEYDOWN:
                if event.key == 275:
                    surface = next_turn(res_game, xml_layout)
                    screen.blit(surface, (0, 0))
                    pygame.display.flip()
                if event.key == 276:
                    surface = previous_turn(res_game, xml_layout)
                    screen.blit(surface, (0, 0))
                    pygame.display.flip()
            elif event.type == pygame.MOUSEMOTION:
                res = get_collision(event.pos, rects)
                if res != '':
                    if band_pos == False:
                        surface = xml_layout.get_surface((res, 2))
                        screen.blit(surface, (0, 0))
                        pygame.display.flip()
                        band_pos = True
                else:
                    if band_pos == True:
                        surface = xml_layout.get_surface()
                        screen.blit(surface, (0, 0))
                        pygame.display.flip()
                        band_pos = False
            elif event.type == pygame.MOUSEBUTTONUP:
                res = get_collision(event.pos, rects)
                if event.button == 1 and res != '':
                    if res == 'button_exit':
                        if music:
                            mixer.music.stop()
                        pygame.display.quit()
                        show_dialog_result((team_a[0], team_b[0]), winner)
                        return winner
                    else:
                        if res == 'button_left_2':
                            surface = first_turn(
                                res_game, xml_layout, (res, 1))
                            screen.blit(surface, (0, 0))
                            pygame.display.flip()
                        elif res == 'button_left_1':
                            surface = previous_turn(
                                res_game, xml_layout, (res, 1))
                            screen.blit(surface, (0, 0))
                            pygame.display.flip()
                        elif res == 'button_right_1':
                            surface = next_turn(
                                res_game, xml_layout, (res, 1))
                            screen.blit(surface, (0, 0))
                            pygame.display.flip()
                        elif res == 'button_right_2':
                            surface = last_turn(
                                res_game, xml_layout, (res, 1))
                            screen.blit(surface, (0, 0))
                            pygame.display.flip()
Exemplo n.º 39
0
def _init_game(game_type,
               teams,
               fast,
               num_turns,
               back_round=False,
               log_base_folder=None):

    logging.info(">>>> INIT GAME")

    if log_base_folder == None:
        log_base_folder = configure.load_configuration()['games_path'] + '/'

    # Generamos el nombre del fichero de log según el tipo de juego
    log_base_name = filenames.generate_filename(game_type, noExtension=True)
    log_folder_name = log_base_folder + log_base_name
    log_file_name = log_folder_name + "/" + game_type + ".txt"

    logging.info("Fichero de log: %s", log_file_name)
    logging.info("Carpeta de log: %s", log_folder_name)

    os.mkdir(log_folder_name)

    # Lanzamos el tipo de juego apropiado
    if game_type == 'cup':
        game = tournament.Tournament(teams,
                                     num_turns,
                                     log_folder=log_folder_name)
    else:
        game = league.League(teams,
                             num_turns,
                             back_round,
                             log_folder=log_folder_name)

    band = False

    # Contenedor para clasificaciones
    classifications = {}

    results = None

    # Cada elemento tendrá una tupla de 3: ganadas, empatadas y perdidas
    estadisticas = {
        "aux_ghost_team": {
            "ganadas": 0,
            "empatadas": 0,
            "perdidas": 0
        }
    }

    for equipo in contest.generate_key_names(teams).keys():
        estadisticas[equipo] = {
            "ganadas": 0,
            "empatadas": 0,
            "perdidas": 0
        }

    # Mientras no se haya completado el juego
    while not game.completed(
    ) and not band and not controlPartida.flagCancelarCampeonato:

        logging.info("---- START OF THE ROUND")

        if results != None:

            # Cargamos el diálogo de resultados
            R = round_results.roundResults(
                classifications,
                results,
                game.get_prev_round_number() + 1,
                game.get_number_of_rounds(),
                show_classifications=(game_type != 'cup'),
                stats=estadisticas,
                show_top_teams=True,
                next_matches=game.matchs[game.get_round_number()])

            # Mostramos el diálogo de resultados
            button_pressed = R.result_dialog.run()

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

            if button_pressed == -4 or button_pressed == 0:
                band = True
                continue

        # Guardamos el número de la ronda
        roundNumber = game.get_round_number()

        if roundNumber == 0:
            show_round_matches(game)

        # Por defecto que la barra de progreso no exista
        progress_bar = None

        # Si no mostramos el progreso del juego, que salga la barra
        if fast:
            progress_bar = pbs.ProgressBarDialog(None,
                                                 _('Running the contest'))
            progress_bar_dialog = progress_bar.progress_bar_dialog
            progress_bar.set_num_elements(
                game.get_round(roundNumber).number_games)
            progress_bar_dialog.show()

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

        # Jugamos esta ronda
        game.play_round(progress_bar, fast)

        if controlPartida.flagCancelarCampeonato:
            return

        # Guardamos en r la ronda actual, con sus resultados y tal
        r = game.get_round(roundNumber)

        # Resultados de la ronda
        results = r.get_round_results()

        # Actualizamos el fichero del log
        update_log_round(log_file_name, results, roundNumber)

        for partido in results:
            if partido[1] == 1:
                estadisticas[partido[0][0]]["ganadas"] += 1
                estadisticas[partido[0][1]]["perdidas"] += 1
            elif partido[1] == -1:
                estadisticas[partido[0][1]]["ganadas"] += 1
                estadisticas[partido[0][0]]["perdidas"] += 1
            else:
                estadisticas[partido[0][0]]["empatadas"] += 1
                estadisticas[partido[0][1]]["empatadas"] += 1

        if game_type == 'cup':
            pass
        else:
            # "Puntuations" es una palabra que no existe
            classifications = game.get_actual_puntuations()

        # Ocultamos la barra de progreso (que ya habrá acabado)
        if fast:
            progress_bar_dialog.hide()

        logging.info("---- END OF THE ROUND")

    if not band:
        # Mostramos los resultados FINALES
        R = round_results.roundResults(
            classifications,
            results,
            game.get_prev_round_number() + 1,
            game.get_number_of_rounds(),
            show_classifications=(game_type != 'cup'),
            show_top_teams=True,
            stats=estadisticas)

        # Mostramos el diálogo de resultados
        button_pressed = R.result_dialog.run()

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

    if not band and not controlPartida.flagCancelarCampeonato:
        if game_type == 'cup':
            update_log_ending_tournament(log_file_name, estadisticas)
            dibujoClasificacion = dibujo_clasificacion.DibujoClasificacion(
                game)
        else:
            update_log_ending_league(log_file_name, classifications)

    logging.info(">>>> END INIT GAME")
    return (band, classifications)
Exemplo n.º 40
0
gettext.bindtextdomain(APP, DIR)
gtk.glade.textdomain(APP)
gtk.glade.bindtextdomain(APP, DIR)

# set the locale to LANG, or the user's default
locale.setlocale(locale.LC_ALL, '')

# this installs _ into python's global namespace, so we don't have to
# explicitly import it elsewhere

from resistencia.nls import gettext as _

from resistencia.gui import main_window
import resistencia.configure as configure

configure.load_configuration()


def main():
    "Main function"

    logging.basicConfig(
        format=
        '[%(levelname)s] [%(filename)s (%(lineno)d) %(funcName)s] %(message)s',
        filename='log_gsiege',
        level=logging.DEBUG)
    logging.info("#" * 40)
    logging.info("Init logging")
    # Crea una nueva instancia de la clase Resistencia, que guarda todos los
    # cuadros de diálogo
    editor = main_window.Resistencia()