From cb6ad0ee19c86639704013999975f30ce25b4f99 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Thu, 19 Jun 2025 11:26:07 -0700 Subject: [PATCH] Cast prestidigitation spells --- commands/wizards.py | 52 +++++++++++++++++++++++++++++++++++++-- typeclasses/characters.py | 10 +++++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/commands/wizards.py b/commands/wizards.py index 01f0af4..3098d2e 100755 --- a/commands/wizards.py +++ b/commands/wizards.py @@ -39,15 +39,63 @@ class CmdFly(Command): self.caller.do_fly(self.args.strip()) +class CmdMagic(Command): + """ + Cast a generic 'magic' spell. + + Usage: + + wave [ effect(s) ] + + Where 'effects' is a statement of what happens after the magic erupts. + Note that you can have multiple effects separated by two semicolons. + + You can tailor the effects to your character with the following: + + - |y$you()|n: Replaced by "you" and your name for others, like "old gnome" + - |y$your()|n: Replaced by "your" and your possessive name for others, like "old gnome's" + - |y$conj(verb)|n: Replaced by "verb" for you, and "verbs" for others. + - |y$pron(you)|n: Replaced by "you" for you, but "he" or "she" for others. + - |y$pron(your)|n: Replaced by "your" for you, but "his" or "her" for others. + + While flexible, you would use this complex replacement in either + |gnicks|n or as part of a standard magical prefix, by setting the + property: + + @set self/magic_msg = "$You() $conj(shake) $pron(your) necklace of bones!" + """ + key = "magic" + aliases = ["wave"] + locks = "cmd:holds()" + + def func(self): + """ + Call the 'do_magic' method on the caller. + """ + wizard = self.caller + msgs = wizard.db.magic_msg + if msgs: + msgs = msgs.split(';;') + else: + msgs = [ + "$You() $conj(wave) $pron(your) " + self.obj.key + ".", + "<< Sparks ^ Colored lights ^ Flashes ^ Flashes >> of |yoctarine|n << appear ^ emerge ^ materialize >> as << the ^ >> magic << coalesces into an amorphous show of power ^ blends into swirling patterns ^ weaves together>>." + ] + + if self.args: + msgs = msgs + self.args.strip().split(';;') + + wizard.spell_sequence(None, msgs, wizard.db.magic_delay or 3) + + class CmdSetWand(CmdSet): """ All wizard spells are tied to a 'wand' that might be flavored. """ - key = "Wand" - def at_cmdset_creation(self): super().at_cmdset_creation() self.add(CmdFly) + self.add(CmdMagic) class CmdMakeCocktail(MuxCommand): diff --git a/typeclasses/characters.py b/typeclasses/characters.py index cb3a0c0..34546d8 100644 --- a/typeclasses/characters.py +++ b/typeclasses/characters.py @@ -318,11 +318,15 @@ class Character(Object, GenderCharacter, ContribRPCharacter): def spell_sequence(self, location, messages, time_delay=1): """ Send one or more messages to 'location' with a delay. + + If the 'location' is None, then send it to the room the + character is in. """ - location.msg_contents("\n" + routput(messages[0])) for idx, msg in enumerate(messages[1:]): - delay(time_delay * (idx + 1), - location.msg_contents, "\n" + routput(msg)) + if location: + delay(time_delay * idx, location.msg_contents, "\n" + routput(msg)) + else: + delay(time_delay * idx, self.announce_action, msg) def do_fly(self, location): """