|
|||||||||
| 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.ColonyTile
public class ColonyTile
Represents a work location on a tile.
| Field Summary | |
|---|---|
private Colony |
colony
|
private boolean |
colonyCenterTile
|
private static java.util.logging.Logger |
logger
|
private Unit |
unit
|
static java.lang.String |
UNIT_CHANGE
|
private Tile |
workTile
|
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| 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 |
canBeWorked()
Check if this WorkLocation is available to the colony. |
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. |
Unit |
getFirstUnit()
Gets the Unit currently working on this ColonyTile. |
GoodsContainer |
getGoodsContainer()
Gets the GoodsContainer this Location use
for storing it's goods. |
Unit |
getLastUnit()
Gets the Unit currently working on this ColonyTile. |
Unit |
getOccupyingUnit()
Returns the unit who is occupying the tile |
Player |
getOwner()
Gets the owner of this Ownable. |
java.util.Set<Modifier> |
getProductionModifiers(GoodsType goodsType,
UnitType unitType)
Returns the production of the given type of goods. |
int |
getProductionOf(GoodsType goodsType)
Returns the production of the given type of goods. |
int |
getProductionOf(Unit unit,
GoodsType goodsType)
Returns the production of the given type of goods which would be produced by the given unit |
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. |
GoodsType |
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. |
boolean |
isOccupied()
Checks whether there is a fortified enemy unit in the tile. |
void |
newTurn()
Prepares this ColonyTile for a new turn. |
private void |
produceGoods()
|
private void |
produceGoodsCenterTile()
|
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, addModelMessage, addToRemoveElement, 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
public static final java.lang.String UNIT_CHANGE
private Colony colony
private Tile workTile
private Unit unit
private boolean colonyCenterTile
| 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
FreeColObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
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 LocationgetColony in interface WorkLocationColony.Location.getColony()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 canBeWorked()
WorkLocation is available to the colony.
Used by canAdd() and the gui to decide whether to draw a border
on this tile in the colony panel.
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 Unit getOccupyingUnit()
isOccupied()public boolean isOccupied()
true if an fortified enemy unit is in the tilepublic void newTurn()
ColonyTile for a new turn.
newTurn in interface WorkLocationprivate void produceGoods()
private void produceGoodsCenterTile()
public GoodsType getWorkType(Unit unit)
unit - a Unit value
public int getProductionOf(GoodsType goodsType)
getProductionOf in interface WorkLocationgoodsType - a GoodsType value
int value
public java.util.Set<Modifier> getProductionModifiers(GoodsType goodsType,
UnitType unitType)
goodsType - a GoodsType valueunitType - a unitType value
int value
public int getProductionOf(Unit unit,
GoodsType goodsType)
unit - an Unit valuegoodsType - a GoodsType value
int valuepublic 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 FreeColObjectin - 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 | ||||||||