Class UnitTypeChange

    • Field Detail

      • from

        public UnitType from
        The unit type to change from.
      • to

        public UnitType to
        The unit type to change to.
      • probability

        public int probability
        The percentage chance of the change occurring.
      • turns

        public int turns
        The number of turns for the change to take, if not immediate.
      • fakeIdIndex

        private static java.util.concurrent.atomic.AtomicInteger fakeIdIndex
    • Constructor Detail

      • UnitTypeChange

        public UnitTypeChange​(java.lang.String id,
                              Specification specification)
        Trivial constructor.
        Parameters:
        id - The object identifier.
        specification - The Specification to use.
      • UnitTypeChange

        public UnitTypeChange​(FreeColXMLReader xr,
                              Specification spec)
                       throws javax.xml.stream.XMLStreamException
        Read a unit change from a stream.
        Parameters:
        xr - The FreeColXMLReader to read from.
        spec - The Specification to read within.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
    • Method Detail

      • isAvailableTo

        public boolean isAvailableTo​(Player player)
        Helper to check if a change is available to a player. This is useful when the change involves a transfer of ownership.
        Parameters:
        player - The Player to test.
        Returns:
        True if the player can use the to-unit-type.
      • 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.