def exit_game(self): """Handles the game ending which is clicked by user.""" messagebox.showinfo(title='Game Over', message='You scored {}!'.format(self._game.get_score())) scoremanager = HighScoreManager(gamemode=self._record_gamename) scoremanager.record(self._game.get_score(), self._game,name=self._name) self._master.destroy()
def save_game(self): """Save game data in json file so that can be replayed again.""" messagebox.showinfo(title='Game Saved', message='You saved your game with score {}!'.format( self._game.get_score())) savemanager = HighScoreManager(file="savedgame.json", gamemode=self._record_gamename) savemanager.record(self._game.get_score(), self._game,name=self._name)
def game_over(self): """Handles the game ending with no tile can be avtivated.""" #show users a messagebox that game ends messagebox.showinfo(title='Game Over', message='You scored {}!'.format(self._game.get_score())) #save score and player's name into json file scoremanager = HighScoreManager(gamemode=self._record_gamename) scoremanager.record(self._game.get_score(), self._game,name=self._name)
def save_record(self): """Save game record.""" record = HighScoreManager() record.record(self._game.get_score(), self._game, self._player_name)