Fix bug in hint system and petting friendly pets

This commit is contained in:
Howard Abrams 2025-07-29 11:48:33 -07:00
parent 22960880fc
commit ce449c8570
4 changed files with 43 additions and 31 deletions

View file

@ -53,7 +53,7 @@ class CmdHint(MuxCommand):
data = self.hint_data() data = self.hint_data()
if data: if data:
room_hints = data[room_key] room_hints = data[room_key]
narrative = room_hints['narrative'] narrative = room_hints.get('narrative')
hints = room_hints['hints'] hints = room_hints['hints']
if not search_string or search_string == "": if not search_string or search_string == "":
@ -64,7 +64,7 @@ class CmdHint(MuxCommand):
def display_hint(self, narrative, phrase, cleaned): def display_hint(self, narrative, phrase, cleaned):
if phrase: if phrase:
if cleaned: if cleaned or not narrative:
self.caller.msg(routput(phrase)) self.caller.msg(routput(phrase))
else: else:
self.caller.msg(choices(narrative, routput(phrase))) self.caller.msg(choices(narrative, routput(phrase)))

View file

@ -12,7 +12,8 @@ class CmdPet(Command):
pet [ <creature> ] pet [ <creature> ]
Just because you |wcan|n do this, doesn't mean the creature |wwants|n you to. Just because you |wcan|n do this, doesn't mean the creature
|wwants|n you to.
""" """
key = "pet" key = "pet"
@ -22,6 +23,7 @@ class CmdPet(Command):
""" """
self.obj.pet_response(self.caller) self.obj.pet_response(self.caller)
class CmdPetSet(CmdSet): class CmdPetSet(CmdSet):
""" """
Things associated with pets. Things associated with pets.

View file

@ -348,22 +348,29 @@ class Friendly(Pet):
Args: Args:
looker (Object): Object doing the looking. looker (Object): Object doing the looking.
""" """
level = self.friendly_reaction(looker)
# looking at the friendly pets makes them nervous... just a little: # looking at the friendly pets makes them nervous... just a little:
self.adjust_character(looker, -1) self.adjust_character(looker, -1)
if level == Reaction.SCARED: (level, loves) = self.highest_friendly_reaction()
return self.db.desc + " " + choices(self.db.scared_msg or "It seems scared of you.") loved = loves[0]
elif level == Reaction.CONCERNED:
return self.db.desc + " " + choices(self.db.concerned_msg or "It seems concerned you are here.") if loved == looker:
elif level == Reaction.INTERESTED: subs = ("you", "your")
return self.db.desc + " " + choices(self.db.interested_msg or "It seems interested in you.")
elif level == Reaction.FRIENDLY:
return self.db.desc + " " + choices(self.db.friendly_msg or "It seems happy to see you.")
else: else:
# If we have an ecstatic message, use it otherwise, grab the friendly: subs = (loved.db._sdesc, loved.db._sdesc + "'s")
return self.db.desc + " " + choices(self.db.ecstatic_msg or self.db.friendly_msg or
"It seems ecstatic to see you.") if level.value > Reaction.ECSTATIC.value and self.db.ecstatic_msg:
suffix = choices(self.db.ecstatic_msg, *subs)
elif level.value > Reaction.FRIENDLY.value and self.db.friendly_msg:
suffix = choices(self.db.friendly_msg, *subs)
elif level.value > Reaction.INTERESTED.value and self.db.interested_msg:
suffix = choices(self.db.interested_msg, *subs)
elif level.value > Reaction.CONCERNED and self.db.concerned_msg:
suffix = choices(self.db.concerned_msg, *subs)
else:
suffix = choices(self.db.scared_msg, *subs)
return self.db.desc + " " + loved.gendered_text(suffix)
def update_state(self, *args, **kwargs): def update_state(self, *args, **kwargs):
""" """
@ -418,27 +425,35 @@ class Friendly(Pet):
""" """
match self.friendly_reaction(petter): match self.friendly_reaction(petter):
case Reaction.SCARED: case Reaction.SCARED:
msg = self.db.pet_scared_response msg = self.db.pet_scared_response \
or f"The {self.name} doesn't let $you() pet it."
self.adjust_character(petter, self.db.pet_scared_adjust or 0) self.adjust_character(petter, self.db.pet_scared_adjust or 0)
case Reaction.CONCERNED: case Reaction.CONCERNED:
msg = self.db.pet_concerned_response msg = self.db.pet_concerned_response or self.db.pet_scared_response \
self.adjust_character(petter, self.db.pet_concerned_adjust or 0) or f"The {self.name} doesn't let $you() pet it."
self.adjust_character(petter, self.db.pet_concerned_adjust or 5)
case Reaction.INTERESTED: case Reaction.INTERESTED:
msg = self.db.pet_interested_response msg = self.db.pet_interested_response \
self.adjust_character(petter, self.db.pet_interested_adjust or 1) or self.db.pet_concerned_response or self.db.pet_scared_response \
or f"The {self.name} doesn't let $you() pet it."
self.adjust_character(petter, self.db.pet_interested_adjust or 8)
case Reaction.FRIENDLY: case Reaction.FRIENDLY:
msg = self.db.pet_friendly_response msg = self.db.pet_friendly_response or self.db.pet_interested_response \
self.adjust_character(petter, self.db.pet_friendly_adjust or 8) or self.db.pet_concerned_response or self.db.pet_scared_response \
or f"The {self.name} doesn't let $you() pet it."
self.adjust_character(petter, self.db.pet_friendly_adjust or 10)
case Reaction.ECSTATIC: case Reaction.ECSTATIC:
msg = self.db.pet_ecstatic_response msg = self.db.pet_ecstatic_response or self.db.pet_friendly_response \
self.adjust_character(petter, self.db.pet_ecstatic_adjust or 10) or self.db.pet_interested_response or self.db.pet_concerned_response \
or self.db.pet_scared_response \
or f"The {self.name} doesn't let $you() pet it."
self.adjust_character(petter, self.db.pet_ecstatic_adjust or 15)
if msg: if msg:
petter.announce_action(msg, self.name) petter.announce_action(msg, self.name)
else: else:
petter.announce_action(f"$You() $conj(pet) {self.name}.") petter.announce_action(f"$You() $conj(pet) {self.name}.")
class BHB(Friendly): class BHB(Friendly):
def return_appearance(self, looker): def return_appearance(self, looker):
if self.db.is_awake: if self.db.is_awake:

