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
    CellClient findCell​(int x, int y)
    Finds a specific cell in the board, based on the received Cartesian input.
    WorkerClient findWorker​(java.lang.String color, java.lang.String sex)
    Finds instance of worker in boardClient
    boolean isInBoard​(int x, int y)
    Allows to know if the input position stays on or off the board.
    void update​(CellClient cellFromServer)
    Updates the clientBoard of the view after receiving a cell from the server.
    java.lang.String workerCellRelativePositionCompass​(WorkerClient selectedWorker, int xTo, int yTo)
    Calculates the relative position selected with respect to the chosen worker.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • findCell

      public CellClient findCell​(int x, int y)
      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

      public void update​(CellClient cellFromServer)
      Updates the clientBoard of the view after receiving a cell from the server.
      Parameters:
      cellFromServer - cell received from the server.
    • findWorker

      public WorkerClient findWorker​(java.lang.String color, java.lang.String sex)
      Finds instance of worker in boardClient
      Parameters:
      color - color of the worker to find
      sex - sex of the worker to find
      Returns:
      reference of the requested worker.