Package VASSAL.counters
Interface GamePiece
- All Superinterfaces:
PropertySource
- All Known Subinterfaces:
EditablePiece
,TranslatablePiece
- All Known Implementing Classes:
ActionButton
,AreaOfEffect
,BasicPiece
,CalculatedProperty
,Clone
,CounterGlobalKeyCommand
,Deck
,Decorator
,Delete
,DynamicProperty
,Embellishment
,Embellishment0
,Footprint
,FreeRotator
,GlobalHotKey
,Hideable
,Immobilized
,Labeler
,Marker
,MenuSeparator
,MovementMarkable
,NonRectangular
,Obscurable
,Pivot
,PlaceMarker
,PlaySound
,PropertySheet
,Replace
,ReportState
,RestrictCommands
,Restricted
,ReturnToDeck
,SendToLocation
,SetGlobalProperty
,Stack
,SubMenu
,TableInfo
,Translate
,TriggerAction
,UsePrototype
public interface GamePiece extends PropertySource
Basic class for representing a physical component of the game
-
Method Summary
Modifier and Type Method Description Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePieceString
getId()
Each GamePiece must have a unique String identifierString
getLocalizedName()
And the translated name for this pieceMap
getMap()
String
getName()
The plain English name for this pieceStack
getParent()
Point
getPosition()
Object
getProperty(Object key)
Shape
getShape()
The shape of the piece from the user's viewpoint.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.Command
keyEvent(KeyStroke stroke)
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likesvoid
setId(String id)
void
setMap(Map map)
Each GamePiece belongs to a singleMap
void
setParent(Stack s)
void
setPosition(Point p)
void
setProperty(Object key, Object val)
Other properties, possibly game-specific, can be associated with a piece.void
setState(String newState)
Methods inherited from interface VASSAL.build.module.properties.PropertySource
getLocalizedProperty
-
Method Details
-
setMap
Each GamePiece belongs to a singleMap
-
getMap
Map getMap() -
draw
Draw this GamePiece- Parameters:
g
-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.
-
getPosition
Point getPosition()- Returns:
- the location of this piece on its owning
Map
-
setPosition
-
boundingBox
Rectangle boundingBox()The area which this GamePiece occupies when drawn at the point (0,0) -
getShape
Shape getShape()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. LikeboundingBox()
, it assumes the position is (0,0) and must be translated to the actual location where the piece is being drawn. -
getParent
Stack getParent()- Returns:
- the
Stack
to which this piece belongs, or null if it doesn't belong to a stack.
-
setParent
-
keyEvent
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likes- Returns:
- a
Command
that, when executed, will invoke the same response. Usually aChangePiece
command. - See Also:
ForwardToKeyBuffer
-
getName
String getName()The plain English name for this piece -
getLocalizedName
String getLocalizedName()And the translated name for this piece -
getId
String getId()Each GamePiece must have a unique String identifier- See Also:
GameState.getNewPieceId()
-
setId
-
getType
String getType()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.- See Also:
BasicCommandEncoder
-
getState
String getState()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
-
setProperty
Other properties, possibly game-specific, can be associated with a piece. The properties may or may not need to be encoded in the piece'sgetState()
method. -
getProperty
- Specified by:
getProperty
in interfacePropertySource
-