|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.Building
public final class Building
Represents a building in a colony.
Each Building has a type and a level. The levels are
NOT_BUILT, HOUSE, SHOP and FACTORY.
The name of a Building depends on both the
type and the level:
Type STOCKADE
Level NOT_BUILT: null
Level HOUSE: "Stockade"
Level SHOP: "Fort"
Level FACTORY: "Fortress"
| Field Summary | |
|---|---|
static int |
ARMORY
The type of a building. |
static int |
BLACKSMITH
The type of a building. |
static int |
CARPENTER
The type of a building. |
static int |
CHURCH
The type of a building. |
static java.lang.String |
COPYRIGHT
|
static int |
CUSTOM_HOUSE
The type of a building. |
static int |
DISTILLER
The type of a building. |
static int |
DOCK
The type of a building. |
static int |
FACTORY
The level of a building. |
static int |
FUR_TRADER
The type of a building. |
static int |
HOUSE
The level of a building. |
static java.lang.String |
LICENSE
|
static int |
MAX_LEVEL
The maximum level. |
static int |
NONE
The type of a building. |
static int |
NOT_BUILT
The level of a building. |
static int |
NUMBER_OF_TYPES
The maximum number of building types. |
static int |
PRINTING_PRESS
The type of a building. |
static java.lang.String |
REVISION
|
static int |
SCHOOLHOUSE
The type of a building. |
static int |
SHOP
The level of a building. |
static int |
STABLES
The type of a building. |
static int |
STOCKADE
The type of a building. |
static int |
TOBACCONIST
The type of a building. |
static int |
TOWN_HALL
The type of a building. |
static int |
WAREHOUSE
The type of a building. |
static int |
WEAVER
The type of a building. |
| Constructor Summary | |
|---|---|
Building(Game game,
Colony colony,
int type,
int level)
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 |
calculateOutput(int goodsInput)
Calculates and returns the output of this building from the input. |
boolean |
canAdd(Locatable locatable)
Checks if the specified Locatable may be added to this
WorkLocation. |
boolean |
canBuildNext()
Checks if this building can have a higher level. |
boolean |
contains(Locatable locatable)
Checks if this Building contains the specified
Locatable. |
void |
dispose()
Disposes this building. |
Colony |
getColony()
Gets a pointer to the colony containing this building. |
int |
getExpertUnitType()
Returns the unit type being an expert in this Building. |
static int |
getExpertUnitType(int type)
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 beeing used to get the current production. |
int |
getGoodsInputType()
Returns the type of goods this building needs for input. |
static int |
getGoodsInputType(int type)
Returns the type of goods this building needs for input. |
int |
getGoodsOutputType()
Returns the type of goods this Building produces. |
static int |
getGoodsOutputType(int type)
Returns the type of goods this Building produces. |
Unit |
getLastUnit()
Gets the last unit in this building. |
int |
getLevel()
Gets the level of the building. |
java.lang.String |
getLocationName()
Returns the name of this location. |
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 |
getName()
Gets the name of a building. |
int |
getNextHammers()
Gets the number of hammers required for the improved building of the same type. |
java.lang.String |
getNextName()
Gets the name of the improved building of the same type. |
int |
getNextPop()
Gets the colony population required for the improved building of the same type. |
int |
getNextTools()
Gets the number of tools required for 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(int goodsType)
Returns the production of the given type of goods. |
Tile |
getTile()
Gets the Tile where this Building is
located. |
int |
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. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
isBuilt()
Checks if the building has been built. |
void |
newTurn()
Prepares this Building for a new turn. |
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. |
void |
setLevel(int level)
Sets the level of the building. |
void |
setName(java.lang.String newName)
Set the Name value. |
void |
setOwner(Player p)
Sets the owner of this Ownable. |
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. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
addModelMessage, addModelMessage, equals, equals, getGame, getGameOptions, getID, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromXML, readFromXMLElement, setFakeID, setGame, setID, toArrayElement, toArrayElement, toArrayElement, toArrayElement, toSavedXML, toString, toXML, toXML, toXML, toXMLElement, toXMLElement, 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 |
|---|
public static final java.lang.String COPYRIGHT
public static final java.lang.String LICENSE
public static final java.lang.String REVISION
public static final int MAX_LEVEL
public static final int NONE
public static final int TOWN_HALL
public static final int CARPENTER
public static final int BLACKSMITH
public static final int TOBACCONIST
public static final int WEAVER
public static final int DISTILLER
public static final int FUR_TRADER
public static final int SCHOOLHOUSE
public static final int ARMORY
public static final int CHURCH
public static final int STOCKADE
public static final int WAREHOUSE
public static final int STABLES
public static final int DOCK
public static final int PRINTING_PRESS
public static final int CUSTOM_HOUSE
public static final int NUMBER_OF_TYPES
public static final int NOT_BUILT
public static final int HOUSE
public static final int SHOP
public static final int FACTORY
| Constructor Detail |
|---|
public Building(Game game,
Colony colony,
int type,
int level)
Building.
game - The Game this object belongs to.colony - The colony in which this building is located.type - The type of building.level - The level of the building: NOT_BUILT,
HOUSE, SHOP or FACTORY.
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
FreeColGameObject.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()
NOT_BUILT,
HOUSE, SHOP and FACTORY.
public void setLevel(int level)
level - The new level of the building. This should be one of
NOT_BUILT, HOUSE, SHOP and
FACTORY.public java.lang.String getName()
getName in interface NameableBuilding or null if the
building has not been built.public void setName(java.lang.String newName)
Name value.
setName in interface NameablenewName - The new Name value.public java.lang.String getLocationName()
getLocationName in interface Locationpublic java.lang.String getNextName()
null if the
improvement does not exist.public int getNextHammers()
-1 if the building does not exist.public int getNextTools()
-1 if the building does not exist.public int getNextPop()
-1 if the building 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 boolean isBuilt()
public Colony getColony()
getColony in interface WorkLocationColony.public int getType()
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 void add(Locatable locatable)
Locatable to this
WorkLocation.
add in interface Locationlocatable - The Locatable that shall be added to this
WorkLocation.public int getExpertUnitType()
Building.
unit type.Unit.getExpertWorkType(),
ColonyTile.getExpertForProducing(int)public static int getExpertUnitType(int type)
Building.
type - The type of building.
unit type.Unit.getExpertWorkType(),
ColonyTile.getExpertForProducing(int)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.
public int getGoodsOutputType()
Building produces.
Building produces or
-1 if there is no goods production by this
Building.public static int getGoodsOutputType(int type)
Building produces.
type - The type of building.
Building produces or
-1 if there is no goods production by this
Building.public int getGoodsInputType()
Building requires as input
in order to produce it's output.public static int getGoodsInputType(int type)
type - The type of building.
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 calculateOutput(int goodsInput)
getProduction,
getProductionNextTurnpublic int getProduction()
Building
the current turn. The type of goods being produced is given by
getGoodsOutputType().getProductionNextTurn(),
getMaximumProduction()public int getProductionNextTurn()
getProduction()public int getProductionOf(int 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.public int getMaximumProduction()
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 FreeColGameObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||