Package VASSAL.counters
Class Deck
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.counters.Stack
VASSAL.counters.Deck
- All Implemented Interfaces:
PlayerRoster.SideChangeListener,PropertySource,GamePiece,StateMergeable,Auditable,ImageSearchTarget
A collection of pieces that behaves like a deck, i.e.: Doesn't move.
Can't be expanded. Can be shuffled. Can be turned face-up and face-down.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn object that parses expression strings from the config windowprotected static classCommand to set the contents of this deck from a saved file. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanstatic final Stringprotected CommandEncoderSpecialCommandEncoderto handle loading/saving Decks from files.protected KeyCommand[]protected Deck.CountExpression[]protected MutableProperty.Implprotected Stringprotected static final StackMetricsprotected intprotected booleanprotected Stringprotected booleanprotected Stringprotected NamedKeyStrokeprotected booleanprotected List<MutableProperty.Impl>protected booleanprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected Stringprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected List<DeckGlobalKeyCommand>protected booleanstatic final Stringprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected Stringprotected intprotected DrawPileThe matching DrawPile that generated this Deckstatic final Stringstatic final Stringprotected Colorprotected String[]protected booleanprotected PropertySourceprotected Stringprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected booleanprotected PropertyExpressionprotected booleanprotected Stringprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected booleanprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected FormattedStringprotected Stringprotected booleanprotected Stringprotected NamedKeyStrokeprotected NamedKeyStrokeListenerprotected Stringprotected Stringprotected Dimensionstatic final Stringstatic final StringFields inherited from class VASSAL.counters.Stack
contents, HAS_LAYER_MARKER, INCR, layer, LAYER_NOT_SET, map, pieceCount, pos, TYPE -
Constructor Summary
ConstructorsConstructorDescriptionDeck()Deprecated, for removal: This API element is subject to removal in a future version.Deck(GameModule gameModule) Create an empty deckDeck(GameModule gameModule, String type) Creates an empty deck using specified type informationDeck(GameModule gameModule, String type, PropertySource source) Creates an empty deck using specified type information -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalKeyCommand(DeckGlobalKeyCommand globalCommand) Adds a Deck Global Key Command (DGKC).voidbooleanprotected voidprotected voidprotected voiddoFaceUp()protected voidprotected voidvoidReturn an iterator of pieces to be drawn from the Deck.Extended Send to Deck Command, based on the configuration of the supplied DeckSendKeyCommand - Deck target can be variable - Optional limit on number of cards to send - Optionally limit selection of cards to those that match an expression - Optionally stop sending cards when a specific card seen (match expression).protected voidSet the_numPieces property in the containing Map protected ColorThe color used to draw boxes representing cards underneath the top one.Return the name of the trait or Component an Auditable isReturn a description of the Type of trait or Component an Auditable isString[]intReturn the number of cards to be returned by next call todrawCards().protected String[]protected KeyCommand[]intReturn the number of pieces that could possible be drawn in the stack, regardless of visibility to any particular playerintReturn a list if pieces in the Deck in Dealable order.String[]getProperty(Object key) Stacks themselves do not have any properties, so always return null.The name of theDrawPileto which the contents of this deck will be sent when the reshuffle command is selectedgetShape()getSize()StackMetricsencapsulate information on how to draw expanded/unexpanded views of stacks.getState()Encodes the game state information of the stack into a stringgetType()importDeck(File f) protected voidinsertPieceAt(GamePiece p, int index) Inserts a piece into a specific position into the Deck (counting down from the top)protected voidinsertPieceAt(GamePiece p, int index, boolean suppressDeckCounts) Inserts a piece into a specific position into the Deck (counting down from the top)booleanReturn if our current player side can access the deckbooleanisAccessibleTo(String playerSide) Return true if the player playing the given side can access this deckbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanReturn true if this deck can be saved to and loaded from a file on diskbooleanbooleanbooleanbooleanbooleanmayContain(GamePiece piece) Does the specified GamePiece meet the rules to be contained in this Deck.voidmyRefreshType(String type) Sets or refreshes the information for this Deck.protected voidPerform some action on a GamePiece that has just been added to this StackPerform some action on a GamePiece that has just been removed this Stackvoidprotected voidvoidRemoves all pieces from the Deck.voidremoveGlobalKeyCommand(DeckGlobalKeyCommand globalCommand) Removes a Deck Global Key Command (DGKC).voidprotected voidremovePieceAt(int index) Removes a piece from a specific location in the deckprotected voidremovePieceAt(int index, boolean suppressDeckCounts) Removes a piece from a specific location in the deckvoidprotected CommandreportCommand(String format, String commandName) Format command report as per module designers setup.protected CommandreportCommand(FormattedString reportFormat, String commandName) Format command report as per module designers setup.reverse()Reverse the order of the contents of the Deckvoidprotected voidSends the I-am-empty key for this deck (whether to send it was already determined when the last piece was removed)Combine the contents of this Deck with the contents of the deck specified byreshuffleTargetvoidsetAllowMultipleDraw(boolean allowMultipleDraw) voidsetAllowSelectDraw(boolean allowSelectDraw) Set the contents of this Deck to a Collection of GamePiecessetContentsFaceDown(boolean value) voidsetCountExpressions(String[] countExpressionsString) voidvoidsetDragCount(int dragCount) Set the number of cards to be returned by next call todrawCards().voidsetDrawFaceUp(boolean drawFaceUp) voidvoidsetDrawOutline(boolean drawOutline) voidvoidvoidsetExpressionCounting(boolean expressionCounting) voidsetFaceDown(boolean faceDown) voidvoidvoidsetFaceDownMsgFormat(String faceDownMsgFormat) voidsetFaceDownOption(String faceDownOption) voidvoidvoidvoidprotected voidsetGlobalCommands(String[] commands) Sets the list of Deck Global Key Commands for this deckvoidsetHotkeyOnEmpty(boolean b) voidvoidvoidvoidSets the Map this Deck appears onvoidsetMaxStack(int maxStack) voidsetOutlineColor(Color outlineColor) voidvoidsetPersistable(boolean persistable) voidsetPropertySource(PropertySource source) Sets the Deck's property sourcevoidsetReshuffleCommand(String reshuffleCommand) voidsetReshuffleKey(NamedKeyStroke reshuffleKey) voidsetReshuffleMsgFormat(String reshuffleMsgFormat) voidsetReshuffleTarget(String reshuffleTarget) voidsetRestrictAccess(boolean b) voidsetRestrictExpression(PropertyExpression restrictExpression) voidsetRestrictOption(boolean restrictOption) voidvoidsetReverseKey(NamedKeyStroke reverseKey) voidsetReverseMsgFormat(String reverseMsgFormat) voidsetReversible(boolean reversible) voidvoidvoidvoidsetSelectDisplayProperty(String promptDisplayProperty) voidsetSelectSortProperty(String promptSortProperty) voidsetShuffle(boolean shuffle) voidvoidsetShuffleKey(NamedKeyStroke shuffleKey) voidsetShuffleMsgFormat(String shuffleMsgFormat) voidsetShuffleOption(String shuffleOption) voidvoidDecodes the game state information of the stack from a stringshuffle()Shuffle the contents of the DeckvoidsideChanged(String oldSide, String newSide) Listener for when the local player changes side.sort(List<SortParameter> sortParameters, FormattedString reportFormat, String menuCommand) Sort the Deck.Methods inherited from class VASSAL.counters.Stack
add, addImageNamesRecursively, asList, bottomPiece, bottomPiece, getDefaultMetrics, getId, getLayer, getLocalizedName, getLocalizedProperty, getMap, getName, getName, getParent, getPieceAbove, getPieceAt, getPieceBeneath, getPieceCount, getPieces, getPiecesInVisibleOrderIterator, getPiecesIterator, getPiecesReverseIterator, getPosition, getStackMetrics, indexOf, insert, insertChild, isEmpty, keyEvent, mergeState, nVisible, remove, selectNext, setDefaultMetrics, setExpanded, setId, setParent, setPosition, setProperty, setPropertyOnContents, topPiece, topPiece, toStringMethods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface VASSAL.counters.GamePiece
checkTrueMoved, finishMove, finishMove, prepareMove
-
Field Details
-
ID
- See Also:
-
ALWAYS
- See Also:
-
NEVER
- See Also:
-
USE_MENU
- See Also:
-
USE_MENU_UP
- See Also:
-
NO_USER
- See Also:
-
deckStackMetrics
-
drawOutline
protected boolean drawOutline -
outlineColor
-
size
-
shuffle
protected boolean shuffle -
faceDownOption
-
shuffleOption
-
shuffleCommand
-
allowMultipleDraw
protected boolean allowMultipleDraw -
allowSelectDraw
protected boolean allowSelectDraw -
reversible
protected boolean reversible -
reshuffleCommand
-
reshuffleTarget
-
reshuffleMsgFormat
-
reshuffleListener
-
reshuffleKey
-
reverseMsgFormat
-
reverseCommand
-
reverseKey
-
reverseListener
-
shuffleMsgFormat
-
shuffleListener
-
shuffleKey
-
faceDownMsgFormat
-
drawFaceUp
protected boolean drawFaceUp -
persistable
protected boolean persistable -
selectDisplayProperty
-
selectSortProperty
-
countProperty
-
expressionProperties
-
deckName
-
localizedDeckName
-
faceDown
protected boolean faceDown -
dragCount
protected int dragCount -
maxStack
protected int maxStack -
countExpressions
-
expressionCounting
protected boolean expressionCounting -
nextDraw
-
commands
-
globalCommands
-
hotkeyOnEmpty
protected boolean hotkeyOnEmpty -
emptyKey
-
restrictOption
protected boolean restrictOption -
restrictExpression
-
propertySource
-
drawMultipleMessage
-
drawSpecificMessage
-
faceUpMessage
-
faceDownMessage
-
faceUpMsgFormat
-
faceUpKey
-
faceDownKey
-
faceFlipKey
-
saveMessage
-
saveKey
-
saveReport
-
loadMessage
-
loadKey
-
loadReport
-
faceUpListener
-
faceDownListener
-
faceFlipListener
-
saveListener
-
loadListener
-
restrictAccess
protected boolean restrictAccess -
owners
-
myPile
The matching DrawPile that generated this Deck -
commandEncoder
SpecialCommandEncoderto handle loading/saving Decks from files.
-
-
Constructor Details
-
Deck
Deprecated, for removal: This API element is subject to removal in a future version.useDeck(GameModule)Not for internal use, but required for initial build of module -
Deck
Create an empty deck- Parameters:
gameModule- The game module
-
Deck
Creates an empty deck using specified type information- Parameters:
gameModule- The game moduletype- Type information for the deck (the configuration information that does not change during the game)
-
Deck
Creates an empty deck using specified type information- Parameters:
gameModule- The game moduletype- Type information for the deck (the configuration information that does not change during the game)source- PropertySource
-
-
Method Details
-
sendEmptyKey
protected void sendEmptyKey()Sends the I-am-empty key for this deck (whether to send it was already determined when the last piece was removed) -
getComponentTypeName
Description copied from interface:AuditableReturn a description of the Type of trait or Component an Auditable is- Specified by:
getComponentTypeNamein interfaceAuditable- Returns:
- Component Type
-
getComponentName
Description copied from interface:AuditableReturn the name of the trait or Component an Auditable is- Specified by:
getComponentNamein interfaceAuditable- Returns:
- Component name
-
setPropertySource
Sets the Deck's property source- Parameters:
source- PropertySource
-
getOwners
-
setOwners
-
isRestrictAccess
public boolean isRestrictAccess() -
setRestrictAccess
public void setRestrictAccess(boolean b) -
sideChanged
Listener for when the local player changes side. Updates all of our counts of expressions of pieces configured to be counted.- Specified by:
sideChangedin interfacePlayerRoster.SideChangeListener- Parameters:
oldSide- local player's old sidenewSide- local player's new side
-
addGlobalKeyCommand
Adds a Deck Global Key Command (DGKC).- Parameters:
globalCommand- The command to add
-
removeGlobalKeyCommand
Removes a Deck Global Key Command (DGKC).- Parameters:
globalCommand- The command to remove
-
getGlobalCommands
- Returns:
- A list of Deck Global Key Commands for this deck, serialized by their encoder.
-
setGlobalCommands
Sets the list of Deck Global Key Commands for this deck- Parameters:
commands- The list of commands to set (in serialized string form)
-
fireNumCardsProperty
protected void fireNumCardsProperty()Set the_numPieces property in the containing Map -
insertPieceAt
Inserts a piece into a specific position into the Deck (counting down from the top)- Overrides:
insertPieceAtin classStack- Parameters:
p- Piece to insertindex- "How many cards down into the Deck" to put it.
-
insertPieceAt
Inserts a piece into a specific position into the Deck (counting down from the top)- Overrides:
insertPieceAtin classStack- Parameters:
p- Piece to insertindex- "How many cards down into the Deck" to put it.suppressDeckCounts- true if ONLY the Stack part of the operation should be performed (we're just rearranging deck order and so don't want extra property updates). Ignored at Stack level.
-
removePieceAt
protected void removePieceAt(int index) Removes a piece from a specific location in the deck- Overrides:
removePieceAtin classStack- Parameters:
index- Piece to remove, counting down from the top
-
removePieceAt
protected void removePieceAt(int index, boolean suppressDeckCounts) Removes a piece from a specific location in the deck- Overrides:
removePieceAtin classStack- Parameters:
index- Piece to remove, counting down from the topsuppressDeckCounts- true if deck counts and firing last card keystroke should be suppressed (because we're actually just rearranging deck order)
-
removeAll
public void removeAll()Removes all pieces from the Deck. -
setMap
Sets the Map this Deck appears on -
addListeners
public void addListeners() -
removeListeners
public void removeListeners() -
myRefreshType
Sets or refreshes the information for this Deck. SeeDecorator.myGetType()- Parameters:
type- a serialized configuration string to set the "type information" of this Deck, which is information that doesn't change during the course of a single game (e.g. Image Files, Context Menu strings, etc, rules about when deck is shuffled, whether it is face-up or face down, etc).
-
mySetType
-
getFaceDownOption
-
isDrawFaceUp
public boolean isDrawFaceUp()- Returns:
- true if cards are turned face up when drawn from this deck
-
setDrawFaceUp
public void setDrawFaceUp(boolean drawFaceUp) -
setFaceDownOption
-
getSize
-
setSize
-
getShuffleOption
-
setShuffleOption
-
isShuffle
public boolean isShuffle() -
getMaxStack
public int getMaxStack() -
getMaximumVisiblePieceCount
public int getMaximumVisiblePieceCount()Description copied from class:StackReturn the number of pieces that could possible be drawn in the stack, regardless of visibility to any particular player- Overrides:
getMaximumVisiblePieceCountin classStack- Returns:
- Piece Count
-
getCountExpressions
-
doesExpressionCounting
public boolean doesExpressionCounting() -
getFaceDownMsgFormat
-
setFaceDownMsgFormat
-
getReverseMsgFormat
-
setReverseMsgFormat
-
getReverseCommand
-
setReverseCommand
-
getReverseKey
-
setReverseKey
-
getShuffleMsgFormat
-
setShuffleMsgFormat
-
getShuffleKey
-
setShuffleKey
-
getShuffleCommand
-
setShuffleCommand
-
setShuffle
public void setShuffle(boolean shuffle) -
isAllowMultipleDraw
public boolean isAllowMultipleDraw() -
setAllowMultipleDraw
public void setAllowMultipleDraw(boolean allowMultipleDraw) -
isAllowSelectDraw
public boolean isAllowSelectDraw() -
setMaxStack
public void setMaxStack(int maxStack) -
setCountExpressions
-
setExpressionCounting
public void setExpressionCounting(boolean expressionCounting) -
setAllowSelectDraw
public void setAllowSelectDraw(boolean allowSelectDraw) -
isReversible
public boolean isReversible() -
setReversible
public void setReversible(boolean reversible) -
setDeckName
-
getDeckName
-
getLocalizedDeckName
-
getReshuffleCommand
- Returns:
- The popup menu text for the command that sends the entire deck to another deck
-
setReshuffleCommand
-
getReshuffleKey
-
setReshuffleKey
-
getReshuffleTarget
The name of theDrawPileto which the contents of this deck will be sent when the reshuffle command is selected -
setReshuffleTarget
-
getReshuffleMsgFormat
- Returns:
- The message to send to the chat window when the deck is reshuffled to another deck
-
setReshuffleMsgFormat
-
getDrawMultipleMessage
-
setDrawMultipleMessage
-
getDrawSpecificMessage
-
setDrawSpecificMessage
-
getFaceUpMessage
-
setFaceUpMessage
-
getFaceDownMessage
-
setFaceDownMessage
-
getFaceUpMsgFormat
-
setFaceUpMsgFormat
-
getFaceUpKey
-
setFaceUpKey
-
getFaceDownKey
-
setFaceDownKey
-
getFaceFlipKey
-
setFaceFlipKey
-
getSaveMessage
-
setSaveMessage
-
getLoadMessage
-
setLoadMessage
-
getSaveKey
-
setSaveKey
-
getLoadKey
-
setLoadKey
-
getSaveReport
-
setSaveReport
-
getLoadReport
-
setLoadReport
-
isHotkeyOnEmpty
public boolean isHotkeyOnEmpty() -
setHotkeyOnEmpty
public void setHotkeyOnEmpty(boolean b) -
getNamedEmptyKey
-
setEmptyKey
-
setRestrictOption
public void setRestrictOption(boolean restrictOption) -
isRestrictOption
public boolean isRestrictOption() -
setRestrictExpression
-
getRestrictExpression
-
mayContain
Does the specified GamePiece meet the rules to be contained in this Deck. -
getType
-
shuffle
Shuffle the contents of the Deck -
getOrderedPieces
Return a list if pieces in the Deck in Dealable order. If this is an Always shuffle Deck, then shuffle the list of pieces, otherwise just reverse the list order so that we deal from the top.- Returns:
- List of pieces in Dealable order
-
drawCards
Return an iterator of pieces to be drawn from the Deck. Normally, a random piece will be drawn, but if the Deck supports it, the user may have specified a particular set of pieces or a fixed number of pieces to select with the next draw. -
setContents
Set the contents of this Deck to a Collection of GamePieces -
getState
Description copied from class:StackEncodes the game state information of the stack into a string -
setState
Description copied from class:StackDecodes the game state information of the stack from a string -
setContentsFaceDown
-
reverse
Reverse the order of the contents of the Deck -
isDrawOutline
public boolean isDrawOutline() -
setOutlineColor
-
setDrawOutline
public void setDrawOutline(boolean drawOutline) -
getOutlineColor
-
isFaceDown
public boolean isFaceDown() -
pieceAdded
Description copied from class:StackPerform some action on a GamePiece that has just been added to this Stack- Overrides:
pieceAddedin classStack- Parameters:
p- Game Piece- Returns:
- a
Commandthat performs the equivalent action when executed
-
pieceRemoved
Description copied from class:StackPerform some action on a GamePiece that has just been removed this Stack- Overrides:
pieceRemovedin classStack- Parameters:
p- GamePiece- Returns:
- a
Commandthat performs the equivalent action when executed
-
setFaceDown
public void setFaceDown(boolean faceDown) -
draw
Description copied from class:StackIf theobsparameter is aMap, delegate drawing of this Stack to theStackMetricsof that Map. Ifobsis not a Map, use the default StackMetrics -
getBlankColor
The color used to draw boxes representing cards underneath the top one. If null, then draw each card normally for face-up decks, and duplicate the top card for face-down decks -
getStackMetrics
Description copied from class:StackStackMetricsencapsulate information on how to draw expanded/unexpanded views of stacks. This method retrieves the appropriate stack metrics to use the stack, based on its map- Overrides:
getStackMetricsin classStack- Returns:
- stack metrics for the map, if provided, or the default one for the module.
-
boundingBox
- Specified by:
boundingBoxin interfaceGamePiece- Overrides:
boundingBoxin classStack- Returns:
- bounding box for the stack (minimum rectangle to contain the bounding boxes of all the pieces inside)
-
getShape
-
getProperty
Description copied from class:StackStacks themselves do not have any properties, so always return null.- Specified by:
getPropertyin interfaceGamePiece- Specified by:
getPropertyin interfacePropertySource- Overrides:
getPropertyin classStack- Parameters:
key- String key of property to be returned- Returns:
- always null
-
doFaceDown
protected void doFaceDown() -
doFaceUp
protected void doFaceUp() -
doFaceFlip
protected void doFaceFlip() -
doSaveDeck
protected void doSaveDeck() -
doLoadDeck
protected void doLoadDeck() -
getKeyCommands
-
reportCommand
Format command report as per module designers setup. -
reportCommand
Format command report as per module designers setup. Use a supplied FormattedString with preset properties -
promptForDragCount
public void promptForDragCount() -
promptForNextDraw
protected void promptForNextDraw() -
sendToDeck
Combine the contents of this Deck with the contents of the deck specified byreshuffleTarget -
extendedSend
Extended Send to Deck Command, based on the configuration of the supplied DeckSendKeyCommand - Deck target can be variable - Optional limit on number of cards to send - Optionally limit selection of cards to those that match an expression - Optionally stop sending cards when a specific card seen (match expression). If anything goes wrong, leave the source Deck untouched and gernate a Bad Data Report- Parameters:
dkc- DeckKeyCommand command containing the Send configuration- Returns:
- Commands executing the send
-
isExpanded
public boolean isExpanded()- Overrides:
isExpandedin classStack- Returns:
- true if stack has been visually expanded by the player
-
isAccessibleTo
Return true if the player playing the given side can access this deck- See Also:
-
isAccessible
public boolean isAccessible()Return if our current player side can access the deck -
isPersistable
public boolean isPersistable()Return true if this deck can be saved to and loaded from a file on disk -
setPersistable
public void setPersistable(boolean persistable) -
saveDeck
- Throws:
IOException
-
loadDeck
- Throws:
IOException
-
importDeck
-
importDeck
- Throws:
IOException
-
getDragCount
public int getDragCount()Return the number of cards to be returned by next call todrawCards(). -
setDragCount
public void setDragCount(int dragCount) Set the number of cards to be returned by next call todrawCards().- Parameters:
dragCount- number of cards to be returned
-
setSelectDisplayProperty
-
setSelectSortProperty
-
getSelectDisplayProperty
-
getSelectSortProperty
-
repaintMap
public void repaintMap() -
sort
public Command sort(List<SortParameter> sortParameters, FormattedString reportFormat, String menuCommand) Sort the Deck. Called from DeckSortKeyCommand- Parameters:
sortParameters- A list of parameters describing the sortreportFormat- A report format to generate when sort performed- Returns:
- Command encapsulating sort
-
Deck(GameModule)