Class Map.Merger

java.lang.Object
VASSAL.build.module.Map.Merger
All Implemented Interfaces:
DeckVisitor, PieceVisitor
Enclosing class:
Map

public static class Map.Merger extends Object implements DeckVisitor
Implements default logic for merging pieces (into a Stack or Deck} at a given location within a map Returns a Command that merges the input GamePiece with an existing piece at the input position, provided the pieces are stackable, visible, in the same layer, etc.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Merger​(Map map, Point pt, GamePiece p)
    Constructor for a Merger.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a command that merges our piece into the specified deck, provided that the Deck shares the location of our merger point provided in the constructor.
    GamePieces that are not handled by one of the type-specific methods (e.g.
    Returns a command to merge our piece into the specified stack, provided that the stack is in the precise map location specified, the map allows stacking, our piece allows stacking, and our stack & piece are in the same layer.

    Methods inherited from class java.lang.Object

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

    • Merger

      public Merger(Map map, Point pt, GamePiece p)
      Constructor for a Merger. This is passed the map, location, and piece we are going to be merging into something.
      Parameters:
      map - map
      pt - point
      p - piece
  • Method Details

    • visitDeck

      public Object visitDeck(Deck d)
      Returns a command that merges our piece into the specified deck, provided that the Deck shares the location of our merger point provided in the constructor.
      Specified by:
      visitDeck in interface DeckVisitor
      Parameters:
      d - Deck to consider merging into
      Returns:
      A command to merge our piece into the specified deck, or null if deck isn't in correct position
    • visitStack

      public Object visitStack(Stack s)
      Returns a command to merge our piece into the specified stack, provided that the stack is in the precise map location specified, the map allows stacking, our piece allows stacking, and our stack & piece are in the same layer.
      Specified by:
      visitStack in interface PieceVisitor
      Parameters:
      s - Stack to consider merging with
      Returns:
      Command to merge into the stack, or null if any of the necessary conditions weren't met
    • visitDefault

      public Object visitDefault(GamePiece piece)
      Description copied from interface: PieceVisitor
      GamePieces that are not handled by one of the type-specific methods (e.g. PieceVisitor.visitStack(VASSAL.counters.Stack)) are handled here
      Specified by:
      visitDefault in interface PieceVisitor
      Parameters:
      piece - piece to consider forming a new stack with.
      Returns:
      a command to form a new stack with a piece found at the our location, provided all of the conditions to form a stack are met. Returns null if the necessary conditions aren't met.