Interface GamePiece

All Superinterfaces:
Auditable, PropertySource
All Known Subinterfaces:
EditablePiece, TranslatablePiece
All Known Implementing Classes:
ActionButton, AreaOfEffect, Attachment, BasicName, BasicPiece, BorderOutline, CalculatedProperty, Clone, Comment, CounterGlobalKeyCommand, Deck, Decorator, Delete, Deselect, DynamicProperty, Embellishment, Embellishment0, Footprint, FreeRotator, GlobalHotKey, Hideable, Immobilized, Labeler, Marker, Mat, MatCargo, MenuSeparator, MovementMarkable, MultiLocationCommand, NonRectangular, Obscurable, Pivot, PlaceMarker, PlaySound, PropertySheet, Replace, ReportState, RestrictCommands, Restricted, ReturnToDeck, SendToLocation, SetGlobalProperty, SetPieceProperty, Stack, SubMenu, TableInfo, TranslatableMessage, Translate, TriggerAction, UsePrototype

public interface GamePiece extends PropertySource
Interface to deal with the behaviors of a physical component of the game, or a Trait of one. Although from the name you might think that anything implementing this would be "a whole piece" (and perhaps in Elder Times that was true), a GamePiece is in fact implemented NOT ONLY by all of the three "basic" piece types: BasicPiece, Stack, or Deck; BUT ALSO it is implemented by all of the Traits (Decorator classes) that form the subcomponents of a full "piece" as we would know it on the game board.

When a GamePiece method of a Trait (Decorator) is called, the Trait first attempts to service the method call, and then normally (though not always, as in the case of "draw" calls to pieces with Invisible/Hideable or Mask/Obscurable traits) calls the same method for the next trait inward from it in the Decorator stack for the overall piece, and so on in turn until the "innermost" piece (normally a BasicPiece) has its method called.
Methods:
getType() - gets type information fixed throughout game
getState() - gets state information changeable during gameplay
setState(java.lang.String) - sets state information changeable during gameplay
setProperty(java.lang.Object, java.lang.Object) - sets other properties, *possibly* game-related, about a piece.
getProperty(java.lang.Object) - gets other properties, *possibly* game-related, about a piece.

draw(java.awt.Graphics, int, int, java.awt.Component, double) - tells this piece or part-of-piece to draw itself
keyEvent(javax.swing.KeyStroke) - gives this piece or Trait a chance to process key events. This is the main way for a GamePiece to receive "events".

getName() - the plain English name of the piece
getLocalizedName() - the localized name of the piece
getMap() and setMap(VASSAL.build.module.Map) - Each GamePiece belongs to a single Map
getPosition() and setPosition(java.awt.Point) - position on the map
getParent() and setParent(VASSAL.counters.Stack) - deals with membership in a Stack
boundingBox() - bounding box
getShape() - shape
getId() and setId(java.lang.String) - each piece has a unique ID

See Also:
extends PropertySource
extended by EditablePiece, TranslatablePiece