net.sf.freecol.common.model
Class UnitType

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.UnitType

public final class UnitType
extends BuildableType


Field Summary
static int DEFAULT_DEFENCE
           
static int DEFAULT_OFFENCE
           
static int FOOD_CONSUMPTION
           
 
Fields inherited from class net.sf.freecol.common.model.BuildableType
NOTHING, UNDEFINED
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
UnitType()
           
UnitType(int index)
          Creates a new UnitType instance.
 
Method Summary
 boolean canBeBuilt()
          Returns true if this UnitType can be built.
 boolean canBeUpgraded(UnitType newType, UnitTypeChange.ChangeType changeType)
          Return true if this UnitType can be upgraded to the given UnitType by the given means of education.
 boolean canCarryGoods()
          Returns true if Units of this type can carry Goods.
 boolean canCarryUnits()
          Returns true if Units of this type can carry other Units.
 EquipmentType[] getDefaultEquipment()
           
 EquipmentType getDefaultEquipmentType()
          Get the DefaultEquipment value.
 int getDefence()
          Get the Defence value.
 int getEducationTurns(UnitType unitType)
          Get the EducationTurns value.
 UnitType getEducationUnit(int maximumSkill)
          Get a UnitType to learn with a level skill less or equal than given level
 GoodsType getExpertProduction()
          Get the ExpertProduction value.
 int getFoodConsumed()
          Returns the amount of food this unit type consumes per turn.
 int getHitPoints()
          Get the HitPoints value.
 int getLineOfSight()
          Get the LineOfSight value.
 int getMaximumAttrition()
          Get the MaximumAttrition value.
 int getMovement()
          Get the Movement value.
 int getOffence()
          Get the Offence value.
 java.lang.String getPathImage()
          Get the PathImage value.
 int getPrice()
          Get the Price value.
 int getProductionFor(GoodsType goodsType, int base)
           
 int getRecruitProbability()
          Get the RecruitProbability value.
 int getScoreValue()
          Get the ScoreValue value.
 int getSkill()
          Get the Skill value.
 java.lang.String getSkillTaught()
          Get the SkillTaught value.
 int getSpace()
          Get the Space value.
 int getSpaceTaken()
          Get the SpaceTaken value.
 java.util.List<UnitTypeChange> getTypeChanges()
           
 UnitType getUnitTypeChange(UnitTypeChange.ChangeType changeType, Player player)
          Describe getUnitTypeChange method here.
 java.util.List<UnitType> getUnitTypesLearntInLostCity()
          Get a list of UnitType which can learn in a lost city rumour
 boolean hasPrice()
          Returns true if this UnitType has a price.
 boolean hasSkill()
          Returns true if this UnitType has a skill.
 boolean isAvailableTo(Player player)
          Returns true if the UnitType is available to the given Player.
 boolean isRecruitable()
          If this UnitType is recruitable in Europe
 void readAttributes(javax.xml.stream.XMLStreamReader in, Specification specification)
           
 void readChildren(javax.xml.stream.XMLStreamReader in, Specification specification)
           
 void setDefaultEquipmentType(EquipmentType newDefaultEquipment)
          Set the DefaultEquipment value.
 void setDefence(int newDefence)
          Set the Defence value.
 void setExpertProduction(GoodsType newExpertProduction)
          Set the ExpertProduction value.
 void setFoodConsumed(int newFoodConsumed)
          Set the FoodConsumed value.
 void setHitPoints(int newHitPoints)
          Set the HitPoints value.
 void setLineOfSight(int newLineOfSight)
          Set the LineOfSight value.
 void setMaximumAttrition(int newMaximumAttrition)
          Set the MaximumAttrition value.
 void setMovement(int newMovement)
          Set the Movement value.
 void setOffence(int newOffence)
          Set the Offence value.
 void setPathImage(java.lang.String newPathImage)
          Set the PathImage value.
 void setPrice(int newPrice)
          Set the Price value.
 void setRecruitProbability(int newRecruitProbability)
          Set the RecruitProbability value.
 void setScoreValue(int newScoreValue)
          Set the ScoreValue value.
 void setSkill(int newSkill)
          Set the Skill value.
 void setSkillTaught(java.lang.String newSkillTaught)
          Set the SkillTaught value.
 void setSpace(int newSpace)
          Set the Space value.
 void setSpaceTaken(int newSpaceTaken)
          Set the SpaceTaken value.
 
