Class Action

java.lang.Object
be.belegkarnil.game.board.tak.Action

public class Action extends Object
This class represents all possible actions during a Game.
Author:
Belegkarnil
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Point
    The destination iff action is a move, null otherwhise
    static final Point
    Constant that is used to specify the destination value (null) if the action is not a move action
    static final Piece
    Constat that is used to specify the piece value (null) if the action is not a place action
    final Piece
    The piece played during the action
    final Point
    The position at which to put the piece during the action, or the src of a move
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an action to skip turn, no action
    Action(Piece piece, Point position)
    Constructor of a Place Action, put the piece at a position
    Action(Point source, Point destination, int[] amount)
    Constructor of a Move Action, move amount of pieces along a path
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Get a copy of the amount array (move action)
    boolean
    Know if the action is to replace/swap a Piece
    boolean
    Know if the action is to place a Piece
    boolean
    Know if the action is to skip the turn

    Methods inherited from class java.lang.Object

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

    • NO_MOVE

      public static final Point NO_MOVE
      Constant that is used to specify the destination value (null) if the action is not a move action
    • NO_PIECE

      public static final Piece NO_PIECE
      Constat that is used to specify the piece value (null) if the action is not a place action
    • piece

      public final Piece piece
      The piece played during the action
    • position

      public final Point position
      The position at which to put the piece during the action, or the src of a move
    • destination

      public final Point destination
      The destination iff action is a move, null otherwhise
  • Constructor Details

    • Action

      public Action(Piece piece, Point position)
      Constructor of a Place Action, put the piece at a position
      Parameters:
      piece - the Piece to place on the Board
      position - the position to place the Piece
    • Action

      public Action(Point source, Point destination, int[] amount)
      Constructor of a Move Action, move amount of pieces along a path
      Parameters:
      source - The position of the stack to take Pieces
      destination - The final position of the move, last place to place one or several Pieces
      amount - The amount of Pieces along the path from source to destination. At pos i, put amount[i] pieces from stack at the source.
    • Action

      public Action()
      Construct an action to skip turn, no action
  • Method Details

    • isPlace

      public boolean isPlace()
      Know if the action is to place a Piece
      Returns:
      true iff the action is to place a Piece
    • isMove

      public boolean isMove()
      Know if the action is to replace/swap a Piece
      Returns:
      true iff the action is to replace/swap a Piece
    • isSkip

      public boolean isSkip()
      Know if the action is to skip the turn
      Returns:
      true iff the action is to skip the turn
    • getAmount

      public int[] getAmount()
      Get a copy of the amount array (move action)
      Returns:
      the amount array