From c085561157ad8ff4c3c5bd7d2070b2702e6cefa5 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Mon, 14 Apr 2025 23:15:11 -0700 Subject: [PATCH] Created first wizard spell, fly. --- commands/wizards.py | 28 ++++++++++++++++++ typeclasses/characters.py | 52 +++++++++++++++++++++++++++++++- typeclasses/tutorial.py | 62 +++++++++++++++++++-------------------- world/version1.ev | 11 +++++++ 4 files changed, 121 insertions(+), 32 deletions(-) create mode 100755 commands/wizards.py diff --git a/commands/wizards.py b/commands/wizards.py new file mode 100755 index 0000000..f9df857 --- /dev/null +++ b/commands/wizards.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +from .command import Command +from evennia import CmdSet + + +class CmdFly(Command): + """Cast the 'fly' spell. + + Make sure you set the following properties, for instance: + + @set self/disappear_msg = "The wizard disappears in a puff of smoke." + @set self/reappear_msg = "A plume of [white|light blue|gray|] smoke appears... ;; When the smoke clears, a wizard [emerges|materializes]." + @set self/appear_delay = 3 + + The last setting is the number of seconds between message segments + (those are separated by double semicolons). + + """ + key = "^fly" + + def func(self): + self.caller.do_fly(self.args.strip()) + + +class CmdSetWizardSpells(CmdSet): + def at_cmdset_creation(self): + self.add(CmdFly) diff --git a/typeclasses/characters.py b/typeclasses/characters.py index 980e9fd..8ed36ee 100644 --- a/typeclasses/characters.py +++ b/typeclasses/characters.py @@ -12,8 +12,10 @@ from re import match from evennia.objects.objects import DefaultCharacter from evennia.prototypes.spawner import spawn +from evennia.utils import delay, logger -# from utils.word_list import routput +from commands.wizards import CmdSetWizardSpells +from utils.word_list import routput from .objects import Object from .tutorial import TutorBird, TutorialState @@ -159,3 +161,51 @@ class Character(Object, DefaultCharacter): # Regardless of what happened before, we return the normal # function call. return super().at_look(target) + +class Wizard(Character): + """ + Upgrade a character with the following features: + + @update self = typeclasses.character.Wizard + """ + def at_object_creation(self): + """ + Called when character is getting promoted to wizardy. + """ + self.cmdset.add(CmdSetWizardSpells) + + def spell_sequence(self, location, messages, time_delay): + """ + Send one or more messages to 'location' with a delay. + """ + 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)) + + def do_fly(self, location): + """ + Allow a wizard to arrive thematically into a new location. + """ + if location == "home": + dest = self.home + else: + dest = self.global_search(location) + if dest and dest.is_typeclass("typeclasses.characters.Character"): + dest = dest.location + elif not dest or not dest.is_typeclass("typeclasses.rooms.Room"): + self.msg(f"Not sure how to go to: {location}") + return + + if self.db.disappear_msg: + # logger.info(f"Got {self.db.disappear_msg}") + self.spell_sequence(self.location, + self.db.disappear_msg.split(';;'), + self.db.appear_delay or 2) + self.move_to(dest, move_type="magic", quiet=True) + + if self.db.reappear_msg: + # logger.info(f"Got {self.db.reappear_msg}") + self.spell_sequence(self.location, + self.db.reappear_msg.split(';;'), + self.db.appear_delay or 2) diff --git a/typeclasses/tutorial.py b/typeclasses/tutorial.py index 562534a..a3611f3 100755 --- a/typeclasses/tutorial.py +++ b/typeclasses/tutorial.py @@ -19,25 +19,25 @@ import random MSGS = { "START": [ - "A small bird flies over to you, and perches on your shoulder. “Hello,” it says in your ear. “I’m the Tutorial Bird,” it chirps, “and I’m here to break the fourth wall, and help you figure out this game. Feel free to |bshoo|n me away, and I’ll leave you alone to explore.”", - "The bird says, “In this story game, you type commands (verbs) to do things. For instance, type the word |blook|n, and press the |wReturn|n key to look around at your surroundings and to see where you are, what you can do, and where you can go.”", + "A small bird flies over to you, and perches on your shoulder. \"Hello,\" it says in your ear. \"I’m the Tutorial Bird,\" it chirps, \"and I’m here to break the fourth wall, and help you figure out this game. Feel free to |bshoo|n me away, and I’ll leave you alone to explore.\"", + "The bird says, \"In this story game, you type commands (verbs) to do things. For instance, type the word |blook|n, and press the |wReturn|n key to look around at your surroundings and to see where you are, what you can do, and where you can go.\"", "The bird perched on your shoulder looks at you expectantly.", - "“Go ahead,” says the bird, “Type |blook|n. If you are on the web site, you may need to click in the box in the lower part of the screen.”", + "\"Go ahead,\" says the bird, \"Type |blook|n. If you are on the web site, you may need to click in the box in the lower part of the screen.\"", "The bird preens itself.", - "The bird says, “Would you like me to stay and help you out?”", - "“If so,” says the bird, “type |blook|n to look around at your surroundings.”", + "The bird says, \"Would you like me to stay and help you out?\"", + "\"If so,\" says the bird, \"type |blook|n to look around at your surroundings.\"", ], "LOOK": [ - "“That’s great,” says the little blue bird. “From that, you know you are standing in a grove of trees near a puddle. You can now type |blook puddle|n to examine it.”", - "“You can also |blook trees|n, |blook moss|n, or … well, you get the idea,” it says.", + "\"That’s great,\" says the little blue bird. \"From that, you know you are standing in a grove of trees near a puddle. You can now type |blook puddle|n to examine it.\"", + "\"You can also |blook trees|n, |blook moss|n, or … well, you get the idea,\" it says.", ], "LOOKAT": [ - "“You seem to be getting the hang of this game,” chirps the bird. “When you typed |blook|n before, you noticed exits. These are directions or places you can go. For instance, if you type |bsouth|n (or just |bs|n as a shortcut), you can check out our pond where you can catch obnoxious fish.”", - "“The path to the |beast|n is the meadow of the BHB, the Big Hairy Beast,” the little bird on your shoulder says. “It's adorable if you can find it. The path to the |bwest|n leads to Dabbler’s place.”", - "“Yes, I could fly myself,” warbles the little bird, “but I’m trying to help you get around.”", + "\"You seem to be getting the hang of this game,\" chirps the bird. \"When you typed |blook|n before, you noticed exits. These are directions or places you can go. For instance, if you type |bsouth|n (or just |bs|n as a shortcut), you can check out our pond where you can catch obnoxious fish.\"", + "\"The path to the |beast|n is the meadow of the BHB, the Big Hairy Beast,\" the little bird on your shoulder says. \"It's adorable if you can find it. The path to the |bwest|n leads to Dabbler’s place.\"", + "\"Yes, I could fly myself,\" warbles the little bird, \"but I’m trying to help you get around.\"", "The bird looks at you expectantly.", - "“Shall we explore other places?” asks the bird on your shoulder.", - "“I hope I’m not rushing you,” the bird mentions, “as you can always come back to explore more.”", + "\"Shall we explore other places?\" asks the bird on your shoulder.", + "\"I hope I’m not rushing you,\" the bird mentions, \"as you can always come back to explore more.\"", ], "MOVE": [ "\"Thanks for lift. This is a nice place,\" says the bird on your shoulder. \"When you come to a new area, the game shows you what you are seeing, so you don’t have to type |blook|n … even though you still can.\"", @@ -46,37 +46,37 @@ MSGS = { ], "SAY": [ - "“How’s it going?” the bird asks, “Are you enjoying this game so far?”", - "The bird says, “This place has been a respite from the outside turbulence.”", + "\"How’s it going?\" the bird asks, \"Are you enjoying this game so far?\"", + "The bird says, \"This place has been a respite from the outside turbulence.\"", "\"A shortcut to |bsay|n is to type either a double or single quote, and then your message.\"", "\"You can also use |bpose|n to state something about yourself, \" it says. \" For instance, type |bpose smiles.|n\"", # POSE: "The bird stands on one leg.", - "“See,” says the bird, “I s’pose I can pose too.”", - "“A shortcut to that command is typing |b:|n (a colon character).”", + "\"See,\" says the bird, \"I s’pose I can pose too.\"", + "\"A shortcut to that command is typing |b:|n (a colon character).\"", "The bird says, \"The game has more commands. Typing |bhelp|n gives you a list of commands. That list changes depending on where you are and what you are carrying. For instance, you could type |bshoo|n for me to fly away, and then that command wouldn’t be available again.\"", # ], # "HELP": [ - "The bird chirps, “You can learn more about the individual commands. For instance, type |bhelp say|n and you would see about the shortcuts I told you about. You can also see new commands, like |bhelp get|n.”", - "“Type |bhelp start|n for a repeat of much of what we’ve talked about,” says the bird.", - "The bird says, “The |binv|n shows you what you are carrying. I see you picked up a letter. You can also type |bread letter|n.”", - "“Since this game hosts many users,” says the bird, “you can show them what they see when they look at you, using the |b@setdesc|n command. Check out the help, |bhelp @setdesc|n, or just type: |w@setdesc A pixie with a shock of blue hair and a gold chain.|n”", - "“I’m guessing your last question,” chirps the little bird on your shoulder, “is the goal of this game.”", - "“That is a good question,” says the bird, “and I’m not sure what to say. This game has no goal, nor point. I guess you could look at it as a philosophical metaphor for existential existence in a post-modern world in the death throes of capitalism, but…”", - "The bird says, “This is a cozy little game about role playing a storybook character and maybe exploring and looking for eggs… no, that’s not right. Something about eggs. Easter eggs? Something like that.”", - "“Wander and look around. Find a cozy place to chat with others who have logged in,” says the bird.", - "“If you’re interested in |wbuilding|n and expanding this world,” chirps the bird, “talk to Dabbler... Oh, see if you can find Dabbler, the guy that made most of this. That is a great goal.”", - "“What do you say?” says the bird. “Think you got the hang of playing this?”", + "The bird chirps, \"You can learn more about the individual commands. For instance, type |bhelp say|n and you would see about the shortcuts I told you about. You can also see new commands, like |bhelp get|n.\"", + "\"Type |bhelp start|n for a repeat of much of what we’ve talked about,\" says the bird.", + "The bird says, \"The |binv|n shows you what you are carrying. I see you picked up a letter. You can also type |bread letter|n.\"", + "\"Since this game hosts many users,\" says the bird, \"you can show them what they see when they look at you, using the |b@setdesc|n command. Check out the help, |bhelp @setdesc|n, or just type: |w@setdesc A pixie with a shock of blue hair and a gold chain.|n\"", + "\"I’m guessing your last question,\" chirps the little bird on your shoulder, \"is the goal of this game.\"", + "\"That is a good question,\" says the bird, \"and I’m not sure what to say. This game has no goal, nor point. I guess you could look at it as a philosophical metaphor for existential existence in a post-modern world in the death throes of capitalism, but…\"", + "The bird says, \"This is a cozy little game about role playing a storybook character and maybe exploring and looking for eggs… no, that’s not right. Something about eggs. Easter eggs? Something like that.\"", + "\"Wander and look around. Find a cozy place to chat with others who have logged in,\" says the bird.", + "\"If you’re interested in |wbuilding|n and expanding this world,\" chirps the bird, \"talk to Dabbler... Oh, see if you can find Dabbler, the guy that made most of this. That is a great goal.\"", + "\"What do you say?\" says the bird. \"Think you got the hang of playing this?\"", ] } MSGS_WAITING = [ "The [little|blue|] bird [on your shoulder|] preens itself.", "The [little|blue|] bird [on your shoulder|] [looks|stares] at you [expectantly|waiting|patiently].", - "The bird looks up at the sky. “It rains here often,” it says.", - "The bird looks up at the sky. “Looks like rain is coming,” it says.", - "“I like the rain,” the bird says, “as it keeps the moss green and the puddles full.”", - "“They say if you don’t like the weather,” tweets the bird, “just wait.”", + "The bird looks up at the sky. \"It rains here often,\" it says.", + "The bird looks up at the sky. \"Looks like rain is coming,\" it says.", + "\"I like the rain,\" the bird says, \"as it keeps the moss green and the puddles full.\"", + "\"They say if you don’t like the weather,\" tweets the bird, \"just wait.\"", ] class TutorialState(Enum): @@ -142,7 +142,7 @@ class TutorBird(CarriableNPC): """ A visual way to stop the tutorial """ - character.msg("“Have fun, and I’ll leave you here,” chirps the bird, as it flies away.") + character.msg("\"Have fun, and I’ll leave you here,\" chirps the bird, as it flies away.") self.delete() def get_msg_level(self, character, level): diff --git a/world/version1.ev b/world/version1.ev index cf2ad59..2a6e4ed 100644 --- a/world/version1.ev +++ b/world/version1.ev @@ -44,6 +44,17 @@ Spectacles perched precariously on the end of his hooked nose, wobble with his h # Character: Dabble:4 ends here + +# And his spells: + + +# [[file:../../../Dropbox/org/projects/mud.org::*Character: Dabble][Character: Dabble:6]] +@set self/disappear_msg = "The gnome, Dabbler, disappears in a puff of smoke." +# +@set self/reappear_msg = "A plume of [white|light blue|gray|] smoke appears... ;; When the smoke clears, an old gnome [emerges|materializes]." +# Character: Dabble:6 ends here + + # Rename the Limbo (or starting place) with the name *Forest*. Note the term =mp01= as a global label that matches my map.