Package VASSAL.counters
Class Deck
java.lang.Object
VASSAL.counters.Stack
VASSAL.counters.Deck
- All Implemented Interfaces:
PlayerRoster.SideChangeListener
,PropertySource
,GamePiece
,StateMergeable
public class Deck extends Stack implements PlayerRoster.SideChangeListener
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 Classes Modifier and Type Class Description static class
Deck.CountExpression
An object that parses expression strings from the config windowprotected static class
Deck.LoadDeckCommand
Command to set the contents of this deck from a saved file. -
Field Summary
Fields inherited from class VASSAL.counters.Stack
contents, HAS_LAYER_MARKER, INCR, layer, LAYER_NOT_SET, map, pieceCount, pos, TYPE
-
Constructor Summary
Constructors Constructor Description Deck()
Deprecated.Deck(String type)
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)
Deck(GameModule gameModule, String type)
Deck(GameModule gameModule, String type, PropertySource source)
-
Method Summary
Modifier and Type Method Description void
addGlobalKeyCommand(DeckGlobalKeyCommand globalCommand)
Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)boolean
doesExpressionCounting()
void
draw(Graphics g, int x, int y, Component obs, double zoom)
PieceIterator
drawCards()
Return an iterator of pieces to be drawn from the Deck.protected void
fireNumCardsProperty()
Set the_numPieces property in the containing Map protected Color
getBlankColor()
The color used to draw boxes representing cards underneath the top one.String[]
getCountExpressions()
String
getDeckName()
int
getDragCount()
Return the number of cards to be returned by next call todrawCards()
.KeyStroke
getEmptyKey()
Deprecated, for removal: This API element is subject to removal in a future version.String
getFaceDownMsgFormat()
String
getFaceDownOption()
protected String[]
getGlobalCommands()
protected KeyCommand[]
getKeyCommands()
String
getLocalizedDeckName()
int
getMaximumVisiblePieceCount()
Return the number of pieces that could possible be drawn in the stack, regardless of visibility to any particular playerint
getMaxStack()
NamedKeyStroke
getNamedEmptyKey()
Color
getOutlineColor()
Object
getProperty(Object key)
String
getReshuffleCommand()
NamedKeyStroke
getReshuffleKey()
String
getReshuffleMsgFormat()
String
getReshuffleTarget()
The name of theDrawPile
to which the contents of this deck will be sent when the reshuffle command is selectedPropertyExpression
getRestrictExpression()
String
getReverseCommand()
NamedKeyStroke
getReverseKey()
String
getReverseMsgFormat()
String
getSelectDisplayProperty()
String
getSelectSortProperty()
Shape
getShape()
The shape of the piece from the user's viewpoint.String
getShuffleCommand()
NamedKeyStroke
getShuffleKey()
String
getShuffleMsgFormat()
String
getShuffleOption()
Dimension
getSize()
StackMetrics
getStackMetrics()
String
getState()
The state information is information that can change during the course of a game.String
getType()
The type information is information that does not change during the course of a game.protected void
insertPieceAt(GamePiece p, int index)
boolean
isAllowMultipleDraw()
boolean
isAllowSelectDraw()
boolean
isDrawFaceUp()
boolean
isDrawOutline()
boolean
isExpanded()
boolean
isFaceDown()
boolean
isHotkeyOnEmpty()
boolean
isPersistable()
Return true if this deck can be saved to and loaded from a file on diskboolean
isRestrictOption()
boolean
isReversible()
boolean
isShuffle()
Command
loadDeck(File f)
boolean
mayContain(GamePiece piece)
Does the specified GamePiece meet the rules to be contained in this Deck.protected void
mySetType(String type)
Command
pieceAdded(GamePiece p)
Perform some action on a GamePiece that has just been added to this StackCommand
pieceRemoved(GamePiece p)
Perform some action on a GamePiece that has just been removed this Stackvoid
promptForDragCount()
protected void
promptForNextDraw()
void
removeAll()
void
removeGlobalKeyCommand(DeckGlobalKeyCommand globalCommand)
protected void
removePieceAt(int index)
protected void
repaintMap()
protected Command
reportCommand(String format, String commandName)
Command
reverse()
Reverse the order of the contents of the Deckvoid
saveDeck(File f)
Command
sendToDeck()
Combine the contents of this Deck with the contents of the deck specified byreshuffleTarget
void
setAllowMultipleDraw(boolean allowMultipleDraw)
void
setAllowSelectDraw(boolean allowSelectDraw)
protected Command
setContents(Collection<GamePiece> c)
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.Command
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
setEmptyKey(NamedKeyStroke k)
void
setExpressionCounting(boolean expressionCounting)
void
setFaceDown(boolean faceDown)
void
setFaceDownMsgFormat(String faceDownMsgFormat)
void
setFaceDownOption(String faceDownOption)
protected void
setGlobalCommands(String[] commands)
void
setHotkeyOnEmpty(boolean b)
void
setMap(Map map)
Each GamePiece belongs to a singleMap
void
setMaxStack(int maxStack)
void
setOutlineColor(Color outlineColor)
void
setPersistable(boolean persistable)
void
setPropertySource(PropertySource source)
void
setReshuffleCommand(String reshuffleCommand)
void
setReshuffleKey(NamedKeyStroke reshuffleKey)
void
setReshuffleMsgFormat(String reshuffleMsgFormat)
void
setReshuffleTarget(String reshuffleTarget)
void
setRestrictExpression(PropertyExpression restrictExpression)
void
setRestrictOption(boolean restrictOption)
void
setReverseCommand(String s)
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
setShuffleCommand(String s)
void
setShuffleKey(NamedKeyStroke shuffleKey)
void
setShuffleMsgFormat(String shuffleMsgFormat)
void
setShuffleOption(String shuffleOption)
void
setSize(Dimension size)
void
setState(String state)
Command
shuffle()
Shuffle the contents of the Deckvoid
sideChanged(String oldSide, String newSide)
Methods inherited from class VASSAL.counters.Stack
add, 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
-
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
-
-
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
-
Deck
-
Deck
-
-
Method Details
-
setPropertySource
-
sideChanged
- Specified by:
sideChanged
in interfacePlayerRoster.SideChangeListener
-
addGlobalKeyCommand
-
removeGlobalKeyCommand
-
getGlobalCommands
-
setGlobalCommands
-
fireNumCardsProperty
protected void fireNumCardsProperty()Set the_numPieces property in the containing Map -
insertPieceAt
- Overrides:
insertPieceAt
in classStack
-
removePieceAt
protected void removePieceAt(int index)- Overrides:
removePieceAt
in classStack
-
removeAll
public void removeAll() -
setMap
Description copied from interface:GamePiece
Each GamePiece belongs to a singleMap
-
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: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
Description copied from interface:GamePiece
The type information is information that does not change during the course of a game. Image file names, popup menu command names, etc., all should be reflected in the type.- Specified by:
getType
in interfaceGamePiece
- Overrides:
getType
in classStack
- See Also:
BasicCommandEncoder
-
shuffle
Shuffle the contents of the Deck -
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 interface:GamePiece
The state information is information that can change during the course of a game. State information is saved when the game is saved and is transferred between players on the server. For example, the relative order of pieces in a stack is state information, but whether the stack is expanded is not -
setState
-
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
x
- 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
- Overrides:
getStackMetrics
in classStack
-
boundingBox
Description copied from interface:GamePiece
The area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBox
in interfaceGamePiece
- Overrides:
boundingBox
in classStack
-
getShape
Description copied from interface:GamePiece
The shape of the piece from the user's viewpoint. This defines the area in which the user must click to select or move the piece, for example. LikeGamePiece.boundingBox()
, it assumes the position is (0,0) and must be translated to the actual location where the piece is being drawn. -
getProperty
- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
- Overrides:
getProperty
in classStack
-
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
-
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)