View file

@ -55,8 +55,7 @@ grotto:
riddle: Ask the |Yknocker|n for the riddle. riddle: Ask the |Yknocker|n for the riddle.
cozy_house: cozy_house:
narrative: {0} narrative: >-
wip: >-
"<< Psst. ^ Heya. ^ Over here. ^ Hey buddy. >>" "<< Psst. ^ Heya. ^ Over here. ^ Hey buddy. >>"
You << look down ^ look down ^ bend down >> and see a You << look down ^ look down ^ bend down >> and see a
<< tiny ^ small ^ >> << brown ^ >> worm on a bookshelf. It says, << tiny ^ small ^ >> << brown ^ >> worm on a bookshelf. It says,
@ -86,7 +85,6 @@ cozy_house:
No, I did not feel like writing multiple novels for this game. No, I did not feel like writing multiple novels for this game.
cramped_kitchen: cramped_kitchen:
narrative: {0}
hints: hints:
default: >- default: >-
Grab yourself some breakfast or an evening snack of |Yscones|n and |Ytea|n. Grab yourself some breakfast or an evening snack of |Yscones|n and |Ytea|n.
@ -99,7 +97,6 @@ cramped_kitchen:
teacup: The cabinet is full of cups, so |gget teacup|n. teacup: The cabinet is full of cups, so |gget teacup|n.
bedroom: bedroom:
narrative: {0}
hints: hints:
default: >- default: >-
Don't steal the slippers, as they are decoration (as even Don't steal the slippers, as they are decoration (as even
@ -108,7 +105,6 @@ bedroom:
wardrobe: If you |gopen|n the |gwardrobe|n, you will find a new exit. wardrobe: If you |gopen|n the |gwardrobe|n, you will find a new exit.
prairie: prairie:
narrative: {0}
hints: hints:
default: >- default: >-
This place should have a sign that reads, |wUnder Construction|n, This place should have a sign that reads, |wUnder Construction|n,
@ -153,7 +149,6 @@ frog_meadow:
bottle: You want to |gfill bottle|n to collect the water. bottle: You want to |gfill bottle|n to collect the water.
lair: lair:
narrative: {0}
hints: hints:
default: >- default: >-
This is the bedroom for the |wBig Hairy Beast|n, and little else. This is the bedroom for the |wBig Hairy Beast|n, and little else.