Player

class Player(startingArea: Area)

A Player object represents a player character controlled by the real-life user of the program.

A player object’s state is mutable: the player’s location and possessions can change, for instance.

NOTE: The AdventureDraft module is not even close to being well designed. See Chapter 9.3 in the course materials.

Value parameters:
startingArea

the player’s initial location

class Object
trait Matchable
class Any

Value members

Concrete methods

def go(direction: String): Unit

Attempts to move the player in the given direction. This is successful if there is an exit from the player’s current location towards the direction name. Prints out the results of the action.

Attempts to move the player in the given direction. This is successful if there is an exit from the player’s current location towards the direction name. Prints out the results of the action.

Determines if the player has indicated a desire to quit the game.

Determines if the player has indicated a desire to quit the game.

Returns the current location of the player.

Returns the current location of the player.

def quit(): Unit

Signals that the player wants to quit the game.

Signals that the player wants to quit the game.

def rest(): Unit

Causes the player to rest for a short while. (This has no substantial effect in game terms.) Prints out a message stating that the player rests.

Causes the player to rest for a short while. (This has no substantial effect in game terms.) Prints out a message stating that the player rests.

override def toString: String

Returns a brief description of the player’s state, for debugging purposes.

Returns a brief description of the player’s state, for debugging purposes.

Definition Classes