|
|||||||||
| 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.FreeColGameObject
net.sf.freecol.common.model.Monarch
public final class Monarch
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 | |
|---|---|
(package private) int |
capacity
The current naval transport capacity. |
private static EquipmentType |
horses
|
private java.util.List<AbstractUnit> |
landUnits
The number of land units in the REF. |
private static java.util.logging.Logger |
logger
|
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 |
private static EquipmentType |
muskets
|
private java.lang.String |
name
The name of this monarch. |
private java.util.List<AbstractUnit> |
navalUnits
The number of naval units in the REF. |
private Player |
player
The player of this monarch. |
(package private) int |
spaceRequired
The space required to transport all land units. |
private boolean |
supportSea
Whether a frigate has been provided. |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| 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()
|
private int |
getEquipmentPrice(EquipmentType equipment)
|
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. |
private int |
getPrice(UnitType unitType,
Unit.Role role)
|
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. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
addModelMessage, addModelMessage, addModelMessage, addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, readFromXMLPartialByClass, setFakeID, setGame, setId, toSavedXML, toString, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject, updateID |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String name
private Player player
private static final java.util.logging.Logger logger
private static final EquipmentType muskets
private static final EquipmentType horses
int spaceRequired
int capacity
private java.util.List<AbstractUnit> landUnits
private java.util.List<AbstractUnit> navalUnits
public static final int MINIMUM_PRICE
public static final int MAXIMUM_TAX_RATE
public static final int MINIMUM_TAX_RATE
private boolean supportSea
| Constructor Detail |
|---|
public Monarch(Game game,
Player player,
java.lang.String name)
game - The Game this Monarch
should be created in.player - The Player to create the
Monarch for.name - The name of the Monarch.
public Monarch(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
Monarch from an Element
and registers this Monarch at the specified game.
game - The Game this object belongs to.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public Monarch(Game game,
org.w3c.dom.Element e)
Monarch from an Element
and registers this Monarch at the specified game.
game - The Game this object belongs to.e - An XML-element that will be used to initialize
this object.
public Monarch(Game game,
java.lang.String id)
Monarch
with the given ID. The object should later be
initialized by calling either
FreeColGameObject.readFromXML(XMLStreamReader) or
FreeColObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public java.lang.String getName()
public Monarch.MonarchAction getAction(java.util.Random random)
public java.util.List<RandomChoice<Monarch.MonarchAction>> getActionChoices()
public java.util.List<AbstractUnit> getREF()
public java.util.List<AbstractUnit> getNavalUnits()
public java.util.List<AbstractUnit> getLandUnits()
public int getNewTax(Monarch.MonarchAction taxChange,
java.util.Random random)
public java.util.List<AbstractUnit> getMercenaries(java.util.Random random)
public java.util.List<AbstractUnit> addToREF(java.util.Random random)
random - The Random number source to use.
public void addToREF(java.util.List<AbstractUnit> units)
units - The addition to the Royal Expeditionary Force.
public int getPrice(java.util.List<AbstractUnit> units,
boolean rebate)
units - The units to get a price for.rebate - Whether to grant a rebate.
private int getPrice(UnitType unitType,
Unit.Role role)
private int getEquipmentPrice(EquipmentType equipment)
public Player declareWar(java.util.Random random)
random - The Random number source to use.
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will
be added to that representation if showAll is
set to false.
toXMLImpl in class FreeColGameObjectout - The target stream.player - The Player this XML-representation
should be made for, or null if
showAll == true.showAll - Only attributes visible to player
will be added to the representation if showAll
is set to false.toSavedGame - If true then information that
is only needed when saving a game is added.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||