class Adventure extends AnyRef
The class Adventure
represents text adventure games. An adventure consists of a player and
a number of areas that make up the game world. It provides methods for playing the game one
turn at a time and for checking the state of the game.
N.B. This version of the class has a lot of "hard-coded" information which pertain to a very
specific adventure game that involves a small trip through a twisted forest. All newly created
instances of class Adventure
are identical to each other. To create other kinds of adventure
games, you will need to modify or replace the source code of this class.
- Alphabetic
- By Inheritance
- Adventure
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Adventure()
Value Members
- def goodbyeMessage: String
Returns a message that is to be displayed to the player at the end of the game.
Returns a message that is to be displayed to the player at the end of the game. The message will be different depending on whether or not the player has completed their quest.
- def isComplete: Boolean
Determines if the adventure is complete, that is, if the player has won.
- def isOver: Boolean
Determines whether the player has won, lost, or quit, thereby ending the game.
- def playTurn(command: String): String
Plays a turn by executing the given in-game command, such as "go west".
Plays a turn by executing the given in-game command, such as "go west". Returns a textual report of what happened, or an error message if the command was unknown. In the latter case, no turns elapse.
- val player: Player
The character who is the protagonist of the adventure and whom the real-life player controls.
- val timeLimit: Int
The maximum number of turns that this adventure game allows before time runs out.
- val title: String
The title of the adventure game.
- var turnCount: Int
The number of turns that have passed since the start of the game.
- def welcomeMessage: String
Returns a message that is to be displayed to the player at the beginning of the game.