Class Nation

    • Field Detail

      • 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.
      • PREFERRED_LATITUDE_TAG

        private static final java.lang.String PREFERRED_LATITUDE_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 - The Specification to 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 new NationType.
      • 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 current Game.
        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:
        copyIn in class FreeColSpecObjectType
        Type Parameters:
        T - The FreeColObject 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 class FreeColObject
        Parameters:
        xw - The FreeColXMLWriter 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 class FreeColSpecObjectType
        Parameters:
        xr - The FreeColXMLReader 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 class FreeColObject
        Returns:
        The tag.