Methods inherited from class net.sf.freecol.common.model.BuildableType
getAbilitiesRequired, getAmountRequiredOf, getGoodsRequired, getGoodsRequiredAsString, getPopulationRequired, setGoodsRequired, setPopulationRequired
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType
addAbility, addModifier, getFeatureContainer, getIndex, getModifierSet, hasAbility, hasAbility, readFromXML, setFeatureContainer, setIndex, toString
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getXMLElementTagName, hasAttribute, hasListeners, readFromXML, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_OFFENCE

public static final int DEFAULT_OFFENCE
See Also:
Constant Field Values

DEFAULT_DEFENCE

public static final int DEFAULT_DEFENCE
See Also:
Constant Field Values

FOOD_CONSUMPTION

public static final int FOOD_CONSUMPTION
See Also:
Constant Field Values
Constructor Detail

UnitType

public UnitType()

UnitType

public UnitType(int index)
Creates a new UnitType instance.

Parameters:
index - an int value
Method Detail

canCarryUnits

public boolean canCarryUnits()
Returns true if Units of this type can carry other Units.

Returns:
a boolean value

canCarryGoods

public boolean canCarryGoods()
Returns true if Units of this type can carry Goods.

Returns:
a boolean value

getScoreValue

public int getScoreValue()
Get the ScoreValue value.

Returns:
an int value

setScoreValue

public void setScoreValue(int newScoreValue)
Set the ScoreValue value.

Parameters:
newScoreValue - The new ScoreValue value.

getOffence

public int getOffence()
Get the Offence value.

Returns:
an int value

setOffence

public void setOffence(int newOffence)
Set the Offence value.

Parameters:
newOffence - The new Offence value.

getDefence

public int getDefence()
Get the Defence value.

Returns:
an int value

setDefence

public void setDefence(int newDefence)
Set the Defence value.

Parameters:
newDefence - The new Defence value.

getLineOfSight

public int getLineOfSight()
Get the LineOfSight value.

Returns:
an int value

setLineOfSight

public void setLineOfSight(int newLineOfSight)
Set the LineOfSight value.

Parameters:
newLineOfSight - The new Defence value.

getSpace

public int getSpace()
Get the Space value.

Returns:
an int value

setSpace

public void setSpace(int newSpace)
Set the Space value.

Parameters:
newSpace - The new Space value.

getHitPoints

public int getHitPoints()
Get the HitPoints value.

Returns:
an int value

setHitPoints

public void setHitPoints(int newHitPoints)
Set the HitPoints value.

Parameters:
newHitPoints - The new HitPoints value.

getSpaceTaken

public int getSpaceTaken()
Get the SpaceTaken value.

Returns:
an int value

setSpaceTaken

public void setSpaceTaken(int newSpaceTaken)
Set the SpaceTaken value.

Parameters:
newSpaceTaken - The new SpaceTaken value.

isRecruitable

public boolean isRecruitable()
If this UnitType is recruitable in Europe

Returns:
an boolean value

getRecruitProbability

public int getRecruitProbability()
Get the RecruitProbability value.

Returns:
an int value

setRecruitProbability

public void setRecruitProbability(int newRecruitProbability)
Set the RecruitProbability value.

Parameters:
newRecruitProbability - The new RecruitProbability value.

getSkill

public int getSkill()
Get the Skill value.

Returns:
an int value

setSkill

public void setSkill(int newSkill)
Set the Skill value.

Parameters:
newSkill - The new Skill value.

getPrice

public int getPrice()
Get the Price value.

Returns:
an int value This returns the base price of the UnitType For the actual price of the unit, use Europe.getUnitPrice(UnitType)

setPrice

public void setPrice(int newPrice)
Set the Price value.

Parameters:
newPrice - The new Price value.

getMovement

public int getMovement()
Get the Movement value.

Returns:
an int value

setMovement

public void setMovement(int newMovement)
Set the Movement value.

Parameters:
newMovement - The new Movement value.

getMaximumAttrition

public int getMaximumAttrition()
Get the MaximumAttrition value.

