Class Worker

java.lang.Object
it.polimi.ingsw.server.model.Worker

public class Worker
extends java.lang.Object
The worker owned by a player. Actions of the player in the game will be referred to the selected worker in each turn.
  • Constructor Summary

    Constructors 
    Constructor Description
    Worker​(Player player, Sex sex)
    Creates a worker.
  • Method Summary

    Modifier and Type Method Description
    void buildBlock​(int x, int y)
    The worker builds a new block in the specified cell.
    void buildDome​(int x, int y)
    The worker builds a new dome in the specified cell.
    WorkerBuildMap getBuildMap()  
    int getLevel()  
    int getLevelVariation()  
    WorkerMoveMap getMoveMap()  
    Player getPlayer()  
    Cell getPosition()  
    Sex getSex()  
    void setPosition​(int x, int y)
    Changes position of the worker and updates level and movedUp.
    void setPosition​(Cell newPosition)
    Changes position of the worker and updates level and movedUp.
    void swapPosition​(Cell newPosition)
    Swaps the Worker with the other worker in the newPosition.

    Methods inherited from class java.lang.Object

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

    • Worker

      public Worker​(Player player, Sex sex)
      Creates a worker.
      Parameters:
      player - The worker's owner.
      sex - A worker can be Male or Female.
  • Method Details

    • setPosition

      public void setPosition​(int x, int y)
      Changes position of the worker and updates level and movedUp.
      Parameters:
      x - Coordinate of the new position of the worker.
      y - Coordinate of the new position of the worker.
    • setPosition

      public void setPosition​(Cell newPosition)
      Changes position of the worker and updates level and movedUp.
      Parameters:
      newPosition - Cell the worker is moving into.
    • swapPosition

      public void swapPosition​(Cell newPosition)
      Swaps the Worker with the other worker in the newPosition. Assumes that there is a worker in the newPosition. If there's no one this method should not be invoked.
      Parameters:
      newPosition - Cell the worker wants to move into.
    • buildBlock

      public void buildBlock​(int x, int y)
      The worker builds a new block in the specified cell.
      Parameters:
      x - Coordinate of the position to build in.
      y - Coordinate of the position to build in.
    • buildDome

      public void buildDome​(int x, int y)
      The worker builds a new dome in the specified cell.
      Parameters:
      x - Coordinate of the position to build in.
      y - Coordinate of the position to build in.
    • getPlayer

      public Player getPlayer()
      Returns:
      The specific player that owns this worker.
    • getPosition

      public Cell getPosition()
      Returns:
      The specific cell of the board of the game where the worker stands on.
    • getLevel

      public int getLevel()
      Returns:
      The level of the cell of the board where the worker stands on.
    • getLevelVariation

      public int getLevelVariation()
      Returns:
      When the worker moves, the difference between the levels of the cells is the level variation.
    • getSex

      public Sex getSex()
    • getMoveMap

      public WorkerMoveMap getMoveMap()
    • getBuildMap

      public WorkerBuildMap getBuildMap()