artipy.artifacts

Submodules

artipy.artifacts.artifact module

Module containing the Artifact class.

class artipy.artifacts.artifact.Artifact[source]

Bases: object

Class representing an artifact in Genshin Impact.

add_substat(substat: SubStat) None[source]

Add a substat to the artifact. If the rarity of the artifact is greater than 0, set the rarity of the substat.

Parameters:

substat (artipy.stats.SubStat) – The substat to add.

property artifact_set: ArtifactSet | None

The artifact set of the artifact.

Returns:

The artifact set of the artifact.

Return type:

Optional[artipy.types.ArtifactSet]

property artifact_slot: ArtifactSlot | None

The artifact slot of the artifact.

Returns:

The artifact slot of the artifact.

Return type:

Optional[artipy.types.ArtifactSlot]

property level: int

The level of the artifact.

Returns:

The level of the artifact.

Return type:

int

property mainstat: MainStat | None

The mainstat of the artifact. Return a placeholder mainstat if the mainstat is None.

Returns:

The mainstat of the artifact.

Return type:

Optional[artipy.stats.MainStat]

property max_level: int
property rarity: int

The rarity of the artifact.

Returns:

The rarity of the artifact.

Return type:

int

property strategy: UpgradeStrategy

The upgrade strategy of the artifact. If the rarity is 1, the strategy inheriters are skipped in favor of the default strategy. Otherwise, if the number of substats is less than the rarity - 1, the add stat strategy is returned. Otherwise, the upgrade stat strategy is returned.

Returns:

The upgrade strategy of the artifact.

Return type:

artipy.artifacts.UpgradeStrategy

property substats: list[SubStat]

The substats of the artifact.

Returns:

The substats of the artifact.

Return type:

list[artipy.stats.SubStat]

upgrade() None[source]

Upgrade the artifact.

artipy.artifacts.builder module

Builder class for creating an Artifact object.

class artipy.artifacts.builder.ArtifactBuilder[source]

Bases: object

Builder class for creating an Artifact object.

Parameters:
  • with_mainstat (-) – Set the mainstat of the artifact

  • with_substat (-) – Add a substat to the artifact

  • with_substats (-) – Add multiple substats to the artifact

  • with_level (-) – Set the level of the artifact

  • with_rarity (-) – Set the rarity of the artifact

  • with_set (-) – Set the artifact set

  • with_slot (-) – Set the artifact slot

- build

Build the artifact object based on the parameters passed into the builder.

build() Artifact[source]

Build the artifact object based on the parameters passed into the builder.

Returns:

The artifact object

Return type:

artipy.artifacts.Artifact

with_level(level: int) ArtifactBuilder[source]

Set the level of the artifact. The level determines the value of the mainstat.

Parameters:

level (int) – The level to set.

Raises:
  • ValueError – If the level is not within the valid range

  • ValueError – If there is a substat length mismatch with the rarity

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_mainstat(stat: StatType, value: float | int = 0) ArtifactBuilder[source]

Set the mainstat of the artifact.

Parameters:
  • stat (artipy.types.StatType) – The mainstat to set.

  • value (float | int, optional) – The value of the mainstat. Defaults to 0.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_rarity(rarity: int) ArtifactBuilder[source]

Set the rarity of the artifact. The rarity determines the number of substats.

Parameters:

rarity (int) – The rarity to set.

Raises:
  • ValueError – If the number of substats exceeds the rarity of the artifact

  • ValueError – If the rarity is not within the valid range

  • ValueError – If the substats are already full

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_set(artifact_set: ArtifactSet) ArtifactBuilder[source]

Set the artifact set.

Parameters:

artifact_set (artipy.types.ArtifactSet) – The artifact set to set.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_slot(artifact_slot: ArtifactSlot) ArtifactBuilder[source]

Set the artifact slot.

Parameters:

artifact_slot (artipy.types.ArtifactSlot) – The artifact slot to set.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_substat(stat: StatType, value: float | int) ArtifactBuilder[source]

Set a single substat of the artifact.

Parameters:
Raises:

ValueError – If the substats are already full

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_substats(substats: list[tuple[StatType, float | int]] | None = None, *, amount: int = 0) ArtifactBuilder[source]

Set the substats of the artifact. If no substats are provided, generate random substats based on the rarity of the artifact.

