from __future__ import annotations

from datetime import datetime
from typing import Annotated

from sqlalchemy import Boolean, DateTime, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column

from .base import Base, DelimitedList


class RosterChange(Base):
    """SQLAlchemy ORM model for RosterChanges"""

    __tablename__ = "RosterChanges"

    # Primary Key
    RosterChangeId: Mapped[str] = mapped_column(String, primary_key=True)

    # Date Information
    Date_Sort: Mapped[datetime | None] = mapped_column(DateTime, default=None)

    # Player Information
    Player: Mapped[str | None] = mapped_column(String, default=None)
    PlayerUnlinked: Mapped[bool | None] = mapped_column(Boolean, default=None)

    # Team Information
    Team: Mapped[str | None] = mapped_column(String, default=None)
    Direction: Mapped[str | None] = mapped_column(String, default=None)

    # Role Information
    RolesIngame: Mapped[Annotated[list[str], DelimitedList(";")] | None] = (
        mapped_column(Text, default=None)
    )  # ;-delimited list
    RolesStaff: Mapped[Annotated[list[str], DelimitedList(";")] | None] = (
        mapped_column(Text, default=None)
    )  # ;-delimited list
    Roles: Mapped[Annotated[list[str], DelimitedList(";")] | None] = mapped_column(
        Text, default=None
    )  # ;-delimited list
    RoleDisplay: Mapped[str | None] = mapped_column(String, default=None)
    Role: Mapped[str | None] = mapped_column(String, default=None)
    RoleModifier: Mapped[str | None] = mapped_column(String, default=None)

    # Status Information
    Status: Mapped[str | None] = mapped_column(String, default=None)
    CurrentTeamPriority: Mapped[int | None] = mapped_column(Integer, default=None)
    AlreadyJoined: Mapped[str | None] = mapped_column(String, default=None)

    # Tournament Information
    Tournaments: Mapped[Annotated[list[str], DelimitedList(",")] | None] = (
        mapped_column(Text, default=None)
    )  # Comma-delimited list

    # Source and Metadata
    Source: Mapped[str | None] = mapped_column(Text, default=None)  # Wikitext
    IsGCD: Mapped[bool | None] = mapped_column(Boolean, default=None)

    # Preload Information
    Preload: Mapped[str | None] = mapped_column(String, default=None)
    PreloadSortNumber: Mapped[int | None] = mapped_column(Integer, default=None)

    # Tags and News
    Tags: Mapped[Annotated[list[str], DelimitedList(",")] | None] = mapped_column(
        Text, default=None
    )  # Comma-delimited list
    NewsId: Mapped[str | None] = mapped_column(String, default=None)
    N_LineInNews: Mapped[int | None] = mapped_column(Integer, default=None)
