Characters
from dgisim import 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.
- class Characters(characters: tuple[Character, ...], active_character_id: None | int)
A class for holding characters.
It always assumes n characters are numbered from 1 to n from left to right.
- factory() CharactersFactory
- Returns:
a factory for the current game state.
- find_first_character(char_type: type[Character]) None | Character
- Returns:
the first character (from left to right) that is of char_type.
- classmethod from_default(characters: tuple[Character, ...]) Characters
Same as Characters(characters, None).
- classmethod from_iterable(characters: Iterable[type[Character]]) Characters
- Returns:
characters with auto-assigned ids. (1 to n from left to right), active_character_id is None.
- get_alive_character_in_activity_order() tuple[Character, ...]
- Returns:
the ordered tuple of alive characters based on their activity.
Same as .get_character_in_activity_order() but filters out defeated characters.
- get_alive_character_in_activity_order_last_active() tuple[Character, ...]
- Returns:
the ordered tuple of alive characters based on their activity.
Same as .get_alive_character_in_activity_order() but the active character is ranked the last.
- get_character(id: int) None | Character
- Returns:
character with id. None is returned if id is not found.
- get_character_in_activity_order() tuple[Character, ...]
- Returns:
the ordered tuple of characters based on their activity.
The order is starting from the active character, count from left to right. If among characters (1, 2, 3), 2 is the active character, (2, 3, 1) is returned.
- get_character_ordered_from_id(char_id: int) tuple[Character, ...]
- Returns:
the ordered characters starting from char_id. (left to right)
- get_id(character: Character) None | int
- Returns:
the id of the character.
The exact same characer object needs to be in the characters.
- get_none_active_characters() tuple[Character, ...]
- Returns:
the none active characters (from left to right)
- get_nth_next_alive_character_in_activity_order(n: int) Character
- Returns:
the nth alive character after the active one.
- get_nth_prev_alive_character_in_activity_order(n: int) Character
- Returns:
the nth alive character before the active one.
- just_get_active_character() Character
- Returns:
the active character. If there is not one, an exception is thrown.
- just_get_active_character_id() int
- Returns:
the active character’s id. If the id is None, an exception is thrown.