moss-n-puddles/typeclasses/puppets.py
2025-05-16 11:33:27 -07:00

64 lines
2.3 KiB
Python
Executable file

#!/usr/bin/env python
from typeclasses.characters import Character
from utils.word_list import routput
class Puppet(Character):
"""
Special character that if not puppetable, stays put.
Perhaps responding or logging information to the GM.
"""
def at_post_puppet(self, **kwargs):
"""
Called just after puppeting has been completed and all
Account<->Object links have been established.
Args:
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default).
Notes:
You can use `self.account` and `self.sessions.get()` to get
account and sessions at this point; the last entry in the
list from `self.sessions.get()` is the latest Session
puppeting this Object.
"""
self.msg("\nYou are puppeting |c{name}|n.".format(name=self.key))
self.msg((self.at_look(self.location), {"type": "look"}), options=None)
def at_post_unpuppet(self, account=None, session=None, **kwargs):
"""
Make the character object remain in the room.
Args:
account (DefaultAccount): The account object that just disconnected
from this object.
session (Session): Session controlling the connection that
just disconnected.
Keyword Args:
reason (str): If given, adds a reason for the unpuppet. This
is set when the user is auto-unpuppeted due to being link-dead.
**kwargs: Arbitrary, optional arguments for users
overriding the call (unused by default).
"""
self.msg("\nNo longer puppeting |c{name}|n.\n".format(name=self.key))
def return_appearance(self, viewer, **kwargs):
"""
Return one of two appearances based on if it is being puppeted or not.
Set either or both:
@set me/desc_puppeted = "A clown bouncing up and down from a box."
@set me/desc_uppuppeted = "A colorful box with a closed lid."
If either is not specified, it uses the standard description.
"""
if self.tags.get(key='puppeted', category='account'):
return self.db.desc_puppeted if self.db.desc_puppeted else self.db.desc
else:
return self.db.desc_unpuppeted if self.db.desc_unpuppeted else self.db.desc