Class HighSeas

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • destinations

        private final java.util.List<Location> destinations
        The destinations this HighSeas object connects.
    • Constructor Detail

      • HighSeas

        public HighSeas​(Game game)
        Simple constructor.
        Parameters:
        game - The enclosing Game.
      • HighSeas

        public HighSeas​(Game game,
                        java.lang.String id)
        Create a new high seas.
        Parameters:
        game - The enclosing Game.
        id - The object identifier.
    • Method Detail

      • getDestinations

        public final java.util.List<Location> getDestinations()
        Get the destinations connected by these seas.
        Returns:
        A list of Locations.
      • destinationsToString

        public final java.lang.String destinationsToString()
        Convenience debug function to collect the destination ids.
        Returns:
        A string representation of the destination identifiers.
      • setDestinations

        protected void setDestinations​(java.util.List<Location> destinations)
        Set the destination list.
        Parameters:
        destinations - The new list of destination Locations.
      • addDestination

        public void addDestination​(Location destination)
        Add a single destination to this HighSeas instance.
        Parameters:
        destination - A destination Location.
      • removeDestination

        public void removeDestination​(Location destination)
        Remove a single destination from this HighSeas instance.
        Parameters:
        destination - A destination Location.
      • up

        public Location up()
        Promote this location to a more meaningful one if possible. For example: a settlement is more meaningful than the tile it occupies.
        Returns:
        A more meaningful Location, or this one.
      • getRank

        public int getRank()
        Get a integer for this location, for the benefit of location comparators.
        Returns:
        A suitable integer.
      • toShortString

        public java.lang.String toShortString()
        Get a short description of this location.
        Returns:
        A short description.
      • getNoAddReason

        public UnitLocation.NoAddReason getNoAddReason​(Locatable locatable)
        Gets the reason why a given Locatable can not be added to this Location. Be careful to test for unit presence last before success (NoAddReason.NONE) except perhaps for the capacity test, so that we can treat ALREADY_PRESENT as success in some cases (e.g. if the unit changes type --- does it still have a required skill?) FIXME: consider moving this up to Location?
        Overrides:
        getNoAddReason in class UnitLocation
        Parameters:
        locatable - The Locatable to test.
        Returns:
        The reason why adding would fail.
      • getLinkTarget

        public FreeColGameObject getLinkTarget​(Player player)
        Get a suitable game object to use as a clickable link in messages to a player. Objects do not have links by default, hence the null return here. However, for example, a player's colony should return itself as a link target.
        Overrides:
        getLinkTarget in class FreeColGameObject
        Parameters:
        player - The Player to make a link for.
        Returns:
        A suitable link target if available, although usually null.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class UnitLocation
        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.
      • 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 class UnitLocation
        Parameters:
        xw - The FreeColXMLWriter to 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:
        readChildren in class UnitLocation
        Parameters:
        xr - The FreeColXMLReader 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 class UnitLocation
        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.