Class Maze

java.lang.Object
nz.ac.vuw.ecs.swen225.gp22.domain.Maze

public class Maze extends Object
This class stores the game state (player, tilemap, entities, and treasures). As such, it is accessed by other packages to query the game state for specific tiles or perform operations on the player.
Author:
Abdul
  • Field Details

    • player

      public static Player player
      Stores the Player entity so that other tiles can access it easily.
    • entities

      public static ArrayList<Entity> entities
      Contains all non-player entities. Suppressed the raw types warning as the generic type is only used for observers and does not affect this use case.
    • unclaimedInteractions

      public static Queue<Entity.Action.Interaction> unclaimedInteractions
      Stores Interaction records to be claimed by entities.
    • globalID

      public static int globalID
      Used to make entity IDs.
  • Constructor Details

    • Maze

      public Maze()
  • Method Details

    • generateMap

      public static void generateMap(Maze.Point dimensions, int treasures, int nextLevelP)
      Generates a new map. This will be used by the persistency module for level loading.
      Parameters:
      dimensions - The size of the map.
      treasures - The number of treasures on the map.
      nextLevelP - Stores the number of the next level to load.
    • getDimensions

      public static Maze.Point getDimensions()
      Returns:
      A Point representing the maps dimensions.
    • getTile

      public static Tile getTile(Maze.Point point)
      Finds a Tile using the tilemap given a point.
      Parameters:
      point - The position of the tile.
      Returns:
      Tile object at the given position.
    • setTile

      public static void setTile(Maze.Point point, Tile tile)
      Sets the value on the tilemap at a given point.
      Parameters:
      point - The position the tile will be at.
      tile - The tile to add to the tilemap.
    • resetTile

      public static void resetTile(Maze.Point point)
      Sets the Tile object at a given point to ground.
      Parameters:
      point - Point to reset.
    • getChangeMap

      public static List<Entity.Action> getChangeMap()
      Returns:
      A list of changes that have occurred since this was last called.
    • apply

      public static void apply(List<Entity.Action> changeMap)
      Applies a change map to the current game, updating the game state.
      Parameters:
      changeMap - A list of changes to apply.
    • undo

      public static void undo(List<Entity.Action> changeMap)
      Undoes a change map to the current game, updating the game state.
      Parameters:
      changeMap - A list of changes to undo.
    • getEntity

      public static Entity getEntity(int id)
      Finds an entity based on its ID, used for replaying and rewinding moves. Suppresses raw types warning because the generic type is only used for observers and does not affect the implementation of this method.
      Parameters:
      id - ID of the entity.
      Returns:
      The entity that matches the ID.
    • collectTreasure

      public static void collectTreasure()
      Reduce the number of treasures left by 1.
    • addTreasure

      public static void addTreasure()
      Increases the number of treasures left by 1.
    • collectedAllTreasures

      public static boolean collectedAllTreasures()
      Returns:
      Whether or not all the Treasure tiles on the map have been collected.
    • getTreasuresLeft

      public static int getTreasuresLeft()
      Returns:
      The number of treasures left to collect.
    • getNextLevel

      public static int getNextLevel()
      Returns:
      The number of the next level to load.
    • gameComplete

      public static boolean gameComplete()
      Returns:
      Whether or not there are more levels to load.
    • gameWon

      public static boolean gameWon()
      Returns:
      Whether or not the game has been won.
    • isGameLost

      public static boolean isGameLost()
      Returns:
      Whether or not the player has lost the game.
    • loseGame

      public static void loseGame()
      Flags the game as over.
    • getStringState

      public static String getStringState()
      Returns:
      The current maze state in string form. Used for testing.