java.lang.Object
nz.ac.vuw.ecs.swen225.gp22.persistency.Parser

public class Parser extends Object
Used to parse XML files.
Author:
Gideon
  • Constructor Details

    • Parser

      public Parser(File file)
      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

      public void parsePlayer(Player player)
      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

      public void parseInventory(Player player, org.dom4j.Element inventory)
      Parse player inventory.
      Parameters:
      player - player with inventory to fill
      inventory - 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

      public List<Entity> getEntities()
      Parse the entities from the file.
      Returns:
      list of entities
    • getTiles

      public List<Tile> 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