Class Parser
java.lang.Object
nz.ac.vuw.ecs.swen225.gp22.persistency.Parser
Used to parse XML files.
- Author:
- Gideon
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if there are entities in this save file.Parse the entities from the file.int
getLevel()
Get the level that is stored in the save file.int
Get the number of keys the player has collected Should only be used for saveFiles, not levelsgetTiles()
Parses all the tiles in the file into a list of tile objects.int
getTime()
Get the amount of time that has passed in a save file.void
parseInventory
(Player player, org.dom4j.Element inventory) Parse player inventory.void
Parse the dimensions of the level, the number of treasures and the player.void
parsePlayer
(Player player) Parse the saved player information from the file.
-
Constructor Details
-
Parser
Read given xml file and store in a document.- Parameters:
file
- file to parse
-
-
Method Details
-
parseMapInfo
public void parseMapInfo()Parse the dimensions of the level, the number of treasures and the player. -
getTime
public int getTime()Get the amount of time that has passed in a save file. Should only be used for saveFiles, not levels.- Returns:
- the time that has passed in this save file
-
getNumKeysCollected
public int getNumKeysCollected()Get the number of keys the player has collected Should only be used for saveFiles, not levels- Returns:
- the number of keys collected in this save file
-
getLevel
public int getLevel()Get the level that is stored in the save file.- Returns:
- the level number of the saved game
-
parsePlayer
Parse the saved player information from the file. create player at saved position and direction. add keys to inventory if present.- Parameters:
player
- the player to be updated
-
parseInventory
Parse player inventory.- Parameters:
player
- player with inventory to fillinventory
- dom4j element containing inventory to parse
-
entitiesPresent
public boolean entitiesPresent()Check if there are entities in this save file.- Returns:
- true if there are entities in this save file
-
getEntities
Parse the entities from the file.- Returns:
- list of entities
-
getTiles
Parses all the tiles in the file into a list of tile objects.- Returns:
- returns a list of all the tiles in the file
-