

from enum import Enum
from multiplayer_crosswords.dictionary import Dictionary
from multiplayer_crosswords.utils import load_en_dictionary, load_de_dictionary
from .server_config import ServerConfig


class Languages(str, Enum):
    EN = "en"
    DE = "de"

    def load_dictionary(self) -> Dictionary:
        if self == Languages.EN:
            return load_en_dictionary()
        elif self == Languages.DE:
            return load_de_dictionary()
        else:
            raise ValueError(f"Unsupported language: {self}")

class BoardSizePreset(str, Enum):
    VERY_SMALL = "very_small"
    SMALL = "small"
    MEDIUM = "medium"
    LARGE = "large"
    VERY_LARGE = "very_large"

    def to_dimensions(self) -> tuple[int, int]:
        server_config = ServerConfig.get_config()
        min_size = server_config.MIN_GRID_SIZE
        max_size = server_config.MAX_GRID_SIZE
        if self == BoardSizePreset.VERY_SMALL:
            return (min_size, min_size)
        elif self == BoardSizePreset.SMALL:
            return (min_size + (max_size - min_size) // 4, min_size + (max_size - min_size) // 4)
        elif self == BoardSizePreset.MEDIUM:
            return (min_size + (max_size - min_size) // 2, min_size + (max_size - min_size) // 2)
        elif self == BoardSizePreset.LARGE:
            return (min_size + 3 * (max_size - min_size) // 4, min_size + 3 * (max_size - min_size) // 4)
        elif self == BoardSizePreset.VERY_LARGE:
            return (max_size, max_size)
        else:
            raise ValueError(f"Unsupported board size preset: {self}")
