net.sf.freecol.common.model
Class EquipmentType

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObjectType
          extended by net.sf.freecol.common.model.BuildableType
              extended by net.sf.freecol.common.model.EquipmentType

public class EquipmentType
extends BuildableType


Field Summary
private  boolean captureEquipmentByIndians
           
private  java.lang.String captureEquipmentId
          What this equipment type becomes if it is captured by Indians (if captureEquipmentByIndians is true) or Europeans (otherwise).
private  int combatLossPriority
          Determines which type of Equipment will be lost first if the Unit carrying it is defeated.
private  java.util.List<java.lang.String> compatibleEquipment
          A List containing the IDs of equipment types compatible with this one.
private  int maximumCount
          The maximum number of equipment items that can be combined.
private  boolean militaryEquipment
          Describe militaryEquipment here.
static EquipmentType[] NO_EQUIPMENT
           
private  Unit.Role role
          The default Role of the Unit carrying this type of Equipment.
 
Fields inherited from class net.sf.freecol.common.model.BuildableType
NOTHING
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
EquipmentType(java.lang.String id, Specification specification)
           
 
Method Summary
 boolean canBeCaptured()
          Returns true if this EquipmentType can be captured in combat.
 boolean equals(java.lang.Object obj)
           
 EquipmentType getCaptureEquipment(boolean byIndians)
          Get the type of equipment to capture, handling the case where Europeans and Indians use different EquipmentTypes for the same underlying goods.
 int getCombatLossPriority()
          Get the CombatLossPriority value.
 int getMaximumCount()
          Get the MaximumCount value.
 Unit.Role getRole()
          Get the Role value.
 java.util.Map<java.lang.String,java.lang.Boolean> getUnitAbilitiesRequired()
          Returns the abilities required by this Type.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 int hashCode()
           
 boolean isCompatibleWith(EquipmentType otherType)
          Returns true if this type of equipment is compatible with the given type of equipment.
 boolean isMilitaryEquipment()
          Returns true if Equipment of this type grants an offence bonus or a defence bonus.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Reads the attributes of this object from an XML stream.
protected  void readChild(javax.xml.stream.XMLStreamReader in)
          Reads a child object.
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
          Reads the children of this object from an XML stream.
 void setCombatLossPriority(int newCombatLossPriority)
          Set the CombatLossPriority value.
 void setMaximumCount(int newMaximumCount)
          Set the MaximumCount value.
 void setMilitaryEquipment(boolean newMilitaryEquipment)
          Set the MilitaryEquipment value.
 void setRole(Unit.Role newRole)
          Set the Role value.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
          Write the children of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.BuildableType
getAbilitiesRequired, getAmountRequiredOf, getGoodsRequired, getLimits, getPopulationRequired, needsGoodsToBuild, setGoodsRequired, setLimits, setPopulationRequired
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType
addAbility, addModifier, applyDifficultyLevel, getDescriptionKey, getFeatureContainer, getIndex, getModifierIndex, getModifierIndex, getModifierSet, getNameKey, hasAbility, hasAbility, isAbstractType, setAbstractType, setFeatureContainer, setIndex, setModifierIndex, toString, toXMLImpl
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_EQUIPMENT

public static final EquipmentType[] NO_EQUIPMENT

maximumCount

private int maximumCount
The maximum number of equipment items that can be combined.


combatLossPriority

private int combatLossPriority
Determines which type of Equipment will be lost first if the Unit carrying it is defeated. Horses should be lost before Muskets, for example.


captureEquipmentId

private java.lang.String captureEquipmentId
What this equipment type becomes if it is captured by Indians (if captureEquipmentByIndians is true) or Europeans (otherwise).


captureEquipmentByIndians

private boolean captureEquipmentByIndians

role

private Unit.Role role
The default Role of the Unit carrying this type of Equipment.


militaryEquipment

private boolean militaryEquipment
Describe militaryEquipment here.


compatibleEquipment

private java.util.List<java.lang.String> compatibleEquipment
A List containing the IDs of equipment types compatible with this one.

Constructor Detail

EquipmentType

public EquipmentType(java.lang.String id,
                     Specification specification)
Method Detail

getMaximumCount

public final int getMaximumCount()
Get the MaximumCount value.

Returns:
an int value

setMaximumCount

public final void setMaximumCount(int newMaximumCount)
Set the MaximumCount value.

Parameters:
newMaximumCount - The new MaximumCount value.

getRole

public final Unit.Role getRole()
Get the Role value.

Returns:
a Role value

setRole

public final void setRole(Unit.Role newRole)
Set the Role value.

Parameters:
newRole - The new Role value.

getCombatLossPriority

public final int getCombatLossPriority()
Get the CombatLossPriority value.

Returns:
an int value

setCombatLossPriority

public final void setCombatLossPriority(int newCombatLossPriority)
Set the CombatLossPriority value.

Parameters:
newCombatLossPriority - The new CombatLossPriority value.

canBeCaptured

public boolean canBeCaptured()
Returns true if this EquipmentType can be captured in combat.

Returns:
a boolean value

getCaptureEquipment

public EquipmentType getCaptureEquipment(boolean byIndians)
Get the type of equipment to capture, handling the case where Europeans and Indians use different EquipmentTypes for the same underlying goods.

Parameters:
byIndians - is the capture by the Indians?
Returns:
an EquipmentType value

getUnitAbilitiesRequired

public java.util.Map<java.lang.String,java.lang.Boolean> getUnitAbilitiesRequired()
Returns the abilities required by this Type.

Returns:
the abilities required by this Type.

isCompatibleWith

public boolean isCompatibleWith(EquipmentType otherType)
Returns true if this type of equipment is compatible with the given type of equipment.

Parameters:
otherType - an EquipmentType value
Returns:
a boolean value

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

isMilitaryEquipment

public final boolean isMilitaryEquipment()
Returns true if Equipment of this type grants an offence bonus or a defence bonus.

Returns:
a boolean value

setMilitaryEquipment

public final void setMilitaryEquipment(boolean newMilitaryEquipment)
Set the MilitaryEquipment value.

Parameters:
newMilitaryEquipment - The new MilitaryEquipment value.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Overrides:
toXMLImpl in class FreeColGameObjectType
Parameters:
out - The output stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

Overrides:
writeAttributes in class BuildableType
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeChildren

protected void writeChildren(javax.xml.stream.XMLStreamWriter out)
                      throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream.

Overrides:
writeChildren in class BuildableType
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.

Overrides:
readAttributes in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.

Overrides:
readChildren in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChild

protected void readChild(javax.xml.stream.XMLStreamReader in)
                  throws javax.xml.stream.XMLStreamException
Reads a child object.

Overrides:
readChild in class BuildableType
Parameters:
in - The XML stream to read.
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"equipment-type".