summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/interface.rst6
-rw-r--r--weatbag/__init__.py7
-rw-r--r--weatbag/tiles/n3.py8
3 files changed, 12 insertions, 9 deletions
diff --git a/doc/interface.rst b/doc/interface.rst
index 796fa4b..dd960b4 100644
--- a/doc/interface.rst
+++ b/doc/interface.rst
@@ -52,3 +52,9 @@ Your module should define a class called ``Tile``, with the following interface:
:param player: the active :class:`~weatbag.Player` instance
:param direction: the direction the player is trying to leave, as a single
lowercase character, n/e/s/w
+
+ .. attribute:: no_path_msg
+
+ *Optional.* The message to display if the player attempts to leave in a
+ direction where there is no tile. The default message says "The undergrowth
+ in that direction is impassable. You turn back."
diff --git a/weatbag/__init__.py b/weatbag/__init__.py
index 9a743e0..511e8bc 100644
--- a/weatbag/__init__.py
+++ b/weatbag/__init__.py
@@ -101,7 +101,9 @@ def main():
name = input("What is your name? ")
player = Player(name)
interact(player)
-
+
+no_path_msg = "The undergrowth in that direction is impassable. You turn back."
+
def interact(player):
world = World()
tile = world[player.position]
@@ -120,8 +122,7 @@ def interact(player):
try:
tile = world[new_posn]
except KeyError:
- print("The undergrowth in that direction is impassable. "
- "You turn back.")
+ print(getattr(tile, 'no_path_msg', no_path_msg))
else:
player.position = new_posn
tile.describe()
diff --git a/weatbag/tiles/n3.py b/weatbag/tiles/n3.py
index 7591110..125898b 100644
--- a/weatbag/tiles/n3.py
+++ b/weatbag/tiles/n3.py
@@ -51,13 +51,9 @@ class Tile:
print("You manage to flee!")
return True
- if direction=='s':
- return True
- if direction=='n':
- return True
+ return True
- print("There is no path leading in that direction.")
- return False
+ no_path_msg = "There is no path leading in that direction."
def action(self, player, do):
if do[0] == "flee":