|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.Feature
net.sf.freecol.common.model.Modifier
public final class Modifier
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 int |
AUTO_PRODUCTION_INDEX
|
static int |
BASIC_PRODUCTION_INDEX
|
static int |
BUILDING_PRODUCTION_INDEX
|
static int |
COLONY_PRODUCTION_INDEX
|
static java.lang.String |
DEFENCE
|
static java.lang.String |
DEFENCE_AGAINST
|
static int |
EXPERT_PRODUCTION_INDEX
|
static int |
FATHER_PRODUCTION_INDEX
|
static int |
IMPROVEMENT_PRODUCTION_INDEX
|
private float |
increment
The value increments per turn. |
private Modifier.Type |
incrementType
The type of increment. |
private int |
index
The sorting index. |
static int |
NATION_PRODUCTION_INDEX
|
static java.lang.String |
OFFENCE
|
static java.lang.String |
OFFENCE_AGAINST
|
static java.lang.String |
TILE_TYPE_CHANGE_PRODUCTION
|
private Modifier.Type |
type
The type of this Modifier |
static float |
UNKNOWN
|
private float |
value
|
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
private |
Modifier()
|
|
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. |
int |
compareTo(Modifier modifier)
Compares this object with the specified object for order. |
boolean |
equals(java.lang.Object o)
|
float |
getIncrement()
Get the Increment increment. |
Modifier.Type |
getIncrementType()
Get the IncrementType value. |
int |
getIndex()
Get the Index 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. |
static Modifier |
makeTimedModifier(java.lang.String id,
Modifier template,
Turn start)
Makes a timed modifier (one with start/end turn and increment) with the specified id from a template modifier (containing the increment and value) and given start turn. |
protected void |
readAttributes(javax.xml.stream.XMLStreamReader in,
Specification specification)
Reads the attributes of this object from an XML stream. |
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 |
setIndex(int newIndex)
Set the Index 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. |
protected void |
writeAttributes(javax.xml.stream.XMLStreamWriter out)
Write the attributes of this object to a stream. |
| Methods inherited from class net.sf.freecol.common.model.Feature |
|---|
appliesTo, appliesTo, copy, getFirstTurn, getLastTurn, getNameKey, getScopes, getSource, hasScope, hasTimeLimit, isOutOfDate, readChildren, setFirstTurn, setLastTurn, setScopes, setSource, writeChildren |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String OFFENCE
public static final java.lang.String DEFENCE
public static final java.lang.String OFFENCE_AGAINST
public static final java.lang.String DEFENCE_AGAINST
public static final java.lang.String TILE_TYPE_CHANGE_PRODUCTION
public static final float UNKNOWN
public static int BASIC_PRODUCTION_INDEX
public static int COLONY_PRODUCTION_INDEX
public static int EXPERT_PRODUCTION_INDEX
public static int FATHER_PRODUCTION_INDEX
public static int IMPROVEMENT_PRODUCTION_INDEX
public static int AUTO_PRODUCTION_INDEX
public static int BUILDING_PRODUCTION_INDEX
public static int NATION_PRODUCTION_INDEX
private float value
private float increment
private Modifier.Type type
private Modifier.Type incrementType
private int index
| Constructor Detail |
|---|
private Modifier()
public Modifier(java.lang.String id,
float value,
Modifier.Type type)
Modifier instance.
id - a String valuevalue - an float valuetype - the Type of the modifier
public Modifier(java.lang.String id,
FreeColGameObjectType source,
float value,
Modifier.Type type)
Modifier instance.
id - a String valuesource - a FreeColGameObjectType valuevalue - an float valuetype - the Type of the modifierpublic Modifier(Modifier template)
Modifier instance.
template - a Modifier value
public Modifier(javax.xml.stream.XMLStreamReader in,
Specification specification)
throws javax.xml.stream.XMLStreamException
Modifier instance.
in - a XMLStreamReader valuespecification - a Specification value
javax.xml.stream.XMLStreamException - if an error occurs| Method Detail |
|---|
public static Modifier makeTimedModifier(java.lang.String id,
Modifier template,
Turn start)
id - The id for the new modifier.template - A template Modifier with increment.start - The starting Turn.
public Modifier.Type getType()
Type value.
Type valuepublic void setType(Modifier.Type newType)
Type value.
newType - The new Type value.public Modifier.Type getIncrementType()
IncrementType value.
Type valuepublic void setIncrementType(Modifier.Type newIncrementType)
IncrementType value.
newIncrementType - The new IncrementType value.public float getValue()
Value value.
float valuepublic void setValue(float newValue)
Value value.
newValue - The new Value value.public float getIncrement()
Increment increment.
float increment
public void setIncrement(float newIncrement,
Modifier.Type type,
Turn firstTurn,
Turn lastTurn)
Increment increment.
newIncrement - The new Increment increment.public boolean hasIncrement()
true if this Modifier has an increment.
boolean valuepublic int getIndex()
Index value.
int valuepublic void setIndex(int newIndex)
Index value.
newIndex - The new Index value.public float applyTo(float number)
number - a float value
float valuepublic int hashCode()
Feature
hashCode in class Featurepublic boolean equals(java.lang.Object o)
Feature
equals in class Featurepublic int compareTo(Modifier modifier)
compareTo in interface java.lang.Comparable<Modifier>modifier - a Modifier value
int value
public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeAttributes in class Featureout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to
the stream.
protected void readAttributes(javax.xml.stream.XMLStreamReader in,
Specification specification)
throws javax.xml.stream.XMLStreamException
readAttributes in class Featurein - The XML input stream.specification - A Specification to use.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.String getXMLElementTagName()
String value
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||