|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.client.Piece
Represents a piece (unit) on the game board. A Piece has several properties; a unique identifier (handle), position, name and type.
Every new instance must be given a handle. The name is a descriptive String. The type determines what symbol to use.
A Piece has several so called Properties. A property contains of a name and value. Every Piece is assumed to only have one Property of a given name.
The Piece is linked to zero or more Actions; things that this specific piece can do. A Piece has a queue of action that are to be executed in order, and at most one action that is currently executed.
A piece contains a number of messages that describe things that has happened to the piece.
A Piece can be marked as selected by a boolean. Selected piece will be painted with a red rectangle around it.
Field Summary | |
static int |
MAX_MESSAGES
The maximum number of messages. |
Constructor Summary | |
Piece(int handle)
Constructor for the Piece object |
|
Piece(int handle,
Position position,
String name,
String type)
Constructor for the Piece object |
Method Summary | |
void |
abortAllExecutingActions()
Removes all executing actions of this piece (both queued and currenlty executing). |
void |
abortQueuedAction(Action a)
Description of the Method |
void |
addAction(Action a)
Adds the given actions to the list of available actions of this piece. |
void |
addMessage(String msg)
Adds a feature to the Message attribute of the Piece object |
boolean |
equals(Object o)
Description of the Method |
Action |
executeNextAction()
Lets the next action execute. |
Enumeration |
getActions()
Returns all actions that this piece can do. |
Vector |
getAllQueuedActions()
Returns all actions that is currently queued for this piece. |
Action |
getExecutingAction()
Returns the currently executing action, or null if no action is executing. |
int |
getHandle()
Gets the Handle attribute of the Piece object |
Enumeration |
getMessages()
Gets the Messages attribute of the Piece object |
String |
getName()
Gets the Name attribute of the Piece object |
int |
getNumberOfMessages()
Gets the NumberOfMessages attribute of the Piece object |
Position |
getPosition()
Gets the Position attribute of the Piece object |
Property[] |
getProperties()
Returns an array containing the properties of this Piece. |
Property |
getProperty(String name)
Returns the property with the given name. |
Image |
getSymbol()
Gets the Symbol attribute of the Piece object |
String |
getType()
Gets the Type attribute of the Piece object |
int |
hashCode()
Description of the Method |
boolean |
isSelected()
Gets the Selected attribute of the Piece object |
void |
paint(Graphics g,
Rectangle bounds)
Paints the symbol on the given graphics, within the given bounding rectangle. |
void |
queue(Action a)
Queues the given action, allowing it to be executed after the other actions has finished. |
void |
removeAction(Action a)
Removes any action that has the same type as the given action from the list of available actions of this piece. |
void |
removeAllActions()
Removes all actions that indicates what this piece can do. |
void |
removeProperty(Property p)
|
void |
removeProperty(String name)
Removes the property with the given name from this Piece. |
void |
setName(String s)
Sets the Name attribute of the Piece object |
void |
setPosition(Position p)
Sets the Position attribute of the Piece object |
void |
setProperty(Property p)
Adds the given property to the properties of this object. |
void |
setProperty(String name,
String value)
Adds a property with the given name and value to the properties of this object. |
void |
setSelected(boolean b)
Sets the Selected attribute of the Piece object |
void |
setType(String s)
Sets the Type attribute of the Piece object |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MAX_MESSAGES
Constructor Detail |
public Piece(int handle)
handle
- Description of Parameterpublic Piece(int handle, Position position, String name, String type)
handle
- Description of Parameterposition
- Description of Parametername
- Description of Parametertype
- Description of ParameterMethod Detail |
public void setPosition(Position p)
p
- The new Position valuepublic void setName(String s)
s
- The new Name valuepublic void setType(String s)
s
- The new Type valuepublic void setSelected(boolean b)
b
- The new Selected valuepublic void setProperty(Property p)
p
- The new Property valuepublic void setProperty(String name, String value)
name
- The new Property valuevalue
- The new Property valuepublic void removeProperty(Property p)
public int getHandle()
public Position getPosition()
public Image getSymbol()
public String getName()
public String getType()
public boolean isSelected()
public Enumeration getActions()
public Property getProperty(String name)
name
- Description of Parameter
public Enumeration getMessages()
public int getNumberOfMessages()
public Property[] getProperties()
public Vector getAllQueuedActions()
public Action getExecutingAction()
public boolean equals(Object o)
equals
in class Object
o
- Description of Parameter
public int hashCode()
hashCode
in class Object
public void addAction(Action a)
a
- The feature to be added to the Action attributepublic void removeAction(Action a)
a
- Description of Parameterpublic void removeAllActions()
public void removeProperty(String name)
name
- Description of Parameterpublic void addMessage(String msg)
msg
- The feature to be added to the Message attributepublic void queue(Action a)
a
- Description of Parameterpublic void abortQueuedAction(Action a)
a
- Description of Parameterpublic void abortAllExecutingActions()
public Action executeNextAction()
public void paint(Graphics g, Rectangle bounds)
g
- Description of Parameterbounds
- Description of Parameterpublic String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |