From 11785cd534d3c62236fd420f73a7e1dea4717aa9 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Mon, 14 Apr 2025 14:11:27 -0700 Subject: [PATCH] Fix bug with undefined variable --- typeclasses/pets.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/typeclasses/pets.py b/typeclasses/pets.py index 3f84293..0ca4558 100755 --- a/typeclasses/pets.py +++ b/typeclasses/pets.py @@ -382,21 +382,25 @@ class Friendly(Pet): self.do_action() def do_action(self): - # Do something based on the highest friendly level is the same area! + # Do something based on the highest friendly level is the same + # area! + msg = None (level, chars) = self.friendly_reaction() - focus = random.choice(chars) + if chars and len(chars) > 0: + focus = random.choice(chars) - if level == Reaction.SCARED: - msg = choices(self.db.scared_actions) - elif level == Reaction.CONCERNED: - msg = choices(self.db.concerned_actions) - elif level == Reaction.INTERESTED: - msg = choices(self.db.interested_actions) - elif level == Reaction.FRIENDLY: - msg = choices(self.db.friendly_actions) - else: - # If we have an ecstatic message, use it otherwise, grab the friendly: - msg = choices(self.db.ecstatic_actions or self.db.friendly_actions) + if level == Reaction.SCARED: + msg = choices(self.db.scared_actions) + elif level == Reaction.CONCERNED: + msg = choices(self.db.concerned_actions) + elif level == Reaction.INTERESTED: + msg = choices(self.db.interested_actions) + elif level == Reaction.FRIENDLY: + msg = choices(self.db.friendly_actions) + else: + # If we have an ecstatic message, use it otherwise, + # grab the friendly: + msg = choices(self.db.ecstatic_actions or self.db.friendly_actions) if msg and msg not in self.db.last_actions: self.db.last_actions.append(msg)