Class Maze
java.lang.Object
nz.ac.vuw.ecs.swen225.gp22.domain.Maze
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Represents a point on the tilemap. -
Field Summary
Modifier and TypeFieldDescriptionContains all non-player entities.static int
Used to make entity IDs.static Player
Stores the Player entity so that other tiles can access it easily.static Queue<Entity.Action.Interaction>
Stores Interaction records to be claimed by entities. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Increases the number of treasures left by 1.static void
apply
(List<Entity.Action> changeMap) Applies a change map to the current game, updating the game state.static boolean
static void
Reduce the number of treasures left by 1.static boolean
static boolean
gameWon()
static void
generateMap
(Maze.Point dimensions, int treasures, int nextLevelP) Generates a new map.static List<Entity.Action>
static Maze.Point
static Entity
getEntity
(int id) Finds an entity based on its ID, used for replaying and rewinding moves.static int
static String
static Tile
getTile
(Maze.Point point) Finds a Tile using the tilemap given a point.static int
static boolean
static void
loseGame()
Flags the game as over.static void
resetTile
(Maze.Point point) Sets the Tile object at a given point to ground.static void
setTile
(Maze.Point point, Tile tile) Sets the value on the tilemap at a given point.static void
undo
(List<Entity.Action> changeMap) Undoes a change map to the current game, updating the game state.
-
Field Details
-
player
Stores the Player entity so that other tiles can access it easily. -
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
Stores Interaction records to be claimed by entities. -
globalID
public static int globalIDUsed to make entity IDs.
-
-
Constructor Details
-
Maze
public Maze()
-
-
Method Details
-
generateMap
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
- Returns:
- A Point representing the maps dimensions.
-
getTile
Finds a Tile using the tilemap given a point.- Parameters:
point
- The position of the tile.- Returns:
- Tile object at the given position.
-
setTile
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
Sets the Tile object at a given point to ground.- Parameters:
point
- Point to reset.
-
getChangeMap
- Returns:
- A list of changes that have occurred since this was last called.
-
apply
Applies a change map to the current game, updating the game state.- Parameters:
changeMap
- A list of changes to apply.
-
undo
Undoes a change map to the current game, updating the game state.- Parameters:
changeMap
- A list of changes to undo.
-
getEntity
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
- Returns:
- The current maze state in string form. Used for testing.
-