Module AM37

Class Action

java.lang.Object
it.polimi.ingsw.model.action.Action
Direct Known Subclasses:
BuildAction, MoveAction

public abstract class Action
extends java.lang.Object
Abstraction for Workers' actions

Each action

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Cell targetCell  
    protected Worker targetWorker  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected Action​(Worker targetWorker, Cell targetCell)
    Default constructor
  • Method Summary

    Modifier and Type Method Description
    abstract void apply()
    Forces an action to be applied
    Cell getStartingCell()
    startingCell getter
    Cell getTargetCell()
    targetCell getter
    Worker getTargetWorker()
    targetWorker getter
    abstract void getValidation​(Game game)
    Checks if the action can be performed, based on the game status

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Action

      protected Action​(Worker targetWorker, Cell targetCell)
      Default constructor
      Parameters:
      targetWorker - the worker performing the action
      targetCell - the cell to perform the action on
  • Method Details

    • getTargetWorker

      public Worker getTargetWorker()
      targetWorker getter
      Returns:
      the worker performing the action
    • getStartingCell

      public Cell getStartingCell()
      startingCell getter
      Returns:
      the worker's current position
    • getTargetCell

      public Cell getTargetCell()
      targetCell getter
      Returns:
      the action's target cell
    • getValidation

      public abstract void getValidation​(Game game) throws IllegalActionException
      Checks if the action can be performed, based on the game status
      Parameters:
      game - the game object which validates the action
      Throws:
      IllegalActionException - if the action cannot be performed
    • apply

      public abstract void apply()
      Forces an action to be applied