Replace split_party_msg with the announce_action

Fixed some long standing inconsistencies.
This commit is contained in:
Howard Abrams 2025-06-01 19:30:39 -07:00
parent 60dc1da080
commit b676bb7421
4 changed files with 30 additions and 38 deletions

View file

@ -277,6 +277,7 @@ class CmdRead(Command):
key = "read"
def find_readable(self, searcher, readable_str):
"""Search the room for a readable item."""
targets = searcher.search(readable_str, quiet=True)
if not targets:
searcher.msg(f"You don't see {readable_str}.")

View file

@ -15,7 +15,7 @@ from evennia.contrib.game_systems.gendersub import GenderCharacter
from evennia.contrib.rpg.rpsystem import ContribRPCharacter
from evennia.contrib.rpg.rpsystem import send_emote
from evennia.prototypes.spawner import spawn
from evennia.utils import delay # , logger
from evennia.utils import delay, logger
from utils.word_list import routput, choices
from .objects import Object
@ -302,6 +302,7 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
# All this does is add the character's gender to the message:
newmsg = sub(r"\$pron\((.*?)\)", f"$pron(\\1, {self.db.gender})", message)
choose = choices(newmsg)
logger.info(choose)
self.location.msg_contents(f"{choose}", from_obj=self, exclude=exclude)
def spell_sequence(self, location, messages, time_delay=1):
@ -369,3 +370,16 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
for puppet in self.puppets_here():
puppet.other_leave(self)
return True
def deeper_search(self, item_str):
targets = self.search(item_str, quiet=True)
if len(targets) > 0:
return targets
for target in self.location.contents:
logger.info(f"Looking for books at {target}")
inv_items = self.search(item_str, quiet=True,
location=target)
if len(inv_items) > 0:
return inv_items
return None

View file

@ -16,6 +16,7 @@ from time import time
import random
from evennia import TICKER_HANDLER
from evennia.utils import logger
from evennia.utils.gametime import schedule
from typeclasses.objects import Object
@ -23,7 +24,7 @@ from typeclasses.characters import Character
# from typeclasses.lightables import LightSource
from commands.feedables import CmdFeedSet
from commands.pets import CmdPetSet
from utils.word_list import squish, choices, split_party_msg
from utils.word_list import squish, choices
class Hunger(Enum):
@ -404,11 +405,11 @@ class Friendly(Pet):
# 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)
# Limit this list so it doesn't grow too large:
self.db.last_actions = self.db.last_actions[-5:]
split_party_msg(focus, msg)
if msg and msg not in self.db.last_actions:
self.db.last_actions.append(msg)
# Limit this list so it doesn't grow too large:
self.db.last_actions = self.db.last_actions[-5:]
focus.announce_action(msg)
def pet_response(self, petter):
"""
@ -432,9 +433,9 @@ class Friendly(Pet):
msg = self.db.pet_ecstatic_response
self.adjust_character(petter, self.db.pet_ecstatic_adjust or 10)
if msg:
split_party_msg(petter, msg)
petter.announce_action(msg, self.name)
else:
petter.msg(f"You pet {self.name}.")
petter.announce_action(f"$You() $conj(pet) {self.name}.")
@ -563,16 +564,16 @@ class BHB(Friendly):
self.adjust_character(thrower, 5)
case Reaction.INTERESTED:
msg = choices("""
The beast <<runs ^ hurries>> at the stick, then looks at <you>, <<wondering ^ curious as to ^ pondering>> what to do with a stick the flies back to its owner. ;;
The beast <<runs ^ hurries>> at the stick, then looks at $you(), <<wondering ^ curious as to ^ pondering>> what to do with a stick the flies back to its owner. ;;
The beast <<rushes ^ runs at>> the stick, and then veers off, thundering around the <<field ^ meadow>>. The stick returns to your hand.
""")
self.adjust_character(thrower, 30)
case _:
msg = choices("""
The <<big hairy ^ >> beast <<dashes ^ runs ^ jumps ^ leaps into the air ^ leaps>> and <<catches ^ snags ^ grabs>> the stick in midair, and drops it in front of <you>. ;;
The <<big hairy ^ >> beast <<gallops ^ trumbles ^ trots>> over to the stick and <<dances ^ prances ^ hops>> around the stick before bringing it back to <you>. ;;
The <<big hairy ^ >> beast <<gallops ^ trumbles ^ trots>> over to the stick and <<dances ^ prances ^ hops>> around the stick before bringing it back to <you>.""")
The <<big hairy ^ >> beast <<dashes ^ runs ^ jumps ^ leaps into the air ^ leaps>> and <<catches ^ snags ^ grabs>> the stick in midair, and drops it in front of $you(). ;;
The <<big hairy ^ >> beast <<gallops ^ trumbles ^ trots>> over to the stick and <<dances ^ prances ^ hops>> around the stick before bringing it back to $you(). ;;
The <<big hairy ^ >> beast <<gallops ^ trumbles ^ trots>> over to the stick and <<dances ^ prances ^ hops>> around the stick before bringing it back to $you().""")
self.adjust_character(thrower, 10)
if msg:
split_party_msg(thrower, msg)
thrower.announce_action(msg)

View file

@ -119,27 +119,3 @@ def choices(text, *substitutions):
if text:
return routput(choice(text), *substitutions)
def split_party_msg(viewer, msg, *substitutions):
"""
Send a message to 'viewer' as well as all people in the area.
Note that 'msg' could have choices separated by ;;
As well as random words, separated by << one ^ two ^ three >>
As well as one word for 'viewer' and other for rest, as in
<( You ^ {0} )> <( give ^ gives )> the ball.
"""
text = choices(msg, viewer.name.title())
pattern = compile(r"\<\( *(.*?) *\^ *(.*?) *\)\>")
# First a message for the view:
viewer.msg( pattern.sub("\\1", text) )
# Then the message for the rest of the area:
viewer.location.msg_contents(
pattern.sub("\\2", text), exclude=viewer)
# def searsonal(text, **kwargs):
# season = kwargs['season'] or kwargs['location'].get_season()
# time_of_day = kwargs['time_of_day'] or kwargs['location'].get_time_of_day()