|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.combat.Body
This class encapsulates a list of body parts that can be used to wear & wield things.
Field Summary | |
protected BodyPart[] |
dist_
|
protected java.util.ArrayList |
parts_
|
protected int |
total_
|
Constructor Summary | |
Body()
Constructs a new Body |
Method Summary | |
void |
addPart(BodyPart part)
Adds the specified body-part to the list. |
void |
addPartFirst(BodyPart part)
Adds a part to the front of the list. |
protected abstract void |
addParts()
This method is invoked by the Body constructor to tell the subclass to add its parts. |
protected void |
addWeightedPart(BodyPart part,
int weight)
Adds a new part with the specified weight. |
BodyPart |
chooseRandomPart()
Asks for a body-part to use as a hit location, computed using the relative "weight" (size) of each body part. |
java.lang.Object |
createClone()
Creates a clone of this parts list. |
boolean |
equals(java.lang.Object o)
Returns true if the passed parts list matches this one. |
BodyPart |
find(GenericPredicate p)
Iterates over the parts, looking for one that satisfies the passed predicate. |
BodyPart |
get(int index)
Returns the part at the specified index, or null if the index is out of bounds. |
BodyPart |
getByHashcode(int hashcode)
Retrieves a part from the list by its hash code. |
java.util.List |
getParts()
Returns the body parts in this list. |
int |
getTotalProbability()
Returns the total of the probability weights of the parts in this body. |
boolean |
isEmpty()
Returns true if there are no parts in the list. |
java.util.Iterator |
iterator()
Returns an iterator over the parts-list. |
protected void |
parsePartElement(org.w3c.dom.Element node)
Parses a "part" element and creates a BodyPart from it. |
protected void |
parsePartProperties(org.w3c.dom.Element node,
BodyPart part)
Parses the XML property declarations and adds them to the (already-constructed) BodyPart |
protected void |
parseToHit(BodyPart part,
org.w3c.dom.Element child,
java.lang.String value)
Parses a "tohit" element and sets the to-hit on the body part |
protected void |
parseWC(BodyPart part,
org.w3c.dom.Element child,
java.lang.String value)
Parses a "wc" element and adds the resulting WC to the body part |
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
void |
removePart(BodyPart part)
Removes the specified body-part from the list. |
void |
replacePart(BodyPart part)
Replaces a body part in the list. |
boolean |
shouldWrite()
Returns true if we should write the property at all. |
int |
size()
Returns the number of parts in the list. |
java.lang.String |
toString()
Returns a String representation of the parts-list. |
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.ArrayList parts_
protected BodyPart[] dist_
protected int total_
Constructor Detail |
public Body()
Method Detail |
public void addPartFirst(BodyPart part)
addPartFirst
in interface PartsList
public void addPart(BodyPart part)
addPart
in interface PartsList
part
- the part to addpublic void replacePart(BodyPart part)
part
- the part to replace. Finds the part in the
list with the same unique name and replace it with the
new part. If the parts don't have unique names, just
replaces the first part with the same name.public void removePart(BodyPart part)
removePart
in interface PartsList
public BodyPart getByHashcode(int hashcode)
getByHashcode
in interface PartsList
public BodyPart find(GenericPredicate p)
find
in interface PartsList
p
- the Predicate functionpublic java.util.Iterator iterator()
iterator
in interface PartsList
public BodyPart get(int index)
get
in interface PartsList
index
- the index in the parts-list
public boolean isEmpty()
isEmpty
in interface PartsList
public int size()
size
in interface PartsList
public java.util.List getParts()
getParts
in interface PartsList
public int getTotalProbability()
public BodyPart chooseRandomPart()
chooseRandomPart
in interface PartsList
public java.lang.Object createClone()
createClone
in interface MutableProperty
public java.lang.String toString()
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
readData
in interface SelfExternalizable
bean
- the DOM node representing the bean element
java.lang.Exception
protected void parsePartElement(org.w3c.dom.Element node) throws java.lang.Exception
node
- the "part" element
java.lang.Exception
protected void parsePartProperties(org.w3c.dom.Element node, BodyPart part) throws java.lang.Exception
node
- the "part" element, with optional child nodes
java.lang.Exception
protected void parseWC(BodyPart part, org.w3c.dom.Element child, java.lang.String value) throws java.lang.Exception
java.lang.Exception
protected void parseToHit(BodyPart part, org.w3c.dom.Element child, java.lang.String value) throws java.lang.Exception
java.lang.Exception
public java.util.List writeData() throws java.lang.Exception
writeData
in interface SelfExternalizable
java.lang.Exception
public boolean shouldWrite()
shouldWrite
in interface SelfExternalizable
public boolean equals(java.lang.Object o)
protected abstract void addParts()
protected void addWeightedPart(BodyPart part, int weight)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |