Class MapGrid
java.lang.Object
model.map.MapGrid
11x11 map grid storing all Cell objects,
with helper methods for validating positions and movement.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCell(int row, int col) Returns the Cell at the specified position.Cell[][]getCells()Returns the full cell array (used by MapLoader to build the map).booleanisAdjacentMove(int fromRow, int fromCol, int toRow, int toCol) Checks whether a move is exactly 1 step in a straight line (no diagonal).booleanisValidPosition(int row, int col) Checks whether a position is within the map bounds.booleanisWalkable(int row, int col) Checks whether a cell is walkable (includes bounds checking).
-
Field Details
-
SIZE
public static final int SIZEMap size (11x11).- See Also:
-
cells
2D array holding all cells.
-
-
Constructor Details
-
MapGrid
public MapGrid()Creates an empty MapGrid where every cell is NORMAL.
-
-
Method Details
-
getCell
Returns the Cell at the specified position.- Parameters:
row- Row (0-10)col- Column (0-10)- Returns:
- Cell at that position
-
isValidPosition
public boolean isValidPosition(int row, int col) Checks whether a position is within the map bounds.- Parameters:
row- Row to checkcol- Column to check- Returns:
trueif the position is within bounds
-
isWalkable
public boolean isWalkable(int row, int col) Checks whether a cell is walkable (includes bounds checking).- Parameters:
row- Rowcol- Column- Returns:
trueif walkable
-
isAdjacentMove
public boolean isAdjacentMove(int fromRow, int fromCol, int toRow, int toCol) Checks whether a move is exactly 1 step in a straight line (no diagonal).- Parameters:
fromRow- Starting rowfromCol- Starting columntoRow- Destination rowtoCol- Destination column- Returns:
trueif the move is a single straight-line step
-
getCells
Returns the full cell array (used by MapLoader to build the map).- Returns:
- The complete Cell[][] of the map
-