def end_game(cls, game, won=False): """Ends the game - if won is True, the player won. - if won is False, the player lost.""" game.game_over = True game.put() # Add the game to the score 'board' score = Score(user=game.user, date=date.today(), won=won, victory_margin=game.user_wins - game.cpu_wins) score.put() # Update the user's stats with the game result user = game.user.get() if won: user.num_wins += 1 else: user.num_losses += 1 user.total_victory_margin += (game.user_wins - game.cpu_wins) user.put()