Package com.bdtripp.hauntedhouse.model
Class Player
java.lang.Object
com.bdtripp.hauntedhouse.model.Player
Represents a player in the game world.
Tracks the player's location, movement history, inventory, and statistics.
- Author:
- Brian Tripp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the status of the beamer chargeReturns the room where the beamer was last charged.Returns the room the player is currently located in.Returns the player's inventory.intCalculates how many moves the player can still make.Returns the previous room and removes it from the room historyReturns the stack of rooms the player has previously visited.getStats()Returns a formatted summary of the player's current stats.Makes a player ingest an itemvoidmoveToRoom(Room room, boolean addToHistory) Moves the player to the specified roomvoidsetBeamerCharge(boolean value) Sets whether the player's beamer is currently charged.voidSets the location of a beamer chargevoidAdds the current room to the room history
-
Constructor Details
-
Player
Creates a new player with the given name and starting inventory.- Parameters:
name- the name of the playerinventory- A collection of items carried by the player
-
-
Method Details
-
setBeamerCharge
public void setBeamerCharge(boolean value) Sets whether the player's beamer is currently charged.- Parameters:
value- true if the beamer is charged, otherwise false
-
getBeamerCharge
public boolean getBeamerCharge()Returns the status of the beamer charge- Returns:
- true if the beamer is charged
-
moveToRoom
Moves the player to the specified room- Parameters:
room- the room to move the player toaddToHistory- true if current room should be added to history
-
updateRoomHistory
public void updateRoomHistory()Adds the current room to the room history -
getRoomHistory
Returns the stack of rooms the player has previously visited.- Returns:
- the history of the rooms the player has been in
-
getCurrentRoom
Returns the room the player is currently located in.- Returns:
- the room the player is currently in
-
getPreviousRoom
Returns the previous room and removes it from the room history- Returns:
- the previous room
-
getMovesLeft
public int getMovesLeft()Calculates how many moves the player can still make.- Returns:
- the number of moves a player has left
-
setBeamerLocation
public void setBeamerLocation()Sets the location of a beamer charge -
getBeamerLocation
Returns the room where the beamer was last charged.- Returns:
- the location of the last beamer charge
-
ingest
Makes a player ingest an item- Parameters:
item- the item to ingest- Returns:
- a message to display
-
getInventory
Returns the player's inventory.- Returns:
- the player's inventory
-
getStats
Returns a formatted summary of the player's current stats.- Returns:
- a string containing health, strength, and carry weight
-