Class Effect

  • All Implemented Interfaces:
    java.lang.Comparable<FreeColObject>, Named, ObjectWithId

    public class Effect
    extends FreeColSpecObjectType
    The effect of a natural disaster or other event. How the probability of the effect is interpreted depends on the number of effects value of the disaster or event. If the number of effects is ALL, the probability is ignored. If it is ONE, then the probability may be an arbitrary integer, and is used only for comparison with other effects. If the number of effects is SEVERAL, however, the probability must be a percentage.
    See Also:
    Disaster
    • Field Detail

      • LOSS_OF_TILE_PRODUCTION

        public static final java.lang.String LOSS_OF_TILE_PRODUCTION
        See Also:
        Constant Field Values
      • LOSS_OF_BUILDING

        public static final java.lang.String LOSS_OF_BUILDING
        See Also:
        Constant Field Values
      • LOSS_OF_BUILDING_PRODUCTION

        public static final java.lang.String LOSS_OF_BUILDING_PRODUCTION
        See Also:
        Constant Field Values
      • probability

        private int probability
        The probability of this effect.
    • Constructor Detail

      • Effect

        protected Effect()
        Deliberately empty constructor.
      • Effect

        public Effect​(FreeColXMLReader xr,
                      Specification specification)
               throws javax.xml.stream.XMLStreamException
        Creates a new Effect instance.
        Parameters:
        xr - The FreeColXMLReader to read from.
        specification - The Specification to refer to.
        Throws:
        javax.xml.stream.XMLStreamException - if an error occurs
      • Effect

        public Effect​(Effect template)
        Create a new effect from an existing one.
        Parameters:
        template - The Effect to copy from.
    • Method Detail

      • getProbability

        public final int getProbability()
        Get the probability of this effect.
        Returns:
        The probability.
      • 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.