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, equipments: EquipmentStatuses, 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, equipments: EquipmentStatuses, 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.

  • equipments – equipment 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.

classmethod ELEMENT() Element
Returns:

the element of the character.

classmethod FACTIONS() frozenset[dgisim.character.enums.Faction]
Returns:

the set of factions the character belongs to.

classmethod WEAPON_TYPE() WeaponType
Returns:

the type of weapon the character wields.

alive() bool

Same as .get_alive().

can_cast_skill() bool
Returns:

if skills can be casted.

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

defeated() bool

Negation of .alive().

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

the encoding of this character.

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

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

get_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.

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.

get_character_statuses() Statuses
Returns:

the character statuses.

get_elemental_aura() ElementalAura
Returns:

the elemental aura.

get_energy() int
Returns:

the current energy.

get_equipment_statuses() EquipmentStatuses
Returns:

the equipment statuses.

get_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.

get_hp() int
Returns:

the current hp.

get_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.

get_max_energy() int
Returns:

the maximum energy.

get_max_hp() int
Returns:

the maximum hp.

hp_lost() int
Returns:

the lost 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.