Class Player

java.lang.Object
com.bdtripp.hauntedhouse.model.Player

public class Player extends Object
Represents a player in the game world. Tracks the player's location, movement history, inventory, and statistics.
Author:
Brian Tripp
  • Constructor Details

    • Player

      public Player(String name, Inventory inventory)
      Creates a new player with the given name and starting inventory.
      Parameters:
      name - the name of the player
      inventory - 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

      public void moveToRoom(Room room, boolean addToHistory)
      Moves the player to the specified room
      Parameters:
      room - the room to move the player to
      addToHistory - true if current room should be added to history
    • updateRoomHistory

      public void updateRoomHistory()
      Adds the current room to the room history
    • getRoomHistory

      public Stack<Room> getRoomHistory()
      Returns the stack of rooms the player has previously visited.
      Returns:
      the history of the rooms the player has been in
    • getCurrentRoom

      public Room getCurrentRoom()
      Returns the room the player is currently located in.
      Returns:
      the room the player is currently in
    • getPreviousRoom

      public Room 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

      public Room getBeamerLocation()
      Returns the room where the beamer was last charged.
      Returns:
      the location of the last beamer charge
    • ingest

      public String ingest(Item item)
      Makes a player ingest an item
      Parameters:
      item - the item to ingest
      Returns:
      a message to display
    • getInventory

      public Inventory getInventory()
      Returns the player's inventory.
      Returns:
      the player's inventory
    • getStats

      public String getStats()
      Returns a formatted summary of the player's current stats.
      Returns:
      a string containing health, strength, and carry weight