Package it.polimi.ingsw.server.model
Class WorkerMoveMap
java.lang.Object
it.polimi.ingsw.server.model.WorkerMap
it.polimi.ingsw.server.model.WorkerMoveMap
public class WorkerMoveMap extends WorkerMap
Represents the positions adjacent to the worker, in which he
may or may not move, depending on the boolean value of the cell.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description WorkerMoveMap(Worker worker) -
Method Summary
Modifier and Type Method Description booleananyAvailableMovePosition()Checks if the worker can move.voidcannotMoveInDomeCell()Forbids worker to move in a cell occupied by a dome.voidcannotMoveInFriendlyWorkerCell()Forbids worker to move in a cell occupied by the other worker of the same player.voidcannotMoveInOccupiedCell()Forbids worker to move in a cell occupied by a dome or another worker.voidcannotStayStill()Forbids worker to not move.booleanisAllowedToMoveBoard(int i, int j)Finds out if worker is allowed to move in a given cell of the board.booleanisAllowedToMoveWorkersMap(int i, int j)Finds out if worker is allowed to move in a given cell of the moveMap.voidupdateMoveUpRestrictions()Allows or forbids player to move up based on the canMoveUp attribute of Player.Methods inherited from class it.polimi.ingsw.server.model.WorkerMap
anyCellOneLevelHigher, anyTrueCell, domeCellFalse, friendlyWorkerCellFalse, getAbsolutePosition, getBooleanCellBoard, getBooleanCellWorkerMap, getWorker, levelDifferenceLessEqualThanX, neighboringEnemyWorkers, occupiedCellFalse, reset, setCell, setCenterPosition, setPerimeterFalse, updateCellsOutOfMap
-
Constructor Details
-
Method Details
-
cannotMoveInDomeCell
public void cannotMoveInDomeCell()Forbids worker to move in a cell occupied by a dome. -
cannotMoveInOccupiedCell
public void cannotMoveInOccupiedCell()Forbids worker to move in a cell occupied by a dome or another worker. -
cannotMoveInFriendlyWorkerCell
public void cannotMoveInFriendlyWorkerCell()Forbids worker to move in a cell occupied by the other worker of the same player. -
cannotStayStill
public void cannotStayStill()Forbids worker to not move. -
isAllowedToMoveBoard
public boolean isAllowedToMoveBoard(int i, int j)Finds out if worker is allowed to move in a given cell of the board.- Parameters:
i- Board coordinate X.j- Board coordinate Y.- Returns:
- True if it can move in cell, false otherwise.
-
isAllowedToMoveWorkersMap
public boolean isAllowedToMoveWorkersMap(int i, int j)Finds out if worker is allowed to move in a given cell of the moveMap.- Parameters:
i- moveMap coordinate X.j- moveMap coordinate Y.- Returns:
- True if it can move in position, false otherwise.
-
updateMoveUpRestrictions
public void updateMoveUpRestrictions()Allows or forbids player to move up based on the canMoveUp attribute of Player. -
anyAvailableMovePosition
public boolean anyAvailableMovePosition()Checks if the worker can move.- Returns:
- Returns true if there is a cell the worker can move in, false otherwise.
-