Package edu.ntnu.idi.idatt.model.tile
Class LadderGameTile
java.lang.Object
edu.ntnu.idi.idatt.model.tile.Tile
edu.ntnu.idi.idatt.model.tile.LadderGameTile
LadderGameTile.
Represents a specialized Tile
for a ladder game. In addition to the standard
tile properties, a LadderGameTile
can have a specific TileAction
associated with it, which is triggered when a player lands on this tile.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLadderGameTile
(int tileId, int[] coordinates, int nextTileId) Constructs aLadderGameTile
with a tile ID, coordinates, and the ID of the next tile in sequence.LadderGameTile
(int tileId, int[] coordinates, int nextTileId, TileAction tileAction) Constructs aLadderGameTile
with a tile ID, coordinates, the ID of the next tile, and a specificTileAction
to be performed when a player lands on this tile. -
Method Summary
Modifier and TypeMethodDescriptionReturns theTileAction
that occurs when a player lands on this tile.void
setLandAction
(TileAction landAction) Sets theTileAction
to be performed when a player lands on this tile.Methods inherited from class edu.ntnu.idi.idatt.model.tile.Tile
getCoordinates, getNextTileId, getTileId
-
Constructor Details
-
LadderGameTile
public LadderGameTile(int tileId, int[] coordinates, int nextTileId) Constructs aLadderGameTile
with a tile ID, coordinates, and the ID of the next tile in sequence. The land action is initially null.- Parameters:
tileId
- The unique identifier for this tile.coordinates
- An array representing the (row, column) position of this tile on the board.nextTileId
- The ID of the tile that logically follows this one in the normal game flow.
-
LadderGameTile
Constructs aLadderGameTile
with a tile ID, coordinates, the ID of the next tile, and a specificTileAction
to be performed when a player lands on this tile.- Parameters:
tileId
- The unique identifier for this tile.coordinates
- An array representing the (row, column) position of this tile on the board.nextTileId
- The ID of the tile that logically follows this one.tileAction
- TheTileAction
associated with landing on this tile.
-
-
Method Details
-
getLandAction
Returns theTileAction
that occurs when a player lands on this tile. This could be, for example, moving to a different tile (ladder/slide) or another effect.- Returns:
- The
TileAction
associated with this tile, ornull
if none.
-
setLandAction
Sets theTileAction
to be performed when a player lands on this tile. The provided action is validated usingtileSetLandActionValidator
.- Parameters:
landAction
- TheTileAction
to set. Must not be null.- Throws:
IllegalArgumentException
- iflandAction
is null.
-