|
||||||||||
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 | |
---|---|
static java.lang.String |
UNIT_CHANGE
|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
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. |
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(). |
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
---|
addToRemoveElement, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toXML, updateFreeColGameObject, updateID |
Methods inherited from class java.lang.Object |
---|
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 UNIT_CHANGE
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 Ownable
Player
controlling this
Ownable
.public void setOwner(Player p)
Ownable
.
setOwner
in interface Ownable
p
- 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 Location
Tile
.public GoodsContainer getGoodsContainer()
Location
GoodsContainer
this Location
use
for storing it's goods.
getGoodsContainer
in interface Location
GoodsContainer
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 Location
getColony
in interface WorkLocation
Colony
.Location.getColony()
public void setUnit(Unit unit)
Unit
to this ColonyTile
.
unit
- The Unit
.getUnit()
public int getUnitCount()
ColonyTile
.
getUnitCount
in interface Location
ColonyTile
.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 Location
locatable
- the Locatable
.
true
if the Unit
may be added
and false
otherwise.public void add(Locatable locatable)
Locatable
to this WorkLocation
.
add
in interface Location
locatable
- The Locatable
that shall be added to this WorkLocation
.public void remove(Locatable locatable)
Locatable
from this WorkLocation
.
remove
in interface Location
locatable
- The Locatable
that shall be removed from this WorkLocation
.public java.util.List<Unit> getUnitList()
Location
getUnitList
in interface Location
public java.util.Iterator<Unit> getUnitIterator()
Location
Iterator
of every Unit
directly
located on this Location
.
getUnitIterator
in interface Location
Iterator
.public boolean contains(Locatable locatable)
ColonyTile
contains the given Locatable
.
contains
in interface Location
locatable
- 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 WorkLocation
public GoodsType getWorkType(Unit unit)
unit
- a Unit
value
public int getProductionOf(GoodsType goodsType)
getProductionOf
in interface WorkLocation
goodsType
- a GoodsType
value
int
valuepublic java.util.Set<Modifier> getProductionModifiers(GoodsType goodsType, UnitType unitType)
goodsType
- a GoodsType
valueunitType
- a unitType
value
int
valuepublic int getProductionOf(Unit unit, GoodsType goodsType)
unit
- an Unit
valuegoodsType
- a GoodsType
value
int
valuepublic void dispose()
FreeColGameObject
dispose
in class FreeColGameObject
public java.lang.String toString()
toString
in class FreeColGameObject
public static java.lang.String getXMLElementTagName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |