hazelmud/commands/encounter/special.py

89 lines
2.4 KiB
Python

from evennia import CmdSet
from commands.encounter import EncounterCommand
class CmdPass(EncounterCommand):
"Pass the turn over to the next character"
energy_cost = 0
key = "pass"
aliases = ["next", "finish", "done"]
help_category = "Encounter"
def func(self):
if super().can_perform():
self.caller.msg("You end your turn")
super().handler().next_turn()
class CmdRP(EncounterCommand):
"Free-form text input (for describing your actions in RP)"
energy_cost = 0
key = "rp"
arg_regex = None
aliases = [">"]
help_category = "Encounter"
def func(self):
if super().can_perform():
super().handler().msg_all(self.args.strip())
class CmdFlee(EncounterCommand):
"Exits the current encounter"
energy_cost = 0
key = "flee"
aliases = ["escape", "run", "run away", "leave"]
help_category = "Encounter"
def func(self):
super().handler().msg_all(f"{self.caller.key} left the encounter")
super().handler().remove_character(self.caller)
class CmdOOC(EncounterCommand):
"Say something out-of-character"
energy_cost = 0
key = "("
arg_regex = None
def func(self):
super().handler().msg_all(f"({self.caller}: {self.args.strip()})")
class CmdPose(EncounterCommand):
"""
strike a pose
Usage:
pose <pose text>
pose's <pose text>
Example:
pose is standing by the wall, smiling.
-> others will see:
Tom is standing by the wall, smiling.
Describe an action being taken. The pose text will
automatically begin with your name.
"""
key = "pose"
aliases = [":", "emote"]
locks = "cmd:all()"
arg_regex = None
energy_cost = 0
def parse(self):
args = self.args
if args and not args[0] in ["'", ",", ":"]:
args = " %s" % args.strip()
self.args = args
def func(self):
if super().can_perform():
if not self.args:
self.msg("What do you want to do?")
else:
msg = f"{self.caller.name}{self.args}"
super().handler().msg_all_rich((msg, {'type':'pose'}), self.caller)
class SetEncounterSpecial(CmdSet):
def at_cmdset_creation(self):
self.add(CmdPass)
self.add(CmdRP)
self.add(CmdFlee)
self.add(CmdOOC)
self.add(CmdPose)