Familiars can have aliases.
This allows Josh to do antics with his frogs or a single frog.
This commit is contained in:
parent
4d76593b1e
commit
9e81276aee
2 changed files with 17 additions and 10 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue