Add a think command
This commit is contained in:
parent
0230d5dc20
commit
21747092b8
3 changed files with 71 additions and 27 deletions
|
|
@ -18,7 +18,7 @@ from evennia import default_cmds
|
|||
from evennia.contrib.grid import extended_room
|
||||
from evennia.contrib.game_systems.gendersub import SetGender
|
||||
from commands.sittables import CmdNoSitStand
|
||||
from commands.take import CmdTake
|
||||
from commands.everyone import CmdTake, CmdThink
|
||||
|
||||
class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||
"""
|
||||
|
|
@ -36,6 +36,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
|||
super().at_cmdset_creation()
|
||||
self.add(CmdNoSitStand)
|
||||
self.add(CmdTake())
|
||||
self.add(CmdThink())
|
||||
self.add(SetGender())
|
||||
self.add(extended_room.ExtendedRoomCmdSet)
|
||||
#
|
||||
|
|
|
|||
69
commands/everyone.py
Executable file
69
commands/everyone.py
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from random import random
|
||||
|
||||
from commands.command import Command
|
||||
from evennia.commands.default.general import NumberedTargetCommand
|
||||
|
||||
from utils.word_list import routput
|
||||
|
||||
|
||||
class CmdThink(Command, NumberedTargetCommand):
|
||||
"""Think a thought out loud.
|
||||
|
||||
Usage:
|
||||
think <message>
|
||||
|
||||
Similar to the 'say' or 'pose' commands, this communicates an
|
||||
inner monologue to other characters in the same area.
|
||||
"""
|
||||
key = "think"
|
||||
aliases = ["thinks", "("]
|
||||
arg_regex = None
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Implements the think out loud command.
|
||||
"""
|
||||
if not self.args:
|
||||
self.caller.msg("What do you want to think out loud?")
|
||||
else:
|
||||
thought = self.args.strip()
|
||||
if (self.caller.db.thinking_count or 0) < 3 or random() < 0.4:
|
||||
msg = routput(
|
||||
f"""{self.caller.name}
|
||||
<< thinks ^ wonders >> << out loud ^ aloud >>
|
||||
o O ( {thought} )
|
||||
"""
|
||||
)
|
||||
else:
|
||||
msg = f"{self.caller.name} . o O ( {thought} )"
|
||||
self.caller.db.thinking_count = (self.caller.db.thinking_count or 0) + 1
|
||||
self.caller.location.msg_contents(msg)
|
||||
|
||||
|
||||
class CmdTake(Command, NumberedTargetCommand):
|
||||
"""
|
||||
Take an object from another character or NPC.
|
||||
|
||||
Usage:
|
||||
take <thing> from <character>
|
||||
|
||||
Note that only some things can be stolen.
|
||||
For instance, the brass ring from the door knocker.
|
||||
"""
|
||||
key = "take"
|
||||
aliases = ["steal"]
|
||||
rhs_split = ("=", " from ")
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Implements the take command. Since this command is designed
|
||||
to work on the object, we operate only on self.obj.
|
||||
"""
|
||||
if not self.args:
|
||||
self.caller.msg("What do you want to take?")
|
||||
elif not self.rhs:
|
||||
self.caller.msg(f"You want to take {self.lhs}, but from whom?")
|
||||
else:
|
||||
self.caller.do_take(self.lhs, self.rhs)
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from commands.command import Command
|
||||
from evennia.commands.default.general import NumberedTargetCommand
|
||||
|
||||
|
||||
class CmdTake(Command, NumberedTargetCommand):
|
||||
"""
|
||||
Steals an object from another.
|
||||
Added to the default_cmdsets.
|
||||
"""
|
||||
key = "take"
|
||||
aliases = ["steal"]
|
||||
rhs_split = ("=", " from ")
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Implements the take command. Since this command is designed
|
||||
to work on the object, we operate only on self.obj.
|
||||
"""
|
||||
if not self.args:
|
||||
self.caller.msg("What do you want to take?")
|
||||
elif not self.rhs:
|
||||
self.caller.msg(f"You want to take {self.lhs}, but from whom?")
|
||||
else:
|
||||
self.caller.do_take(self.lhs, self.rhs)
|
||||
Loading…
Reference in a new issue