Commits

Anonymous committed a2bd59c

branching story: some polishing.

  • Participants
  • Parent commits 0bceb15

Comments (0)

Files changed (1)

File branching_story.py

 You reach your car and leave the woods, 
 but a memory of old trees, dark shadows and wonder remains.
 """, 
+
 'the angry boar': """
 As you enter a darker region of the woods, you hear the rustling of leaves behind you. 
 Minutes later, you still don't quite know, how you escaped, 
         self.target = target
         #: The terrain / maze
         self.maze = maze
-        #: Descriptions for the places in thge terrain / maze
+        #: Descriptions for the places in the terrain / maze
         self.descriptions = descriptions
         #: The function to use for telling stories
         self.story = story
 self.pos_to_name(directions[i]) for i in answers])
         story(description)
         target = ""
+        # Ask the user until he/she supplies a valid answer. 
         while not target:  
             story("", autoscroll=True)
-            ans = ask(question)
+            ans = ask(question).strip() # removing any whitespace before the first letter
+            # the users input fits any of the answers 
+            # of the name of teh region for that answer, 
+            # Pick that as target. 
             for i in answers: 
                 name = self.maze[directions[i][1]][directions[i][0]]
                 if ans.lower() in [i.lower(), i.lower()[0], name, " ".join(name.split()[1:])]: 
         story("""You go to """ + self.pos_to_name(self.position))
         story(self.get_description(self.pos_to_name(self.position)))
 
-path = Path(start=(2,2), target=(0,0), maze=wood, descriptions=location_descriptions, story=story, ask=ask)
+
+### Usage ###
+
+# Get the path to move in. 
+path = Path(        start=(2,2), # Where we begin
+                    target=(0,0), # Where we want to get
+                    maze=wood, # The maze in which we move
+                    descriptions=location_descriptions, # Descriptions for the named locations in the maze
+                    story=story, 
+                    ask=ask)
+
+# Move until we reach the target. 
 while not path.position == path.target:
     path.move()