Adventure Docs
Fall 2025
API

# Adventure

o1.adventure.Adventure
class Adventure

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 that pertains 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.

## Attributes

Graph
Supertypes
  class Object
  trait Matchable
  class Any

## Members list

### Value members

#### Concrete methods

def goodbyeMessage: String

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 the player has completed their quest.

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 the player has completed their quest.

## Attributes

def isComplete: Boolean

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

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

## Attributes

def isOver: Boolean

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

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

## Attributes

def playTurn(`command`: String): String

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.

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.

## Attributes

def welcomeMessage: String

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

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

## Attributes

#### Concrete fields

val player: Player

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

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

## Attributes

val timeLimit: Int

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

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

## Attributes

val title: String

the name of the game

the name of the game

## Attributes

var turnCount: Int

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

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

## Attributes