from __future__ import annotations

from datetime import datetime

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

from .base import Base


class ScoreboardGame(Base):
    """SQLAlchemy ORM model for ScoreboardGames"""

    __tablename__ = "ScoreboardGames"

    # Primary Key - using GameId as primary key
    GameId: Mapped[str] = mapped_column(String, primary_key=True)

    # Basic Information
    OverviewPage: Mapped[str | None] = mapped_column(String, default=None)
    Tournament: Mapped[str | None] = mapped_column(String, default=None)
    Team1: Mapped[str | None] = mapped_column(String, default=None)
    Team2: Mapped[str | None] = mapped_column(String, default=None)
    WinTeam: Mapped[str | None] = mapped_column(String, default=None)
    LossTeam: Mapped[str | None] = mapped_column(String, default=None)
    DateTime_UTC: Mapped[datetime | None] = mapped_column(DateTime, default=None)
    DST: Mapped[str | None] = mapped_column(String, default=None)
    Team1Score: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Score: Mapped[int | None] = mapped_column(Integer, default=None)
    Winner: Mapped[int | None] = mapped_column(Integer, default=None)
    Gamelength: Mapped[str | None] = mapped_column(String, default=None)
    Gamelength_Number: Mapped[float | None] = mapped_column(Float, default=None)

    # Bans and Picks (stored as comma-delimited strings)
    Team1Bans: Mapped[str | None] = mapped_column(String, default=None)
    Team2Bans: Mapped[str | None] = mapped_column(String, default=None)
    Team1Picks: Mapped[str | None] = mapped_column(String, default=None)
    Team2Picks: Mapped[str | None] = mapped_column(String, default=None)
    Team1Players: Mapped[str | None] = mapped_column(String, default=None)
    Team2Players: Mapped[str | None] = mapped_column(String, default=None)

    # Dragon Statistics
    Team1Dragons: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Dragons: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Clouds: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Infernals: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Mountains: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Oceans: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Hextechs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Chemtechs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Elders: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Clouds: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Infernals: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Mountains: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Oceans: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Hextechs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Chemtechs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Elders: Mapped[int | None] = mapped_column(Integer, default=None)

    # Objective Statistics
    Team1Barons: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Barons: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Towers: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Towers: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Gold: Mapped[float | None] = mapped_column(Float, default=None)
    Team2Gold: Mapped[float | None] = mapped_column(Float, default=None)
    Team1Kills: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Kills: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1RiftHeralds: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2RiftHeralds: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1VoidGrubs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2VoidGrubs: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Atakhans: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Atakhans: Mapped[int | None] = mapped_column(Integer, default=None)
    Team1Inhibitors: Mapped[int | None] = mapped_column(Integer, default=None)
    Team2Inhibitors: Mapped[int | None] = mapped_column(Integer, default=None)

    # Patch and Metadata
    Patch: Mapped[str | None] = mapped_column(String, default=None)
    LegacyPatch: Mapped[str | None] = mapped_column(String, default=None)
    PatchSort: Mapped[str | None] = mapped_column(String, default=None)
    MatchHistory: Mapped[str | None] = mapped_column(Text, default=None)
    VOD: Mapped[str | None] = mapped_column(Text, default=None)  # Wikitext

    # Navigation/Indexing
    N_Page: Mapped[int | None] = mapped_column(Integer, default=None)
    N_MatchInTab: Mapped[int | None] = mapped_column(Integer, default=None)
    N_MatchInPage: Mapped[int | None] = mapped_column(Integer, default=None)
    N_GameInMatch: Mapped[int | None] = mapped_column(Integer, default=None)

    # Identifiers
    Gamename: Mapped[str | None] = mapped_column(String, default=None)
    UniqueLine: Mapped[str | None] = mapped_column(String, default=None)
    MatchId: Mapped[str | None] = mapped_column(String, default=None)
    RiotPlatformGameId: Mapped[str | None] = mapped_column(String, default=None)
    RiotPlatformId: Mapped[str | None] = mapped_column(String, default=None)
    RiotGameId: Mapped[str | None] = mapped_column(String, default=None)
    RiotHash: Mapped[str | None] = mapped_column(String, default=None)
    RiotVersion: Mapped[int | None] = mapped_column(Integer, default=None)
