Skip to content

Commit

Permalink
Fix typing annotations in ICharacter class
Browse files Browse the repository at this point in the history
  • Loading branch information
KiloOscarSix committed Jan 31, 2024
1 parent 02e77a1 commit 07706ae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 43 deletions.
68 changes: 39 additions & 29 deletions CharacterService_ren.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CharacterService:
@staticmethod
def get_user(
character: Union["ICharacter", "CustomCharacter", "MainCharacter"]
) -> ICharacter:
) -> "ICharacter":
try:
if isinstance(character, PlayableCharacter):
user = mc
Expand All @@ -32,8 +32,8 @@ def get_user(

@staticmethod
def get_relationship(
character: ICharacter, target: Optional[ICharacter] = None
) -> Relationship:
character: "ICharacter", target: Optional["ICharacter"] = None
) -> "Relationship":
if target is None:
target = mc

Expand All @@ -44,9 +44,9 @@ def get_relationship(

@staticmethod
def has_relationship(
character: ICharacter,
relationship: Relationship,
target: Optional[ICharacter] = None,
character: "ICharacter",
relationship: "Relationship",
target: Optional["ICharacter"] = None,
) -> bool:
if target is None:
target = mc
Expand All @@ -55,9 +55,9 @@ def has_relationship(

@staticmethod
def set_relationship(
character: ICharacter,
relationship: Relationship,
target: Optional[ICharacter] = None,
character: "ICharacter",
relationship: "Relationship",
target: Optional["ICharacter"] = None,
) -> None:
if target is None:
target = mc
Expand All @@ -81,26 +81,26 @@ def set_relationship(
target.relationships[character] = relationship

@staticmethod
def get_mood(character: ICharacter) -> Moods:
def get_mood(character: "ICharacter") -> "Moods":
return character.mood

@staticmethod
def has_mood(character: ICharacter, mood: Moods) -> bool:
def has_mood(character: "ICharacter", mood: "Moods") -> bool:
return mood == character.mood or character.mood & mood == mood

@staticmethod
def set_mood(character: ICharacter, mood: Moods) -> None:
def set_mood(character: "ICharacter", mood: "Moods") -> None:
if mood == character.mood:
return

character.mood = mood

@staticmethod
def reset_mood(character: ICharacter) -> None:
def reset_mood(character: "ICharacter") -> None:
character.mood = Moods.NORMAL

@staticmethod
def add_mood(character: ICharacter, mood: Moods) -> None:
def add_mood(character: "ICharacter", mood: "Moods") -> None:
if mood == character.mood:
return

Expand All @@ -111,7 +111,7 @@ def add_mood(character: ICharacter, mood: Moods) -> None:
character.mood = character.mood | mood

@staticmethod
def remove_mood(character: ICharacter, mood: Moods) -> None:
def remove_mood(character: "ICharacter", mood: "Moods") -> None:
character.mood = character.mood & ~mood

@staticmethod
Expand All @@ -129,7 +129,7 @@ def get_profile_pictures(character_name: str) -> list[str]:

@staticmethod
def is_exclusive_girlfriend(
character: ICharacter, target: Optional[ICharacter] = None
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc
Expand All @@ -142,7 +142,7 @@ def is_exclusive_girlfriend(

@staticmethod
def is_girlfriend(
character: ICharacter, target: Optional[ICharacter] = None
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc
Expand All @@ -153,7 +153,7 @@ def is_girlfriend(

@staticmethod
def is_girlfriends(
characters: Iterable[ICharacter], target: Optional[ICharacter] = None
characters: Iterable["ICharacter"], target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc
Expand All @@ -165,7 +165,7 @@ def is_girlfriends(

@staticmethod
def is_exclusive(
character: ICharacter, target: Optional[ICharacter] = None
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc
Expand All @@ -177,14 +177,16 @@ def is_exclusive(
)

@staticmethod
def is_fwb(character: ICharacter, target: Optional[ICharacter] = None) -> bool:
def is_fwb(character: "ICharacter", target: Optional["ICharacter"] = None) -> bool:
if target is None:
target = mc

return CharacterService.has_relationship(character, Relationship.FWB, target)

@staticmethod
def is_fwbs(characters: Iterable[ICharacter], target: Optional[ICharacter] = None):
def is_fwbs(
characters: Iterable["ICharacter"], target: Optional["ICharacter"] = None
):
if target is None:
target = mc

Expand All @@ -193,29 +195,35 @@ def is_fwbs(characters: Iterable[ICharacter], target: Optional[ICharacter] = Non
)

@staticmethod
def is_dating(character: ICharacter, target: Optional[ICharacter] = None) -> bool:
def is_dating(
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc

return CharacterService.has_relationship(character, Relationship.DATING, target)

@staticmethod
def is_kissed(character: ICharacter, target: Optional[ICharacter] = None) -> bool:
def is_kissed(
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc

return CharacterService.has_relationship(character, Relationship.KISSED, target)

@staticmethod
def is_friend(character: ICharacter, target: Optional[ICharacter] = None) -> bool:
def is_friend(
character: "ICharacter", target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc

return CharacterService.has_relationship(character, Relationship.FRIEND, target)

@staticmethod
def is_friends(
characters: Iterable[ICharacter], target: Optional[ICharacter] = None
characters: Iterable["ICharacter"], target: Optional["ICharacter"] = None
) -> bool:
if target is None:
target = mc
Expand All @@ -225,14 +233,16 @@ def is_friends(
)

@staticmethod
def is_ex(character: ICharacter, target: Optional[ICharacter] = None) -> bool:
def is_ex(character: "ICharacter", target: Optional["ICharacter"] = None) -> bool:
if target is None:
target = mc

return CharacterService.has_relationship(character, Relationship.EX, target)

@staticmethod
def is_exes(characters: Iterable[ICharacter], target: Optional[ICharacter] = None):
def is_exes(
characters: Iterable["ICharacter"], target: Optional["ICharacter"] = None
):
if target is None:
target = mc

Expand All @@ -241,9 +251,9 @@ def is_exes(characters: Iterable[ICharacter], target: Optional[ICharacter] = Non
)

@staticmethod
def is_mad(character: ICharacter) -> bool:
def is_mad(character: "ICharacter") -> bool:
return CharacterService.has_mood(character, Moods.MAD)

@staticmethod
def is_threatened(character: ICharacter) -> bool:
def is_threatened(character: "ICharacter") -> bool:
return CharacterService.has_mood(character, Moods.THREATENED)
28 changes: 14 additions & 14 deletions ICharacter_ren.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ICharacter:
name: str
_username: str

relationships: dict["ICharacter", Relationship]
mood: Moods
relationships: dict["ICharacter", "Relationship"]
mood: "Moods"

_profile_pictures: list[str]
_profile_picture: str
Expand All @@ -24,11 +24,11 @@ class ICharacter:
vindictive_characters: tuple["ICharacter", ...]
is_talkative: bool

_pending_text_messages: list[Message]
_text_messages: list[Message]
_pending_text_messages: list["Message"]
_text_messages: list["Message"]

_pending_simplr_messages: list[Message]
_simplr_messages: list[Message]
_pending_simplr_messages: list["Message"]
_simplr_messages: list["Message"]

@property
def username(self) -> str:
Expand Down Expand Up @@ -57,33 +57,33 @@ def profile_picture(self, value: str) -> None:
self._profile_picture = value

@property
def pending_text_messages(self) -> list[Message]:
def pending_text_messages(self) -> list["Message"]:
return self._pending_text_messages

@pending_text_messages.setter
def pending_text_messages(self, value: list[Message]) -> None:
def pending_text_messages(self, value: list["Message"]) -> None:
self._pending_text_messages = value

@property
def text_messages(self) -> list[Message]:
def text_messages(self) -> list["Message"]:
return self._text_messages

@text_messages.setter
def text_messages(self, value: list[Message]) -> None:
def text_messages(self, value: list["Message"]) -> None:
self._text_messages = value

@property
def pending_simplr_messages(self) -> list[Message]:
def pending_simplr_messages(self) -> list["Message"]:
return self._pending_simplr_messages

@pending_simplr_messages.setter
def pending_simplr_messages(self, value: list[Message]) -> None:
def pending_simplr_messages(self, value: list["Message"]) -> None:
self._pending_simplr_messages = value

@property
def simplr_messages(self) -> list[Message]:
def simplr_messages(self) -> list["Message"]:
return self._simplr_messages

@simplr_messages.setter
def simplr_messages(self, value: list[Message]) -> None:
def simplr_messages(self, value: list["Message"]) -> None:
self._simplr_messages = value

0 comments on commit 07706ae

Please sign in to comment.