Class GameRefresher
java.lang.Object
VASSAL.build.module.GameRefresher
- All Implemented Interfaces:
GameComponent
,CommandEncoder
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 Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTo
(AbstractConfigurable parent) Translate a String into aCommand
Translate aCommand
into a Stringvoid
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.List
<VASSAL.build.module.GameRefresher.Refresher> 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.When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullvoid
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 the references are about to be jumbled/invalidated when new updated versions of pieces are created.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 Nameboolean
boolean
void
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.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.void
setup
(boolean gameStarting) Enable Refresh menu item when game is running only.void
start()
int
warnings()
-
Field Details
-
COMMAND_PREFIX
- See Also:
-
USE_NAME
- See Also:
-
FIX_GPID
- See Also:
-
USE_LABELER_NAME
- See Also:
-
USE_LAYER_NAME
- See Also:
-
USE_ROTATE_NAME
- See Also:
-
TEST_MODE
- See Also:
-
DELETE_NO_MAP
- See Also:
-
REFRESH_DECKS
- See Also:
-
REFRESH_PIECES
- See Also:
-
DELETE_OLD_DECKS
- See Also:
-
ADD_NEW_DECKS
- See Also:
-
USE_HOTKEY
- See Also:
-
SUPPRESS_INFO_REPORTS
- See Also:
-
ERROR_MESSAGE_PREFIX
- See Also:
-
SEPARATOR
- See Also:
-
-
Constructor Details
-
GameRefresher
-
-
Method Details
-
getModuleDrawPiles
-
warnings
public int warnings() -
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-
addTo
-
getRefreshAction
-
isTestMode
public boolean isTestMode() -
isDeleteNoMap
public boolean isDeleteNoMap() -
start
public void start() -
log
-
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:
- refreshables List of refreshable items
-
execute
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 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
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
AFTER the piece refresh, we now need to go through and restore all the broken Attachment mappings using the indices we created. -
refreshAttachment
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
- Piece to be checked and processedcommand
- Command under construction
-
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
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 interfaceGameComponent
-
setup
public void setup(boolean gameStarting) Enable Refresh menu item when game is running only.- Specified by:
setup
in interfaceGameComponent
- Parameters:
gameStarting
- if true, a game is starting. If false, then a game is ending
-