def game_over(won, difficulty): global name global moves global leaderboard time = str(date.now()) score = Score(name, moves, time) #sends the players name, score, and time finished to the score class so the data can be manipulated later by the leaderboard. if won == True: print("You won!") else: print ("\nOH NO! You ran out of lives!") #Lets the player know if they won or why they lost moves = score.get_score() #gets the most recent score/moves of the player if won == True: leaderboard.update(score) moves = moves-(difficulty*100) #changes the value of moves to reflect the actual amount of moves they made and not their total score(lives included) print ("Choices made:", moves) #Tells the player how many choices they made and lets them know the game has ended. print ("\n\t\tGAME OVER.\n") leaderboard.print_board() #prints the leaderboard leaderboard.saving_leaderboard() #saves the current leaderboard outside of the game program so that it can be called back when the game program is restarted name = "" moves = 0 print ("\n*************************************************************\n")
def update(self, score): for dictionary in self.board: if dictionary["score"] > Score.get_score(): self.insert(score, dictionary["place"])