diff --git a/commands/misc.py b/commands/misc.py index 1ae0c4c..6800807 100755 --- a/commands/misc.py +++ b/commands/misc.py @@ -295,10 +295,10 @@ class CmdFrog(Command): or |w/blonde elf|n. """ key = "frog" - aliases = ["pus"] + aliases = ["frogs", "toad", "toads"] def func(self): - self.obj.at_do(self.caller, self.args.strip()) + self.obj.at_do(self.caller, self.args.strip(), self.cmdstring) class CmdSetFrog(CmdSet): diff --git a/typeclasses/npcs.py b/typeclasses/npcs.py index 7693850..36df4eb 100755 --- a/typeclasses/npcs.py +++ b/typeclasses/npcs.py @@ -84,11 +84,17 @@ class Familiar(NPC): These are pets that can be controlled by their owner to do antics. """ - def at_do(self, owner, antics): + def at_do(self, owner, antics, alias=None): """ Issue a 'send_emote' into the room with a antic. """ - def new_name(name): + def name_and_adjs(name): + """ + Split a long name into its parts. + """ + return list(filter(lambda s: s != "", split(r"[, ]+", name))) + + def new_name(parts): """ Take a long name, like: fat, black cat And return _part_ of the name, like: @@ -97,9 +103,6 @@ class Familiar(NPC): - black cat - cat """ - - parts = list(filter(lambda s: s != "", split(r"[, ]+", name))) - num_adjs = len(parts)-1 lst_adjs = parts[randint(0, num_adjs):num_adjs] @@ -107,13 +110,17 @@ class Familiar(NPC): adjs = ', '.join(lst_adjs) return f"{adjs} {noun}" if len(adjs) > 0 else noun + parts = name_and_adjs(self.db._sdesc or self.name) # The familiar's name: - name = self.db._sdesc or self.name + if not alias or alias == parts[-1]: + name = new_name(parts) + else: + name = alias if antics.startswith("'"): - owner.announce_action(f"$Your() {new_name(name)}{antics}") + owner.announce_action(f"$Your() {name}{antics}") else: - owner.announce_action(f"$Your() {new_name(name)} {antics}") + owner.announce_action(f"$Your() {name} {antics}") class Cat(Familiar):