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 boolean
capital
Whether this SettlementType is a capital.private static java.lang.String
CAPITAL_TAG
private static java.lang.String
CLAIMABLE_RADIUS_TAG
private int
claimableRadius
How many tiles this SettlementType can claim.private static java.lang.String
CONVERT_THRESHOLD_TAG
private int
convertThreshold
The threshold at which a new convert occurs.private static java.lang.String
EXTRA_CLAIMABLE_RADIUS_TAG
private int
extraClaimableRadius
The extra radius beyond the claimableRadius where wandering units may claim as yet unclaimed tiles.private RandomRange
gifts
The gifts this SettlementType generates when visited by a scout.private static java.lang.String
GIFTS_TAG
private static java.lang.String
MAXIMUM_GROWTH_TAG
private static java.lang.String
MAXIMUM_SIZE_TAG
private int
maximumGrowth
The maximum number of tiles to grown this SettlementType.private int
maximumSize
The maximum number of units for this SettlementType.private static java.lang.String
MINIMUM_GROWTH_TAG
private static java.lang.String
MINIMUM_SIZE_TAG
private int
minimumGrowth
The minimum number of tiles to grow this SettlementType.private int
minimumSize
The minimum number of units for this SettlementType.private static java.lang.String
OLD_CLAIMABLE_RADIUS_TAG
private static java.lang.String
OLD_CONVERT_THRESHOLD_TAG
private static java.lang.String
OLD_EXTRA_CLAIMABLE_RADIUS_TAG
private static java.lang.String
OLD_MAXIMUM_GROWTH_TAG
private static java.lang.String
OLD_MAXIMUM_SIZE_TAG
private static java.lang.String
OLD_MINIMUM_GROWTH_TAG
private static java.lang.String
OLD_MINIMUM_SIZE_TAG
private static java.lang.String
OLD_TRADE_BONUS_TAG
private static java.lang.String
OLD_VISIBLE_RADIUS_TAG
private static java.lang.String
OLD_WANDERING_RADIUS_TAG
private java.util.List<PlunderType>
plunderTypes
The plunder this SettlementType generates when destroyed.static java.lang.String
TAG
private static java.lang.String
TRADE_BONUS_TAG
private int
tradeBonus
The general trade bonus, roughly proportional to the settlement size and general sophistication.private static java.lang.String
VISIBLE_RADIUS_TAG
private int
visibleRadius
How many tiles this SettlementType can see.private static java.lang.String
WANDERING_RADIUS_TAG
private int
wanderingRadius
How 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 void
addPlunderType(PlunderType pt)
Add a plunder type.<T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.int
getClaimableRadius()
Get the claimable radius of this settlement type.int
getConvertThreshold()
Gets the convert threshold for this settlement.int
getExtraClaimableRadius()
Get the extra claimable radius.RandomRange
getGifts()
Get the range of gifts available to a unit.int
getMaximumGrowth()
Get the maximum growth value.int
getMaximumSize()
Get the maximum size of this settlement type.int
getMinimumGrowth()
Get the minimum growth value.int
getMinimumSize()
Get the minimum size of this settlement type.RandomRange
getPlunderRange(Unit unit)
Gets the plunder range available for the supplied unit.java.util.List<PlunderType>
getPlunderTypes()
Get the list of plunder types.int
getTradeBonus()
Gets the trade bonus.int
getVisibleRadius()
Get the visible radius of this settlement type.int
getWanderingRadius()
Get the wandering radius for this settlement type.int
getWarehouseCapacity()
Gets the warehouse capacity of this settlement.java.lang.String
getXMLTagName()
Get the serialization tag for this object.boolean
isCapital()
Is this a capital settlement type?protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.protected void
readChild(FreeColXMLReader xr)
Reads a single child object.protected void
readChildren(FreeColXMLReader xr)
Reads the children of this object from an XML stream.protected void
setPlunderTypes(java.util.List<PlunderType> plunderTypes)
Set the plunder types.protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.protected void
writeChildren(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
- TheSpecification
to refer to.
-
SettlementType
public SettlementType(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a new settlement type.- Parameters:
xr
- TheFreeColXMLReader
to read from.specification
- TheSpecification
to 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
PlunderType
s.
-
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
- TheUnit
to check.- Returns:
- The plunder range, or null if none applicable.
-
addPlunderType
private void addPlunderType(PlunderType pt)
Add a plunder type.- Parameters:
pt
- ThePlunderType
to 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:
copyIn
in classFreeColSpecObjectType
- Type Parameters:
T
- TheFreeColObject
subclass 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:
writeAttributes
in classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
to 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:
writeChildren
in classFreeColSpecObjectType
- Parameters:
xw
- TheFreeColXMLWriter
to 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:
readAttributes
in classFreeColSpecObjectType
- Parameters:
xr
- TheFreeColXMLReader
to 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:
readChildren
in classFreeColSpecObjectType
- Parameters:
xr
- TheFreeColXMLReader
to 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:
readChild
in classFreeColSpecObjectType
- Parameters:
xr
- TheFreeColXMLReader
to 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:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
-