Class GameState

java.lang.Object
com.mg105.entities.GameState

public class GameState extends Object
A class that represents the state of the game

This class has all attributes that the game relies on

  • Constructor Details

    • GameState

      public GameState(Inventory inventory, BattleCharacter[] party, WalkingCharacter walkingCharacter)
      Create a new game state.
      Parameters:
      inventory - the player's inventory.
      party - the player's party.
      walkingCharacter - the player's character data.
    • GameState

      public GameState(Inventory inventory, WalkingCharacter walkingCharacter)
      Create a new game state.
      Parameters:
      inventory - the player's inventory.
      walkingCharacter - the player's character data.
  • Method Details

    • getInventory

      public Inventory getInventory()
      Returns the inventory of GameState The Inventory is class that manages the items in a game
      Returns:
      the inventory of GameState
      See Also:
    • getPartyAliveMember

      public BattleCharacter getPartyAliveMember(@NotNull @NotNull String characterName)
      Returns the character in party based on the given name Only returns a party member that is not fainted return null iff the name is not of a non-fainted party member
      Parameters:
      characterName - the name of the character
      Returns:
      a character in party
    • addPartyMemberToAlive

      public void addPartyMemberToAlive(BattleCharacter character)
      Adds the battleCharacter to the party
      Parameters:
      character - the ALIVE character to add to the party
    • getFaintedPartyMember

      public BattleCharacter getFaintedPartyMember(@NotNull @NotNull String characterName) throws NoSuchElementException
      Returns the character in the party based on the given name Only returns a party member that is fainted return null iff the name is not of a fainted party member
      Parameters:
      characterName - the name of the character to be returned
      Returns:
      a character in party
      Throws:
      NoSuchElementException
    • removeFaintedPartyMember

      public void removeFaintedPartyMember(@NotNull @NotNull String characterName)
      Removes the given fainted party This should only be done to fainted party members whose hp is about to become above zero
      Parameters:
      characterName - the name of the party member that is fainted
    • getPartyMember

      @NotNull public @NotNull BattleCharacter getPartyMember(String characterName) throws NoSuchElementException
      Returns the correct party member given a name
      Parameters:
      characterName - the name of the party member to return
      Returns:
      the correct party member given a name
      Throws:
      NoSuchElementException - iff there is no party member of this name
    • getWalkingCharacter

      @NotNull public @NotNull WalkingCharacter getWalkingCharacter()
      Get the current WalkingCharacter the user is controlling.
      Returns:
      the walkingCharacter.
    • setMap

      public void setMap(@NotNull @NotNull Room firstRoom, @NotNull @NotNull Room lastRoom)
      Swap out the map of the game state to a new one defined by an interconnected graph between firstRoom and lastRoom. It should be noted that the interconnectedness is not checked here.

      Additionally, the current room is also set as the first room.

      Parameters:
      firstRoom - the first room of the map (where the tutorial is played).
      lastRoom - the end room of the map (where the game is won).
    • getCurrentRoom

      @NotNull public @NotNull Room getCurrentRoom()
      Get the room the player happens to currently be in.
      Returns:
      the current room.
    • setCurrentRoom

      public void setCurrentRoom(@NotNull @NotNull Room room)
      Set the current room. room must be graph-connected to the rest of the map.
      Parameters:
      room - the room to be set.
    • getCurrEncounter

      public Battle getCurrEncounter()
      Returns the active Battle, or null if there is none.
      Returns:
      the current Battle, or null if there is no active encounter.
    • setCurrEncounter

      public void setCurrEncounter(Battle currEncounter)
      Set currEncounter to the given active Battle.
      Parameters:
      currEncounter - the Battle to set currEncounter to.
    • removeCurrEncounter

      public void removeCurrEncounter()
      Removes the current active battle from the game state.
    • hasCurrEncounter

      public boolean hasCurrEncounter()
      Returns true iff the player is currently in a battle
      Returns:
      true iff the player is currently in a battle
    • getParty

      public ArrayList<BattleCharacter> getParty()
      Returns an ArrayList of the player's characters.
      Returns:
      An ArrayList of the player's characters.
    • setParty

      public void setParty(@NotNull @NotNull BattleCharacter[] party)
      Sets these BattleCharacters as the party This function should really only ever be called once
      Parameters:
      party - the battles character to the set the party to
    • getFainted

      public ArrayList<BattleCharacter> getFainted()
      Returns an ArrayList of the player's fainted characters.
      Returns:
      An ArrayList of the player's fainted characters.
    • getCurrOpponent

      public OpponentSet getCurrOpponent()
      Returns the currently selected OpponentSet.
      Returns:
      the currently selected OpponentSet.
    • setCurrOpponent

      public void setCurrOpponent(OpponentSet currOpponent)
      Sets the current OpponentSet to be faced.
      Parameters:
      currOpponent - the currently selected OpponentSet.
    • isCurrentRoomLastRoom

      public boolean isCurrentRoomLastRoom()
      Get if the player is in the last room.
      Returns:
      true if the player is in the last room, false otherwise.