Returns:
an int value

setMaximumAttrition

public void setMaximumAttrition(int newMaximumAttrition)
Set the MaximumAttrition value.

Parameters:
newMaximumAttrition - The new MaximumAttrition value.

getExpertProduction

public GoodsType getExpertProduction()
Get the ExpertProduction value.

Returns:
a GoodsType value

setExpertProduction

public void setExpertProduction(GoodsType newExpertProduction)
Set the ExpertProduction value.

Parameters:
newExpertProduction - The new ExpertProduction value.

getDefaultEquipmentType

public EquipmentType getDefaultEquipmentType()
Get the DefaultEquipment value.

Returns:
an EquipmentType value

setDefaultEquipmentType

public void setDefaultEquipmentType(EquipmentType newDefaultEquipment)
Set the DefaultEquipment value.

Parameters:
newDefaultEquipment - The new DefaultEquipment value.

getDefaultEquipment

public EquipmentType[] getDefaultEquipment()

getTypeChanges

public java.util.List<UnitTypeChange> getTypeChanges()

getPathImage

public java.lang.String getPathImage()
Get the PathImage value.

Returns:
a String value

setPathImage

public void setPathImage(java.lang.String newPathImage)
Set the PathImage value.

Parameters:
newPathImage - The new PathImage value.

getSkillTaught

public java.lang.String getSkillTaught()
Get the SkillTaught value.

Returns:
an String value

setSkillTaught

public void setSkillTaught(java.lang.String newSkillTaught)
Set the SkillTaught value.

Parameters:
newSkillTaught - The new SkillTaught value.

getFoodConsumed

public int getFoodConsumed()
Returns the amount of food this unit type consumes per turn. At the moment, this is 2 for all unit types.

Returns:
an int value

setFoodConsumed

public void setFoodConsumed(int newFoodConsumed)
Set the FoodConsumed value.

Parameters:
newFoodConsumed - The new FoodConsumed value.

isAvailableTo

public boolean isAvailableTo(Player player)
Returns true if the UnitType is available to the given Player.

Parameters:
player - a Player value
Returns:
a boolean value

getUnitTypeChange

public UnitType getUnitTypeChange(UnitTypeChange.ChangeType changeType,
                                  Player player)
Describe getUnitTypeChange method here.

Parameters:
changeType - an UnitTypeChange.Type value
player - a Player value
Returns:
an UnitType value

canBeUpgraded

public boolean canBeUpgraded(UnitType newType,
                             UnitTypeChange.ChangeType changeType)
Return true if this UnitType can be upgraded to the given UnitType by the given means of education. If the given UnitType is null, return true if the UnitType can be upgraded to any other UnitType by the given means of education.

Parameters:
newType - the UnitType to learn
changeType - an ChangeType value
Returns:
true if can learn the given UnitType

getUnitTypesLearntInLostCity

public java.util.List<UnitType> getUnitTypesLearntInLostCity()
Get a list of UnitType which can learn in a lost city rumour

Returns:
UnitType with a skill equal or less than given maximum

getEducationUnit

public UnitType getEducationUnit(int maximumSkill)
Get a UnitType to learn with a level skill less or equal than given level

Parameters:
maximumSkill - the maximum level skill which we are searching for
Returns:
UnitType with a skill equal or less than given maximum

getEducationTurns

public int getEducationTurns(UnitType unitType)
Get the EducationTurns value.

Returns:
a int value

readAttributes

public void readAttributes(javax.xml.stream.XMLStreamReader in,
                           Specification specification)
                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

readChildren

public void readChildren(javax.xml.stream.XMLStreamReader in,
                         Specification specification)
                  throws javax.xml.stream.XMLStreamException
Overrides:
readChildren in class FreeColGameObjectType
Throws:
javax.xml.stream.XMLStreamException

hasSkill

public boolean hasSkill()
Returns true if this UnitType has a skill.

Returns:
a boolean value

canBeBuilt

public boolean canBeBuilt()
Returns true if this UnitType can be built.

Returns:
a boolean value

hasPrice

public boolean hasPrice()
Returns true if this UnitType has a price.

Returns:
a boolean value

getProductionFor

public int getProductionFor(GoodsType goodsType,
                            int base)