Module genshin.models.honkai.chronicle.modes

Honkai battle chronicle models.

Classes

class Boss (**data: Any)

Represents a Boss encountered in Abyss or Memorial Arena.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class Boss(APIModel, Unique):
    """Represents a Boss encountered in Abyss or Memorial Arena."""

    id: int
    name: str
    icon: str = Aliased("avatar")

    @pydantic.field_validator("icon")
    def __fix_url(cls, url: str) -> str:
        # I noticed that sometimes the urls are returned incorrectly, which appears to be
        # a problem on the hoyolab website too, so I expect this to be fixed sometime.
        # For now, this hotfix seems to work.
        return re.sub(r"/boss_\d+\.", lambda m: str.upper(m[0]), url, flags=re.IGNORECASE)

Ancestors

Class variables

var icon : str
var id : int
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var name : str
class ELF (**data: Any)

Represents an ELF equipped for a battle.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class ELF(APIModel, Unique):
    """Represents an ELF equipped for a battle."""

    id: int
    name: str
    icon: str = Aliased("avatar")
    rarity: str
    upgrade_level: int = Aliased("star")

    @pydantic.field_validator("rarity", mode="before")
    def __fix_rank(cls, rarity: typing.Union[int, str]) -> str:
        if isinstance(rarity, str):
            return rarity

        # ELFs come in rarities A and S, API returns 4 and 5, respectively
        return ["A", "S"][rarity - 4]

Ancestors

Class variables

var icon : str
var id : int
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var name : str
var rarity : str
var upgrade_level : int
class ElysianRealm (**data: Any)

Represents one completed run of Elysean Realms.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class ElysianRealm(APIModel):
    """Represents one completed run of Elysean Realms."""

    completed_at: datetime.datetime = Aliased("settle_time_second")
    floors_cleared: int = Aliased("level")
    score: int
    difficulty: int = Aliased("punish_level")
    conditions: typing.Sequence[Condition]
    signets: typing.Sequence[Signet] = Aliased("buffs")
    leader: battlesuit.Battlesuit = Aliased("main_avatar")
    supports: typing.Sequence[battlesuit.Battlesuit] = Aliased("support_avatars")
    elf: typing.Optional[ELF]
    remembrance_sigil: RemembranceSigil = Aliased("extra_item_icon")

    @pydantic.field_validator("remembrance_sigil", mode="before")
    def __extend_sigil(cls, sigil: typing.Any) -> typing.Any:
        if isinstance(sigil, str):
            return dict(icon=sigil)

        return sigil

    @property
    def lineup(self) -> typing.Sequence[battlesuit.Battlesuit]:
        return [self.leader, *self.supports]

Ancestors

Class variables

var completed_at : datetime.datetime
var conditions : Sequence[genshin.models.honkai.chronicle.modes.Condition]
var difficulty : int
var elf : Optional[ELF]
var floors_cleared : int
var leaderBattlesuit
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var remembrance_sigil : genshin.models.honkai.chronicle.modes.RemembranceSigil
var score : int
var signets : Sequence[genshin.models.honkai.chronicle.modes.Signet]
var supports : Sequence[Battlesuit]

Instance variables

prop lineup : typing.Sequence[battlesuit.Battlesuit]
Expand source code
@property
def lineup(self) -> typing.Sequence[battlesuit.Battlesuit]:
    return [self.leader, *self.supports]
class MemorialArena (**data: Any)

Represents aggregate weekly performance for the entire Memorial Arena rotation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class MemorialArena(APIModel):
    """Represents aggregate weekly performance for the entire Memorial Arena rotation."""

    score: int
    ranking: float = Aliased("ranking_percentage")
    raw_rank: int = Aliased("rank")
    raw_tier: int = Aliased("area")
    end_time: datetime.datetime = Aliased("time_second")
    battle_data: typing.Sequence[MemorialBattle] = Aliased("battle_infos")

    @property
    def rank(self) -> str:
        """The user's Memorial Arena rank as displayed in-game."""
        return prettify_MA_rank(self.raw_rank)

Ancestors

Class variables

var battle_data : Sequence[MemorialBattle]
var end_time : datetime.datetime
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var ranking : float
var raw_rank : int
var raw_tier : int
var score : int

Instance variables

prop rank : str

The user's Memorial Arena rank as displayed in-game.

Expand source code
@property
def rank(self) -> str:
    """The user's Memorial Arena rank as displayed in-game."""
    return prettify_MA_rank(self.raw_rank)
class MemorialBattle (**data: Any)

Represents weekly performance against a single Memorial Arena boss.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class MemorialBattle(APIModel):
    """Represents weekly performance against a single Memorial Arena boss."""

    score: int
    lineup: typing.Sequence[battlesuit.Battlesuit]
    elf: typing.Optional[ELF]
    boss: Boss

Ancestors

Class variables

var bossBoss
var elf : Optional[ELF]
var lineup : Sequence[Battlesuit]
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var score : int
class OldAbyss (**data: Any)

Represents once cycle of Quantum Singularis or Dirac Sea.

Exclusive to players of level 80 and below.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class OldAbyss(BaseAbyss):
    """Represents once cycle of Quantum Singularis or Dirac Sea.

    Exclusive to players of level 80 and below.
    """

    end_time: datetime.datetime = Aliased("time_second")
    raw_type: str = Aliased("type")
    result: str = Aliased("reward_type")
    raw_rank: int = Aliased("level")

    @pydantic.field_validator("raw_rank", mode="before")
    def __normalize_level(cls, rank: str) -> int:
        # The latestOldAbyssReport endpoint returns ranks as D/C/B/A,
        # while newAbyssReport returns them as 1/2/3/4(/5) respectively.
        # Having them as ints at base seems more useful than strs.
        # (in-game, they use the same names (Sinful, Agony, etc.))
        if isinstance(rank, int):
            return rank

        return 69 - ord(rank)

Ancestors

  • genshin.models.honkai.chronicle.modes.BaseAbyss
  • APIModel
  • pydantic.main.BaseModel

Class variables

var end_time : datetime.datetime
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var raw_rank : int
var raw_type : str
var result : str
class SuperstringAbyss (**data: Any)

Represents one cycle of Superstring Abyss, exclusive to players of level 81 and up.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class SuperstringAbyss(BaseAbyss):
    """Represents one cycle of Superstring Abyss, exclusive to players of level 81 and up."""

    # NOTE endpoint: game_record/honkai3rd/api/latestOldAbyssReport

    end_time: datetime.datetime = Aliased("updated_time_second")
    raw_tier: int = 4  # Not returned by API, always the case
    placement: int = Aliased("rank")
    trophies_gained: int = Aliased("settled_cup_number")
    end_trophies: int = Aliased("cup_number")
    raw_start_rank: int = Aliased("level")
    raw_end_rank: int = Aliased("settled_level")

    @property
    def start_trophies(self) -> int:
        return self.end_trophies - self.trophies_gained

Ancestors

  • genshin.models.honkai.chronicle.modes.BaseAbyss
  • APIModel
  • pydantic.main.BaseModel

Class variables

var end_time : datetime.datetime
var end_trophies : int
var model_computed_fields
var model_config : pydantic.config.ConfigDict
var model_fields
var placement : int
var raw_end_rank : int
var raw_start_rank : int
var raw_tier : int
var trophies_gained : int

Instance variables

prop start_trophies : int
Expand source code
@property
def start_trophies(self) -> int:
    return self.end_trophies - self.trophies_gained