Player
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.
- Value parameters:
- startingArea
the player’s initial location
Value members
Concrete methods
Tries to drop an item of the given name. This is successful if such an item is currently in the player’s possession. If so, the item is removed from the player’s inventory and placed in the area. Returns a description of the result of the attempt: "You drop the ITEM." or "You don't have that!".
Tries to drop an item of the given name. This is successful if such an item is currently in the player’s possession. If so, the item is removed from the player’s inventory and placed in the area. Returns a description of the result of the attempt: "You drop the ITEM." or "You don't have that!".
Causes the player to examine the item of the given name. This is successful if such an item is currently in the player’s possession. Returns a description of the result, which, if the attempt is successful, includes a description of the item. The description has the form: "You look closely at the ITEM.\nDESCRIPTION" or "If you want to examine something, you need to pick it up first."
Causes the player to examine the item of the given name. This is successful if such an item is currently in the player’s possession. Returns a description of the result, which, if the attempt is successful, includes a description of the item. The description has the form: "You look closely at the ITEM.\nDESCRIPTION" or "If you want to examine something, you need to pick it up first."
Tries to pick up an item of the given name. This is successful if such an item is located in the player’s current location. If so, the item is added to the player’s inventory. Returns a description of the result: "You pick up the ITEM." or "There is no ITEM here to pick up."
Tries to pick up an item of the given name. This is successful if such an item is located in the player’s current location. If so, the item is added to the player’s inventory. Returns a description of the result: "You pick up the ITEM." or "There is no ITEM here to pick up."
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. Returns a description of the result: "You go DIRECTION." or "You can't go DIRECTION."
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. Returns a description of the result: "You go DIRECTION." or "You can't go DIRECTION."
Determines whether the player is carrying an item of the given name.
Determines whether the player is carrying an item of the given name.
Determines if the player has indicated a desire to quit the game.
Determines if the player has indicated a desire to quit the game.
Causes the player to list what they are carrying. Returns a listing of the player’s possessions or a statement indicating that the player is carrying nothing. The return value has the form "You are carrying:\nITEMS ON SEPARATE LINES" or "You are empty-handed." The items are listed in an arbitrary order.
Causes the player to list what they are carrying. Returns a listing of the player’s possessions or a statement indicating that the player is carrying nothing. The return value has the form "You are carrying:\nITEMS ON SEPARATE LINES" or "You are empty-handed." The items are listed in an arbitrary order.
Signals that the player wants to quit the game. Returns a description of what happened within the game as a result (which is the empty string, in this case).
Signals that the player wants to quit the game. Returns a description of what happened within the game as a result (which is the empty string, in this case).