net.sf.freecol.common.model
Class FoundingFather

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObjectType
          extended by net.sf.freecol.common.model.FoundingFather

public class FoundingFather
extends FreeColGameObjectType

Represents one FoundingFather to be contained in a Player object. The FoundingFather is able to grant new abilities or bonuses to the player, or to cause certain events.


Nested Class Summary
static class FoundingFather.FoundingFatherType
           
 
Field Summary
private  java.util.List<Event> events
          Describe events here.
private  java.util.List<Scope> scopes
          Players that want to elect this founding father must match all scopes.
private  FoundingFather.FoundingFatherType type
          The type of this FoundingFather.
private  java.util.List<AbstractUnit> units
          A list of AbstractUnits generated by this FoundingFather.
private  java.util.Map<UnitType,UnitType> upgrades
          Holds the upgrades of Units caused by this FoundingFather.
private  int[] weight
          The probability of this FoundingFather being offered for selection.
 
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
FoundingFather(java.lang.String id, Specification specification)
           
 
Method Summary
 void fixup09x()
          Compatibility hack, called from the specification when it is finishing up.
 java.util.List<Event> getEvents()
          Get the Events value.
 java.util.List<Scope> getScopes()
          Get the Scopes value.
 FoundingFather.FoundingFatherType getType()
          Return the type of this FoundingFather.
 java.lang.String getTypeKey()
          Return the localized type of this FoundingFather.
static java.lang.String getTypeKey(FoundingFather.FoundingFatherType type)
          Return the localized type of the given FoundingFather.
 java.util.List<AbstractUnit> getUnits()
          Get the Units value.
 java.util.Map<UnitType,UnitType> getUpgrades()
          Get the Upgrades value.
 int getWeight(int age)
          Get the weight of this FoundingFather.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isAvailableTo(Player player)
          Returns true if this FoundingFather is available to the Player given.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Reads the attributes of this object from an XML stream.
protected  void readChild(javax.xml.stream.XMLStreamReader in)
          Reads a child object.
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
          Reads the children of this object from an XML stream.
 void setEvents(java.util.List<Event> newEvents)
          Set the Events value.
 void setType(FoundingFather.FoundingFatherType type)
          Return the type of this FoundingFather.
 void setUnits(java.util.List<AbstractUnit> newUnits)
          Set the Units value.
 void setUpgrades(java.util.Map<UnitType,UnitType> newUpgrades)
          Set the Upgrades value.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
          Write the children of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType
addAbility, addModifier, applyDifficultyLevel, getDescriptionKey, getFeatureContainer, getIndex, getModifierIndex, getModifierIndex, getModifierSet, getNameKey, hasAbility, hasAbility, isAbstractType, setAbstractType, setFeatureContainer, setIndex, setModifierIndex, toString, toXMLImpl
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

weight

private int[] weight
The probability of this FoundingFather being offered for selection.


type

private FoundingFather.FoundingFatherType type
The type of this FoundingFather. One of the following constants.


scopes

private java.util.List<Scope> scopes
Players that want to elect this founding father must match all scopes.


events

private java.util.List<Event> events
Describe events here.


upgrades

private java.util.Map<UnitType,UnitType> upgrades
Holds the upgrades of Units caused by this FoundingFather.


units

private java.util.List<AbstractUnit> units
A list of AbstractUnits generated by this FoundingFather.

Constructor Detail

FoundingFather

public FoundingFather(java.lang.String id,
                      Specification specification)
Method Detail

getType

public FoundingFather.FoundingFatherType getType()
Return the type of this FoundingFather.

Returns:
The type of this FoundingFather.

setType

public void setType(FoundingFather.FoundingFatherType type)
Return the type of this FoundingFather.

Parameters:
type - A new FoundingFatherType.

getTypeKey

public java.lang.String getTypeKey()
Return the localized type of this FoundingFather.

Returns:
a String value

getTypeKey

public static java.lang.String getTypeKey(FoundingFather.FoundingFatherType type)
Return the localized type of the given FoundingFather.

Parameters:
type - an int value
Returns:
a String value

getWeight

public int getWeight(int age)
Get the weight of this FoundingFather. This is used to select a random FoundingFather.

Parameters:
age - an int value
Returns:
an int value

getUnits

public final java.util.List<AbstractUnit> getUnits()
Get the Units value.

Returns:
a List value

setUnits

public final void setUnits(java.util.List<AbstractUnit> newUnits)
Set the Units value.

Parameters:
newUnits - The new Units value.

getEvents

public final java.util.List<Event> getEvents()
Get the Events value.

Returns:
a List value

setEvents

public final void setEvents(java.util.List<Event> newEvents)
Set the Events value.

Parameters:
newEvents - The new Events value.

getScopes

public final java.util.List<Scope> getScopes()
Get the Scopes value.

Returns:
a List value

isAvailableTo

public boolean isAvailableTo(Player player)
Returns true if this FoundingFather is available to the Player given.

Parameters:
player - a Player value
Returns:
a boolean value

getUpgrades

public final java.util.Map<UnitType,UnitType> getUpgrades()
Get the Upgrades value.

Returns:
a Map value

setUpgrades

public final void setUpgrades(java.util.Map<UnitType,UnitType> newUpgrades)
Set the Upgrades value.

Parameters:
newUpgrades - The new Upgrades value.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Overrides:
toXMLImpl in class FreeColGameObjectType
Parameters:
out - The output stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

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

writeChildren

protected void writeChildren(javax.xml.stream.XMLStreamWriter out)
                      throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream.

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

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.

Overrides:
readAttributes in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.

Overrides:
readChildren in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChild

protected void readChild(javax.xml.stream.XMLStreamReader in)
                  throws javax.xml.stream.XMLStreamException
Reads a child object.

Overrides:
readChild in class FreeColGameObjectType
Parameters:
in - The XML stream to read.
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

fixup09x

public void fixup09x()
Compatibility hack, called from the specification when it is finishing up.


getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"founding-father".