|
||||||||||
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.Building
public final class Building
Represents a building in a colony.
Field Summary | |
---|---|
static java.lang.String |
UNIT_CHANGE
|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
Constructor Summary | |
---|---|
Building(Game game,
Colony colony,
BuildingType type)
Creates a new Building . |
|
Building(Game game,
org.w3c.dom.Element e)
Initiates a new Building from an XML representation. |
|
Building(Game game,
java.lang.String id)
Initiates a new Building with the given ID. |
|
Building(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new Building from an XML representation. |
Method Summary | |
---|---|
void |
add(Locatable locatable)
Adds the specified Locatable to this
WorkLocation . |
int |
applyModifiers(int productivity)
Returns the Production from this building applying the production bonus of the colony to the given productivity of the worker(s). |
boolean |
canAdd(Locatable locatable)
Checks if the specified Locatable may be added to this
WorkLocation . |
boolean |
canAdd(UnitType unitType)
Checks if the specified UnitType may be added to this
WorkLocation . |
boolean |
canAutoProduce()
Returns true if this building can produce goods without workers. |
boolean |
canBeDamaged()
Returns whether this building can be damaged |
boolean |
canBuildNext()
Checks if this building can have a higher level. |
boolean |
contains(Locatable locatable)
Checks if this Building contains the specified
Locatable . |
void |
damage()
Reduces this building to previous level (is set to UpgradesFrom attribute in BuildingType) or is destroyed if it's the first level |
void |
dispose()
Disposes this building. |
Unit |
findStudent(Unit teacher)
|
int |
getAdditionalProduction(Unit addUnit)
Returns the maximum production of a given unit to be added to this building. |
int |
getAdditionalProductionNextTurn(Unit addUnit)
Returns the additional production of new Unit at this building for next turn. |
static java.util.Comparator<Building> |
getBuildingComparator()
|
Colony |
getColony()
Gets a pointer to the colony containing this building. |
UnitType |
getExpertUnitType()
Returns the unit type being an expert in this Building . |
Unit |
getFirstUnit()
Gets the first unit in this building. |
GoodsContainer |
getGoodsContainer()
Gets this Location 's GoodsContainer . |
int |
getGoodsInput()
Returns the amount of goods being used to get the current production . |
int |
getGoodsInputNextTurn()
Returns the amount of goods being used to get the current production at the next turn. |
GoodsType |
getGoodsInputType()
Returns the type of goods this building needs for input. |
GoodsType |
getGoodsOutputType()
Returns the type of goods this Building produces. |
Unit |
getLastUnit()
Gets the last unit in this building. |
int |
getLevel()
Returns the level of this building. |
int |
getMaximumGoodsInput()
Returns the amount of goods needed to have a full production. |
int |
getMaximumProduction()
Returns the maximum production of this building. |
int |
getMaxUnits()
Gets the maximum number of units allowed in this Building . |
java.lang.String |
getNextName()
Gets the name of the improved building of the same type. |
Player |
getOwner()
Gets the owner of this Ownable . |
int |
getProduction()
Returns the actual production of this building. |
int |
getProductionNextTurn()
Returns the actual production of this building for next turn. |
int |
getProductionOf(GoodsType goodsType)
Returns the production of the given type of goods. |
Tile |
getTile()
Gets the Tile where this Building is
located. |
BuildingType |
getType()
Gets the type of this building. |
int |
getUnitCount()
Gets the amount of units at this WorkLocation . |
java.util.Iterator<Unit> |
getUnitIterator()
Gets an Iterator of every Unit directly
located on this Building . |
java.util.List<Unit> |
getUnitList()
Returns a list containing all the Units present at this Location. |
int |
getUnitProductivity(Unit prodUnit)
Returns the maximum productivity of a unit working in this building. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
void |
newTurn()
Prepares this Building for a new turn. |
void |
remove(Locatable locatable)
Removes the specified Locatable from this
WorkLocation . |
void |
setOwner(Player p)
Sets the owner of this Ownable . |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
upgrade()
Upgrades this building to next level (is set to UpgradesTo attribute in BuildingType) |
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 Building(Game game, Colony colony, BuildingType type)
Building
.
game
- The Game
this object belongs to.colony
- The colony in which this building is located.type
- The type of building.public Building(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 a problem was encountered during parsing.public Building(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 Building(Game game, java.lang.String id)
Building
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 Tile getTile()
Tile
where this Building
is
located.
getTile
in interface Location
Tile
.public int getLevel()
int
valuepublic java.lang.String getNextName()
null
if the
improvement does not exist.public boolean canBuildNext()
Building
can have a higher level, that
Adam Smith
is present for manufactoring
factory level buildings and that the Colony
containing this Building
has a sufficiently high
population.public Colony getColony()
getColony
in interface Location
getColony
in interface WorkLocation
Colony
.Location.getColony()
public BuildingType getType()
getType
in interface Typed<BuildingType>
public boolean canBeDamaged()
true
if can be damageddamage()
public void damage()
public void upgrade()
public int getMaxUnits()
Building
.
public int getUnitCount()
WorkLocation
.
getUnitCount
in interface Location
WorkLocation
.public boolean canAdd(Locatable locatable)
Locatable
may be added to this
WorkLocation
.
canAdd
in interface Location
locatable
- the Locatable
.
public boolean canAdd(UnitType unitType)
UnitType
may be added to this
WorkLocation
.
unitType
- the UnitTYpe
.
public void add(Locatable locatable)
Locatable
to this
WorkLocation
.
add
in interface Location
locatable
- The Locatable
that shall be added to this
WorkLocation
.public UnitType getExpertUnitType()
Building
.
public void remove(Locatable locatable)
Locatable
from this
WorkLocation
.
remove
in interface Location
locatable
- The Locatable
that shall be removed from
this WorkLocation
.public boolean contains(Locatable locatable)
Building
contains the specified
Locatable
.
contains
in interface Location
locatable
- The Locatable
to test the presence of.
>true
if the specified
Locatable
is in this Building
andfalse
otherwise.public Unit getFirstUnit()
Unit
.public Unit getLastUnit()
Unit
.public java.util.Iterator<Unit> getUnitIterator()
Iterator
of every Unit
directly
located on this Building
.
getUnitIterator
in interface Location
Iterator
.public java.util.List<Unit> getUnitList()
Location
getUnitList
in interface Location
public GoodsContainer getGoodsContainer()
Location
's GoodsContainer
.
getGoodsContainer
in interface Location
null
.public void newTurn()
Building
for a new turn.
newTurn
in interface WorkLocation
public Unit findStudent(Unit teacher)
public GoodsType getGoodsOutputType()
Building
produces.
Building
produces or
-1
if there is no goods production by this
Building
.public GoodsType getGoodsInputType()
Building
requires as input
in order to produce it's output
.public int getMaximumGoodsInput()
input
being used this turn, provided that the amount of goods in the
Colony
is either larger or the same as the value
returned by this method.getGoodsInput()
,
getProduction()
public int getGoodsInput()
production
.
getMaximumGoodsInput()
,
getProduction()
public int getGoodsInputNextTurn()
production
at the next turn.
getMaximumGoodsInput()
,
getProduction()
public int getProduction()
Building
the current turn. The type of goods being produced is given by
getGoodsOutputType()
.getProductionNextTurn()
,
getMaximumProduction()
public int getProductionNextTurn()
getProduction()
public boolean canAutoProduce()
boolean
valuepublic int getAdditionalProductionNextTurn(Unit addUnit)
Unit
at this building for next turn.
getProduction()
public int getProductionOf(GoodsType goodsType)
getProductionOf
in interface WorkLocation
goodsType
- The type of goods to get the production for.
getProduction()
if the given type of
goods is the same as getGoodsOutputType()
and
0
otherwise.public int getUnitProductivity(Unit prodUnit)
Building
,
assuming enough "input goods".public int getMaximumProduction()
public int getAdditionalProduction(Unit addUnit)
0
.public int applyModifiers(int productivity)
productivity
- From getProductivity(net.sf.freecol.common.model.Unit...)
public static java.util.Comparator<Building> getBuildingComparator()
public void dispose()
Building as it's location will be disposed
.
dispose
in class FreeColGameObject
public static java.lang.String getXMLElementTagName()
public java.lang.String toString()
FreeColGameObject
toString
in class FreeColGameObject
String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |