# Released under the MIT License. See LICENSE for details.
#
"""Playlist ui functionality."""

import bascenev1 as bs


# FIXME: Could change this to be a classmethod of session types?
class PlaylistTypeVars:
    """Defines values for a playlist type (config names to use, etc)."""

    def __init__(self, sessiontype: type[bs.Session]):
        from bascenev1 import (
            classicassets,
            get_default_teams_playlist,
            get_default_free_for_all_playlist,
        )

        self.sessiontype: type[bs.Session]

        if issubclass(sessiontype, bs.DualTeamSession):
            play_mode_name = classicassets.strings.play_modes.teams
            self.get_default_list_call = get_default_teams_playlist
            self.session_type_name = 'bascenev1.DualTeamSession'
            self.config_name = 'Team Tournament'
            self.window_title_name = classicassets.strings.play_modes.teams
            self.sessiontype = bs.DualTeamSession

        elif issubclass(sessiontype, bs.FreeForAllSession):
            play_mode_name = classicassets.strings.play_modes.free_for_all
            self.get_default_list_call = get_default_free_for_all_playlist
            self.session_type_name = 'bascenev1.FreeForAllSession'
            self.config_name = 'Free-for-All'
            self.window_title_name = (
                classicassets.strings.play_modes.free_for_all
            )
            self.sessiontype = bs.FreeForAllSession

        else:
            raise RuntimeError(
                f'Playlist type vars undefined for sessiontype: {sessiontype}'
            )
        self.default_list_name = (
            classicassets.strings.playlist.default_list_name(
                playmode=play_mode_name
            )
        )
        self.default_new_list_name = (
            classicassets.strings.playlist.default_new_list_name(
                playmode=play_mode_name
            )
        )
