Package it.polimi.ingsw.client
Class BoardClient
java.lang.Object
it.polimi.ingsw.client.BoardClient
public class BoardClient
extends java.lang.Object
Representation of the game Board client-side.
-
Constructor Summary
Constructors Constructor Description BoardClient() -
Method Summary
Modifier and Type Method Description CellClientfindCell(int x, int y)Finds a specific cell in the board, based on the received Cartesian input.WorkerClientfindWorker(java.lang.String color, java.lang.String sex)Finds instance of worker in boardClientbooleanisInBoard(int x, int y)Allows to know if the input position stays on or off the board.voidupdate(CellClient cellFromServer)Updates the clientBoard of the view after receiving a cell from the server.java.lang.StringworkerCellRelativePositionCompass(WorkerClient selectedWorker, int xTo, int yTo)Calculates the relative position selected with respect to the chosen worker.
-
Constructor Details
-
BoardClient
public BoardClient()
-
-
Method Details
-
findCell
Finds a specific cell in the board, based on the received Cartesian input.- Parameters:
x- Cartesian coordinate that refers to the row of the board.y- Cartesian coordinate that refers to the column of the board.- Returns:
- The cell that has that specific position on the board.
-
workerCellRelativePositionCompass
public java.lang.String workerCellRelativePositionCompass(WorkerClient selectedWorker, int xTo, int yTo)Calculates the relative position selected with respect to the chosen worker.- Parameters:
selectedWorker- The chosen worker from which the computation will be referred to.xTo- The row delta with respect to the chosen worker.yTo- The column delta with respect to the chosen worker.- Returns:
- The relative position with respect to the chosen worker, expressed in compass coordinates.
-
isInBoard
public boolean isInBoard(int x, int y)Allows to know if the input position stays on or off the board.- Parameters:
x- Cartesian coordinate that refers to the row of the board.y- Cartesian coordinate that refers to the column of the board.- Returns:
- True if the input is inside the board, false otherwise.
-
update
Updates the clientBoard of the view after receiving a cell from the server.- Parameters:
cellFromServer- cell received from the server.
-
findWorker
Finds instance of worker in boardClient- Parameters:
color- color of the worker to findsex- sex of the worker to find- Returns:
- reference of the requested worker.
-