mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 12:37:16 +02:00
contrib/tutorial_world/rooms.py Update markup +
whitespace and added `?` alias to help command consistent with pre-login and command help commands.
This commit is contained in:
parent
8dbd7163be
commit
ad1b0c7b77
1 changed files with 68 additions and 56 deletions
|
|
@ -23,7 +23,7 @@ from evennia.contrib.tutorial_world.objects import LightSource
|
|||
from django.conf import settings
|
||||
_SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
|
||||
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
#
|
||||
# Tutorial room - parent room class
|
||||
#
|
||||
|
|
@ -31,11 +31,11 @@ _SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
|
|||
# It defines a tutorial command on itself (available to
|
||||
# all those who are in a tutorial room).
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Special command available in all tutorial rooms
|
||||
#
|
||||
|
||||
|
||||
class CmdTutorial(Command):
|
||||
"""
|
||||
|
|
@ -62,16 +62,16 @@ class CmdTutorial(Command):
|
|||
caller = self.caller
|
||||
|
||||
if not self.args:
|
||||
target = self.obj # this is the room the command is defined on
|
||||
target = self.obj # this is the room the command is defined on
|
||||
else:
|
||||
target = caller.search(self.args.strip())
|
||||
if not target:
|
||||
return
|
||||
helptext = target.db.tutorial_info
|
||||
if helptext:
|
||||
caller.msg("{G%s{n" % helptext)
|
||||
caller.msg("|G%s|n" % helptext)
|
||||
else:
|
||||
caller.msg("{RSorry, there is no tutorial help available here.{n")
|
||||
caller.msg("|RSorry, there is no tutorial help available here.|n")
|
||||
|
||||
|
||||
# for the @detail command we inherit from MuxCommand, since
|
||||
|
|
@ -204,7 +204,7 @@ class TutorialRoomCmdSet(CmdSet):
|
|||
priority = 1
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"add the tutorial-room commands"
|
||||
"""add the tutorial-room commands"""
|
||||
self.add(CmdTutorial())
|
||||
self.add(CmdTutorialSetDetail())
|
||||
self.add(CmdTutorialLook())
|
||||
|
|
@ -216,7 +216,7 @@ class TutorialRoom(DefaultRoom):
|
|||
It defines a cmdset on itself for reading tutorial info about the location.
|
||||
"""
|
||||
def at_object_creation(self):
|
||||
"Called when room is first created"
|
||||
"""Called when room is first created"""
|
||||
self.db.tutorial_info = "This is a tutorial room. It allows you to use the 'tutorial' command."
|
||||
self.cmdset.add_default(TutorialRoomCmdSet)
|
||||
|
||||
|
|
@ -270,11 +270,11 @@ class TutorialRoom(DefaultRoom):
|
|||
self.db.details = {detailkey.lower(): description}
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
#
|
||||
# Weather room - room with a ticker
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
# These are rainy weather strings
|
||||
WEATHER_STRINGS = (
|
||||
|
|
@ -290,6 +290,7 @@ WEATHER_STRINGS = (
|
|||
"You hear the distant howl of what sounds like some sort of dog or wolf.",
|
||||
"Large clouds rush across the sky, throwing their load of rain over the world.")
|
||||
|
||||
|
||||
class WeatherRoom(TutorialRoom):
|
||||
"""
|
||||
This should probably better be called a rainy room...
|
||||
|
|
@ -328,8 +329,7 @@ class WeatherRoom(TutorialRoom):
|
|||
"""
|
||||
if random.random() < 0.2:
|
||||
# only update 20 % of the time
|
||||
self.msg_contents("{w%s{n" % random.choice(WEATHER_STRINGS))
|
||||
|
||||
self.msg_contents("|w%s|n" % random.choice(WEATHER_STRINGS))
|
||||
|
||||
|
||||
SUPERUSER_WARNING = "\nWARNING: You are playing as a superuser ({name}). Use the {quell} command to\n" \
|
||||
|
|
@ -338,14 +338,15 @@ SUPERUSER_WARNING = "\nWARNING: You are playing as a superuser ({name}). Use the
|
|||
"the scenes later).\n" \
|
||||
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
# Intro Room - unique room
|
||||
#
|
||||
# This room marks the start of the tutorial. It sets up properties on
|
||||
# the player char that is needed for the tutorial.
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
|
||||
class IntroRoom(TutorialRoom):
|
||||
"""
|
||||
|
|
@ -377,10 +378,10 @@ class IntroRoom(TutorialRoom):
|
|||
|
||||
if character.is_superuser:
|
||||
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="|w@quell|r"))
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
#
|
||||
# Bridge - unique room
|
||||
#
|
||||
|
|
@ -394,7 +395,7 @@ class IntroRoom(TutorialRoom):
|
|||
# divided into five steps:
|
||||
# westroom <- 0 1 2 3 4 -> eastroom
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
|
||||
class CmdEast(Command):
|
||||
|
|
@ -419,7 +420,7 @@ class CmdEast(Command):
|
|||
help_category = "TutorialWorld"
|
||||
|
||||
def func(self):
|
||||
"move one step eastwards"
|
||||
"""move one step eastwards"""
|
||||
caller = self.caller
|
||||
|
||||
bridge_step = min(5, caller.db.tutorial_bridge_position + 1)
|
||||
|
|
@ -463,7 +464,7 @@ class CmdWest(Command):
|
|||
help_category = "TutorialWorld"
|
||||
|
||||
def func(self):
|
||||
"move one step westwards"
|
||||
"""move one step westwards"""
|
||||
caller = self.caller
|
||||
|
||||
bridge_step = max(-1, caller.db.tutorial_bridge_position - 1)
|
||||
|
|
@ -484,25 +485,31 @@ class CmdWest(Command):
|
|||
caller.execute_cmd("look")
|
||||
|
||||
|
||||
BRIDGE_POS_MESSAGES = ("You are standing {wvery close to the the bridge's western foundation{n. If you go west you will be back on solid ground ...",
|
||||
"The bridge slopes precariously where it extends eastwards towards the lowest point - the center point of the hang bridge.",
|
||||
"You are {whalfways{n out on the unstable bridge.",
|
||||
"The bridge slopes precariously where it extends westwards towards the lowest point - the center point of the hang bridge.",
|
||||
"You are standing {wvery close to the bridge's eastern foundation{n. If you go east you will be back on solid ground ...")
|
||||
BRIDGE_POS_MESSAGES = ("You are standing |wvery close to the the bridge's western foundation|n."
|
||||
" If you go west you will be back on solid ground ...",
|
||||
"The bridge slopes precariously where it extends eastwards"
|
||||
" towards the lowest point - the center point of the hang bridge.",
|
||||
"You are |whalfways|n out on the unstable bridge.",
|
||||
"The bridge slopes precariously where it extends westwards"
|
||||
" towards the lowest point - the center point of the hang bridge.",
|
||||
"You are standing |wvery close to the bridge's eastern foundation|n."
|
||||
" If you go east you will be back on solid ground ...")
|
||||
BRIDGE_MOODS = ("The bridge sways in the wind.", "The hanging bridge creaks dangerously.",
|
||||
"You clasp the ropes firmly as the bridge sways and creaks under you.",
|
||||
"From the castle you hear a distant howling sound, like that of a large dog or other beast.",
|
||||
"The bridge creaks under your feet. Those planks does not seem very sturdy.",
|
||||
"Far below you the ocean roars and throws its waves against the cliff, as if trying its best to reach you.",
|
||||
"Far below you the ocean roars and throws its waves against the cliff,"
|
||||
" as if trying its best to reach you.",
|
||||
"Parts of the bridge come loose behind you, falling into the chasm far below!",
|
||||
"A gust of wind causes the bridge to sway precariously.",
|
||||
"Under your feet a plank comes loose, tumbling down. For a moment you dangle over the abyss ...",
|
||||
"The section of rope you hold onto crumble in your hands, parts of it breaking apart. You sway trying to regain balance.")
|
||||
"The section of rope you hold onto crumble in your hands,"
|
||||
" parts of it breaking apart. You sway trying to regain balance.")
|
||||
|
||||
FALL_MESSAGE = "Suddenly the plank you stand on gives way under your feet! You fall!" \
|
||||
"\nYou try to grab hold of an adjoining plank, but all you manage to do is to " \
|
||||
"divert your fall westwards, towards the cliff face. This is going to hurt ... " \
|
||||
"\n ... The world goes dark ...\n\n" \
|
||||
"\n ... The world goes dark ...\n\n"
|
||||
|
||||
|
||||
class CmdLookBridge(Command):
|
||||
|
|
@ -520,20 +527,20 @@ class CmdLookBridge(Command):
|
|||
help_category = "TutorialWorld"
|
||||
|
||||
def func(self):
|
||||
"Looking around, including a chance to fall."
|
||||
"""Looking around, including a chance to fall."""
|
||||
caller = self.caller
|
||||
bridge_position = self.caller.db.tutorial_bridge_position
|
||||
# this command is defined on the room, so we get it through self.obj
|
||||
location = self.obj
|
||||
# randomize the look-echo
|
||||
message = "{c%s{n\n%s\n%s" % (location.key,
|
||||
message = "|c%s|n\n%s\n%s" % (location.key,
|
||||
BRIDGE_POS_MESSAGES[bridge_position],
|
||||
random.choice(BRIDGE_MOODS))
|
||||
|
||||
chars = [obj for obj in self.obj.contents_get(exclude=caller) if obj.has_player]
|
||||
if chars:
|
||||
# we create the You see: message manually here
|
||||
message += "\n You see: %s" % ", ".join("{c%s{n" % char.key for char in chars)
|
||||
message += "\n You see: %s" % ", ".join("|c%s|n" % char.key for char in chars)
|
||||
self.caller.msg(message)
|
||||
|
||||
# there is a chance that we fall if we are on the western or central
|
||||
|
|
@ -542,10 +549,10 @@ class CmdLookBridge(Command):
|
|||
# we fall 5% of time.
|
||||
fall_exit = search_object(self.obj.db.fall_exit)
|
||||
if fall_exit:
|
||||
self.caller.msg("{r%s{n" % FALL_MESSAGE)
|
||||
self.caller.msg("|r%s|n" % FALL_MESSAGE)
|
||||
self.caller.move_to(fall_exit[0], quiet=True)
|
||||
# inform others on the bridge
|
||||
self.obj.msg_contents("A plank gives way under %s's feet and " \
|
||||
self.obj.msg_contents("A plank gives way under %s's feet and "
|
||||
"they fall from the bridge!" % self.caller.key)
|
||||
|
||||
|
||||
|
|
@ -555,24 +562,25 @@ class CmdBridgeHelp(Command):
|
|||
Overwritten help command while on the bridge.
|
||||
"""
|
||||
key = "help"
|
||||
aliases = ["h"]
|
||||
aliases = ["h", "?"]
|
||||
locks = "cmd:all()"
|
||||
help_category = "Tutorial world"
|
||||
|
||||
def func(self):
|
||||
"Implements the command."
|
||||
string = "You are trying hard not to fall off the bridge ..."
|
||||
string += "\n\nWhat you can do is trying to cross the bridge {weast{n "
|
||||
string += "or try to get back to the mainland {wwest{n)."
|
||||
"""Implements the command."""
|
||||
string = "You are trying hard not to fall off the bridge ..." \
|
||||
"\n\nWhat you can do is trying to cross the bridge |weast|n" \
|
||||
" or try to get back to the mainland |wwest|n)."
|
||||
self.caller.msg(string)
|
||||
|
||||
|
||||
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"
|
||||
priority = 1 # this gives it precedence over the normal look/help commands.
|
||||
priority = 1 # this gives it precedence over the normal look/help commands.
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"Called at first cmdset creation"
|
||||
"""Called at first cmdset creation"""
|
||||
self.add(CmdTutorial())
|
||||
self.add(CmdEast())
|
||||
self.add(CmdWest())
|
||||
|
|
@ -618,7 +626,7 @@ class BridgeRoom(WeatherRoom):
|
|||
|
||||
"""
|
||||
def at_object_creation(self):
|
||||
"Setups the room"
|
||||
"""Setups the room"""
|
||||
# this will start the weather room's ticker and tell
|
||||
# it to call update_weather regularly.
|
||||
super(BridgeRoom, self).at_object_creation()
|
||||
|
|
@ -644,7 +652,7 @@ class BridgeRoom(WeatherRoom):
|
|||
"""
|
||||
if random.random() < 80:
|
||||
# send a message most of the time
|
||||
self.msg_contents("{w%s{n" % random.choice(BRIDGE_WEATHER))
|
||||
self.msg_contents("|w%s|n" % random.choice(BRIDGE_WEATHER))
|
||||
|
||||
def at_object_receive(self, character, source_location):
|
||||
"""
|
||||
|
|
@ -658,7 +666,7 @@ class BridgeRoom(WeatherRoom):
|
|||
eexit = search_object(self.db.east_exit)
|
||||
fexit = search_object(self.db.fall_exit)
|
||||
if not (wexit and eexit and fexit):
|
||||
character.msg("The bridge's exits are not properly configured. "\
|
||||
character.msg("The bridge's exits are not properly configured. "
|
||||
"Contact an admin. Forcing west-end placement.")
|
||||
character.db.tutorial_bridge_position = 0
|
||||
return
|
||||
|
|
@ -679,7 +687,7 @@ class BridgeRoom(WeatherRoom):
|
|||
del character.db.tutorial_bridge_position
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------------
|
||||
#
|
||||
# Dark Room - a room with states
|
||||
#
|
||||
|
|
@ -687,7 +695,7 @@ class BridgeRoom(WeatherRoom):
|
|||
# LightSource object (LightSource is defined in
|
||||
# tutorialworld.objects.LightSource)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------------
|
||||
|
||||
|
||||
DARK_MESSAGES = ("It is pitch black. You are likely to be eaten by a grue.",
|
||||
|
|
@ -695,16 +703,20 @@ DARK_MESSAGES = ("It is pitch black. You are likely to be eaten by a grue.",
|
|||
"You don't see a thing. You feel around, managing to bump your fingers hard against something. Ouch!",
|
||||
"You don't see a thing! Blindly grasping the air around you, you find nothing.",
|
||||
"It's totally dark here. You almost stumble over some un-evenness in the ground.",
|
||||
"You are completely blind. For a moment you think you hear someone breathing nearby ... \n ... surely you must be mistaken.",
|
||||
"You are completely blind. For a moment you think you hear someone breathing nearby ... "
|
||||
"\n ... surely you must be mistaken.",
|
||||
"Blind, you think you find some sort of object on the ground, but it turns out to be just a stone.",
|
||||
"Blind, you bump into a wall. The wall seems to be covered with some sort of vegetation, but its too damp to burn.",
|
||||
"Blind, you bump into a wall. The wall seems to be covered with some sort of vegetation,"
|
||||
" but its too damp to burn.",
|
||||
"You can't see anything, but the air is damp. It feels like you are far underground.")
|
||||
|
||||
ALREADY_LIGHTSOURCE = "You don't want to stumble around in blindness anymore. You already " \
|
||||
"found what you need. Let's get light already!"
|
||||
|
||||
FOUND_LIGHTSOURCE = "Your fingers bump against a splinter of wood in a corner. It smells of resin and seems dry enough to burn! " \
|
||||
"You pick it up, holding it firmly. Now you just need to {wlight{n it using the flint and steel you carry with you."
|
||||
FOUND_LIGHTSOURCE = "Your fingers bump against a splinter of wood in a corner." \
|
||||
" It smells of resin and seems dry enough to burn! " \
|
||||
"You pick it up, holding it firmly. Now you just need to" \
|
||||
" |wlight|n it using the flint and steel you carry with you."
|
||||
|
||||
|
||||
class CmdLookDark(Command):
|
||||
|
|
@ -774,7 +786,7 @@ class CmdDarkNoMatch(Command):
|
|||
locks = "cmd:all()"
|
||||
|
||||
def func(self):
|
||||
"Implements the command."
|
||||
"""Implements the command."""
|
||||
self.caller.msg("Until you find some light, there's not much you can do. Try feeling around.")
|
||||
|
||||
|
||||
|
|
@ -793,7 +805,7 @@ class DarkCmdSet(CmdSet):
|
|||
priority = 2
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
"populate the cmdset."
|
||||
"""populate the cmdset."""
|
||||
self.add(CmdTutorial())
|
||||
self.add(CmdLookDark())
|
||||
self.add(CmdDarkHelp())
|
||||
|
|
@ -901,7 +913,7 @@ class DarkRoom(TutorialRoom):
|
|||
self.check_light_state(exclude=obj)
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
#
|
||||
# Teleport room - puzzles solution
|
||||
#
|
||||
|
|
@ -914,7 +926,7 @@ class DarkRoom(TutorialRoom):
|
|||
# oneself, and then pick the grave chamber with the
|
||||
# matching imagery for this attribute.
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
|
||||
class TeleportRoom(TutorialRoom):
|
||||
|
|
@ -931,7 +943,7 @@ class TeleportRoom(TutorialRoom):
|
|||
|
||||
"""
|
||||
def at_object_creation(self):
|
||||
"Called at first creation"
|
||||
"""Called at first creation"""
|
||||
super(TeleportRoom, self).at_object_creation()
|
||||
# what character.db.puzzle_clue must be set to, to avoid teleportation.
|
||||
self.db.puzzle_value = 1
|
||||
|
|
@ -977,13 +989,13 @@ class TeleportRoom(TutorialRoom):
|
|||
results[0].at_object_receive(character, self)
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
#
|
||||
# Outro room - unique exit room
|
||||
#
|
||||
# Cleans up the character from all tutorial-related properties.
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
# -------------------------------------------------------------
|
||||
|
||||
class OutroRoom(TutorialRoom):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue