net.sf.freecol.common.model
Class Monarch

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.Monarch

public final class Monarch
extends FreeColGameObject

This class implements the player's monarch, whose functions prior to the revolution include raising taxes, declaring war on other European countries, and occasionally providing military support.


Nested Class Summary
static class Monarch.MonarchAction
          Constants describing monarch actions.
 
Field Summary
static int MAXIMUM_TAX_RATE
          The maximum possible tax rate (given in percentage).
static int MINIMUM_PRICE
          The minimum price for mercenaries.
static int MINIMUM_TAX_RATE
          The minimum tax rate (given in percentage) from where it can be lowered
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
Monarch(Game game, org.w3c.dom.Element e)
          Initiates a new Monarch from an Element and registers this Monarch at the specified game.
Monarch(Game game, Player player, java.lang.String name)
          Constructor.
Monarch(Game game, java.lang.String id)
          Initiates a new Monarch with the given ID.
Monarch(Game game, javax.xml.stream.XMLStreamReader in)
          Initiates a new Monarch from an Element and registers this Monarch at the specified game.
 
Method Summary
 void addToREF(java.util.List<AbstractUnit> units)
          Adds units to the Royal Expeditionary Force.
 java.util.List<AbstractUnit> addToREF(java.util.Random random)
          Returns units to be added to the Royal Expeditionary Force.
 Player declareWar(java.util.Random random)
          Returns the nation of another player to declare war on.
 Monarch.MonarchAction getAction(java.util.Random random)
          Returns a monarch action.
 java.util.List<RandomChoice<Monarch.MonarchAction>> getActionChoices()
           
 java.util.List<AbstractUnit> getLandUnits()
          Returns only the land units.
 java.util.List<AbstractUnit> getMercenaries(java.util.Random random)
          Returns units available as mercenaries.
 java.lang.String getName()
           
 java.util.List<AbstractUnit> getNavalUnits()
          Returns only the naval units.
 int getNewTax(Monarch.MonarchAction taxChange, java.util.Random random)
          Returns the new increased tax.
 int getPrice(java.util.List<AbstractUnit> units, boolean rebate)
          Returns the price for the given units.
 java.util.List<AbstractUnit> getREF()
          Returns a List of all REF units.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toString, toXML, updateFreeColGameObject, updateID
 
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, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM_PRICE

public static final int MINIMUM_PRICE
The minimum price for mercenaries.

See Also:
Constant Field Values

MAXIMUM_TAX_RATE

public static final int MAXIMUM_TAX_RATE
The maximum possible tax rate (given in percentage).

See Also:
Constant Field Values

MINIMUM_TAX_RATE

public static final int MINIMUM_TAX_RATE
The minimum tax rate (given in percentage) from where it can be lowered

See Also:
Constant Field Values
Constructor Detail

Monarch

public Monarch(Game game,
               Player player,
               java.lang.String name)
Constructor.

Parameters:
game - The Game this Monarch should be created in.
player - The Player to create the Monarch for.
name - The name of the Monarch.

Monarch

public Monarch(Game game,
               javax.xml.stream.XMLStreamReader in)
        throws javax.xml.stream.XMLStreamException
Initiates a new Monarch from an Element and registers this Monarch at the specified game.

Parameters:
game - The Game this object belongs to.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

Monarch

public Monarch(Game game,
               org.w3c.dom.Element e)
Initiates a new Monarch from an Element and registers this Monarch at the specified game.

Parameters:
game - The Game this object belongs to.
e - An XML-element that will be used to initialize this object.

Monarch

public Monarch(Game game,
               java.lang.String id)
Initiates a new Monarch with the given ID. The object should later be initialized by calling either FreeColGameObject.readFromXML(XMLStreamReader) or FreeColObject.readFromXMLElement(Element).

Parameters:
game - The Game in which this object belong.
id - The unique identifier for this object.
Method Detail

getName

public java.lang.String getName()

getAction

public Monarch.MonarchAction getAction(java.util.Random random)
Returns a monarch action. Not all actions are always applicable, and their probability depends on the player's difficulty settings. This method can only be called by the server.

Returns:
A monarch action.

getActionChoices

public java.util.List<RandomChoice<Monarch.MonarchAction>> getActionChoices()

getREF

public java.util.List<AbstractUnit> getREF()
Returns a List of all REF units.

Returns:
a List of all REF units.

getNavalUnits

public java.util.List<AbstractUnit> getNavalUnits()
Returns only the naval units.

Returns:
the naval units

getLandUnits

public java.util.List<AbstractUnit> getLandUnits()
Returns only the land units.

Returns:
the land units

getNewTax

public int getNewTax(Monarch.MonarchAction taxChange,
                     java.util.Random random)
Returns the new increased tax.

Returns:
The increased tax.

getMercenaries

public java.util.List<AbstractUnit> getMercenaries(java.util.Random random)
Returns units available as mercenaries.

Returns:
A troop of mercenaries.

addToREF

public java.util.List<AbstractUnit> addToREF(java.util.Random random)
Returns units to be added to the Royal Expeditionary Force.

Parameters:
random - The Random number source to use.
Returns:
An addition to the Royal Expeditionary Force.

addToREF

public void addToREF(java.util.List<AbstractUnit> units)
Adds units to the Royal Expeditionary Force.

Parameters:
units - The addition to the Royal Expeditionary Force.

getPrice

public int getPrice(java.util.List<AbstractUnit> units,
                    boolean rebate)
Returns the price for the given units.

Parameters:
units - The units to get a price for.
rebate - Whether to grant a rebate.
Returns:
The price fo the units.

declareWar

public Player declareWar(java.util.Random random)
Returns the nation of another player to declare war on.

Parameters:
random - The Random number source to use.
Returns:
The enemy nation.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object. This method should be overwritten by any sub-class, preferably with the name of the class with the first letter in lower case.

Returns:
"monarch".