Package net.sf.freecol.common.model
Class SettlementType
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.model.FreeColSpecObjectType
-
- net.sf.freecol.common.model.SettlementType
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Named,ObjectWithId
public class SettlementType extends FreeColSpecObjectType
The various types of settlements in the game.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancapitalWhether this SettlementType is a capital.private static java.lang.StringCAPITAL_TAGprivate static java.lang.StringCLAIMABLE_RADIUS_TAGprivate intclaimableRadiusHow many tiles this SettlementType can claim.private static java.lang.StringCONVERT_THRESHOLD_TAGprivate intconvertThresholdThe threshold at which a new convert occurs.private static java.lang.StringEXTRA_CLAIMABLE_RADIUS_TAGprivate intextraClaimableRadiusThe extra radius beyond the claimableRadius where wandering units may claim as yet unclaimed tiles.private RandomRangegiftsThe gifts this SettlementType generates when visited by a scout.private static java.lang.StringGIFTS_TAGprivate static java.lang.StringMAXIMUM_GROWTH_TAGprivate static java.lang.StringMAXIMUM_SIZE_TAGprivate intmaximumGrowthThe maximum number of tiles to grown this SettlementType.private intmaximumSizeThe maximum number of units for this SettlementType.private static java.lang.StringMINIMUM_GROWTH_TAGprivate static java.lang.StringMINIMUM_SIZE_TAGprivate intminimumGrowthThe minimum number of tiles to grow this SettlementType.private intminimumSizeThe minimum number of units for this SettlementType.private static java.lang.StringOLD_CLAIMABLE_RADIUS_TAGprivate static java.lang.StringOLD_CONVERT_THRESHOLD_TAGprivate static java.lang.StringOLD_EXTRA_CLAIMABLE_RADIUS_TAGprivate static java.lang.StringOLD_MAXIMUM_GROWTH_TAGprivate static java.lang.StringOLD_MAXIMUM_SIZE_TAGprivate static java.lang.StringOLD_MINIMUM_GROWTH_TAGprivate static java.lang.StringOLD_MINIMUM_SIZE_TAGprivate static java.lang.StringOLD_TRADE_BONUS_TAGprivate static java.lang.StringOLD_VISIBLE_RADIUS_TAGprivate static java.lang.StringOLD_WANDERING_RADIUS_TAGprivate java.util.List<PlunderType>plunderTypesThe plunder this SettlementType generates when destroyed.static java.lang.StringTAGprivate static java.lang.StringTRADE_BONUS_TAGprivate inttradeBonusThe general trade bonus, roughly proportional to the settlement size and general sophistication.private static java.lang.StringVISIBLE_RADIUS_TAGprivate intvisibleRadiusHow many tiles this SettlementType can see.private static java.lang.StringWANDERING_RADIUS_TAGprivate intwanderingRadiusHow far units from this SettlementType may roam.-
Fields inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
DELETE_TAG, EXTENDS_TAG, PRESERVE_TAG
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description SettlementType(java.lang.String id, Specification specification)Creates a new settlement type.SettlementType(FreeColXMLReader xr, Specification specification)Creates a new settlement type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPlunderType(PlunderType pt)Add a plunder type.<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.intgetClaimableRadius()Get the claimable radius of this settlement type.intgetConvertThreshold()Gets the convert threshold for this settlement.intgetExtraClaimableRadius()Get the extra claimable radius.RandomRangegetGifts()Get the range of gifts available to a unit.intgetMaximumGrowth()Get the maximum growth value.intgetMaximumSize()Get the maximum size of this settlement type.intgetMinimumGrowth()Get the minimum growth value.intgetMinimumSize()Get the minimum size of this settlement type.RandomRangegetPlunderRange(Unit unit)Gets the plunder range available for the supplied unit.java.util.List<PlunderType>getPlunderTypes()Get the list of plunder types.intgetTradeBonus()Gets the trade bonus.intgetVisibleRadius()Get the visible radius of this settlement type.intgetWanderingRadius()Get the wandering radius for this settlement type.intgetWarehouseCapacity()Gets the warehouse capacity of this settlement.java.lang.StringgetXMLTagName()Get the serialization tag for this object.booleanisCapital()Is this a capital settlement type?protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.protected voidreadChild(FreeColXMLReader xr)Reads a single child object.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.protected voidsetPlunderTypes(java.util.List<PlunderType> plunderTypes)Set the plunder types.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
addScope, appliesTo, copyScopes, getDescriptionKey, getFeatureContainer, getIndex, getNameKey, getScopeList, getScopes, isAbstractType, removeScope, setIndex, toString
-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObject
getSpecification, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
capital
private boolean capital
Whether this SettlementType is a capital.
-
visibleRadius
private int visibleRadius
How many tiles this SettlementType can see.
-
claimableRadius
private int claimableRadius
How many tiles this SettlementType can claim.
-
extraClaimableRadius
private int extraClaimableRadius
The extra radius beyond the claimableRadius where wandering units may claim as yet unclaimed tiles.
-
wanderingRadius
private int wanderingRadius
How far units from this SettlementType may roam.
-
minimumSize
private int minimumSize
The minimum number of units for this SettlementType.
-
maximumSize
private int maximumSize
The maximum number of units for this SettlementType.
-
minimumGrowth
private int minimumGrowth
The minimum number of tiles to grow this SettlementType.
-
maximumGrowth
private int maximumGrowth
The maximum number of tiles to grown this SettlementType.
-
tradeBonus
private int tradeBonus
The general trade bonus, roughly proportional to the settlement size and general sophistication.
-
convertThreshold
private int convertThreshold
The threshold at which a new convert occurs.
-
plunderTypes
private java.util.List<PlunderType> plunderTypes
The plunder this SettlementType generates when destroyed.
-
gifts
private RandomRange gifts
The gifts this SettlementType generates when visited by a scout.
-
CAPITAL_TAG
private static final java.lang.String CAPITAL_TAG
- See Also:
- Constant Field Values
-
CLAIMABLE_RADIUS_TAG
private static final java.lang.String CLAIMABLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
CONVERT_THRESHOLD_TAG
private static final java.lang.String CONVERT_THRESHOLD_TAG
- See Also:
- Constant Field Values
-
EXTRA_CLAIMABLE_RADIUS_TAG
private static final java.lang.String EXTRA_CLAIMABLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
GIFTS_TAG
private static final java.lang.String GIFTS_TAG
- See Also:
- Constant Field Values
-
MAXIMUM_GROWTH_TAG
private static final java.lang.String MAXIMUM_GROWTH_TAG
- See Also:
- Constant Field Values
-
MAXIMUM_SIZE_TAG
private static final java.lang.String MAXIMUM_SIZE_TAG
- See Also:
- Constant Field Values
-
MINIMUM_GROWTH_TAG
private static final java.lang.String MINIMUM_GROWTH_TAG
- See Also:
- Constant Field Values
-
MINIMUM_SIZE_TAG
private static final java.lang.String MINIMUM_SIZE_TAG
- See Also:
- Constant Field Values
-
TRADE_BONUS_TAG
private static final java.lang.String TRADE_BONUS_TAG
- See Also:
- Constant Field Values
-
VISIBLE_RADIUS_TAG
private static final java.lang.String VISIBLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
WANDERING_RADIUS_TAG
private static final java.lang.String WANDERING_RADIUS_TAG
- See Also:
- Constant Field Values
-
OLD_CLAIMABLE_RADIUS_TAG
private static final java.lang.String OLD_CLAIMABLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
OLD_CONVERT_THRESHOLD_TAG
private static final java.lang.String OLD_CONVERT_THRESHOLD_TAG
- See Also:
- Constant Field Values
-
OLD_EXTRA_CLAIMABLE_RADIUS_TAG
private static final java.lang.String OLD_EXTRA_CLAIMABLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
OLD_MAXIMUM_GROWTH_TAG
private static final java.lang.String OLD_MAXIMUM_GROWTH_TAG
- See Also:
- Constant Field Values
-
OLD_MAXIMUM_SIZE_TAG
private static final java.lang.String OLD_MAXIMUM_SIZE_TAG
- See Also:
- Constant Field Values
-
OLD_MINIMUM_GROWTH_TAG
private static final java.lang.String OLD_MINIMUM_GROWTH_TAG
- See Also:
- Constant Field Values
-
OLD_MINIMUM_SIZE_TAG
private static final java.lang.String OLD_MINIMUM_SIZE_TAG
- See Also:
- Constant Field Values
-
OLD_TRADE_BONUS_TAG
private static final java.lang.String OLD_TRADE_BONUS_TAG
- See Also:
- Constant Field Values
-
OLD_VISIBLE_RADIUS_TAG
private static final java.lang.String OLD_VISIBLE_RADIUS_TAG
- See Also:
- Constant Field Values
-
OLD_WANDERING_RADIUS_TAG
private static final java.lang.String OLD_WANDERING_RADIUS_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SettlementType
public SettlementType(java.lang.String id, Specification specification)Creates a new settlement type.- Parameters:
id- The object identifier.specification- TheSpecificationto refer to.
-
SettlementType
public SettlementType(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a new settlement type.- Parameters:
xr- TheFreeColXMLReaderto read from.specification- TheSpecificationto refer to.- Throws:
javax.xml.stream.XMLStreamException- if there is problem reading the stream.
-
-
Method Detail
-
isCapital
public final boolean isCapital()
Is this a capital settlement type?- Returns:
- True if this is a capital.
-
getMinimumSize
public final int getMinimumSize()
Get the minimum size of this settlement type.- Returns:
- The minimum settlement size.
-
getMaximumSize
public final int getMaximumSize()
Get the maximum size of this settlement type.- Returns:
- The maximum settlement size.
-
getVisibleRadius
public final int getVisibleRadius()
Get the visible radius of this settlement type.- Returns:
- The visible radius.
-
getClaimableRadius
public final int getClaimableRadius()
Get the claimable radius of this settlement type.- Returns:
- The claimable radius.
-
getExtraClaimableRadius
public final int getExtraClaimableRadius()
Get the extra claimable radius.- Returns:
- The extra claimable radius.
-
getWanderingRadius
public final int getWanderingRadius()
Get the wandering radius for this settlement type.- Returns:
- The wandering radius.
-
getMinimumGrowth
public final int getMinimumGrowth()
Get the minimum growth value.- Returns:
- The minimum number of tiles to try to grow this settlement type by.
-
getMaximumGrowth
public final int getMaximumGrowth()
Get the maximum growth value.- Returns:
- The maximum number of tiles to try to grow this settlement type by.
-
getTradeBonus
public final int getTradeBonus()
Gets the trade bonus.- Returns:
- The general bonus to trade.
-
getConvertThreshold
public int getConvertThreshold()
Gets the convert threshold for this settlement.- Returns:
- The convert threshold.
-
getPlunderTypes
public java.util.List<PlunderType> getPlunderTypes()
Get the list of plunder types.- Returns:
- The list of
PlunderTypes.
-
setPlunderTypes
protected void setPlunderTypes(java.util.List<PlunderType> plunderTypes)
Set the plunder types.- Parameters:
plunderTypes- The new plunder type list.
-
getPlunderRange
public final RandomRange getPlunderRange(Unit unit)
Gets the plunder range available for the supplied unit.- Parameters:
unit- TheUnitto check.- Returns:
- The plunder range, or null if none applicable.
-
addPlunderType
private void addPlunderType(PlunderType pt)
Add a plunder type.- Parameters:
pt- ThePlunderTypeto add.
-
getGifts
public final RandomRange getGifts()
Get the range of gifts available to a unit.- Returns:
- A range of gifts, or null if none applicable.
-
getWarehouseCapacity
public int getWarehouseCapacity()
Gets the warehouse capacity of this settlement.- Returns:
- The warehouse capacity of this settlement.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classFreeColSpecObjectType- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
writeChildren
protected void writeChildren(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeChildrenin classFreeColSpecObjectType- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classFreeColSpecObjectType- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildrenin classFreeColSpecObjectType- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChild
protected void readChild(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.- Overrides:
readChildin classFreeColSpecObjectType- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
-