Parameters:
  • substats (list[tuple[artipy.types.StatType, float | int]], optional) – The substats to set. Defaults to None.

  • amount (int, optional) – The amount of stats to generate. Defaults to 0.

Raises:
  • ValueError – If the amount is not within the valid range

  • ValueError – If the number of substats exceeds the rarity of the artifact

Returns:

The artifact builder object

Return type:

ArtifactBuilder

artipy.artifacts.upgrade_strategy module

This module contains classes for upgrading artifacts.

class artipy.artifacts.upgrade_strategy.AddStatStrategy[source]

Bases: UpgradeStrategy

A Strategy class for adding a new substat to an artifact.

This strategy is used when initially creating an artifact and when an artifact is capable of generating a new substat.

pick_stat(artifact: Artifact) SubStat[source]

Pick a new substat for the artifact.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to pick a substat for.

Returns:

The new substat to add to the artifact.

Return type:

artipy.stats.SubStat

upgrade(artifact: Artifact) None[source]

Upgrade the artifact. If the artifact level is divisible by the upgrade step, add a new substat to the artifact.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to upgrade.

class artipy.artifacts.upgrade_strategy.UpgradeStatStrategy[source]

Bases: UpgradeStrategy

A Strategy class for upgrading a substat on an artifact.

This strategy is used when an artifact is capable of upgrading a substat. The substat to upgrade is chosen randomly.

upgrade(artifact: Artifact) None[source]

Upgrade the artifact. If the artifact level is divisible by the upgrade step, upgrade a random substat on the artifact.

Parameters:

artifact (aritpy.artifacts.Artifact) – The artifact to upgrade.

class artipy.artifacts.upgrade_strategy.UpgradeStrategy[source]

Bases: object

A base Strategy class for upgrading artifacts.

upgrade(artifact: Artifact) None[source]

Upgrade the artifact’s level by one.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to upgrade.

artipy.artifacts.utils module

Utility functions for the artifacts module.

artipy.artifacts.utils.choose(population: tuple[Any], weights: tuple[float | int]) Any[source]

Helper function to choose a random element from a population with weights. This skips having to do slicing of the result of random.choices.

Parameters:
  • population (tuple[Any]) – The population to choose from.

  • weights (tuple[float | int]) – The weights of the population.

Returns:

The chosen element.

Return type:

Any

Module contents

Artifacts module.

class artipy.artifacts.AddStatStrategy[source]

Bases: UpgradeStrategy

A Strategy class for adding a new substat to an artifact.

This strategy is used when initially creating an artifact and when an artifact is capable of generating a new substat.

pick_stat(artifact: Artifact) SubStat[source]

Pick a new substat for the artifact.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to pick a substat for.

Returns:

The new substat to add to the artifact.

Return type:

artipy.stats.SubStat

upgrade(artifact: Artifact) None[source]

Upgrade the artifact. If the artifact level is divisible by the upgrade step, add a new substat to the artifact.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to upgrade.

class artipy.artifacts.Artifact[source]

Bases: object

Class representing an artifact in Genshin Impact.

add_substat(substat: SubStat) None[source]

Add a substat to the artifact. If the rarity of the artifact is greater than 0, set the rarity of the substat.

Parameters:

substat (artipy.stats.SubStat) – The substat to add.

property artifact_set: ArtifactSet | None

The artifact set of the artifact.

Returns:

The artifact set of the artifact.

Return type:

Optional[artipy.types.ArtifactSet]

property artifact_slot: ArtifactSlot | None

The artifact slot of the artifact.

Returns:

The artifact slot of the artifact.

Return type:

Optional[artipy.types.ArtifactSlot]

property level: int

The level of the artifact.

Returns:

The level of the artifact.

Return type:

int

property mainstat: MainStat | None

The mainstat of the artifact. Return a placeholder mainstat if the mainstat is None.

Returns:

The mainstat of the artifact.

Return type:

Optional[artipy.stats.MainStat]

property max_level: int
property rarity: int

The rarity of the artifact.

Returns:

The rarity of the artifact.

Return type:

int

property strategy: UpgradeStrategy

The upgrade strategy of the artifact. If the rarity is 1, the strategy inheriters are skipped in favor of the default strategy. Otherwise, if the number of substats is less than the rarity - 1, the add stat strategy is returned. Otherwise, the upgrade stat strategy is returned.

