Create an octopus familiar

This commit is contained in:
Howard Abrams 2025-06-02 22:22:29 -07:00
parent b676bb7421
commit afb092bfb0
2 changed files with 53 additions and 8 deletions

View file

@ -192,3 +192,32 @@ class CmdCat(Command):
class CmdSetCat(CmdSet):
def at_cmdset_creation(self):
self.add(CmdCat)
class CmdOctopus(Command):
"""Have your octopus do some antics.
Usage:
octopus <phrase>
Or:
octopus's <phrase>
Will announce your octopus's antics to the room.
You can target another character in the antics by preceding the
character's description with a |w/|n, as in |w/elf|n
or |w/blonde elf|n.
"""
key = "octopus"
aliases = ["pus"]
def func(self):
self.obj.at_do(self.caller, self.args.strip())
class CmdSetOctopus(CmdSet):
def at_cmdset_creation(self):
self.add(CmdOctopus)

View file

@ -4,7 +4,7 @@ from random import randint
from re import split
from typeclasses.objects import Object
from commands.misc import CmdSetCat
from commands.misc import CmdSetCat, CmdSetOctopus
from utils.word_list import routput
@ -75,14 +75,12 @@ class CarriableNPC(NPC):
f"The {self.name}, carried by {self.location.name}, says, \"{message}\"", exclude=owner)
class Cat(NPC):
class Familiar(NPC):
"""
A puppetable 'cat' that acts based on that 'command'.
"""
def at_object_creation(self):
"Called when a cat is first created."
self.cmdset.add(CmdSetCat, persistent=True)
Parent class for all familiars.
These are pets that can be controlled by their owner to do antics.
"""
def at_do(self, owner, antics):
"""
Issue a 'send_emote' into the room with a antic.
@ -106,10 +104,28 @@ class Cat(NPC):
adjs = ', '.join(lst_adjs)
return f"{adjs} {noun}" if len(adjs) > 0 else noun
# The cat's name:
# The familiar's name:
name = self.db._sdesc or self.name
if antics.startswith("'"):
owner.announce_action(f"$Your() {new_name(name)}{antics}")
else:
owner.announce_action(f"$Your() {new_name(name)} {antics}")
class Cat(Familiar):
"""
A puppetable 'cat' that acts based on that 'command'.
"""
def at_object_creation(self):
"Called when a cat is first created."
self.cmdset.add(CmdSetCat, persistent=True)
class Octopus(Familiar):
"""
A puppetable 'octopus' that acts based on that 'command'.
"""
def at_object_creation(self):
"Called when a octopus is first created."
self.cmdset.add(CmdSetOctopus, persistent=True)