|
|||||||||
| 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
public abstract class WorkLocation
The WorkLocation is a place in a Colony where
Units can work. The unit capacity of a WorkLocation is
likely to be limited. ColonyTiles can only hold a single worker,
and Buildings can hold no more than three workers, for example.
WorkLocations do not store any Goods. They take any Goods they
consume from the Colony, and put all Goods they produce there,
too. Although the WorkLocation implements Ownable, its
owner can not be changed directly, as it is always owned by the
owner of the Colony.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
UnitLocation.NoAddReason |
| Field Summary | |
|---|---|
private Colony |
colony
Describe colony here. |
| 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 |
WorkLocation()
Constructor for ServerWorkLocation. |
protected |
WorkLocation(Game game)
Constructor for ServerWorkLocation. |
|
WorkLocation(Game game,
java.lang.String id)
Initiates a new WorkLocation with the given ID. |
|
WorkLocation(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new WorkLocation from an XML representation. |
| Method Summary | |
|---|---|
boolean |
add(Locatable locatable)
Adds the specified locatable to this building. |
abstract boolean |
canAutoProduce()
Can this work location can produce goods without workers? |
boolean |
canBeWorked()
Checks if this colony tile can be worked. |
boolean |
canTeach()
Returns true if this work location has the Ability to
teach skills. |
Colony |
getColony()
Returns the Colony this WorkLocation is
located in. |
UnitLocation.NoAddReason |
getNoAddReason(Locatable locatable)
Gets the reason why a given Locatable can not be
added to this Location. |
abstract UnitLocation.NoAddReason |
getNoWorkReason()
Checks if this work location is available to the colony to be worked. |
Player |
getOwner()
Gets the owner of this Ownable. |
abstract 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 work location. |
abstract int |
getProductionOf(GoodsType goodsType)
Gets the production of the given type of goods. |
abstract int |
getProductionOf(Unit unit,
GoodsType goodsType)
Gets the production of the given type of goods produced by a unit. |
Settlement |
getSettlement()
Returns the settlement containing this building. |
Tile |
getTile()
Gets the Tile where this work location is
located. |
void |
readAttributes(javax.xml.stream.XMLStreamReader in)
Reads the attributes of this object from an XML stream. |
boolean |
remove(Locatable locatable)
Removes the specified locatable from this building. |
void |
setColony(Colony newColony)
Set the Colony value. |
void |
setOwner(Player p)
Sets the owner of this Ownable. |
void |
writeAttributes(javax.xml.stream.XMLStreamWriter out)
Write the attributes of this object to a stream. |
| Methods inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
canAdd, contains, dispose, disposeList, getGoodsContainer, getLocationName, getLocationNameFor, getSpaceTaken, getUnitCapacity, getUnitCount, getUnitIterator, getUnitList, isEmpty, isFull, readChild, readChildren, writeChildren |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, getXMLElementTagName, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toString, toXML, toXMLImpl, 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.Location |
|---|
getId |
| Field Detail |
|---|
private Colony colony
| Constructor Detail |
|---|
protected WorkLocation()
protected WorkLocation(Game game)
game - The Game this object belongs to.
public WorkLocation(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
WorkLocation from an XML representation.
game - The Game this object belongs to.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
public WorkLocation(Game game,
java.lang.String id)
WorkLocation 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 abstract int getProductionOf(GoodsType goodsType)
goodsType - The type of goods to get the production of.
public abstract int getProductionOf(Unit unit,
GoodsType goodsType)
unit - The unit to do the work.goodsType - The type of goods to get the production of.
public abstract int getPotentialProduction(UnitType unitType,
GoodsType goodsType)
unitType - The UnitType to produce the goods.goodsType - The GoodsType to produce.
public abstract boolean canAutoProduce()
public abstract UnitLocation.NoAddReason getNoWorkReason()
public boolean canBeWorked()
public UnitLocation.NoAddReason getNoAddReason(Locatable locatable)
Locatable can not be
added to this Location.
getNoAddReason in class UnitLocationlocatable - The Locatable to test.
public final Colony getColony()
Colony this WorkLocation is
located in.
This method always returns a colony != null (in contrast to
Location.getColony(), which might return null).
getColony in interface LocationgetColony in class UnitLocationColony this WorkLocation is
located in.Location.getColony()public final void setColony(Colony newColony)
Colony value.
newColony - The new Colony value.public Tile getTile()
Tile where this work location is
located.
getTile in interface LocationgetTile in class UnitLocationTile.public Settlement getSettlement()
getSettlement in interface LocationgetSettlement in class UnitLocationpublic Player getOwner()
Ownable.
getOwner in interface OwnablePlayer controlling this
Ownable.public void setOwner(Player p)
Ownable. Do not call this
method, ever. Since the owner of this WorkLocation is the owner
of the Colony, you must set the owner of the Colony instead.
setOwner in interface Ownablep - The Player that should take ownership
of this Ownable.
java.lang.UnsupportedOperationException - is always thrown by
this method.public boolean canTeach()
true if this work location has the Ability to
teach skills.
Ability.CAN_TEACHpublic boolean add(Locatable locatable)
add in interface Locationadd in class UnitLocationlocatable - The Locatable to add.public boolean remove(Locatable locatable)
remove in interface Locationremove in class UnitLocationlocatable - The Locatable to remove.
public void readAttributes(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readAttributes in class FreeColObjectin - The XML input stream.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public void writeAttributes(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeAttributes in class UnitLocationout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||