"""Season system derived from game day count."""

from __future__ import annotations

SEASONS: list[str] = ["spring", "summer", "autumn", "winter"]
DAYS_PER_SEASON: int = 7  # 28-day year


def get_season(game_day: int, days_per_season: int = DAYS_PER_SEASON) -> str:
    """Return the current season based on game day count.

    Args:
        game_day: Current game day (0-based)
        days_per_season: Number of days per season (default 7)

    Returns:
        Current season: "spring", "summer", "autumn", or "winter"
    """
    if game_day < 0:
        game_day = 0

    days_per_year = days_per_season * 4
    day_of_year = game_day % days_per_year
    season_index = day_of_year // days_per_season

    return SEASONS[season_index]


def get_day_of_year(game_day: int, days_per_season: int = DAYS_PER_SEASON) -> int:
    """Return the day within the current year (0 to days_per_season*4 - 1).

    Args:
        game_day: Current game day (0-based)
        days_per_season: Number of days per season (default 7)

    Returns:
        Day of year (0-based)
    """
    if game_day < 0:
        game_day = 0

    days_per_year = days_per_season * 4
    return game_day % days_per_year


def get_season_description(season: str, terrain: str) -> str:
    """Return a seasonal description variant for a terrain type.

    Args:
        season: Current season
        terrain: Terrain type

    Returns:
        Seasonal description for this terrain, or empty string if no variation
    """
    # Only grass and forest have seasonal variation
    descriptions = {
        ("spring", "grass"): "fresh green grass springs up everywhere",
        ("summer", "grass"): "golden grass waves in the breeze",
        ("autumn", "grass"): "the grass turns brown and brittle",
        ("winter", "grass"): "frost clings to brittle brown grass",
        ("spring", "forest"): "the trees burst with pale blossoms",
        ("summer", "forest"): "a thick green canopy spreads overhead",
        ("autumn", "forest"): "the trees blaze with amber and crimson",
        ("winter", "forest"): "bare branches reach toward the sky",
    }

    return descriptions.get((season, terrain), "")
