def end_game(self, *a): self.pt.sideletters.set_sensitive(False) text = _('Game over.') text += '\n' #----------------------------- if len(self.pt.list_letters_repeated) == 0: if len(self.pt.list_07_letters_computer) == 0: text += _('The computer does not have any pieces.') elif len(self.pt.list_07_letters_player) == 0: text += _('You does not have any pieces.') else: text += _('You can not play both.') else: text += _('You can not play both.') text += '\n' #----------------------------- self.count_residual_points() if self.pt.points_computer > self.pt.points_player: text += _('You lost, Try again.') if self.pt.points_computer < self.pt.points_player: text += _('You won, Congratulations to you.') if self.pt.points_computer == self.pt.points_player: text += _("They drew, It's okay.") text += '\n' #----------------------------- text += _('Computer Points: {}.').format(self.pt.points_computer, ) text += '\n' #----------------------------- text += _('Your Points: {}.').format(self.pt.points_player, ) self.pt.text_msg = text self.pt.ended = True config.setv('saved', 0) self.pt.chequer.queue_draw()
def ch_color(self, btn): nconf = btn.get_name() color = btn.get_rgba().to_string() config.setv(nconf, color) self.pt.sideinfo.wordviewer.change_theme() self.pt.hd_bar.view.change_theme() self.pt.sideletters.change_theme() self.pt.chequer.queue_draw()
def set_autohide_letters(self, btn): n = btn.get_active() if n: config.setv('autohide_letters', 1) if self.pt.all_letters == 0: self.pt.vb_letters.set_no_show_all(True) self.pt.vb_letters.hide() else: config.setv('autohide_letters', 0) if self.pt.all_letters == 0: self.pt.vb_letters.set_no_show_all(False) self.pt.vb_letters.show_all()
def sel_language_scrabble(self, btn): name = btn.get_active_text() if name == config.getv('language_scrabble'): return self.pt.hd_bar.btn_pref.set_active(False) if list(self.pt.dict_chequer.values()) == [0,]*225 or self.pt.ended == True: pass else: res = sure(self.pt, _('If you want to change the language you will need to start a new game. \n Do you want that?')) if res == -8: pass else: btn.set_active(config.getn('language_scrabble')) return config.setv('language_scrabble', name) self.pt.sideinfo.label_language_scrabble.set_label(name) self.pt.pagestarting.label_language_scrabble.set_label(_('Playing language:')+' '+name) self.pt.pagestarting.restor_to_starting_page() self.pt.restart_game()
def quit_app(self, *a): if list(self.dict_chequer.values()) != [ 0, ] * 225 and self.ended == False and self.all_letters == 0: res = sure(self, _('Do you want to save this game?')) if res == -8: config.setv('saved', 1) save_game(self.dict_chequer.copy(), self.text_words_with_points, self.list_letters_repeated.copy(), self.list_07_letters_player.copy(), self.list_07_letters_computer.copy(), self.points_player, self.points_computer, self.cells_empty_letter.copy(), self.computer_empty_letter.copy()) if res == -9: config.setv('saved', 0) config.setv('points_player', 0) config.setv('points_computer', 0) Gtk.main_quit()
def restart_game(self, *a): self.ended = False self.pagestarting.restor_to_starting_page() config.setv('saved', 0) self.dict_new.clear() self.dict_new_computer.clear() self.list_07_letters_player = [] self.list_07_letters_computer = [] self.cells_empty_letter = [] self.computer_empty_letter = [] self.points_player = 0 self.points_computer = 0 self.text_words_with_points = '' config.setv('points_player', 0) config.setv('points_computer', 0) self.dict_chequer.clear_dict_all() self.sideletters.liststore_letters_player.clear() self.sideinfo.lab_points_computer.set_label('00') self.sideinfo.lab_points_player.set_label('00') self.sideinfo.wordviewer_buf.set_text('') self.load()
def set_default(self, btn, n): self.pt.hd_bar.btn_pref.set_active(False) res = sure(self.pt, _('Do you want to restore the default settings?')) if res == -8: if n == 2: fg_pieces = 'rgb(32,74,135)' fg_cell = 'rgb(46,52,54)' bg_pieces = 'rgb(253,253,215)' bg_no_install = 'rgb(255,245,154)' bg_last_word = 'rgb(221,245,125)' fg_nbr = 'rgb(204,0,0)' sel_pieces = 'rgb(255,108,97)' br_pieces = 'rgb(204,0,0)' bg_area = 'rgb(186,189,182)' bg_grid = 'rgb(242,204,145)' br_grid = 'rgb(117,80,123)' bg_lines = 'rgb(136,138,133)' fg_msg = 'rgb(32,74,135)' bg_hX2 = 'rgb(201,236,228)' bg_hX3 = 'rgb(114,159,207)' bg_kX2 = 'rgb(255,185,185)' bg_kX3 = 'rgb(251,95,95)' bg_start = 'rgb(252,233,79)' config.setv('fg_pieces', fg_pieces) config.setv('fg_nbr', fg_nbr) config.setv('fg_cell', fg_cell) config.setv('bg_pieces', bg_pieces) config.setv('bg_no_install', bg_no_install) config.setv('bg_last_word', bg_last_word) config.setv('sel_pieces', sel_pieces) config.setv('br_pieces', br_pieces) config.setv('bg_area', bg_area) config.setv('bg_grid', bg_grid) config.setv('br_grid', br_grid) config.setv('bg_lines', bg_lines) config.setv('fg_msg', fg_msg) config.setv('bg_hX2', bg_hX2) config.setv('bg_hX3', bg_hX3) config.setv('bg_kX2', bg_kX2) config.setv('bg_kX3', bg_kX3) config.setv('bg_start', bg_start) elif n == 1: config.setv('font_pieces', 'Sans 11') config.setv('font_msg', 'Sans 25') config.setv('font_win', 'Sans 15') config.setv('font_special', 'Sans 15') config.setv('br_thick', 1) elif n == 3: config.setv('pipe_drop', 9000) config.setv('pipe_ok', 5000) config.setv('pipe_undo', 1300) config.setv('pipe_add', 9000) config.setv('pipe_drop_ms', 20) config.setv('pipe_ok_ms', 20) config.setv('pipe_undo_ms', 20) config.setv('pipe_add_ms', 20) self.pt.ch_font() self.pt.sideinfo.wordviewer.change_theme() self.pt.hd_bar.view.change_theme() self.pt.sideletters.change_theme() self.pt.chequer.queue_draw()
def ch_thick(self, btn): v = btn.get_value() config.setv('br_thick', v) self.pt.chequer.queue_draw()
def ch_font(self, btn): nconf = btn.get_name() font = btn.get_font() config.setv(nconf, font) self.pt.ch_font() self.pt.chequer.queue_draw()
def ch_sound(self, btn): nconf = btn.get_name() config.setv(nconf, btn.get_value()) name = nconf.replace('_ms', '').replace('pipe_', '') play_sound(name)
def on_switch_activated(self, *a): if self.switch_sound.get_active(): config.setv('sound', 1) else: config.setv('sound', 0)
def sel_grade(self, btn, n): config.setv('grade', n) self.pt.sideinfo.label_grade.set_label(self.pt.LIST_GRADE[n])
def sel_language_surface(self, btn): self.pt.hd_bar.btn_pref.set_active(False) name = btn.get_active_text() config.setv('language_surface', name) info(self.pt, _('It will do the change after you restart the program.'))