|
|||||||||
| 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.Building
public class Building
Represents a building in a colony.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
UnitLocation.NoAddReason |
| Field Summary | |
|---|---|
protected BuildingType |
buildingType
The type of building. |
private static java.util.logging.Logger |
logger
|
static java.lang.String |
UNIT_CHANGE
|
| 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 |
| Fields inherited from interface net.sf.freecol.common.model.Consumer |
|---|
BUILDING_PRIORITY, COLONY_PRIORITY, COMPARATOR, POPULATION_PRIORITY, UNIT_PRIORITY |
| Constructor Summary | |
|---|---|
protected |
Building()
Constructor for ServerBuilding. |
protected |
Building(Game game)
Constructor for ServerBuilding. |
|
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 | |
|---|---|
boolean |
add(Locatable locatable)
Adds the specified locatable to this building. |
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. |
int |
compareTo(Building other)
|
boolean |
consumes(GoodsType goodsType)
Returns true if this Consumer consumes the given GoodsType. |
boolean |
damage()
Reduces this building to previous level (is set to UpgradesFrom attribute in BuildingType) or is destroyed if it's the first level |
int |
getAdditionalProductionNextTurn(Unit addUnit)
Returns the additional production of new Unit at
this building for next turn. |
java.util.List<AbstractGoods> |
getConsumedGoods()
Returns a list of GoodsTypes this Consumer consumes. |
UnitType |
getExpertUnitType()
Returns the unit type being an expert in this Building. |
GoodsType |
getGoodsInputType()
Returns the type of goods this building needs for input, or null if the Building does not consume any goods. |
GoodsType |
getGoodsOutputType()
Returns the type of goods this Building produces,
or null if the Building does not produce any
goods. |
int |
getLevel()
Returns the level of this building. |
StringTemplate |
getLocationName()
Returns the name of this location. |
int |
getMaximumProduction()
Returns the maximum production of this building. |
java.util.Set<Modifier> |
getModifierSet(java.lang.String id)
Returns the modifier set with the given id. |
java.lang.String |
getNameKey()
Gets the name of this Named. |
java.lang.String |
getNextNameKey()
Gets the name of the improved building of the same type. |
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. |
int |
getPotentialProduction(UnitType unitType,
GoodsType goodsType)
Gets the potential productivity of a given goods type from using a unit of a given type in this building. |
int |
getPriority()
The priority of this Consumer. |
int |
getProduction()
Returns the actual production of this building. |
ProductionInfo |
getProductionInfo()
Returns the ProductionInfo for this Building from the Colony's cache. |
ProductionInfo |
getProductionInfo(AbstractGoods output,
java.util.List<AbstractGoods> input)
Returns the ProductionInfo for this Building. |
java.util.List<Modifier> |
getProductionModifiers()
Returns a List of all Modifiers that influence the total production of the Building. |
int |
getProductionOf(GoodsType goodsType)
Returns the production of the given type of goods. |
int |
getProductionOf(Unit unit,
GoodsType goodsType)
Gets the production of the given type of goods produced by a unit. |
private int |
getProductivity(Unit... additionalUnits)
Returns the maximum productivity of worker/s currently working in this building. |
BuildingType |
getType()
Gets the type of this building. |
int |
getUnitCapacity()
Gets the maximum number of Units this Location
can hold. |
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. |
boolean |
hasAbility(java.lang.String id)
Describe hasAbility method here. |
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. |
boolean |
remove(Locatable locatable)
Removes the specified locatable from this building. |
private void |
setType(BuildingType newBuildingType)
Changes the type of the Building. |
java.lang.String |
toString()
String converter for debugging. |
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. |
boolean |
upgrade()
Upgrades this building to next level (is set to UpgradesTo attribute in BuildingType) |
| 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.Location |
|---|
getId |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final java.lang.String UNIT_CHANGE
protected BuildingType buildingType
| Constructor Detail |
|---|
protected Building()
protected Building(Game game)
game - The Game this object belongs to.
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 java.lang.String getNameKey()
Named.
getNameKey in interface NamedNamed.public int getLevel()
int valuepublic StringTemplate getLocationName()
getLocationName in interface LocationgetLocationName in class UnitLocationpublic java.lang.String getNextNameKey()
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 BuildingType getType()
public boolean hasAbility(java.lang.String id)
hasAbility method here.
hasAbility in interface ConsumerhasAbility in class FreeColObjectid - a String value
boolean valuepublic boolean canBeDamaged()
true if can be damageddamage()public boolean damage()
public boolean upgrade()
private void setType(BuildingType newBuildingType)
newBuildingType - upgrade(),
damage()public int getUnitCapacity()
Units this Location
can hold. To be overridden by subclasses.
getUnitCapacity in class UnitLocationpublic UnitType getExpertUnitType()
Building.
public 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 canAdd(UnitType unitType)
UnitType may be added to this
WorkLocation.
unitType - the UnitType.
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 remove.public GoodsType getGoodsOutputType()
Building produces,
or null if the Building does not produce any
goods.
Building producespublic GoodsType getGoodsInputType()
null if the Building does not consume any goods.
Building requires as input
in order to produce it's output.public ProductionInfo getProductionInfo()
ProductionInfo object
public ProductionInfo getProductionInfo(AbstractGoods output,
java.util.List<AbstractGoods> input)
output - the output goods already available in the colony,
necessary in order to avoid excess productioninput - the input goods available
ProductionInfo objectpublic int getProduction()
Building
the current turn. The type of goods being produced is given by
getGoodsOutputType().getMaximumProduction()public int getMaximumProduction()
public int getAdditionalProductionNextTurn(Unit addUnit)
Unit at
this building for next turn.
TODO: Make this work properly. In the past, the method never
worked correctly anyway, since it did not take the possible
decrease in the production of input goods into account that
might be caused by moving a unit to this Building from another
WorkLocation. To do this right, it would be necessary to
re-calculate the production for the whole getColony().
public boolean canAutoProduce()
boolean valueprivate int getProductivity(Unit... additionalUnits)
additionalUnits - units to add before calculating result
public int getUnitProductivity(Unit prodUnit)
Building,
assuming enough "input goods".public int getProductionOf(GoodsType goodsType)
getProductionOf in class WorkLocationgoodsType - 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 getProductionOf(Unit unit,
GoodsType goodsType)
getProductionOf in class WorkLocationunit - The unit to do the work.goodsType - The type of goods to get the production of.
public int getPotentialProduction(UnitType unitType,
GoodsType goodsType)
getPotentialProduction in class WorkLocationunitType - The UnitType to check.goodsType - The GoodsType to check.
public java.util.List<Modifier> getProductionModifiers()
public int compareTo(Building other)
compareTo in interface java.lang.Comparable<Building>public boolean consumes(GoodsType goodsType)
goodsType - a GoodsType value
boolean valuepublic java.util.List<AbstractGoods> getConsumedGoods()
getConsumedGoods in interface ConsumerList valuepublic int getPriority()
getPriority in interface Consumerint valuepublic java.util.Set<Modifier> getModifierSet(java.lang.String id)
getModifierSet in interface Consumerid - a String value
boolean value
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 | ||||||||