-
Notifications
You must be signed in to change notification settings - Fork 40
Terminal class documentation
carolineclark edited this page Jul 21, 2015
·
1 revision
The Terminal class has several default behaviours and member functions available to the story maker.
print_text
- Default value, [""]
- This text is printed on the top of the narrative side (or StoryBook side) of the application, as opposed to be typed. This is used for the echo commands flow (to show your previous choice in replying to a user.)
story
- Default value, [""]
- This is the text that is typed at the start of the step.
start_dir
- Default value "~"
- This is the starting point for the user in that Step. The path listed need to be the path that the user sees and that exists in the story, otherwise it will raise an error.
end_dir
- Default value "~"
- This is where the user needs to end up in that Step to pass the level. The path listed need to be the path that the user sees and that exists in the story, otherwise it will raise an error.
commands
- Default value ""
- This is the list of commands that the user needs to type one of to pass the step. If it is empty, then the user does not need to type a specific command (e.g. if the aim of the Step is for the user to move to the correct directory, then the user should be evaluated on the fact they are in the correct directory, not the command they typed.)
hints
- Default value, "" This is the hints shown to the user if they do a command that doesn't pass the step. If it a string, then only one hint is shown to the user If it is an array of strings, then the hints are shown in order until the last hint, which is then repeatedly shown while the user makes mistakes.
last_step
- Default value False
- If this is True, then when the user finished this Step, they will be considered to have finished the challenge and their progress will be recorded to profile.
challenge_number
- Default value ""
- This decides what is shown at the top of the story side of the application, which is the challenge number. Also used in recording the profile when the user levels up.
story_dict
- Default value {}
- This is a way of adding files needed for that particular step.
deleted_items
- Default value, []
- This deletes items in the file tree according to their file path. We could also do this using story_dict?
last_user_input
- This contains the last string the user typed with the whitespace stripped off.
real_path
- The actual path that the user is currently at
current_path
- The "fake" path that the user is currently at
next(self)
- Decides which Step should be launched next
block_command(self)
- Decides whether we should block that particular command
- Default behaviour - blocks commands containing cd, mv or mkdir.
check_output(self, output)
- Decides whether we should level up on the basis on the output of the command
check_command(self)
- Default behaviour - checks the command that the user typed and the current location of the user, and decides whether the user should level up
exit(self)
- Sends a message to the server saying it wants to exit
send_text(self, hint)
- Sends the text to the story side of the server. If multiple requests are made to the server, it will only pass the first one that hits it, so don't make too many calls
send_hint(self, hint=None)
- If hint text is provided, then it will type out on the server side of the application. If a hint isn't provided, then a default hint will be sent to the story side