|
|||||||||
| 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.UnitLocation
net.sf.freecol.common.model.WorkLocation
net.sf.freecol.common.model.ColonyTile
public class ColonyTile
Represents a work location on a tile. Each ColonyTile except the colony center tile provides a work place for a single unit and produces a single type of goods. The colony center tile generally produces two different of goods, one food type and one new world raw material.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
UnitLocation.NoAddReason |
| Field Summary | |
|---|---|
protected boolean |
colonyCenterTile
Is this colony tile at the center of the colony. |
private static java.util.logging.Logger |
logger
|
static int |
UNIT_CAPACITY
The maximum number of units a ColonyTile can hold. |
static java.lang.String |
UNIT_CHANGE
|
protected Tile |
workTile
The tile to work. |
| Fields inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
UNITS_TAG_NAME |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
protected |
ColonyTile()
Constructor for ServerColonyTile. |
protected |
ColonyTile(Game game,
Colony colony,
Tile workTile)
Constructor for ServerColonyTile. |
|
ColonyTile(Game game,
org.w3c.dom.Element e)
Initiates a new ColonyTile 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 ColonyTile from an
XML representation. |
| Method Summary | |
|---|---|
boolean |
add(Locatable locatable)
Add the specified locatable to this colony tile. |
StringTemplate |
getLabel()
Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow). |
StringTemplate |
getLocationName()
Returns the (non-unique) name of this ColonyTile. |
UnitLocation.NoAddReason |
getNoAddReason(Locatable locatable)
Gets the reason why a given Locatable can not be
added to this Location. |
UnitLocation.NoAddReason |
getNoWorkReason()
Checks if this work location is available to the colony to be worked. |
Unit |
getOccupyingUnit()
Returns the unit who is occupying the tile |
int |
getPotentialProduction(UnitType unitType,
GoodsType goodsType)
Gets the potential production of a given goods type from using a unit of a given type in this building. |
private AbstractGoods |
getPrimaryProduction()
Returns the primary production of a colony center tile. |
java.util.List<AbstractGoods> |
getProduction()
|
java.util.Set<Modifier> |
getProductionModifiers(GoodsType goodsType,
UnitType unitType)
Gets the production modifiers for the given type of goods and unit. |
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 |
private AbstractGoods |
getSecondaryProduction()
Returns the secondary production of a colony center tile. |
Unit |
getUnit()
Gets the Unit currently working on this
ColonyTile. |
int |
getUnitCapacity()
Gets the maximum number of Units this Location
can hold. |
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. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
protected void |
readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
Partial reader, so that "remove" messages can be brief. |
void |
relocateWorkers()
Relocates any worker on this ColonyTile. |
boolean |
remove(Locatable locatable)
Remove the specified locatable from this colony tile. |
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. |
protected void |
toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
java.lang.String[] fields)
Partial writer, so that "remove" messages can be brief. |
| Methods inherited from class net.sf.freecol.common.model.WorkLocation |
|---|
canBeWorked, canTeach, getColony, getOwner, getSettlement, getTile, readAttributes, setColony, setOwner, writeAttributes |
| Methods inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
canAdd, contains, dispose, disposeList, getGoodsContainer, getLocationNameFor, getSpaceTaken, getUnitCount, getUnitIterator, getUnitList, isEmpty, isFull, readChild, readChildren, writeChildren, writeChildren |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.freecol.common.model.Ownable |
|---|
getOwner, setOwner |
| 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
public static final int UNIT_CAPACITY
protected Tile workTile
protected boolean colonyCenterTile
| Constructor Detail |
|---|
protected ColonyTile()
protected ColonyTile(Game game,
Colony colony,
Tile workTile)
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
ColonyTile 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)
ColonyTile 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 StringTemplate getLocationName()
ColonyTile.
getLocationName in interface LocationgetLocationName in class UnitLocationpublic StringTemplate getLabel()
public boolean isColonyCenterTile()
Colony is located.
public Tile getWorkTile()
ColonyTile represents a
WorkLocation for.public Unit getUnit()
Unit currently working on this
ColonyTile.
Unit or null if no unit is present.
TODO: deprecate this in favour of using the unit list, as we are
unnecessarily encoding the assumption that there can only be one unit.public int getUnitCapacity()
Units this Location
can hold. To be overridden by subclasses.
getUnitCapacity in class UnitLocationpublic UnitLocation.NoAddReason getNoWorkReason()
getNoWorkReason in class WorkLocationpublic UnitLocation.NoAddReason getNoAddReason(Locatable locatable)
Locatable can not be
added to this Location.
getNoAddReason in class WorkLocationlocatable - The Locatable to test.
public boolean add(Locatable locatable)
add in interface Locationadd in class WorkLocationlocatable - The Locatable to add.public boolean remove(Locatable locatable)
remove in interface Locationremove in class WorkLocationlocatable - The Locatable to be removed.public void relocateWorkers()
ColonyTile.
The workers are added to another WorkLocation
within the Colony.
public Unit getOccupyingUnit()
isOccupied()public boolean isOccupied()
true if an fortified enemy unit is in the tilepublic GoodsType getWorkType(Unit unit)
unit - a Unit value
private AbstractGoods getPrimaryProduction()
AbstractGoods valueprivate AbstractGoods getSecondaryProduction()
int valuepublic java.util.List<AbstractGoods> getProduction()
public java.util.Set<Modifier> getProductionModifiers(GoodsType goodsType,
UnitType unitType)
goodsType - The GoodsType to produce.unitType - The unitType to produce them.
public int getProductionOf(GoodsType goodsType)
getProductionOf in class WorkLocationgoodsType - a GoodsType value
int value
public int getProductionOf(Unit unit,
GoodsType goodsType)
getProductionOf in class WorkLocationunit - an Unit valuegoodsType - a GoodsType value
int value
public int getPotentialProduction(UnitType unitType,
GoodsType goodsType)
getPotentialProduction in class WorkLocationunitType - The UnitType to check.goodsType - The GoodsType to check.
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.
protected void toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
java.lang.String[] fields)
throws javax.xml.stream.XMLStreamException
toXMLPartialImpl in class FreeColObjectout - The target stream.fields - The fields to write.
javax.xml.stream.XMLStreamException - If there are problems writing the stream.
protected void readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLPartialImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - If there are problems reading the stream.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 | ||||||||