From afb092bfb08f95ec5687321d4ce016060b5c04fe Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Mon, 2 Jun 2025 22:22:29 -0700 Subject: [PATCH] Create an octopus familiar --- commands/misc.py | 29 +++++++++++++++++++++++++++++ typeclasses/npcs.py | 32 ++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/commands/misc.py b/commands/misc.py index 6dceeb4..77c111f 100755 --- a/commands/misc.py +++ b/commands/misc.py @@ -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 + + Or: + + octopus's + + 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) diff --git a/typeclasses/npcs.py b/typeclasses/npcs.py index 7d06278..ed7eb9b 100755 --- a/typeclasses/npcs.py +++ b/typeclasses/npcs.py @@ -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)