|
|||||||||
| 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.Europe
public final class Europe
Represents Europe in the game. Each Player has it's own
Europe.
recruit(int, net.sf.freecol.common.model.Unit, net.sf.freecol.common.model.UnitType) and train(net.sf.freecol.common.model.Unit)
new units. You may also sell/buy goods.
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private static int |
LOWER_CAP_INITIAL
|
private Player |
owner
|
static int |
RECRUIT_COUNT
|
private static int |
RECRUIT_PRICE_INITIAL
|
private UnitType[] |
recruitables
This array represents the types of the units that can be recruited in Europe. |
private int |
recruitLowerCap
|
private int |
recruitPrice
|
static java.lang.String |
UNIT_CHANGE
|
private java.util.Map<UnitType,java.lang.Integer> |
unitPrices
|
private java.util.List<Unit> |
units
Contains the units on this location. |
static java.lang.String |
UNITS_TAG_NAME
|
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| Constructor Summary | |
|---|---|
Europe(Game game,
org.w3c.dom.Element e)
Initializes this object from an XML-representation of this object. |
|
Europe(Game game,
Player owner)
Creates a new Europe. |
|
Europe(Game game,
java.lang.String id)
Initiates a new Europe with the given ID. |
|
Europe(Game game,
javax.xml.stream.XMLStreamReader in)
Initializes this object from an XML-representation of this object. |
|
| Method Summary | |
|---|---|
void |
add(Locatable locatable)
Adds a Locatable to this Location. |
boolean |
canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to this Location. |
boolean |
canBuildEquipment(EquipmentType equipmentType)
Return true if this Europe could build at least one item of the given EquipmentType. |
boolean |
contains(Locatable locatable)
Checks if the specified Locatable is at this
Location. |
void |
disposeUnitList()
Dispose of all units in this Europe. |
Colony |
getColony()
Europe does not belong to a colony. |
Unit |
getFirstUnit()
Gets the first Unit in this Europe. |
GoodsContainer |
getGoodsContainer()
Gets the GoodsContainer this Location use
for storing it's goods. |
Unit |
getLastUnit()
Gets the last Unit in this Europe. |
java.lang.String |
getName()
Returns the name of the owner's home port. |
Player |
getOwner()
Gets the Player using this Europe. |
UnitType |
getRecruitable(int slot)
Gets the type of the recruitable in Europe at the given slot. |
int |
getRecruitPrice()
Gets the current price for a recruit. |
Tile |
getTile()
Returns null. |
int |
getUnitCount()
Gets the amount of Units at this Location. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets an Iterator of every Unit directly
located in this Europe. |
java.util.List<Unit> |
getUnitList()
Gets a List of every Unit directly located
in this Europe. |
int |
getUnitPrice(UnitType unitType)
Returns the price of a unit in Europe. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
private void |
increasePrice(Unit unit,
int price)
Increases the price for a unit, if needed. |
private void |
incrementRecruitPrice()
|
void |
newTurn()
Prepares this object for a new turn. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
recruit(int slot,
Unit unit,
UnitType newRecruitable)
Recruits a unit from Europe. |
boolean |
recruitablesDiffer()
Returns true if not all recruitables are of the same type. |
void |
remove(Locatable locatable)
Removes a Locatable from this Location. |
void |
setOwner(Player p)
Sets the owner of this Ownable. |
void |
setRecruitable(int slot,
UnitType type)
Sets the type of the recruitable in Europe at the given slot to the given type. |
java.lang.String |
toString()
Returns a suitable name. |
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. |
void |
train(Unit unit)
Train or purchase a unit in Europe. |
private void |
unitsToXML(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
|
| 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, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject, updateID |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.freecol.common.model.Location |
|---|
getId |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private static final int RECRUIT_PRICE_INITIAL
private static final int LOWER_CAP_INITIAL
public static final java.lang.String UNITS_TAG_NAME
public static final java.lang.String UNIT_CHANGE
private UnitType[] recruitables
public static final int RECRUIT_COUNT
private java.util.Map<UnitType,java.lang.Integer> unitPrices
private int recruitPrice
private int recruitLowerCap
private java.util.List<Unit> units
private Player owner
| Constructor Detail |
|---|
public Europe(Game game,
Player owner)
Europe.
game - The Game in which this object belong.owner - The Player that will be using this object of
Europe.
public Europe(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
game - The Game in which this object belong.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if an error occurred during parsing.
public Europe(Game game,
org.w3c.dom.Element e)
game - The Game in which this object belong.e - An XML-element that will be used to initialize this object.
public Europe(Game game,
java.lang.String id)
Europe 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 boolean canBuildEquipment(EquipmentType equipmentType)
equipmentType - an EquipmentType value
boolean valuepublic boolean recruitablesDiffer()
boolean valuepublic UnitType getRecruitable(int slot)
slot - The slot of the recruitable whose type needs to be returned.
Should be 0, 1 or 2. NOTE - used to be 1, 2 or 3 and was
called with 1-3 by some classes and 0-2 by others, the method
itself expected 0-2.
java.lang.IllegalArgumentException - if the given slot does
not exist.
public void setRecruitable(int slot,
UnitType type)
slot - The slot of the recruitable whose type needs to be set.
Should be 0, 1 or 2. NOTE - changed in order to match
getRecruitable above!type - The new type for the unit at the given slot in Europe. Should
be a valid unit type.
public void recruit(int slot,
Unit unit,
UnitType newRecruitable)
slot - The slot the recruited unit(type) came from. This is needed
for setting a new recruitable to this slot.unit - The recruited unit.newRecruitable - The recruitable that will fill the now empty slot.
java.lang.IllegalArgumentException - if unit == null.
java.lang.IllegalStateException - if the player recruiting the unit cannot
afford the price.public Tile getTile()
getTile in interface Locationpublic Colony getColony()
getColony in interface Locationpublic void add(Locatable locatable)
Locatable to this Location.
add in interface Locationlocatable - The Locatable to add to this Location.public void remove(Locatable locatable)
Locatable from this Location.
remove in interface Locationlocatable - The Locatable to remove from this
Location.public boolean contains(Locatable locatable)
Locatable is at this
Location.
contains in interface Locationlocatable - The Locatable to test the presence of.
public GoodsContainer getGoodsContainer()
LocationGoodsContainer this Location use
for storing it's goods.
getGoodsContainer in interface LocationGoodsContainer or null if the
Location cannot store any goods.public boolean canAdd(Locatable locatable)
Location.
canAdd in interface Locationlocatable - The Locatable to test the addabillity of.
public int getUnitCount()
getUnitCount in interface Locationpublic java.util.List<Unit> getUnitList()
List of every Unit directly located
in this Europe. This does not include Units
on ships.
getUnitList in interface LocationList.public void disposeUnitList()
Europe.
public java.util.Iterator<Unit> getUnitIterator()
Iterator of every Unit directly
located in this Europe. This does not include
Units on ships.
getUnitIterator in interface LocationIterator.public Unit getFirstUnit()
Unit in this Europe.
Unit in this Europe.public Unit getLastUnit()
Unit in this Europe.
Unit in this Europe.public int getUnitPrice(UnitType unitType)
unitType - The type of unit of which you need the price.
public void train(Unit unit)
unit - The trained unit.
java.lang.IllegalArgumentException - if unit == null.
java.lang.IllegalArgumentException - if the unit to be trained doesn't
have price
java.lang.IllegalStateException - if the player recruiting the unit cannot
afford the price.
private void increasePrice(Unit unit,
int price)
unit - The unit, trained or purchasedprice - The current price of the unitpublic int getRecruitPrice()
Europe.private void incrementRecruitPrice()
public Player getOwner()
Player using this Europe.
getOwner in interface OwnablePlayer controlling this
Ownable.public void setOwner(Player p)
Ownable.
setOwner in interface Ownablep - The Player that should take ownership of this
Ownable.
java.lang.UnsupportedOperationException - is always thrown by this method.public void newTurn()
public java.lang.String getName()
getName in interface Namedpublic java.lang.String toString()
toString in class FreeColGameObjectString
private void unitsToXML(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
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 | ||||||||