Package net.sf.freecol.common.model
Class Nation
- 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.Nation
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Named,ObjectWithId
public class Nation extends FreeColSpecObjectType
Represents one of the nations present in the game.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.ColorcolorThe color of this nation.private static java.lang.StringCOLOR_TAGprivate static java.util.List<java.lang.String>EUROPEAN_NATIONSA list of European nation names, where model.nation.X.name exists.private static java.lang.StringNATION_TYPE_TAGprivate static java.lang.StringOLD_PREFERRED_LATITUDE_TAGprivate static java.lang.StringOLD_STARTS_ON_EAST_COAST_TAGprivate static java.lang.StringPREFERRED_LATITUDE_TAGprivate intpreferredLatitudeThe preferred starting latitude for this nation.private static java.lang.StringREF_TAGprivate NationrefNationThe REF nation to oppose this nation.private booleanselectableCan this nation be selected?private static java.lang.StringSELECTABLE_TAGprivate static java.lang.StringSTARTS_ON_EAST_COAST_TAGprivate booleanstartsOnEastCoastWhether this nation starts on the East coast by default.static java.lang.StringTAGprivate NationTypetypeThe nation type, European, native, etc.static java.awt.ColorUNKNOWN_NATION_COLORThe last resort unknown nation color.static java.lang.StringUNKNOWN_NATION_IDThe unknown enemy id.-
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 Nation(java.lang.String id, Specification specification)Create a new nation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.java.awt.ColorgetColor()Get the nation color.intgetPreferredLatitude()Get the preferred latitude of this nation.static java.lang.StringgetRandomNonPlayerNationNameKey(Game game, java.util.Random random)Get a random player name key that is not in use by an active player.NationgetRebelNation()Get the rebel nation to oppose this REF nation.NationgetREFNation()Get the REF nation to oppose this nation.java.lang.StringgetRulerName()Get the name of the nation monarch.java.lang.StringgetRulerNameKey()Get a message key for the ruler of this nation.booleangetStartsOnEastCoast()Does this nation start on the east coast by default?NationTypegetType()Get the nation type.java.lang.StringgetXMLTagName()Get the serialization tag for this object.booleanisSelectable()Is this nation selectable?booleanisUnknownEnemy()Is this the unknown enemy nation?protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.voidsetColor(java.awt.Color color)Set the nation color.voidsetType(NationType type)Set the nation type.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes 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, readChild, readChildren, removeScope, setIndex, toString, writeChildren
-
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
-
UNKNOWN_NATION_ID
public static final java.lang.String UNKNOWN_NATION_ID
The unknown enemy id.- See Also:
- Constant Field Values
-
UNKNOWN_NATION_COLOR
public static final java.awt.Color UNKNOWN_NATION_COLOR
The last resort unknown nation color.
-
EUROPEAN_NATIONS
private static final java.util.List<java.lang.String> EUROPEAN_NATIONS
A list of European nation names, where model.nation.X.name exists. Used by getNonPlayerNation().
-
type
private NationType type
The nation type, European, native, etc.
-
selectable
private boolean selectable
Can this nation be selected?
-
refNation
private Nation refNation
The REF nation to oppose this nation.
-
preferredLatitude
private int preferredLatitude
The preferred starting latitude for this nation.
-
startsOnEastCoast
private boolean startsOnEastCoast
Whether this nation starts on the East coast by default.
-
color
private java.awt.Color color
The color of this nation.
-
COLOR_TAG
private static final java.lang.String COLOR_TAG
- See Also:
- Constant Field Values
-
NATION_TYPE_TAG
private static final java.lang.String NATION_TYPE_TAG
- See Also:
- Constant Field Values
-
PREFERRED_LATITUDE_TAG
private static final java.lang.String PREFERRED_LATITUDE_TAG
- See Also:
- Constant Field Values
-
REF_TAG
private static final java.lang.String REF_TAG
- See Also:
- Constant Field Values
-
SELECTABLE_TAG
private static final java.lang.String SELECTABLE_TAG
- See Also:
- Constant Field Values
-
STARTS_ON_EAST_COAST_TAG
private static final java.lang.String STARTS_ON_EAST_COAST_TAG
- See Also:
- Constant Field Values
-
OLD_PREFERRED_LATITUDE_TAG
private static final java.lang.String OLD_PREFERRED_LATITUDE_TAG
- See Also:
- Constant Field Values
-
OLD_STARTS_ON_EAST_COAST_TAG
private static final java.lang.String OLD_STARTS_ON_EAST_COAST_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Nation
public Nation(java.lang.String id, Specification specification)Create a new nation.- Parameters:
id- The object identifier.specification- TheSpecificationto refer to.
-
-
Method Detail
-
isUnknownEnemy
public final boolean isUnknownEnemy()
Is this the unknown enemy nation?- Returns:
- True if this is the unknown enemy.
-
getType
public final NationType getType()
Get the nation type.- Returns:
- The nation type.
-
setType
public final void setType(NationType type)
Set the nation type. Needed to when "no advantages" is selected.- Parameters:
type- The newNationType.
-
isSelectable
public final boolean isSelectable()
Is this nation selectable?- Returns:
- True if the nation is selectable.
-
getREFNation
public final Nation getREFNation()
Get the REF nation to oppose this nation.- Returns:
- The REF
Nation, or null if not applicable.
-
getRebelNation
public final Nation getRebelNation()
Get the rebel nation to oppose this REF nation.- Returns:
- The rebel
Nation, or null if not applicable.
-
getPreferredLatitude
public final int getPreferredLatitude()
Get the preferred latitude of this nation.- Returns:
- The preferred latitude.
-
getStartsOnEastCoast
public final boolean getStartsOnEastCoast()
Does this nation start on the east coast by default?- Returns:
- True if the nation starts on the east coast.
-
getColor
public java.awt.Color getColor()
Get the nation color.- Returns:
- The color for this nation.
-
setColor
public void setColor(java.awt.Color color)
Set the nation color.- Parameters:
color- The new nation color.
-
getRulerNameKey
public final java.lang.String getRulerNameKey()
Get a message key for the ruler of this nation.- Returns:
- The name key for the ruler.
-
getRulerName
public java.lang.String getRulerName()
Get the name of the nation monarch.- Returns:
- The ruler name.
-
getRandomNonPlayerNationNameKey
public static java.lang.String getRandomNonPlayerNationNameKey(Game game, java.util.Random random)
Get a random player name key that is not in use by an active player.- Parameters:
game- The currentGame.random- A pseudo-random number source.- Returns:
- A player name key, or an empty string on failure.
-
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.
-
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.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
-