Skip to content

Team

Represents a team in a match.

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class Team:
    """Represents a team in a match."""

    team_id: int
    """Team identifier (100 for blue, 200 for red)."""

    win: bool
    """Whether this team won the match."""

    bans: list[Ban] | None = None
    """List of champion bans for this team. May be None for some game modes."""

    objectives: Objectives | None = None
    """Objectives taken by this team. May be None for some game modes."""

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "Team":
        """Create Team from API response."""
        return cls(
            team_id=data["teamId"],
            win=data["win"],
            bans=[Ban.from_api_response(ban) for ban in data.get("bans", [])],
            objectives=Objectives.from_api_response(obj_data) if (obj_data := data.get("objectives")) else None,
        )

bans = None class-attribute instance-attribute

List of champion bans for this team. May be None for some game modes.

objectives = None class-attribute instance-attribute

Objectives taken by this team. May be None for some game modes.

team_id instance-attribute

Team identifier (100 for blue, 200 for red).

win instance-attribute

Whether this team won the match.

from_api_response(data) classmethod

Create Team from API response.

Source code in nexar/models/match/team.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "Team":
    """Create Team from API response."""
    return cls(
        team_id=data["teamId"],
        win=data["win"],
        bans=[Ban.from_api_response(ban) for ban in data.get("bans", [])],
        objectives=Objectives.from_api_response(obj_data) if (obj_data := data.get("objectives")) else None,
    )

Enhanced team information with participants and aggregated stats.

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class TeamInfo:
    """Enhanced team information with participants and aggregated stats."""

    team_id: int
    """Team identifier (100 for blue, 200 for red)."""

    win: bool
    """Whether this team won the match."""

    bans: list[Ban]
    """List of champion bans for this team."""

    objectives: Objectives
    """Objectives taken by this team."""

    participants: list["Participant"]
    """List of participants on this team."""

    @property
    def total_damage(self) -> int:
        """Total damage dealt to champions by all team members."""
        return sum(p.total_damage_dealt_to_champions for p in self.participants)

    @property
    def total_damage_taken(self) -> int:
        """Total damage taken by all team members."""
        return sum(p.total_damage_taken for p in self.participants)

    @property
    def total_gold_earned(self) -> int:
        """Total gold earned by all team members."""
        return sum(p.gold_earned for p in self.participants)

    @property
    def total_kills(self) -> int:
        """Total kills by all team members."""
        return sum(p.kills for p in self.participants)

    @property
    def total_deaths(self) -> int:
        """Total deaths by all team members."""
        return sum(p.deaths for p in self.participants)

    @property
    def total_assists(self) -> int:
        """Total assists by all team members."""
        return sum(p.assists for p in self.participants)

    @property
    def total_vision_score(self) -> int:
        """Total vision score by all team members."""
        return sum(p.vision_score for p in self.participants)

bans instance-attribute

List of champion bans for this team.

objectives instance-attribute

Objectives taken by this team.

participants instance-attribute

List of participants on this team.

team_id instance-attribute

Team identifier (100 for blue, 200 for red).

total_assists property

Total assists by all team members.

total_damage property

Total damage dealt to champions by all team members.

total_damage_taken property

Total damage taken by all team members.

total_deaths property

Total deaths by all team members.

total_gold_earned property

Total gold earned by all team members.

total_kills property

Total kills by all team members.

total_vision_score property

Total vision score by all team members.

win instance-attribute

Whether this team won the match.

Container for blue and red team information.

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class TeamsInfo:
    """Container for blue and red team information."""

    blue: TeamInfo
    """Information for the blue side team (team_id=100)."""

    red: TeamInfo
    """Information for the red side team (team_id=200)."""

    def __iter__(self) -> Iterator[TeamInfo]:
        """Allow iteration over teams."""
        yield self.blue
        yield self.red

blue instance-attribute

Information for the blue side team (team_id=100).

red instance-attribute

Information for the red side team (team_id=200).

__iter__()

Allow iteration over teams.

Source code in nexar/models/match/team.py
def __iter__(self) -> Iterator[TeamInfo]:
    """Allow iteration over teams."""
    yield self.blue
    yield self.red

Represents a champion ban.

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class Ban:
    """Represents a champion ban."""

    champion_id: int
    """ID of the banned champion."""

    pick_turn: int
    """The pick/ban turn number when this ban occurred."""

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "Ban":
        """Create Ban from API response."""
        return cls(
            champion_id=data["championId"],
            pick_turn=data["pickTurn"],
        )

champion_id instance-attribute

ID of the banned champion.

pick_turn instance-attribute

The pick/ban turn number when this ban occurred.

from_api_response(data) classmethod

Create Ban from API response.

Source code in nexar/models/match/team.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "Ban":
    """Create Ban from API response."""
    return cls(
        champion_id=data["championId"],
        pick_turn=data["pickTurn"],
    )

Represents an objective (baron, dragon, etc.).

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class Objective:
    """Represents an objective (baron, dragon, etc.)."""

    first: bool
    """Whether this objective was taken first by the team."""

    kills: int
    """Number of times this objective was taken by the team."""

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "Objective":
        """Create Objective from API response."""
        return cls(
            first=data["first"],
            kills=data["kills"],
        )

first instance-attribute

Whether this objective was taken first by the team.

kills instance-attribute

Number of times this objective was taken by the team.

from_api_response(data) classmethod

Create Objective from API response.

Source code in nexar/models/match/team.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "Objective":
    """Create Objective from API response."""
    return cls(
        first=data["first"],
        kills=data["kills"],
    )

Represents team objectives.

Source code in nexar/models/match/team.py
@dataclass(frozen=True)
class Objectives:
    """Represents team objectives."""

    baron: Objective
    """Baron Nashor objective stats."""

    champion: Objective
    """Champion takedown objective stats."""

    dragon: Objective
    """Dragon objective stats."""

    horde: Objective
    """TODO"""

    inhibitor: Objective
    """Inhibitor objective stats."""

    rift_herald: Objective
    """Rift Herald objective stats."""

    tower: Objective
    """Tower objective stats."""

    @classmethod
    def from_api_response(cls, data: dict[str, Any]) -> "Objectives":
        """Create Objectives from API response."""
        return cls(
            baron=Objective.from_api_response(data["baron"]),
            champion=Objective.from_api_response(data["champion"]),
            dragon=Objective.from_api_response(data["dragon"]),
            horde=Objective.from_api_response(data["horde"]),
            inhibitor=Objective.from_api_response(data["inhibitor"]),
            rift_herald=Objective.from_api_response(data["riftHerald"]),
            tower=Objective.from_api_response(data["tower"]),
        )

baron instance-attribute

Baron Nashor objective stats.

champion instance-attribute

Champion takedown objective stats.

dragon instance-attribute

Dragon objective stats.

horde instance-attribute

TODO

inhibitor instance-attribute

Inhibitor objective stats.

rift_herald instance-attribute

Rift Herald objective stats.

tower instance-attribute

Tower objective stats.

from_api_response(data) classmethod

Create Objectives from API response.

Source code in nexar/models/match/team.py
@classmethod
def from_api_response(cls, data: dict[str, Any]) -> "Objectives":
    """Create Objectives from API response."""
    return cls(
        baron=Objective.from_api_response(data["baron"]),
        champion=Objective.from_api_response(data["champion"]),
        dragon=Objective.from_api_response(data["dragon"]),
        horde=Objective.from_api_response(data["horde"]),
        inhibitor=Objective.from_api_response(data["inhibitor"]),
        rift_herald=Objective.from_api_response(data["riftHerald"]),
        tower=Objective.from_api_response(data["tower"]),
    )