moss-n-puddles/typeclasses/sittables.py
Howard Abrams f3aef6cc54 Fix bugs with Steve
The 'say' command works with the webclient
Unplugging from the game makes you stand
Trying to sit on someone else's character, now uses the RP system
The fish now gets the right phrasing.
2025-05-13 21:37:37 -07:00

88 lines
2.5 KiB
Python
Executable file

#!/usr/bin/env python
from typeclasses.objects import Object
from commands.sittables import CmdSetSit
from utils.word_list import routput
class Sittable(Object):
multiple = False
def at_object_creation(self):
self.cmdset.add_default(CmdSetSit)
def sit_msg(self):
adjective = self.db.adjective or "on"
article = self.db.article or "the"
extra = self.db.extra or ""
return routput(f"You sit {adjective} {article} {self.key}. {extra}")
def stand_msg(self):
return f"You stand up from {self.key}."
def do_sit(self, sitter):
"""
Called when trying to sit on/in this object.
Args:
sitter (Object): The one trying to sit down.
"""
adjective = self.db.adjective or "on"
article = self.db.article or "the"
current = self.db.sitter
if sitter.db.is_sitting:
sitter.msg(f"You are already sitting {adjective} {article} {self.key}.")
return
if self.db.sitter and not self.multiple:
sitter.msg(f"You can't sit {adjective} {article} {self.key} "
f"- {current.get_display_name(sitter)} is already sitting there!")
return
self.db.sitter = sitter
sitter.db.is_sitting = self
sitter.msg(self.sit_msg())
sitter.announce_action(f"sits {adjective} {article} {self.key}.")
def do_stand(self, stander):
"""
Called when trying to stand from this object.
Args:
stander (Object): The one trying to stand up.
"""
adjective = self.db.adjective or "on"
current = self.db.sitter
if not stander == current:
stander.msg(f"You are not sitting {adjective} {self.key}.")
else:
self.db.sitter = None
del stander.db.is_sitting
stander.msg(self.stand_msg())
class Sittables(Sittable):
multiple = True
def sit_msg(self):
aliases = self.aliases.all()
adjective = self.db.adjective or "on"
article = self.db.article or "the"
name = aliases[-1] # Last alias is singular
default = f"{article} {name}"
singular = self.db.singular or default
extra = self.db.extra or ""
return routput(f"You sit {adjective} {singular}. {extra}")
def stand_msg(self):
article = self.db.article or "the"
default = f"{article} {self.db.name}"
singular = self.db.singular or default
return f"You stand up from {singular}."