artipy.stats

Submodules

artipy.stats.mainstat module

Mainstat dataclass for a Genshin Impact artifact.

class artipy.stats.mainstat.MainStat(name: StatType, _value: float | int | Decimal = Decimal('0'), rarity: int = 5)[source]

Bases: Stat

Mainstat dataclass for a Genshin Impact artifact.

rarity: int
set_value_by_level(level: int) None[source]

Set the value of the mainstat based on the level of the artifact.

Parameters:

level (int) – The level of the artifact.

artipy.stats.stats module

Stat types and data for Genshin Impact artifacts.

class artipy.stats.stats.Stat(name: StatType, _value: float | int | Decimal = Decimal('0'))[source]

Bases: object

Dataclass for a stat in Genshin Impact.

name: StatType
property value: Decimal

Get the value of the stat.

Returns:

The value of the stat.

Return type:

Decimal

artipy.stats.substat module

Substats for Genshin Impact artifacts.

class artipy.stats.substat.SubStat(name: StatType, _value: float | int | Decimal = Decimal('0'), rarity: int = 5)[source]

Bases: Stat

Substat dataclass for a Genshin Impact artifact.

rarity: int
roll() Decimal[source]

Roll a random value for the substat. This is used when initially creating the substat and when upgrading it.

Returns:

A random value for the substat.

Return type:

Decimal

upgrade() None[source]
artipy.stats.substat.create_substat(*, name: StatType = StatType.DEF_PERCENT, rarity: int) SubStat[source]

Create a new SubStat object.

The stat type is either randomly chosen or specified. The rarity is required to determine the possible values for the substat.

Parameters:
  • name (StatType, optional) – The stat name, defaults to random.choice(StatType)

  • rarity (int) – The rarity of the artifact

Returns:

A new SubStat object

Return type:

SubStat

artipy.stats.utils module

Utilities for stats module.

artipy.stats.utils.map_to_decimal(values: Iterable[float | int]) tuple[Decimal, ...][source]

Map the values to Decimal.

Parameters:

values (Iterable[float | int]) – The values to map.

Returns:

The mapped values.

Return type:

tuple[Decimal, …]

artipy.stats.utils.possible_mainstat_values(stat: StatType, rarity: int) tuple[Decimal, ...][source]

Get the possible values for a mainstat based on the stat type and rarity. Map the values to Decimal.

Parameters:
  • stat (StatType) – The stat type to get the values for.

  • rarity (int) – The rarity of the artifact.

Returns:

The possible values for the mainstat.

Return type:

tuple[Decimal, …]

artipy.stats.utils.possible_substat_values(stat: StatType, rarity: int) tuple[Decimal, ...][source]

Get the possible values for a substat based on the stat type and rarity. Map the values to Decimal.

Parameters:
  • stat (StatType) – The stat type to get the values for.

  • rarity (int) – The rarity of the artifact.

Returns:

The possible values for the substat.

Return type:

tuple[Decimal, …]

Module contents

Module for handling stats and their data.

class artipy.stats.MainStat(name: StatType, _value: float | int | Decimal = Decimal('0'), rarity: int = 5)[source]

Bases: Stat

Mainstat dataclass for a Genshin Impact artifact.

rarity: int
set_value_by_level(level: int) None[source]

Set the value of the mainstat based on the level of the artifact.

Parameters:

level (int) – The level of the artifact.

class artipy.stats.SubStat(name: StatType, _value: float | int | Decimal = Decimal('0'), rarity: int = 5)[source]

Bases: Stat

Substat dataclass for a Genshin Impact artifact.

rarity: int
roll() Decimal[source]

Roll a random value for the substat. This is used when initially creating the substat and when upgrading it.

Returns:

A random value for the substat.

Return type:

Decimal

upgrade() None[source]
artipy.stats.create_substat(*, name: StatType = StatType.DEF_PERCENT, rarity: int) SubStat[source]

Create a new SubStat object.

The stat type is either randomly chosen or specified. The rarity is required to determine the possible values for the substat.

Parameters:
  • name (StatType, optional) – The stat name, defaults to random.choice(StatType)

  • rarity (int) – The rarity of the artifact

Returns:

A new SubStat object

Return type:

SubStat