Package net.sf.freecol.common.model
Class Effect
- 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.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 Summary
Fields Modifier and Type Field Description static java.lang.String
DAMAGED_UNIT
static java.lang.String
LOSS_OF_BUILDING
static java.lang.String
LOSS_OF_BUILDING_PRODUCTION
static java.lang.String
LOSS_OF_GOODS
static java.lang.String
LOSS_OF_MONEY
static java.lang.String
LOSS_OF_TILE_PRODUCTION
static java.lang.String
LOSS_OF_UNIT
private int
probability
The probability of this effect.private static java.lang.String
PROBABILITY_TAG
static java.lang.String
TAG
-
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 Modifier Constructor Description protected
Effect()
Deliberately empty constructor.Effect(FreeColXMLReader xr, Specification specification)
Creates a newEffect
instance.Effect(Effect template)
Create a new effect from an existing one.
-
Method Summary
All 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.int
getProbability()
Get the probability of this effect.java.lang.String
getXMLTagName()
Get the serialization tag for this object.protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.java.lang.String
toString()
protected void
writeAttributes(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, 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
-
DAMAGED_UNIT
public static final java.lang.String DAMAGED_UNIT
- See Also:
- Constant Field Values
-
LOSS_OF_UNIT
public static final java.lang.String LOSS_OF_UNIT
- See Also:
- Constant Field Values
-
LOSS_OF_MONEY
public static final java.lang.String LOSS_OF_MONEY
- See Also:
- Constant Field Values
-
LOSS_OF_GOODS
public static final java.lang.String LOSS_OF_GOODS
- See Also:
- Constant Field Values
-
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.
-
PROBABILITY_TAG
private static final java.lang.String PROBABILITY_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Effect
protected Effect()
Deliberately empty constructor.
-
Effect
public Effect(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a newEffect
instance.- Parameters:
xr
- TheFreeColXMLReader
to read from.specification
- TheSpecification
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
- TheEffect
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 classFreeColSpecObjectType
- Type Parameters:
T
- TheFreeColObject
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 classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
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 classFreeColSpecObjectType
- Parameters:
xr
- TheFreeColXMLReader
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 classFreeColObject
- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFreeColSpecObjectType
-
-