Packages

c

o1.adventure

Adventure

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Adventure
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Adventure()

Value Members

  1. 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.

  2. def isComplete: Boolean

    Determines if the adventure is complete, that is, if the player has won.

  3. def isOver: Boolean

    Determines whether the player has won, lost, or quit, thereby ending the game.

  4. 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.

  5. val player: Player

    The character who is the protagonist of the adventure and whom the real-life player controls.

  6. val timeLimit: Int

    The maximum number of turns that this adventure game allows before time runs out.

  7. val title: String

    The title of the adventure game.

  8. var turnCount: Int

    The number of turns that have passed since the start of the game.

  9. def welcomeMessage: String

    Returns a message that is to be displayed to the player at the beginning of the game.