Skip to content

Commit

Permalink
Add error handling for character mood in CharacterService
Browse files Browse the repository at this point in the history
  • Loading branch information
KiloOscarSix committed May 22, 2024
1 parent 74c2605 commit 51f187e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CharacterService_ren.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,24 @@ def set_relationship(

@staticmethod
def get_mood(character: "NonPlayableCharacter") -> "Moods":
try:
return character.mood
except AttributeError:
character.mood = Moods.NORMAL

return character.mood

@staticmethod
def has_mood(character: "NonPlayableCharacter", mood: "Moods") -> bool:
try:
character.mood
except AttributeError:
character.mood = Moods.NORMAL

return mood == character.mood or character.mood & mood == mood

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

character.mood = mood

@staticmethod
Expand All @@ -115,9 +122,6 @@ def reset_mood(character: "NonPlayableCharacter") -> None:

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

if character.mood == Moods.NORMAL:
character.mood = mood
return
Expand Down

0 comments on commit 51f187e

Please sign in to comment.