java.lang.Object
All Implemented Interfaces:
RuleSetStrategy

public class Swap
extends MovementStrategy
Swap position with opponents' workers workers when moving

This effect alters the workers' walkable cells: workers can swap their position with an opponent worker if it is in an adjacent cell

  • Constructor Details

  • Method Details

    • swapAction

      public void swapAction​(MoveAction action)
      Applies the action and eventually swaps the target cell's occupant position
      Parameters:
      action - the action to be performed
    • isMoveActionValid

      public boolean isMoveActionValid​(MoveAction action)
      Determines if a moveAction is legal and applies it

      g this ruleSet, a movement action is considered valid if the following conditions are all true:

      • no worker has been moved yet during the turn
      • the target cell is a walkable cell (see getWalkableCells(Worker)) for the worker to be moved
      Specified by:
      isMoveActionValid in interface RuleSetStrategy
      Overrides:
      isMoveActionValid in class RuleSetBase
      Parameters:
      action - the movement action to validate
      Returns:
      true if the action has been applied, false otherwise
    • getWalkableCells

      public java.util.List<Cell> getWalkableCells​(Worker worker)
      Provides a list of cells on which the worker can walk on

      Using this ruleSet, a worker can walk on the cells adjacent to its starting cell which height difference is at most one compared to the starting cell (domes do not count) and has no dome built on it; a worker can walk on a cell occupied by another worker (if the opponent worker's cell satisfies the condition above mentioned). If moving in a cell determines an immediate loss, the cell causing this behavior is not considered walkable; if all the cells lead to an immediate loss, the rule above is no longer applied and the player is free to choose which move to make before losing (see canBuildOnAtLeastOneCell(Cell))

      Specified by:
      getWalkableCells in interface RuleSetStrategy
      Overrides:
      getWalkableCells in class RuleSetBase
      Parameters:
      worker - the worker to be moved
      Returns:
      a list of walkable cells
    • cloneStrategy

      public RuleSetStrategy cloneStrategy​(Game game)
      Creates a clone of this object
      Specified by:
      cloneStrategy in interface RuleSetStrategy
      Overrides:
      cloneStrategy in class RuleSetBase
      Parameters:
      game - the current game
      Returns:
      a clone of this object