|
|||||||||
| 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 | |
|---|---|
private static java.util.Comparator<Building> |
buildingComparator
|
private BuildingType |
buildingType
|
private Colony |
colony
The colony containing this building. |
private static java.util.logging.Logger |
logger
|
static java.lang.String |
UNIT_CHANGE
|
private java.util.List<Unit> |
units
List of the units which have this Building as it's
location. |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| 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). |
private boolean |
assignStudent(Unit teacher)
|
private int |
calculateGoodsInput(int maximumGoodsInput,
int addToWarehouse)
|
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. |
private int |
getAutoProduction(int availableInput)
Returns the production of a building with no workplaces with given input. |
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. |
private int |
getGoodsInputAuto(int available)
|
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. |
private int |
getMaximumAutoProduction()
Returns the maximum production of a building with 0 workplaces |
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. |
private int |
getProductionAdding(int availableGoodsInput,
Unit... additionalUnits)
Returns the actual production of this building if Unit was added. |
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. |
private int |
getProductivity(Unit... additionalUnits)
Returns the maximum productivity of worker/s currently working in this building. |
private int |
getStoredInput()
|
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. |
private void |
produceGoods()
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
remove(Locatable locatable)
Removes the specified Locatable from this
WorkLocation. |
private void |
repairUnits()
|
void |
setOwner(Player p)
Sets the owner of this Ownable. |
private void |
setType(BuildingType newBuildingType)
|
java.lang.String |
toString()
Returns a string representation of the object. |
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. |
private void |
trainStudents()
|
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 |
|---|
addModelMessage, addModelMessage, addModelMessage, addToRemoveElement, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, readFromXMLPartialByClass, setFakeID, setGame, setId, toSavedXML, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject, updateID |
| 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 java.util.logging.Logger logger
public static final java.lang.String UNIT_CHANGE
private Colony colony
private java.util.List<Unit> units
Building as it's
location.
private BuildingType buildingType
private static java.util.Comparator<Building> buildingComparator
| 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 OwnablePlayer controlling this Ownable.public void setOwner(Player p)
Ownable.
setOwner in interface Ownablep - 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 LocationTile.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 LocationgetColony in interface WorkLocationColony.Location.getColony()public BuildingType getType()
getType in interface Typed<BuildingType>public boolean canBeDamaged()
true if can be damageddamage()public void damage()
public void upgrade()
private void setType(BuildingType newBuildingType)
public int getMaxUnits()
Building.
public int getUnitCount()
WorkLocation.
getUnitCount in interface LocationWorkLocation.public boolean canAdd(Locatable locatable)
Locatable may be added to this
WorkLocation.
canAdd in interface Locationlocatable - 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 Locationlocatable - 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 Locationlocatable - The Locatable that shall be removed from
this WorkLocation.public boolean contains(Locatable locatable)
Building contains the specified
Locatable.
contains in interface Locationlocatable - The Locatable to test the presence of.
>trueif 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 LocationIterator.public java.util.List<Unit> getUnitList()
Location
getUnitList in interface Locationpublic GoodsContainer getGoodsContainer()
Location's GoodsContainer.
getGoodsContainer in interface Locationnull.public void newTurn()
Building for a new turn.
newTurn in interface WorkLocationprivate void repairUnits()
private void produceGoods()
public Unit findStudent(Unit teacher)
private boolean assignStudent(Unit teacher)
private void trainStudents()
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()private int getStoredInput()
public int getGoodsInput()
production.
getMaximumGoodsInput(),
getProduction()public int getGoodsInputNextTurn()
production at the next turn.
getMaximumGoodsInput(),
getProduction()private int getGoodsInputAuto(int available)
private int calculateGoodsInput(int maximumGoodsInput,
int addToWarehouse)
private int getProductionAdding(int availableGoodsInput,
Unit... additionalUnits)
Unit was added.
additionalUnits - The Unit that was added
Buildingpublic 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 valueprivate int getAutoProduction(int availableInput)
availableInput - an int value
int valuepublic int getAdditionalProductionNextTurn(Unit addUnit)
Unit at this building for next turn.
getProduction()public int getProductionOf(GoodsType goodsType)
getProductionOf in interface 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.private int getProductivity(Unit... additionalUnits)
additionalUnits - units to add before calculating result
public int getUnitProductivity(Unit prodUnit)
Building,
assuming enough "input goods".public int getMaximumProduction()
private int getMaximumAutoProduction()
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
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.public static java.lang.String getXMLElementTagName()
public java.lang.String toString()
FreeColGameObject
toString in class FreeColGameObjectString
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||