from dataclasses import dataclass
from enum import Enum
from typing import Self

from src.ezgg_lan_manager.types.User import User

class TeamStatus(Enum):
    MEMBER = 0
    OFFICER = 1
    LEADER = 2

    @classmethod
    def from_str(cls, team_status: str) -> Self:
        if team_status == "MEMBER":
            return TeamStatus.MEMBER
        elif team_status == "OFFICER":
            return TeamStatus.OFFICER
        elif team_status == "LEADER":
            return TeamStatus.LEADER
        raise ValueError


@dataclass(frozen=True)
class Team:
    id: int
    name: str
    abbreviation: str
    members: dict[User, TeamStatus]
    join_password: str

    def __hash__(self) -> int:
        return hash(self.id)

    def __eq__(self, other):
        if not isinstance(other, Team):
            return NotImplemented
        return self.id == other.id
