Character

Character class is the base of all implemented characters.

__eq__ and __hash__ are implemented so that any two characters with the equivalent content are equal to each other and have the same hash.

from dgisim import Character
class Character(id: int, alive: bool, hp: int, max_hp: int, energy: int, max_energy: int, hiddens: Statuses, statuses: Statuses, elemental_aura: ElementalAura)

The base class for all characters.

__init__(id: int, alive: bool, hp: int, max_hp: int, energy: int, max_energy: int, hiddens: Statuses, statuses: Statuses, elemental_aura: ElementalAura)
Parameters:
  • id – the unique identifier to distinguish from other characters of the same player.

  • alive – used to indicate if the character is marked as defeated.

  • hp – current hp.

  • max_hp – maximum hp.

  • energy – current energy.

  • hiddens – hidden statuses.

  • statuses – character statuses.

  • aura – elemental aura.

Returns:

a new instance of the character.

factory() CharacterFactory
Returns:

a factory for the current character.

The factory allows modifications to the existing a copy of the origial character to produce a new one.

You may call .<attribute-name>(new_val) to replace the current value.

Or call .f_<attribute-name>(<function>) to make modifications based on the current value.

e.g. character.factory().f_hp(lambda h: h - 1).alive(False).build() returns a new character with 1 less hp and marked defeated.

property alive: bool
Returns:

the boolean value indicating if the character is actually defeated. This is different from hp being 0.

e.g. when Keqing’s burst kills the next character and overloads to them, they can still be swapped out. But a character that has been defeated long ago cannot be overloaded out. In this case the just defeated characters are still marked as alive despite hp being 0, and alive turns False at a later time.

can_cast_skill() bool
Returns:

if skills can be casted.

A character cannot cast skill when it is frozen, petrified or defeated.

property character_statuses: Statuses
Returns:

the character statuses.

property elemental_aura: ElementalAura
Returns:

the elemental aura.

encoding(encoding_plan: EncodingPlan) list[int]
Returns:

the encoding of this character.

property energy: int
Returns:

the current energy.

abstract classmethod from_default(id: int = -1) Character
Parameters:

id – the id of the character. If not provided, a default id is used. Note that the default id may conflict with other characters for a game.

Returns:

the default state of a character. Usually used to initialize a new instance of the character.

get_all_statuses_ordered() list[dgisim.status.statuses.Statuses]
Returns:

a list of Statuses that are ordered so that those that should be executed first has a lower index.

get_all_statuses_ordered_flattened() tuple[dgisim.status.status.Status, ...]
Returns:

a tuple of statuses that are ordered so that those that should be executed first has a lower index.

property hidden_statuses: Statuses
Returns:

the hidden statuses.

Hidden statuses are the statues that belongs to the character but invisible in the game.

e.g. Ganyu’s talent deals more damage if Ganyu casted Frost Arrow before. So Ganyu needs a hidden status to record that information.

property hp: int
Returns:

the current hp.

hp_lost() int
Returns:

the lost hp.

property id: int
Returns:

the id as an unique identifier for a character of a player.

Typically, when a player has n characters, each character is assigned an id from 1 to n from left to right.

is_alive() bool

Same as .alive.

is_defeated() bool

Negation of .alive.

property max_energy: int
Returns:

the maximum energy.

property max_hp: int
Returns:

the maximum hp.

name() str
Returns:

name of the character (without breaks).

classmethod of_faction(faction: Faction) bool
Returns:

if this character belongs to the faction.

satiated() bool
Returns:

if character is satiated.

skill(game_state: GameState, source: StaticTarget, skill_type: CharacterSkill) tuple[eft.Effect, ...]
Parameters:
  • game_state – current game state when the skill is casted.

  • source – location information of this character.

  • skill_type – the skill that is to be casted.

Returns:

the effects of the skill in the context.

This should only be called to get effects right before the skill is to be executed. Otherwise faulty effects may be generated.

classmethod skill_actual_type(skill: CharacterSkill) CharacterSkillType
Returns:

the type of skill the character’s skill is. e.g. Ganyu’s Frost Arrow (SKILL3) is of type Normal Attack.

classmethod skill_cost(skill_type: CharacterSkill) AbstractDice
Returns:

the basic dice cost of skill_type.

skill_energy_cost(skill_type: CharacterSkill) int
Returns:

the basic energy cost of skill_type.

classmethod skills() tuple[dgisim.character.enums.CharacterSkill, ...]
Returns:

the skill types the character supports

talent_equipped() bool
Returns:

if the talent is equipped.