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
,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
Modifier and TypeClassDescriptionstatic class
An object that parses expression strings from the config windowprotected static class
Command to set the contents of this deck from a saved file. -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
static String
protected CommandEncoder
SpecialCommandEncoder
to handle loading/saving Decks from files.protected KeyCommand[]
protected Deck.CountExpression[]
protected MutableProperty.Impl
protected String
protected static StackMetrics
protected int
protected boolean
protected boolean
protected NamedKeyStroke
protected boolean
protected List<MutableProperty.Impl>
protected boolean
protected String
protected String
protected List<DeckGlobalKeyCommand>
protected boolean
static String
protected String
protected int
static String
static String
protected Color
protected boolean
protected PropertySource
protected String
protected NamedKeyStroke
protected NamedKeyStrokeListener
protected String
protected String
protected PropertyExpression
protected boolean
protected String
protected NamedKeyStroke
protected NamedKeyStrokeListener
protected String
protected boolean
protected FormattedString
protected String
protected boolean
protected String
protected NamedKeyStroke
protected NamedKeyStrokeListener
protected String
protected String
protected Dimension
static String
Fields inherited from class VASSAL.counters.Stack
contents, HAS_LAYER_MARKER, INCR, layer, LAYER_NOT_SET, map, pieceCount, pos, TYPE
-
Constructor Summary
ConstructorDescriptionDeck()
Deprecated.Deprecated, for removal: This API element is subject to removal in a future version.Deck(String type, PropertySource source)
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 TypeMethodDescriptionvoid
addGlobalKeyCommand(DeckGlobalKeyCommand globalCommand)
Adds a Deck Global Key Command (DGKC).void
boolean
void
Return an iterator of pieces to be drawn from the Deck.protected void
Set the_numPieces property in the containing Map protected Color
The color used to draw boxes representing cards underneath the top one.String[]
int
Return the number of cards to be returned by next call todrawCards()
.Deprecated, for removal: This API element is subject to removal in a future version.protected String[]
protected KeyCommand[]
int
Return the number of pieces that could possible be drawn in the stack, regardless of visibility to any particular playerint
Return a list if pieces in the Deck in Dealable order.getProperty(Object key)
Stacks themselves do not have any properties, so always return null.The name of theDrawPile
to which the contents of this deck will be sent when the reshuffle command is selectedgetShape()
getSize()
StackMetrics
encapsulate information on how to draw expanded/unexpanded views of stacks.getState()
Encodes the game state information of the stack into a stringgetType()
protected void
insertPieceAt(GamePiece p, int index)
Inserts a piece into a specific position into the Deck (counting down from the top)boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
Return true if this deck can be saved to and loaded from a file on diskboolean
boolean
boolean
boolean
mayContain(GamePiece piece)
Does the specified GamePiece meet the rules to be contained in this Deck.protected void
Sets the information for this Deck.pieceAdded(GamePiece p)
Perform some action on a GamePiece that has just been added to this StackPerform some action on a GamePiece that has just been removed this Stackvoid
protected void
void
Removes all pieces from the Deck.void
removeGlobalKeyCommand(DeckGlobalKeyCommand globalCommand)
Removes a Deck Global Key Command (DGKC).void
protected void
removePieceAt(int index)
Removes a piece from a specific location in the deckprotected void
protected Command
reportCommand(String format, String commandName)
reverse()
Reverse the order of the contents of the Deckvoid
Combine the contents of this Deck with the contents of the deck specified byreshuffleTarget
void
setAllowMultipleDraw(boolean allowMultipleDraw)
void
setAllowSelectDraw(boolean allowSelectDraw)
protected Command
Set the contents of this Deck to a Collection of GamePiecesprotected Command
setContents(Iterator<GamePiece> it)
Deprecated, for removal: This API element is subject to removal in a future version.UsesetContents(Collection)
instead.setContentsFaceDown(boolean value)
void
setCountExpressions(String[] countExpressionsString)
void
setDeckName(String n)
void
setDragCount(int dragCount)
Set the number of cards to be returned by next call todrawCards()
.void
setDrawFaceUp(boolean drawFaceUp)
void
setDrawOutline(boolean drawOutline)
void
setEmptyKey(KeyStroke k)
Deprecated, for removal: This API element is subject to removal in a future version.void
void
setExpressionCounting(boolean expressionCounting)
void
setFaceDown(boolean faceDown)
void
setFaceDownMsgFormat(String faceDownMsgFormat)
void
setFaceDownOption(String faceDownOption)
protected void
setGlobalCommands(String[] commands)
Sets the list of Deck Global Key Commands for this deckvoid
setHotkeyOnEmpty(boolean b)
void
Sets the Map this Deck appears onvoid
setMaxStack(int maxStack)
void
setOutlineColor(Color outlineColor)
void
setPersistable(boolean persistable)
void
setPropertySource(PropertySource source)
Sets the Deck's property sourcevoid
setReshuffleCommand(String reshuffleCommand)
void
setReshuffleKey(NamedKeyStroke reshuffleKey)
void
setReshuffleMsgFormat(String reshuffleMsgFormat)
void
setReshuffleTarget(String reshuffleTarget)
void
setRestrictExpression(PropertyExpression restrictExpression)
void
setRestrictOption(boolean restrictOption)
void
void
setReverseKey(NamedKeyStroke reverseKey)
void
setReverseMsgFormat(String reverseMsgFormat)
void
setReversible(boolean reversible)
void
setSelectDisplayProperty(String promptDisplayProperty)
void
setSelectSortProperty(String promptSortProperty)
void
setShuffle(boolean shuffle)
void
void
setShuffleKey(NamedKeyStroke shuffleKey)
void
setShuffleMsgFormat(String shuffleMsgFormat)
void
setShuffleOption(String shuffleOption)
void
void
Decodes the game state information of the stack from a stringshuffle()
Shuffle the contents of the Deckvoid
sideChanged(String oldSide, String newSide)
Listener for when the local player changes side.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, getPiecesInReverseOrder, getPiecesInVisibleOrder, getPiecesInVisibleOrderIterator, getPiecesIterator, getPiecesReverseIterator, getPosition, getStackMetrics, indexOf, insert, insertChild, keyEvent, mergeState, nVisible, remove, selectNext, setDefaultMetrics, setExpanded, setId, setParent, setPosition, setProperty, setPropertyOnContents, topPiece, topPiece, toString
Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
ALWAYS
- See Also:
- Constant Field Values
-
NEVER
- See Also:
- Constant Field Values
-
USE_MENU
- See Also:
- Constant Field Values
-
NO_USER
- See Also:
- Constant Field Values
-
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
-
commandEncoder
SpecialCommandEncoder
to handle loading/saving Decks from files.
-
-
Constructor Details
-
Deck
Deprecated.useDeck(GameModule)
Not for internal use, but required for initial build of module -
Deck
Deprecated, for removal: This API element is subject to removal in a future version. -
Deck
Deprecated, for removal: This API element is subject to removal in a future version. -
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
-
setPropertySource
Sets the Deck's property source- Parameters:
source
- PropertySource
-
sideChanged
Listener for when the local player changes side. Updates all of our counts of expressions of pieces configured to be counted.- Specified by:
sideChanged
in 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:
insertPieceAt
in classStack
- Parameters:
p
- Piece to insertindex
- "How many cards down into the Deck" to put it.
-
removePieceAt
protected void removePieceAt(int index)Removes a piece from a specific location in the deck- Overrides:
removePieceAt
in classStack
- Parameters:
index
- Piece to remove, counting down from the top
-
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() -
mySetType
Sets 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).
-
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:Stack
Return the number of pieces that could possible be drawn in the stack, regardless of visibility to any particular player- Overrides:
getMaximumVisiblePieceCount
in 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 theDrawPile
to 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
-
isHotkeyOnEmpty
public boolean isHotkeyOnEmpty() -
setHotkeyOnEmpty
public void setHotkeyOnEmpty(boolean b) -
getEmptyKey
Deprecated, for removal: This API element is subject to removal in a future version. -
getNamedEmptyKey
-
setEmptyKey
Deprecated, for removal: This API element is subject to removal in a future version. -
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
- Specified by:
getType
in interfaceGamePiece
- Overrides:
getType
in classStack
- Returns:
- the encoding type
- See Also:
BasicCommandEncoder
-
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 -
setContents
@Deprecated(since="2020-08-06", forRemoval=true) protected Command setContents(Iterator<GamePiece> it)Deprecated, for removal: This API element is subject to removal in a future version.UsesetContents(Collection)
instead.Set the contents of this Deck to an Iterator of GamePieces -
getState
Description copied from class:Stack
Encodes the game state information of the stack into a string -
setState
Description copied from class:Stack
Decodes 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:Stack
Perform some action on a GamePiece that has just been added to this Stack- Overrides:
pieceAdded
in classStack
- Parameters:
p
- Game Piece- Returns:
- a
Command
that performs the equivalent action when executed
-
pieceRemoved
Description copied from class:Stack
Perform some action on a GamePiece that has just been removed this Stack- Overrides:
pieceRemoved
in classStack
- Parameters:
p
- GamePiece- Returns:
- a
Command
that performs the equivalent action when executed
-
setFaceDown
public void setFaceDown(boolean faceDown) -
draw
Description copied from class:Stack
If theobs
parameter is aMap
, delegate drawing of this Stack to theStackMetrics
of that Map. Ifobs
is not a Map, use the default StackMetrics- Specified by:
draw
in interfaceGamePiece
- Overrides:
draw
in classStack
- Parameters:
g
- target Graphics objectx
- x-location of the center of the piecey
- y-location of the center of the pieceobs
- the Component on which this piece is being drawnzoom
- the scaling factor.- See Also:
StackMetrics.draw(VASSAL.counters.Stack, java.awt.Graphics, int, int, java.awt.Component, double)
,Stack.getDefaultMetrics()
-
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:Stack
StackMetrics
encapsulate 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:
getStackMetrics
in classStack
- Returns:
- stack metrics for the map, if provided, or the default one for the module.
-
boundingBox
- Specified by:
boundingBox
in interfaceGamePiece
- Overrides:
boundingBox
in 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:Stack
Stacks themselves do not have any properties, so always return null.- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
- Overrides:
getProperty
in classStack
- Parameters:
key
- String key of property to be returned- Returns:
- always null
-
getKeyCommands
-
reportCommand
-
promptForDragCount
public void promptForDragCount() -
promptForNextDraw
protected void promptForNextDraw() -
sendToDeck
Combine the contents of this Deck with the contents of the deck specified byreshuffleTarget
-
isExpanded
public boolean isExpanded()- Overrides:
isExpanded
in classStack
- Returns:
- true if stack has been visually expanded by the player
-
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
-
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
protected void repaintMap()
-
Deck(GameModule)