net.sf.freecol.common.model
Class Modifier

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.Feature
          extended by net.sf.freecol.common.model.Modifier

public final class Modifier
extends Feature

The Modifier class encapsulates a bonus or penalty that can be applied to any action within the game, most obviously combat. The Modifier may be applicable only to certain Objects specified by means of Scope objects.


Nested Class Summary
static class Modifier.Type
           
 
Field Summary
static java.lang.String CAPITAL_DEFENCE
           
static java.lang.String DEFENCE
           
static java.lang.String OFFENCE
           
static java.lang.String SETTLEMENT_DEFENCE
           
static float UNKNOWN
           
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
Modifier(org.w3c.dom.Element element)
          Creates a new Modifier instance.
Modifier(Modifier template)
          Creates a new Modifier instance.
Modifier(java.lang.String id, float value, Modifier.Type type)
          Creates a new Modifier instance.
Modifier(java.lang.String id, FreeColGameObjectType source, float value, Modifier.Type type)
          Creates a new Modifier instance.
Modifier(javax.xml.stream.XMLStreamReader in, Specification specification)
          Creates a new Modifier instance.
 
Method Summary
 float applyTo(float number)
          Applies this Modifier to a number.
static Modifier createTeaPartyModifier(Turn turn)
           
 boolean equals(java.lang.Object o)
           
 float getIncrement()
          Get the Increment increment.
 Modifier.Type getIncrementType()
          Get the IncrementType value.
 Modifier.Type getType()
          Get the Type value.
 float getValue()
          Get the Value value.
static java.lang.String getXMLElementTagName()
          Returns the XML tag name for this element.
 int hashCode()
           
 boolean hasIncrement()
          Returns true if this Modifier has an increment.
 void readAttributes(javax.xml.stream.XMLStreamReader in, Specification specification)
           
 void setIncrement(float newIncrement, Modifier.Type type, Turn firstTurn, Turn lastTurn)
          Set the Increment increment.
 void setIncrementType(Modifier.Type newIncrementType)
          Set the IncrementType value.
 void setType(Modifier.Type newType)
          Set the Type value.
 void setValue(float newValue)
          Set the Value value.
 java.lang.String toString()
           
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 void writeAttributes(javax.xml.stream.XMLStreamWriter out)
           
 
Methods inherited from class net.sf.freecol.common.model.Feature
appliesTo, appliesTo, getFirstTurn, getLastTurn, getScopes, getSource, hasScope, hasTimeLimit, isOutOfDate, setFirstTurn, setLastTurn, setScopes, setSource
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXML, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OFFENCE

public static final java.lang.String OFFENCE
See Also:
Constant Field Values

DEFENCE

public static final java.lang.String DEFENCE
See Also:
Constant Field Values

CAPITAL_DEFENCE

public static final java.lang.String CAPITAL_DEFENCE
See Also:
Constant Field Values

SETTLEMENT_DEFENCE

public static final java.lang.String SETTLEMENT_DEFENCE
See Also:
Constant Field Values

UNKNOWN

public static final float UNKNOWN
See Also:
Constant Field Values
Constructor Detail

Modifier

public Modifier(java.lang.String id,
                float value,
                Modifier.Type type)
Creates a new Modifier instance.

Parameters:
id - a String value
value - an float value
type - the Type of the modifier

Modifier

public Modifier(java.lang.String id,
                FreeColGameObjectType source,
                float value,
                Modifier.Type type)
Creates a new Modifier instance.

Parameters:
id - a String value
source - a FreeColGameObjectType value
value - an float value
type - the Type of the modifier

Modifier

public Modifier(Modifier template)
Creates a new Modifier instance.

Parameters:
template - a Modifier value

Modifier

public Modifier(org.w3c.dom.Element element)
Creates a new Modifier instance.

Parameters:
element - an Element value

Modifier

public Modifier(javax.xml.stream.XMLStreamReader in,
                Specification specification)
         throws javax.xml.stream.XMLStreamException
Creates a new Modifier instance.

Parameters:
in - a XMLStreamReader value
specification - a Specification value
Throws:
javax.xml.stream.XMLStreamException - if an error occurs
Method Detail

getType

public Modifier.Type getType()
Get the Type value.

Returns:
an Type value

setType

public void setType(Modifier.Type newType)
Set the Type value.

Parameters:
newType - The new Type value.

getIncrementType

public Modifier.Type getIncrementType()
Get the IncrementType value.

Returns:
a Type value

setIncrementType

public void setIncrementType(Modifier.Type newIncrementType)
Set the IncrementType value.

Parameters:
newIncrementType - The new IncrementType value.

getValue

public float getValue()
Get the Value value.

Returns:
a float value

setValue

public void setValue(float newValue)
Set the Value value.

Parameters:
newValue - The new Value value.

getIncrement

public float getIncrement()
Get the Increment increment.

Returns:
a float increment

setIncrement

public void setIncrement(float newIncrement,
                         Modifier.Type type,
                         Turn firstTurn,
                         Turn lastTurn)
Set the Increment increment.

Parameters:
newIncrement - The new Increment increment.

hasIncrement

public boolean hasIncrement()
Returns true if this Modifier has an increment.

Returns:
a boolean value

applyTo

public float applyTo(float number)
Applies this Modifier to a number. This method does not take scopes, increments or time limits into account.

Parameters:
number - a float value
Returns:
a float value

hashCode

public int hashCode()
Overrides:
hashCode in class Feature

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class Feature

createTeaPartyModifier

public static Modifier createTeaPartyModifier(Turn turn)

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the XML tag name for this element.

Returns:
a String value

readAttributes

public void readAttributes(javax.xml.stream.XMLStreamReader in,
                           Specification specification)
                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeAttributes

public void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object