Created first wizard spell, fly.

This commit is contained in:
Howard Abrams 2025-04-14 23:15:11 -07:00
parent b31c4a9aaa
commit c085561157
4 changed files with 121 additions and 32 deletions

28
commands/wizards.py Executable file
View file

@ -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)

View file

@ -12,8 +12,10 @@ from re import match
from evennia.objects.objects import DefaultCharacter from evennia.objects.objects import DefaultCharacter
from evennia.prototypes.spawner import spawn 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 .objects import Object
from .tutorial import TutorBird, TutorialState from .tutorial import TutorBird, TutorialState
@ -159,3 +161,51 @@ class Character(Object, DefaultCharacter):
# Regardless of what happened before, we return the normal # Regardless of what happened before, we return the normal
# function call. # function call.
return super().at_look(target) 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)

View file

@ -19,25 +19,25 @@ import random
MSGS = { MSGS = {
"START": [ "START": [
"A small bird flies over to you, and perches on your shoulder. “Hello,” it says in your ear. “Im the Tutorial Bird,” it chirps, “and Im here to break the fourth wall, and help you figure out this game. Feel free to |bshoo|n me away, and Ill leave you alone to explore.", "A small bird flies over to you, and perches on your shoulder. \"Hello,\" it says in your ear. \"Im the Tutorial Bird,\" it chirps, \"and Im here to break the fourth wall, and help you figure out this game. Feel free to |bshoo|n me away, and Ill 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 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.", "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 preens itself.",
"The bird says, “Would you like me to stay and help you out?”", "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.”", "\"If so,\" says the bird, \"type |blook|n to look around at your surroundings.\"",
], ],
"LOOK": [ "LOOK": [
"“Thats 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.", "\"Thats 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.", "\"You can also |blook trees|n, |blook moss|n, or … well, you get the idea,\" it says.",
], ],
"LOOKAT": [ "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.", "\"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 Dabblers place.", "\"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 Dabblers place.\"",
"“Yes, I could fly myself,” warbles the little bird, “but Im trying to help you get around.”", "\"Yes, I could fly myself,\" warbles the little bird, \"but Im trying to help you get around.\"",
"The bird looks at you expectantly.", "The bird looks at you expectantly.",
"“Shall we explore other places?” asks the bird on your shoulder.", "\"Shall we explore other places?\" asks the bird on your shoulder.",
"“I hope Im not rushing you,” the bird mentions, “as you can always come back to explore more.”", "\"I hope Im not rushing you,\" the bird mentions, \"as you can always come back to explore more.\"",
], ],
"MOVE": [ "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 dont have to type |blook|n … even though you still can.\"", "\"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 dont have to type |blook|n … even though you still can.\"",
@ -46,37 +46,37 @@ MSGS = {
], ],
"SAY": [ "SAY": [
"“Hows it going?” the bird asks, “Are you enjoying this game so far?”", "\"Hows 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.”", "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.\"", "\"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\"", "\"You can also use |bpose|n to state something about yourself, \" it says. \" For instance, type |bpose smiles.|n\"",
# POSE: # POSE:
"The bird stands on one leg.", "The bird stands on one leg.",
"“See,” says the bird, “I spose I can pose too.”", "\"See,\" says the bird, \"I spose I can pose too.\"",
"A shortcut to that command is typing |b:|n (a colon character).", "\"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 wouldnt be available again.\"", "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 wouldnt be available again.\"",
# ], # ],
# "HELP": [ # "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.", "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 weve talked about, says the bird.", "\"Type |bhelp start|n for a repeat of much of what weve 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.", "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", "\"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\"",
"“Im guessing your last question,” chirps the little bird on your shoulder, “is the goal of this game.”", "\"Im 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 Im 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…", "\"That is a good question,\" says the bird, \"and Im 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, thats not right. Something about eggs. Easter eggs? Something like that.", "The bird says, \"This is a cozy little game about role playing a storybook character and maybe exploring and looking for eggs… no, thats 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.", "\"Wander and look around. Find a cozy place to chat with others who have logged in,\" says the bird.",
"If youre 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.", "\"If youre 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?”", "\"What do you say?\" says the bird. \"Think you got the hang of playing this?\"",
] ]
} }
MSGS_WAITING = [ MSGS_WAITING = [
"The [little|blue|] bird [on your shoulder|] preens itself.", "The [little|blue|] bird [on your shoulder|] preens itself.",
"The [little|blue|] bird [on your shoulder|] [looks|stares] at you [expectantly|waiting|patiently].", "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. \"It rains here often,\" it says.",
"The bird looks up at the sky. “Looks like rain is coming,” 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.”", "\"I like the rain,\" the bird says, \"as it keeps the moss green and the puddles full.\"",
"“They say if you dont like the weather,” tweets the bird, “just wait.”", "\"They say if you dont like the weather,\" tweets the bird, \"just wait.\"",
] ]
class TutorialState(Enum): class TutorialState(Enum):
@ -142,7 +142,7 @@ class TutorBird(CarriableNPC):
""" """
A visual way to stop the tutorial A visual way to stop the tutorial
""" """
character.msg("“Have fun, and Ill leave you here,” chirps the bird, as it flies away.") character.msg("\"Have fun, and Ill leave you here,\" chirps the bird, as it flies away.")
self.delete() self.delete()
def get_msg_level(self, character, level): def get_msg_level(self, character, level):

View file

@ -44,6 +44,17 @@ Spectacles perched precariously on the end of his hooked nose, wobble with his h
# Character: Dabble:4 ends here # 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. # Rename the Limbo (or starting place) with the name *Forest*. Note the term =mp01= as a global label that matches my map.