Returns:

The upgrade strategy of the artifact.

Return type:

artipy.artifacts.UpgradeStrategy

property substats: list[SubStat]

The substats of the artifact.

Returns:

The substats of the artifact.

Return type:

list[artipy.stats.SubStat]

upgrade() None[source]

Upgrade the artifact.

class artipy.artifacts.ArtifactBuilder[source]

Bases: object

Builder class for creating an Artifact object.

Parameters:
  • with_mainstat (-) – Set the mainstat of the artifact

  • with_substat (-) – Add a substat to the artifact

  • with_substats (-) – Add multiple substats to the artifact

  • with_level (-) – Set the level of the artifact

  • with_rarity (-) – Set the rarity of the artifact

  • with_set (-) – Set the artifact set

  • with_slot (-) – Set the artifact slot

- build

Build the artifact object based on the parameters passed into the builder.

build() Artifact[source]

Build the artifact object based on the parameters passed into the builder.

Returns:

The artifact object

Return type:

artipy.artifacts.Artifact

with_level(level: int) ArtifactBuilder[source]

Set the level of the artifact. The level determines the value of the mainstat.

Parameters:

level (int) – The level to set.

Raises:
  • ValueError – If the level is not within the valid range

  • ValueError – If there is a substat length mismatch with the rarity

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_mainstat(stat: StatType, value: float | int = 0) ArtifactBuilder[source]

Set the mainstat of the artifact.

Parameters:
  • stat (artipy.types.StatType) – The mainstat to set.

  • value (float | int, optional) – The value of the mainstat. Defaults to 0.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_rarity(rarity: int) ArtifactBuilder[source]

Set the rarity of the artifact. The rarity determines the number of substats.

Parameters:

rarity (int) – The rarity to set.

Raises:
  • ValueError – If the number of substats exceeds the rarity of the artifact

  • ValueError – If the rarity is not within the valid range

  • ValueError – If the substats are already full

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_set(artifact_set: ArtifactSet) ArtifactBuilder[source]

Set the artifact set.

Parameters:

artifact_set (artipy.types.ArtifactSet) – The artifact set to set.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_slot(artifact_slot: ArtifactSlot) ArtifactBuilder[source]

Set the artifact slot.

Parameters:

artifact_slot (artipy.types.ArtifactSlot) – The artifact slot to set.

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_substat(stat: StatType, value: float | int) ArtifactBuilder[source]

Set a single substat of the artifact.

Parameters:
Raises:

ValueError – If the substats are already full

Returns:

The artifact builder object

Return type:

ArtifactBuilder

with_substats(substats: list[tuple[StatType, float | int]] | None = None, *, amount: int = 0) ArtifactBuilder[source]

Set the substats of the artifact. If no substats are provided, generate random substats based on the rarity of the artifact.

Parameters:
  • substats (list[tuple[artipy.types.StatType, float | int]], optional) – The substats to set. Defaults to None.

  • amount (int, optional) – The amount of stats to generate. Defaults to 0.

Raises:
  • ValueError – If the amount is not within the valid range

  • ValueError – If the number of substats exceeds the rarity of the artifact

Returns:

The artifact builder object

Return type:

ArtifactBuilder

class artipy.artifacts.ArtifactSlot(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Enum representing the artifact slots in Genshin Impact.

CIRCLET = 'circlet'
FLOWER = 'flower'
GOBLET = 'goblet'
PLUME = 'plume'
SANDS = 'sands'
static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

class artipy.artifacts.UpgradeStatStrategy[source]

Bases: UpgradeStrategy

A Strategy class for upgrading a substat on an artifact.

This strategy is used when an artifact is capable of upgrading a substat. The substat to upgrade is chosen randomly.

upgrade(artifact: Artifact) None[source]

Upgrade the artifact. If the artifact level is divisible by the upgrade step, upgrade a random substat on the artifact.

Parameters:

artifact (aritpy.artifacts.Artifact) – The artifact to upgrade.

class artipy.artifacts.UpgradeStrategy[source]

Bases: object

A base Strategy class for upgrading artifacts.

upgrade(artifact: Artifact) None[source]

Upgrade the artifact’s level by one.

Parameters:

artifact (artipy.artifacts.Artifact) – The artifact to upgrade.