# Buggy code
def __init__(self, game_id=None):
    super().__init__()
    self.id = game_id  # pylint: disable=invalid-name
    self.runner = None
    self.config = None

    # Load attributes from database
    game_data = pga.get_game_by_field(game_id, "id")
    self.slug = game_data.get("slug") or ""
    self.runner_name = game_data.get("runner") or ""
    self.directory = game_data.get("directory") or ""
    self.name = game_data.get("name") or ""

    self.game_config_id = game_data.get("configpath") or ""
    self.is_installed = bool(game_data.get("installed")) and self.game_config_id
    self.platform = game_data.get("platform") or ""
    self.year = game_data.get("year") or ""
    self.lastplayed = game_data.get("lastplayed") or 0
    self.steamid = game_data.get("steamid") or ""
    self.has_custom_banner = bool(game_data.get("has_custom_banner"))
    self.has_custom_icon = bool(game_data.get("has_custom_icon"))
    try:
        self.playtime = float(game_data.get("playtime") or 0.0)
    except ValueError:
        logger.error("Invalid playtime value %s", game_data.get("playtime"))

    if self.game_config_id:
        self.load_config()
    self.game_thread = None
    self.prelaunch_executor = None
    self.heartbeat = None
    self.killswitch = None
    self.state = self.STATE_IDLE
    self.exit_main_loop = False
    self.xboxdrv_thread = None
    self.game_runtime_config = {}
    self.resolution_changed = False
    self.compositor_disabled = False
    self.stop_compositor = self.start_compositor = ""
    self.original_outputs = None
    self.log_buffer = Gtk.TextBuffer()
    self.log_buffer.create_tag("warning", foreground="red")

    self.timer = Timer()


# Traceback (AttributeError)
INFO     2019-02-02 10:25:28,606 [application.do_command_line:222]:Running Lutris 0.5.0
INFO     2019-02-02 10:25:28,607 [startup.check_driver:43]:Using NVIDIA drivers 396.54 for x86_64
INFO     2019-02-02 10:25:28,607 [startup.check_driver:47]:GPU: GeForce GTX 1070 Ti
INFO     2019-02-02 10:25:28,607 [startup.check_driver:63]:GPU: 10DE:1B82 1043:861E using nvidia drivers
INFO     2019-02-02 10:25:28,653 [startup.check_vulkan:84]:Vulkan is supported
ERROR    2019-02-02 10:25:28,654 [game.__init__:69]:Invalid playtime value 0.0 hrs
ERROR    2019-02-02 10:25:28,656 [startup.fill_missing_platforms:98]:Providing missing platorm for game super-smash-bros-melee
WARNING  2019-02-02 10:25:28,656 [game.set_platform_from_runner:193]:Can't get platform for runner Dolphin
DEBUG    2019-02-02 10:25:28,656 [game.save:201]:Saving Super Smash Bros. Melee (dolphin)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/lutris/gui/application.py", line 223, in do_command_line
run_all_checks()
File "/usr/lib/python3/dist-packages/lutris/startup.py", line 109, in run_all_checks
fill_missing_platforms()
File "/usr/lib/python3/dist-packages/lutris/startup.py", line 100, in fill_missing_platforms
game.save(metadata_only=True)
File "/usr/lib/python3/dist-packages/lutris/game.py", line 216, in save
playtime=self.playtime,
AttributeError: 'Game' object has no attribute 'playtime'
INFO     2019-02-02 10:25:28,688 [application.do_shutdown:439]:Shutting down Lutris

# Fixed code
def __init__(self, game_id=None):
    super().__init__()
    self.id = game_id  # pylint: disable=invalid-name
    self.runner = None
    self.config = None

    # Load attributes from database
    game_data = pga.get_game_by_field(game_id, "id")
    self.slug = game_data.get("slug") or ""
    self.runner_name = game_data.get("runner") or ""
    self.directory = game_data.get("directory") or ""
    self.name = game_data.get("name") or ""

    self.game_config_id = game_data.get("configpath") or ""
    self.is_installed = bool(game_data.get("installed")) and self.game_config_id
    self.platform = game_data.get("platform") or ""
    self.year = game_data.get("year") or ""
    self.lastplayed = game_data.get("lastplayed") or 0
    self.steamid = game_data.get("steamid") or ""
    self.has_custom_banner = bool(game_data.get("has_custom_banner"))
    self.has_custom_icon = bool(game_data.get("has_custom_icon"))
    try:
        self.playtime = float(game_data.get("playtime") or 0.0)
    except ValueError:
        logger.error("Invalid playtime value %s", game_data.get("playtime"))
        self.playtime = 0.0

    if self.game_config_id:
        self.load_config()
    self.game_thread = None
    self.prelaunch_executor = None
    self.heartbeat = None
    self.killswitch = None
    self.state = self.STATE_IDLE
    self.exit_main_loop = False
    self.xboxdrv_thread = None
    self.game_runtime_config = {}
    self.resolution_changed = False
    self.compositor_disabled = False
    self.stop_compositor = self.start_compositor = ""
    self.original_outputs = None
    self.log_buffer = Gtk.TextBuffer()
    self.log_buffer.create_tag("warning", foreground="red")

    self.timer = Timer()