Replace split_party_msg with the announce_action
Fixed some long standing inconsistencies.
This commit is contained in:
parent
60dc1da080
commit
b676bb7421
4 changed files with 30 additions and 38 deletions
|
|
@ -277,6 +277,7 @@ class CmdRead(Command):
|
||||||
key = "read"
|
key = "read"
|
||||||
|
|
||||||
def find_readable(self, searcher, readable_str):
|
def find_readable(self, searcher, readable_str):
|
||||||
|
"""Search the room for a readable item."""
|
||||||
targets = searcher.search(readable_str, quiet=True)
|
targets = searcher.search(readable_str, quiet=True)
|
||||||
if not targets:
|
if not targets:
|
||||||
searcher.msg(f"You don't see {readable_str}.")
|
searcher.msg(f"You don't see {readable_str}.")
|
||||||
|
|
|
||||||
|
|
@ -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 ContribRPCharacter
|
||||||
from evennia.contrib.rpg.rpsystem import send_emote
|
from evennia.contrib.rpg.rpsystem import send_emote
|
||||||
from evennia.prototypes.spawner import spawn
|
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 utils.word_list import routput, choices
|
||||||
from .objects import Object
|
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:
|
# All this does is add the character's gender to the message:
|
||||||
newmsg = sub(r"\$pron\((.*?)\)", f"$pron(\\1, {self.db.gender})", message)
|
newmsg = sub(r"\$pron\((.*?)\)", f"$pron(\\1, {self.db.gender})", message)
|
||||||
choose = choices(newmsg)
|
choose = choices(newmsg)
|
||||||
|
logger.info(choose)
|
||||||
self.location.msg_contents(f"{choose}", from_obj=self, exclude=exclude)
|
self.location.msg_contents(f"{choose}", from_obj=self, exclude=exclude)
|
||||||
|
|
||||||
def spell_sequence(self, location, messages, time_delay=1):
|
def spell_sequence(self, location, messages, time_delay=1):
|
||||||
|
|
@ -369,3 +370,16 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
|
||||||
for puppet in self.puppets_here():
|
for puppet in self.puppets_here():
|
||||||
puppet.other_leave(self)
|
puppet.other_leave(self)
|
||||||
return True
|
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
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ from time import time
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from evennia import TICKER_HANDLER
|
from evennia import TICKER_HANDLER
|
||||||
|
from evennia.utils import logger
|
||||||
from evennia.utils.gametime import schedule
|
from evennia.utils.gametime import schedule
|
||||||
|
|
||||||
from typeclasses.objects import Object
|
from typeclasses.objects import Object
|
||||||
|
|
@ -23,7 +24,7 @@ from typeclasses.characters import Character
|
||||||
# from typeclasses.lightables import LightSource
|
# from typeclasses.lightables import LightSource
|
||||||
from commands.feedables import CmdFeedSet
|
from commands.feedables import CmdFeedSet
|
||||||
from commands.pets import CmdPetSet
|
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):
|
class Hunger(Enum):
|
||||||
|
|
@ -404,11 +405,11 @@ class Friendly(Pet):
|
||||||
# grab the friendly:
|
# grab the friendly:
|
||||||
msg = choices(self.db.ecstatic_actions or self.db.friendly_actions)
|
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)
|
||||||
# Limit this list so it doesn't grow too large:
|
# Limit this list so it doesn't grow too large:
|
||||||
self.db.last_actions = self.db.last_actions[-5:]
|
self.db.last_actions = self.db.last_actions[-5:]
|
||||||
split_party_msg(focus, msg)
|
focus.announce_action(msg)
|
||||||
|
|
||||||
def pet_response(self, petter):
|
def pet_response(self, petter):
|
||||||
"""
|
"""
|
||||||
|
|
@ -432,9 +433,9 @@ class Friendly(Pet):
|
||||||
msg = self.db.pet_ecstatic_response
|
msg = self.db.pet_ecstatic_response
|
||||||
self.adjust_character(petter, self.db.pet_ecstatic_adjust or 10)
|
self.adjust_character(petter, self.db.pet_ecstatic_adjust or 10)
|
||||||
if msg:
|
if msg:
|
||||||
split_party_msg(petter, msg)
|
petter.announce_action(msg, self.name)
|
||||||
else:
|
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)
|
self.adjust_character(thrower, 5)
|
||||||
case Reaction.INTERESTED:
|
case Reaction.INTERESTED:
|
||||||
msg = choices("""
|
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.
|
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)
|
self.adjust_character(thrower, 30)
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
msg = choices("""
|
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 <<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 <<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)
|
self.adjust_character(thrower, 10)
|
||||||
if msg:
|
if msg:
|
||||||
split_party_msg(thrower, msg)
|
thrower.announce_action(msg)
|
||||||
|
|
|
||||||
|
|
@ -119,27 +119,3 @@ def choices(text, *substitutions):
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
return routput(choice(text), *substitutions)
|
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()
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue