diff --git a/commands/default_cmdsets.py b/commands/default_cmdsets.py index f81cce8..237ef41 100644 --- a/commands/default_cmdsets.py +++ b/commands/default_cmdsets.py @@ -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) # diff --git a/commands/everyone.py b/commands/everyone.py new file mode 100755 index 0000000..ee847ea --- /dev/null +++ b/commands/everyone.py @@ -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 + + 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 from + + 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) diff --git a/commands/take.py b/commands/take.py deleted file mode 100755 index ae2b207..0000000 --- a/commands/take.py +++ /dev/null @@ -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)