Package com.mg105.entities
Class GameState
java.lang.Object
com.mg105.entities.GameState
A class that represents the state of the game
This class has all attributes that the game relies on
-
Constructor Summary
ConstructorDescriptionGameState
(Inventory inventory, BattleCharacter[] party, WalkingCharacter walkingCharacter) Create a new game state.GameState
(Inventory inventory, WalkingCharacter walkingCharacter) Create a new game state. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPartyMemberToAlive
(BattleCharacter character) Adds the battleCharacter to the partyReturns the active Battle, or null if there is none.@NotNull Room
Get the room the player happens to currently be in.Returns the currently selected OpponentSet.Returns an ArrayList of the player's fainted characters.getFaintedPartyMember
(@NotNull String characterName) 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 memberReturns the inventory of GameState The Inventory is class that manages the items in a gamegetParty()
Returns an ArrayList of the player's characters.getPartyAliveMember
(@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@NotNull BattleCharacter
getPartyMember
(String characterName) Returns the correct party member given a name@NotNull WalkingCharacter
Get the current WalkingCharacter the user is controlling.boolean
Returns true iff the player is currently in a battleboolean
Get if the player is in the last room.void
Removes the current active battle from the game state.void
removeFaintedPartyMember
(@NotNull String characterName) Removes the given fainted party This should only be done to fainted party members whose hp is about to become above zerovoid
setCurrEncounter
(Battle currEncounter) Set currEncounter to the given active Battle.void
setCurrentRoom
(@NotNull Room room) Set the current room.void
setCurrOpponent
(OpponentSet currOpponent) Sets the current OpponentSet to be faced.void
Swap out the map of the game state to a new one defined by an interconnected graph between firstRoom and lastRoom.void
setParty
(@NotNull BattleCharacter[] party) Sets these BattleCharacters as the party This function should really only ever be called once
-
Constructor Details
-
GameState
Create a new game state.- Parameters:
inventory
- the player's inventory.party
- the player's party.walkingCharacter
- the player's character data.
-
GameState
Create a new game state.- Parameters:
inventory
- the player's inventory.walkingCharacter
- the player's character data.
-
-
Method Details
-
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
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
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
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
Get the current WalkingCharacter the user is controlling.- Returns:
- the walkingCharacter.
-
setMap
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
Get the room the player happens to currently be in.- Returns:
- the current room.
-
setCurrentRoom
Set the current room. room must be graph-connected to the rest of the map.- Parameters:
room
- the room to be set.
-
getCurrEncounter
Returns the active Battle, or null if there is none.- Returns:
- the current Battle, or null if there is no active encounter.
-
setCurrEncounter
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
Returns an ArrayList of the player's characters.- Returns:
- An ArrayList of the player's characters.
-
setParty
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
Returns an ArrayList of the player's fainted characters.- Returns:
- An ArrayList of the player's fainted characters.
-
getCurrOpponent
Returns the currently selected OpponentSet.- Returns:
- the currently selected OpponentSet.
-
setCurrOpponent
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.
-