Add abort command to tutorial-world and some bugfixes

This commit is contained in:
Griatch 2020-09-23 21:14:00 +02:00
parent ee0fedfdf7
commit ff59163d22
3 changed files with 50 additions and 22 deletions

View file

@ -104,16 +104,8 @@ tutorial
# ... and describe it. # ... and describe it.
# #
@desc @desc
|gWelcome to the Evennia tutorial!|n |gWelcome to the Evennia tutorial-world!|n
This small quest shows some examples of Evennia usage.
The following tutorial consists of a small single-player quest
area. The various rooms are designed to show off some of the power
and possibilities of the Evennia mud creation system. At any time
during this tutorial you can use the |wtutorial|n (or |wtut|n)
command to get some background info about the room or certain objects
to see what is going on "behind the scenes".
To get into the mood of this miniature quest, imagine you are an To get into the mood of this miniature quest, imagine you are an
adventurer out to find fame and fortune. You have heard rumours of an adventurer out to find fame and fortune. You have heard rumours of an
@ -126,14 +118,17 @@ tutorial
and rain screaming in your face you stand where the moor meet the sea and rain screaming in your face you stand where the moor meet the sea
along a high, rocky coast ... along a high, rocky coast ...
Try 'tutorial' to get behind-the-scenes help anywhere, and 'give up'
if you want to abort.
|gwrite 'begin' to start your quest!|n
|g(write 'start' or 'begin' to start the tutorial. Try 'tutorial'
to get behind-the-scenes help anywhere.)|n
# #
# Show that the tutorial command works ... # Show that the tutorial command works ...
# #
@set here/tutorial_info = @set here/tutorial_info =
You just tried the tutorial command. Use it in various rooms to see You just tried the |wtutorial|G command. Use it in various rooms to see
what's technically going on and what you could try in each room. The what's technically going on and what you could try in each room. The
intro room assigns some properties to your character, like a simple intro room assigns some properties to your character, like a simple
"health" property used when fighting. Other rooms and puzzles might do "health" property used when fighting. Other rooms and puzzles might do

View file

@ -69,12 +69,14 @@ class CmdTutorial(Command):
target = caller.search(self.args.strip()) target = caller.search(self.args.strip())
if not target: if not target:
return return
helptext = target.db.tutorial_info helptext = target.db.tutorial_info or ""
if helptext:
caller.msg("|G%s|n" % helptext)
else:
caller.msg("|RSorry, there is no tutorial help available here.|n")
if helptext:
helptext = f" |G{helptext}|n"
else:
helptext = " |RSorry, there is no tutorial help available here.|n"
helptext += "\n\n (Write 'give up' if you want to abandon your quest.)"
caller.msg(helptext)
# for the @detail command we inherit from MuxCommand, since # for the @detail command we inherit from MuxCommand, since
# we want to make use of MuxCommand's pre-parsing of '=' in the # we want to make use of MuxCommand's pre-parsing of '=' in the
@ -200,6 +202,26 @@ class CmdTutorialLook(default_cmds.CmdLook):
looking_at_obj.at_desc(looker=caller) looking_at_obj.at_desc(looker=caller)
return return
class CmdTutorialGiveUp(default_cmds.MuxCommand):
"""
Give up the tutorial-world quest and return to Limbo, the start room of the
server.
"""
key = "give up"
aliases = ['abort']
def func(self):
outro_room = OutroRoom.objects.all()
if outro_room:
outro_room = outro_room[0]
else:
self.caller.msg("That didn't work (seems like a bug). "
"Try to use the |wteleport|n command instead.")
return
self.caller.move_to(outro_room)
class TutorialRoomCmdSet(CmdSet): class TutorialRoomCmdSet(CmdSet):
""" """
@ -216,6 +238,7 @@ class TutorialRoomCmdSet(CmdSet):
self.add(CmdTutorial()) self.add(CmdTutorial())
self.add(CmdTutorialSetDetail()) self.add(CmdTutorialSetDetail())
self.add(CmdTutorialLook()) self.add(CmdTutorialLook())
self.add(CmdTutorialGiveUp())
class TutorialRoom(DefaultRoom): class TutorialRoom(DefaultRoom):
@ -396,7 +419,12 @@ class IntroRoom(TutorialRoom):
if character.is_superuser: if character.is_superuser:
string = "-" * 78 + SUPERUSER_WARNING + "-" * 78 string = "-" * 78 + SUPERUSER_WARNING + "-" * 78
character.msg("|r%s|n" % string.format(name=character.key, quell="|w@quell|r")) character.msg("|r%s|n" % string.format(name=character.key, quell="|wquell|r"))
else:
# quell user
if character.account:
character.account.execute_cmd("quell")
character.msg("(Auto-quelling while in tutorial-world)")
# ------------------------------------------------------------- # -------------------------------------------------------------
@ -617,7 +645,7 @@ class BridgeCmdSet(CmdSet):
"""This groups the bridge commands. We will store it on the room.""" """This groups the bridge commands. We will store it on the room."""
key = "Bridge commands" key = "Bridge commands"
priority = 1 # this gives it precedence over the normal look/help commands. priority = 2 # this gives it precedence over the normal look/help commands.
def at_cmdset_creation(self): def at_cmdset_creation(self):
"""Called at first cmdset creation""" """Called at first cmdset creation"""
@ -679,7 +707,7 @@ class BridgeRoom(WeatherRoom):
self.db.east_exit = "gate" self.db.east_exit = "gate"
self.db.fall_exit = "cliffledge" self.db.fall_exit = "cliffledge"
# add the cmdset on the room. # add the cmdset on the room.
self.cmdset.add_default(BridgeCmdSet) self.cmdset.add(BridgeCmdSet, permanent=True)
# since the default Character's at_look() will access the room's # since the default Character's at_look() will access the room's
# return_description (this skips the cmdset) when # return_description (this skips the cmdset) when
# first entering it, we need to explicitly turn off the room # first entering it, we need to explicitly turn off the room
@ -1108,3 +1136,8 @@ class OutroRoom(TutorialRoom):
if obj.typeclass_path.startswith("evennia.contrib.tutorial_world"): if obj.typeclass_path.startswith("evennia.contrib.tutorial_world"):
obj.delete() obj.delete()
character.tags.clear(category="tutorial_world") character.tags.clear(category="tutorial_world")
def at_object_leave(self, character, destination):
if character.account:
character.account.execute_cmd("unquell")

View file

@ -321,7 +321,7 @@ class EvMenuCmdSet(CmdSet):
# ------------------------------------------------------------- # -------------------------------------------------------------
class EvMenu(object): class EvMenu:
""" """
This object represents an operational menu. It is initialized from This object represents an operational menu. It is initialized from
a menufile.py instruction. a menufile.py instruction.