1414from tibiapy .utils import parse_json , parse_tibia_date , parse_tibia_datetime , parse_tibiacom_content , \
1515 parse_tibiadata_date , parse_tibiadata_datetime , try_datetime , try_enum
1616
17+ # Extracts the scheduled deletion date of a character."""
1718deleted_regexp = re .compile (r'([^,]+), will be deleted at (.*)' )
1819# Extracts the death's level and killers.
1920death_regexp = re .compile (r'Level (?P<level>\d+) by (?P<killers>.*)\.</td>' )
2930house_regexp = re .compile (r'paid until (.*)' )
3031guild_regexp = re .compile (r'([\s\w]+)\sof the\s(.+)' )
3132
32- __all__ = ("AccountInformation" , "Achievement" , "Character" , "Death" , "GuildMembership" , "Killer" , "OtherCharacter" ,
33- "OnlineCharacter" )
33+ __all__ = (
34+ "AccountInformation" ,
35+ "Achievement" ,
36+ "Character" ,
37+ "Death" ,
38+ "GuildMembership" ,
39+ "Killer" ,
40+ "OtherCharacter" ,
41+ "OnlineCharacter" ,
42+ )
3443
3544
3645class AccountInformation (abc .Serializable ):
@@ -45,7 +54,11 @@ class AccountInformation(abc.Serializable):
4554 loyalty_title: :class:`str`, optional
4655 The loyalty title of the account, if any.
4756 """
48- __slots__ = ("created" , "loyalty_title" , "position" )
57+ __slots__ = (
58+ "created" ,
59+ "loyalty_title" ,
60+ "position" ,
61+ )
4962
5063 def __init__ (self , created , loyalty_title = None , position = None ):
5164 self .created = try_datetime (created )
@@ -65,15 +78,22 @@ class Achievement(abc.Serializable):
6578 The name of the achievement.
6679 grade: :class:`int`
6780 The grade of the achievement, also known as stars.
81+ secret: :class:´bool´
82+ Whether the achievement is secret or not.
6883 """
69- __slots__ = ("name" , "grade" )
84+ __slots__ = (
85+ "name" ,
86+ "grade" ,
87+ "secret" ,
88+ )
7089
71- def __init__ (self , name , grade ):
90+ def __init__ (self , name , grade , secret = False ):
7291 self .name = name # type: str
7392 self .grade = int (grade )
93+ self .secret = secret
7494
7595 def __repr__ (self ):
76- return "<%s name=%r grade=%d>" % (self .__class__ .__name__ , self .name , self .grade )
96+ return "<%s name=%r grade=%d secret=%s >" % (self .__class__ .__name__ , self .name , self .grade , self . secret )
7797
7898
7999class Character (abc .BaseCharacter ):
@@ -332,7 +352,11 @@ def _parse_achievements(self, rows):
332352 field , value = cols
333353 grade = str (field ).count ("achievement-grade-symbol" )
334354 name = value .text .strip ()
335- self .achievements .append (Achievement (name , grade ))
355+ secret_image = value .find ("img" )
356+ secret = False
357+ if secret_image :
358+ secret = True
359+ self .achievements .append (Achievement (name , grade , secret ))
336360
337361 def _parse_character_information (self , rows ):
338362 """
@@ -393,6 +417,8 @@ def _parse_character_information(self, rows):
393417 try :
394418 setattr (self , k , v )
395419 except AttributeError :
420+ # This means that there is a attribute in the character's information table that does not have a
421+ # corresponding class attribute.
396422 pass
397423 if house :
398424 self .house = CharacterHouse (house ["id" ], house ["name" ], self .world , house ["town" ], self .name ,
@@ -616,7 +642,8 @@ def killer(self):
616642
617643
618644class GuildMembership (abc .BaseGuild ):
619- """Represents the guild information of a character.
645+ """
646+ Represents the guild information of a character.
620647
621648 Attributes
622649 ----------
@@ -685,7 +712,8 @@ def url(self):
685712
686713
687714class OnlineCharacter (abc .BaseCharacter ):
688- """Represents an online character.
715+ """
716+ Represents an online character.
689717
690718 Attributes
691719 ----------
@@ -709,7 +737,7 @@ def __init__(self, name, world, level, vocation):
709737
710738class OtherCharacter (abc .BaseCharacter ):
711739 """
712- Represents other character's displayed in the Character's information page.
740+ Represents other characters displayed in the Character's information page.
713741
714742 Attributes
715743 ----------
0 commit comments