|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.ColonyTile
public class ColonyTile
Represents a work location on a tile.
| Field Summary | |
|---|---|
static java.lang.String |
COPYRIGHT
|
static java.lang.String |
LICENSE
|
static java.lang.String |
REVISION
|
| Constructor Summary | |
|---|---|
ColonyTile(Game game,
Colony colony,
Tile workTile)
Creates a new ColonyTile. |
|
ColonyTile(Game game,
org.w3c.dom.Element e)
Initiates a new Building from an
XML representation. |
|
ColonyTile(Game game,
java.lang.String id)
Initiates a new ColonyTile
with the given ID. |
|
ColonyTile(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new Building from an
XML representation. |
|
| Method Summary | |
|---|---|
void |
add(Locatable locatable)
Add the specified Locatable to this WorkLocation. |
boolean |
canAdd(Locatable locatable)
Checks if the specified Locatable may be added to this WorkLocation. |
boolean |
contains(Locatable locatable)
Checks if this ColonyTile contains the given Locatable. |
void |
dispose()
Removes all references to this object. |
Colony |
getColony()
Gets a pointer to the colony containing this tile. |
int |
getExpertForProducing(int goodsType)
Returns the unit type producing the greatest amount of the given goods at this tile. |
Unit |
getFirstUnit()
Gets the Unit currently working on this ColonyTile. |
int |
getFoodProduction()
Returns the production of food on this tile. |
GoodsContainer |
getGoodsContainer()
Gets the GoodsContainer this Location use
for storing it's goods. |
java.lang.String |
getLabel()
Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow) |
Unit |
getLastUnit()
Gets the Unit currently working on this ColonyTile. |
java.lang.String |
getLocationName()
Returns the (non-unique) name of this ColonyTile. |
Player |
getOwner()
Gets the owner of this Ownable. |
int |
getProductionOf(int goodsType)
Returns the production of the given type of goods. |
Tile |
getTile()
Gets the tile where the colony is located. |
Unit |
getUnit()
Gets the Unit currently working on this ColonyTile. |
int |
getUnitCount()
Gets the amount of Units at this ColonyTile. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets a Iterator of every Unit directly
located on this Location. |
java.util.List<Unit> |
getUnitList()
Returns a list containing all the Units present at this Location. |
Tile |
getWorkTile()
Gets the work tile. |
int |
getWorkType(Unit unit)
Returns a worktype for a unit. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
isColonyCenterTile()
Checks if this is the tile where the Colony is located. |
void |
newTurn()
Prepares this ColonyTile for a new turn. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
relocateWorkers()
Relocates any worker on this ColonyTile. |
void |
remove(Locatable locatable)
Remove the specified Locatable from this WorkLocation. |
void |
setOwner(Player p)
Sets the owner of this Ownable. |
void |
setUnit(Unit unit)
Sets a Unit to this ColonyTile. |
java.lang.String |
toString()
Will return the position of the tile and the name of the colony in addition to the FreeColObject.toString(). |
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, equals, equals, getGame, getGameOptions, getID, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromXML, readFromXMLElement, setFakeID, setGame, setID, toArrayElement, toArrayElement, toArrayElement, toArrayElement, toSavedXML, toXML, toXML, toXML, toXMLElement, toXMLElement, 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 |
|---|
public static final java.lang.String COPYRIGHT
public static final java.lang.String LICENSE
public static final java.lang.String REVISION
| Constructor Detail |
|---|
public ColonyTile(Game game,
Colony colony,
Tile workTile)
ColonyTile.
game - The Game this object belongs to.colony - The Colony this object belongs to.workTile - The tile in which this ColonyTile represents a
WorkLocation for.
public ColonyTile(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
Building from an
XML representation.
game - The Game this object belongs to.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if an error occured during parsing.
public ColonyTile(Game game,
org.w3c.dom.Element e)
Building from an
XML representation.
game - The Game this object belongs to.e - An XML-element that will be used to initialize
this object.
public ColonyTile(Game game,
java.lang.String id)
ColonyTile
with the given ID. The object should later be
initialized by calling either
FreeColGameObject.readFromXML(XMLStreamReader) or
FreeColGameObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public java.lang.String getLocationName()
ColonyTile.
getLocationName in interface Locationpublic java.lang.String getLabel()
public Player getOwner()
Ownable.
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 boolean isColonyCenterTile()
Colony is located.
public Tile getWorkTile()
ColonyTile represents a
WorkLocation for.public Tile getTile()
getTile in interface LocationTile.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 Unit getUnit()
Unit currently working on this ColonyTile.
Unit or null if no unit is present.setUnit(net.sf.freecol.common.model.Unit)public Colony getColony()
getColony in interface WorkLocationColony.public void setUnit(Unit unit)
Unit to this ColonyTile.
unit - The Unit.getUnit()public int getUnitCount()
ColonyTile.
getUnitCount in interface LocationColonyTile.public void relocateWorkers()
ColonyTile.
The workers are added to another WorkLocation
within the Colony.
public boolean canAdd(Locatable locatable)
Locatable may be added to this WorkLocation.
canAdd in interface Locationlocatable - the Locatable.
true if the Unit may be added and false otherwise.public void add(Locatable locatable)
Locatable to this WorkLocation.
add in interface Locationlocatable - The Locatable that shall be added to this WorkLocation.public void remove(Locatable locatable)
Locatable from this WorkLocation.
remove in interface Locationlocatable - The Locatable that shall be removed from this WorkLocation.public java.util.List<Unit> getUnitList()
Location
getUnitList in interface Locationpublic java.util.Iterator<Unit> getUnitIterator()
LocationIterator of every Unit directly
located on this Location.
getUnitIterator in interface LocationIterator.public boolean contains(Locatable locatable)
ColonyTile contains the given Locatable.
contains in interface Locationlocatable - The Locatable.
public Unit getFirstUnit()
Unit currently working on this ColonyTile.
Unit or null if no unit is present.setUnit(net.sf.freecol.common.model.Unit)public Unit getLastUnit()
Unit currently working on this ColonyTile.
Unit or null if no unit is present.setUnit(net.sf.freecol.common.model.Unit)public void newTurn()
ColonyTile for a new turn.
public int getFoodProduction()
getProductionOf(Goods.FOOD).
public int getWorkType(Unit unit)
unit - a Unit value
public int getProductionOf(int goodsType)
getProductionOf in interface WorkLocationgoodsType - The type of goods to get the production of.
public int getExpertForProducing(int goodsType)
goodsType - The type of goods.
unit type.Unit.getExpertWorkType(),
Building.getExpertUnitType()public void dispose()
FreeColGameObject
dispose in class FreeColGameObject
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 FreeColGameObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public java.lang.String toString()
toString in class FreeColGameObjectpublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||