Fix bug with undefined variable

This commit is contained in:
Howard Abrams 2025-04-14 14:11:27 -07:00
parent 46590de8ab
commit 11785cd534

View file

@ -382,21 +382,25 @@ class Friendly(Pet):
self.do_action() self.do_action()
def do_action(self): 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() (level, chars) = self.friendly_reaction()
focus = random.choice(chars) if chars and len(chars) > 0:
focus = random.choice(chars)
if level == Reaction.SCARED: if level == Reaction.SCARED:
msg = choices(self.db.scared_actions) msg = choices(self.db.scared_actions)
elif level == Reaction.CONCERNED: elif level == Reaction.CONCERNED:
msg = choices(self.db.concerned_actions) msg = choices(self.db.concerned_actions)
elif level == Reaction.INTERESTED: elif level == Reaction.INTERESTED:
msg = choices(self.db.interested_actions) msg = choices(self.db.interested_actions)
elif level == Reaction.FRIENDLY: elif level == Reaction.FRIENDLY:
msg = choices(self.db.friendly_actions) msg = choices(self.db.friendly_actions)
else: else:
# If we have an ecstatic message, use it otherwise, grab the friendly: # If we have an ecstatic message, use it otherwise,
msg = choices(self.db.ecstatic_actions or self.db.friendly_actions) # grab the friendly:
msg = choices(self.db.ecstatic_actions or self.db.friendly_actions)
if msg and msg not in self.db.last_actions: if msg and msg not in self.db.last_actions:
self.db.last_actions.append(msg) self.db.last_actions.append(msg)