gchar.games.base¶
- Overview:
Character basic modeling, including the character model itself, the character name, the character gender, and the character skins.
Character¶
-
class
gchar.games.base.
Character
[source]¶ Base class for modeling characters in different games.
The class provides methods for accessing and managing character attributes, such as name, gender, skins, etc. It also provides class methods for retrieving and listing characters.
Usage: - Inherit from the gchar.games.base.Character class and implement the required methods to customize the character model.
- Variables:
__repository__ – The repository name for the character data.
__game_name__ – The name of the game.
__official_name__ – The official name of the character.
__cnname_class__ – The class for modeling Chinese character names.
__enname_class__ – The class for modeling English character names.
__jpname_class__ – The class for modeling Japanese character names.
__alias_name_class__ – The optional class for modeling alias names.
-
property
alias_names
¶ Get all alias names of the character.
- Returns:
The alias names of the character.
- Return type:
List[Union[gchar.games.base.ChineseName, gchar.games.base.GenericAliasName]]
-
classmethod
all
(contains_extra: bool = True, sorted: bool = True) → List[source]¶ Get all characters.
- Parameters:
contains_extra (bool) – Whether to include extra characters in the result.
sorted (bool) – Whether to sort the characters by order.
- Returns:
All characters.
- Return type:
-
property
cnname
¶ Get the Chinese name of the character.
- Returns:
The Chinese name of the character.
- Return type:
-
property
cnnames
¶ Get additional Chinese names of the character.
- Returns:
The additional Chinese names of the character.
- Return type:
-
property
enname
¶ Get the English name of the character.
- Returns:
The English name of the character.
- Return type:
-
property
ennames
¶ Get additional English names of the character.
- Returns:
The additional English names of the character.
- Return type:
-
property
gender
¶ Get the gender of the character.
- Returns:
The gender of the character.
- Return type:
-
classmethod
get
(name, **kwargs)[source]¶ Get a character by name.
- Parameters:
name (str) – The name of the character.
- Returns:
The character with the given name, or None if not found.
- Return type:
Optional[gchar.games.base.Character]
-
property
index
¶ Get the index of the character.
- Returns:
The index of the character.
- Return type:
Any
-
property
is_extra
¶ Check if the character is an extra character.
- Returns:
True if the character is an extra character, False otherwise.
- Return type:
bool
-
property
jpname
¶ Get the Japanese name of the character.
- Returns:
The Japanese name of the character.
- Return type:
-
property
jpnames
¶ Get additional Japanese names of the character.
- Returns:
The additional Japanese names of the character.
- Return type:
-
property
names
¶ Get all names of the character as strings.
- Returns:
The names of the character.
- Return type:
List[str]
-
property
release_time
¶ Get the release time of the character.
- Returns:
The release time of the character as a UNIX timestamp, or None if unknown.
- Return type:
Optional[float]
list_all_characters¶
-
gchar.games.base.
list_all_characters
(*chs: Union[gchar.games.base.character.Character, list, tuple, Type[gchar.games.base.character.Character]], **kwargs) → List[gchar.games.base.character.Character][source]¶ List all characters.
- Parameters:
chs (Union[gchar.games.base.Character, list, tuple, Type[gchar.games.base.Character]]) – The characters or lists of characters.
contains_extra (bool) – Whether to include extra characters in the result.
- Returns:
All characters.
- Return type:
ChineseName¶
-
class
gchar.games.base.
ChineseName
(name: str)[source]¶ Class for modeling Chinese character names.
The class inherits from TextName and represents character names written in Chinese.
Usage: - Use the ChineseName class to model Chinese character names.
- Parameters:
name (str) – The name of the character.
EnglishName¶
-
class
gchar.games.base.
EnglishName
(name: Union[str, List[str]])[source]¶ Class for modeling English character names.
The class inherits from SegmentName and represents character names written in English.
Usage: - Use the EnglishName class to model English character names.
- Parameters:
name (Union[SegmentName, TextName, str, List[str]]) – The name of the character.
JapaneseName¶
-
class
gchar.games.base.
JapaneseName
(name: str)[source]¶ Class for modeling Japanese character names.
The class inherits from TextName and represents character names written in Japanese.
Usage: - Use the JapaneseName class to model Japanese character names.
- Parameters:
name (str) – The name of the character.
TextName¶
-
class
gchar.games.base.
TextName
(name: str)[source]¶ Class for modeling character names based on text.
The class inherits from _BaseName and provides methods for string representation and comparison. It supports containment check, length calculation, and item retrieval.
- Usage:
Use the TextName class to model character names based on text.
- Parameters:
name (str) – The name of the character.
SegmentName¶
-
class
gchar.games.base.
SegmentName
(name: Union[str, List[str]])[source]¶ Class for modeling character names based on segments.
The class inherits from _BaseName and provides methods for string representation and comparison. It supports containment check, length calculation, and item retrieval.
- Usage:
Use the SegmentName class to model character names based on segments.
- Parameters:
name (Union[str, List[str]]) – The name of the character.
Gender¶
-
enum
gchar.games.base.
Gender
(value)[source]¶ Enumeration class representing the gender of a character.
The class provides three gender options: OTHER, MALE, and FEMALE. It supports equality comparison with other Gender objects and string values. The class also provides a method loads for parsing and converting string values into Gender objects.
- Usage:
Use the Gender enum to represent the gender of a character.
- Supported string values for each gender:
OTHER: “OTHER”
MALE: “MALE”, “男”, “男性”, “boy”, “man”, “male”
FEMALE: “FEMALE”, “女”, “女性”, “girl”, “woman”, “female”
Valid values are as follows:
-
OTHER
= <Gender.OTHER: 0>¶
-
MALE
= <Gender.MALE: 1>¶
-
FEMALE
= <Gender.FEMALE: 2>¶
The
Enum
and its members also have the following methods:-
classmethod
loads
(val) → gchar.games.base.property.Gender[source]¶ Parse and convert a string value into a Gender object.
The method accepts string values representing genders and converts them into the corresponding Gender enum object. If the input value is already a Gender object, it is returned as is.
Skin¶
-
class
gchar.games.base.
Skin
(game: str, ch_index: Union[int, str], name: str, url: str)[source]¶ Represents a skin of a game character.
The class stores information about the game, character index, skin name, and original URL of the skin. It provides a property selected_url that returns the URL of the skin, which is either the Hugging Face Hub URL if the skin has been synchronized or the original URL.
- Parameters:
game (str) – The game name.
ch_index (Union[int, str]) – The index or ID of the game character.
name (str) – The name of the skin.
url (str) – The original URL of the skin.
-
property
selected_url
¶ Get the URL of the skin.
If the skin has been synchronized to the Hugging Face Hub, the Hugging Face Hub URL is returned. Otherwise, the original URL is returned.
- Returns:
The URL of the skin.
- Return type:
str