Class GameRefresher

java.lang.Object
VASSAL.build.module.GameRefresher
All Implemented Interfaces:
GameComponent, CommandEncoder

public final class GameRefresher extends Object implements CommandEncoder, GameComponent
GameRefresher Replace all counters in the same game with the current version of the counters defined in the module

Note: Counters that are Hidden or Obscured to us cannot be updated.

  • Field Details

  • Constructor Details

    • GameRefresher

      public GameRefresher(GpIdSupport gpIdSupport)
  • Method Details

    • getModuleDrawPiles

      public List<DrawPile> getModuleDrawPiles()
    • encode

      public String encode(Command c)
      Description copied from interface: CommandEncoder
      Translate a Command into a String
      Specified by:
      encode in interface CommandEncoder
    • decode

      public Command decode(String s)
      Description copied from interface: CommandEncoder
      Translate a String into a Command
      Specified by:
      decode in interface CommandEncoder
    • addTo

      public void addTo(AbstractConfigurable parent)
    • getRefreshAction

      public Action getRefreshAction()
    • isTestMode

      public boolean isTestMode()
    • isDeleteNoMap

      public boolean isDeleteNoMap()
    • start

      public void start()
    • log

      public void log(String message)
    • getRefreshables

      public List<VASSAL.build.module.GameRefresher.Refresher> getRefreshables()
      Build a list of all the Refreshables in the module in Visual order (bottom to top) so that we can ensure the visibility order of the refreshed pieces does not change. A Refreshable can be one of - Stack - Deck - Mat with contained Cargo - Single non-Mat unstacked piece
      Returns:
    • execute

      public void execute(Set<String> options, Command command) throws IllegalBuildException
      This method is used by PredefinedSetup.refresh() to update a PredefinedSetup in a GameModule The default execute() method calls: GameModule.getGameModule().getGameState().getAllPieces() to set the pieces list, this method provides an alternative way to specify which pieces should be refreshed.
      Throws:
      IllegalBuildException - - if we get a gpIdChecker error
    • indexAllAttachments

      public void indexAllAttachments()
      Before refreshing, we need to go through every piece and commemorate all the Attachment trait relationships, since they contain direct references to other GamePieces, and all of the references are about to be jumbled/invalidated when new updated versions of pieces are created. attachmentIndex maps the old attachments (using a reference hash of the outermost piece's Unique ID plus the notionally unique Attachment Name) to the list of attachments (which are the actual old gamepieces) updatedPieces (which will be created during the piece Refresh) is a forward mapping of old pieces (outermost pieces) to their replacement pieces formerPieces (also created during the piece Refresh) is a backward mapping of replacement pieces (again outermost pieces) to their original old pieces
    • indexAttachment

      public void indexAttachment(GamePiece piece)
      Index any attachments in this piece, storing a list of the attachments' contents, each under a hash made by taking the outermost piece's Unique ID and adding the notionally unique Attachment Name
      Parameters:
      piece - outer piece to be indexed
    • refreshAllAttachments

      public void refreshAllAttachments(Command command)
      AFTER the piece refresh, we now need to go through and restore all the broken Attachment mappings using the indices we created.
    • refreshAttachment

      public void refreshAttachment(GamePiece piece, Command command)
      For each *new* outermost piece that has Attachments, we look up the *old* outermost piece, and use its Unique ID plus each Attachment trait's name as a lookup hash to find the old list of contents. Then since the old list of contents is references to old versions of pieces, we use the "updatedPieces" index to look up the new pieces and create a new set of contents for the trait.
      Parameters:
      piece -
      command -
    • getRestoreCommand

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
      Specified by:
      getRestoreCommand in interface GameComponent
    • setup

      public void setup(boolean gameStarting)
      Enable Refresh menu item when game is running only.
      Specified by:
      setup in interface GameComponent
      Parameters:
      gameStarting - if true, a game is starting. If false, then a game is ending