Package net.sf.freecol.common.model
Class IndianNationType
- 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.NationType
-
- net.sf.freecol.common.model.IndianNationType
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Named,ObjectWithId
public class IndianNationType extends NationType
Represents one of the native nations present in the game.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.NationType
NationType.AggressionLevel, NationType.SettlementNumber
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringPROBABILITY_TAGprivate java.util.List<java.lang.String>regionsIdentifiers for the regions that can be settled by this Nation.private static java.lang.StringSKILL_TAGprivate java.util.List<RandomChoice<UnitType>>skillsStores the ids of the skills taught by this Nation.static java.lang.StringTAG-
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 IndianNationType(java.lang.String id, Specification specification)Create a new native nation type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddRegion(java.lang.String id)Add a region identifier.private voidaddSkill(UnitType unitType, int probability)Add a skill.<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.java.util.List<RandomChoice<UnitType>>generateSkillsForTile(Tile tile)Generates choices for skill that could be taught from a settlement on a given Tile.java.util.List<java.lang.String>getRegions()Gets the list of regions in which this tribe may settle.java.lang.StringgetSettlementTypeKey(boolean plural)Get a message id for the general type of settlements of this nation.java.util.List<RandomChoice<UnitType>>getSkills()Gets a list of this Nation's skills.java.lang.StringgetXMLTagName()Get the serialization tag for this object.booleanisEuropean()Is this a European nation type?booleanisIndian()Is this a native nation type?booleanisREF()Is this a REF nation type?protected voidreadChild(FreeColXMLReader xr)Reads a single child object.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.protected voidsetRegions(java.util.List<java.lang.String> regions)Set the settleable regions list.protected voidsetSkills(java.util.List<RandomChoice<UnitType>> skills)Set the skills of this nation.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.NationType
getAggression, getCapitalType, getNumberOfSettlements, getSettlementType, getSettlementType, getSettlementTypes, readAttributes, setSettlementTypes, writeAttributes
-
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
-
skills
private java.util.List<RandomChoice<UnitType>> skills
Stores the ids of the skills taught by this Nation.
-
regions
private java.util.List<java.lang.String> regions
Identifiers for the regions that can be settled by this Nation.
-
PROBABILITY_TAG
private static final java.lang.String PROBABILITY_TAG
- See Also:
- Constant Field Values
-
SKILL_TAG
private static final java.lang.String SKILL_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndianNationType
public IndianNationType(java.lang.String id, Specification specification)Create a new native nation type.- Parameters:
id- The object identifier.specification- TheSpecificationto refer to.
-
-
Method Detail
-
isEuropean
public boolean isEuropean()
Is this a European nation type?- Specified by:
isEuropeanin classNationType- Returns:
- False.
-
isIndian
public boolean isIndian()
Is this a native nation type?- Specified by:
isIndianin classNationType- Returns:
- True.
-
isREF
public boolean isREF()
Is this a REF nation type?- Specified by:
isREFin classNationType- Returns:
- False.
-
getSettlementTypeKey
public final java.lang.String getSettlementTypeKey(boolean plural)
Get a message id for the general type of settlements of this nation.- Parameters:
plural- Choose the plural form or not.- Returns:
- A suitable message id.
-
getSkills
public java.util.List<RandomChoice<UnitType>> getSkills()
Gets a list of this Nation's skills.- Returns:
- A list of national skills.
-
setSkills
protected void setSkills(java.util.List<RandomChoice<UnitType>> skills)
Set the skills of this nation.- Parameters:
skills- The new skills list.
-
addSkill
private void addSkill(UnitType unitType, int probability)
Add a skill.- Parameters:
unitType- TheUnitTypeskill taught.probability- The probability of the skill.
-
generateSkillsForTile
public java.util.List<RandomChoice<UnitType>> generateSkillsForTile(Tile tile)
Generates choices for skill that could be taught from a settlement on a given Tile.- Parameters:
tile- TheTilewhere the settlement will be located.- Returns:
- A random choice set of skills.
-
getRegions
public java.util.List<java.lang.String> getRegions()
Gets the list of regions in which this tribe may settle.- Returns:
- A list of regions identifiers.
-
setRegions
protected void setRegions(java.util.List<java.lang.String> regions)
Set the settleable regions list.- Parameters:
regions- The new list of region identifiers.
-
addRegion
private void addRegion(java.lang.String id)
Add a region identifier.- Parameters:
id- The object identifier.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classNationType- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
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 classNationType- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to 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 classNationType- 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 classNationType- 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.
-
-