|
|||||||||
| 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.Settlement
net.sf.freecol.common.model.Colony
public final class Colony
Represents a colony. A colony contains Buildings and
ColonyTiles. The latter represents the tiles around the
Colony where working is possible.
| Field Summary | |
|---|---|
static int |
BUILDING_UNIT_ADDITION
|
static java.lang.String |
COPYRIGHT
|
static java.lang.String |
LICENSE
|
static java.lang.String |
REVISION
|
| Fields inherited from class net.sf.freecol.common.model.Settlement |
|---|
goodsContainer, owner, RADIUS, tile |
| Constructor Summary | |
|---|---|
Colony(Game game,
org.w3c.dom.Element e)
Initiates a new Colony from an XML representation. |
|
Colony(Game game,
Player owner,
java.lang.String name,
Tile tile)
Creates a new Colony. |
|
Colony(Game game,
java.lang.String id)
Initiates a new Colony with the given ID. |
|
Colony(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new Colony from an XML representation. |
|
| Method Summary | |
|---|---|
void |
add(Locatable locatable)
Adds a Locatable to this Location. |
void |
addBells(int amount)
Adds to the bell count of the colony. |
void |
addGoods(int type,
int amount)
|
void |
addHammers(int amount)
Adds to the hammer count of the colony. |
void |
addSoL(int amount)
Adds to the bell count of the colony. |
void |
bombard(Unit defender,
int result)
Bombard a unit with the given outcome. |
boolean |
canAdd(Locatable locatable)
Checks wether or not the specified locatable may be added to this Location. |
boolean |
canBuildUnit(int unitType)
Checks if this colony may build the given unit type. |
boolean |
contains(Locatable locatable)
Checks if this Location contains the specified
Locatable. |
void |
damageAllShips()
Damages all ship located on this Colony's
Tile. |
void |
dispose()
Disposes this Colony. |
int |
getBells()
Returns the bell count of the colony. |
java.util.Iterator<java.lang.Integer> |
getBuildableUnitIterator()
Returns an Iterator of every unit type this colony may
build. |
Building |
getBuilding(int type)
Gets a Building of the specified type. |
Building |
getBuildingForConsuming(int goodsType)
Returns the colony's existing building for the given goods type. |
Building |
getBuildingForProducing(int goodsType)
Returns the building for producing the given type of goods. |
java.util.Iterator<Building> |
getBuildingIterator()
Gets an Iterator of every Building in this
Colony. |
ColonyTile |
getColonyTile(int x,
int y)
Gets the specified ColonyTile. |
ColonyTile |
getColonyTile(Tile t)
Returns the ColonyTile matching the given
Tile. |
java.util.Iterator<ColonyTile> |
getColonyTileIterator()
Gets an Iterator of every ColonyTile in this
Colony. |
java.util.Iterator<Goods> |
getCompactGoodsIterator()
Gets an Iterator of every Goods in this
Colony. |
int |
getCurrentlyBuilding()
Returns the type of building currently being built. |
Unit |
getDefendingUnit(Unit attacker)
Gets the Unit that is currently defending this
Colony. |
int[] |
getExportLevel()
Get the ExportLevel value. |
boolean |
getExports(Goods goods)
Returns true if the custom house should export these goods. |
boolean |
getExports(int type)
Returns true if the custom house should export this type of goods. |
int |
getFoodConsumption()
Gives the food needed to keep all current colonists alive in this colony. |
int |
getFoodProduction()
Gets the production of food. |
int |
getGoodsCount(int type)
Gets the amount of one type of Goods at this Colony. |
java.util.Iterator<Goods> |
getGoodsIterator()
|
int |
getHammers()
Returns the hammer count of the colony. |
int[] |
getHighLevel()
Get the HighLevel value. |
int |
getHorseProduction()
Gets the production of horses in this Colony. |
java.lang.String |
getLocationName()
Returns the name of this location. |
int[] |
getLowLevel()
Get the LowLevel value. |
int |
getMembers()
Return the number of sons of liberty |
java.lang.String |
getName()
Gets the name of this Colony. |
int |
getPotentialHorseProduction()
Returns the horse production (given that enough food is being produced and a sufficient storage capacity). |
int |
getPriceForBuilding()
Returns the price for the remaining hammers and tools for the Building that is currently being built. |
int |
getProductionBonus()
Returns the production bonus, if any, of the colony. |
int |
getProductionNetOf(int goodsType)
Returns how much of a Good will be produced by this colony this turn, taking into account how much is consumed - by workers, horses, etc. |
int |
getProductionOf(int goodsType)
Returns the production of the given type of goods. |
Unit |
getRandomUnit()
Returns a random unit from this colony. |
int |
getSoL()
Returns the current SoL membership of the colony. |
int |
getTory()
Returns the Tory membership of the colony. |
int |
getUnitCount()
Gets the amount of Units at this Location. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets a Iterator of every Unit directly
located on this Location. |
java.util.List<Unit> |
getUnitList()
Returns a list containing all the Units present at this Location. |
ColonyTile |
getVacantColonyTileFor(Unit unit,
int goodsType)
Returns a vacant ColonyTile where the given
unit produces the maximum output of the given
goodsType. |
int |
getVacantColonyTileProductionFor(Unit unit,
int goodsType)
Returns the production of a vacant ColonyTile where the
given unit produces the maximum output of the given
goodsType. |
WorkLocation |
getVacantWorkLocationFor(Unit locatable)
Gets a vacant WorkLocation for the given Unit. |
int |
getWarehouseCapacity()
Returns the capacity of this colony's warehouse. |
java.util.Iterator<WorkLocation> |
getWorkLocationIterator()
Gets an Iterator of every location in this
Colony where a Unit can work. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
isLandLocked()
Returns whether this colony is landlocked, or has access to the ocean. |
boolean |
isUndead()
Returns whether this colony has undead units. |
void |
newTurn()
Prepares this Colony for a new turn. |
void |
payForBuilding()
Buys the remaining hammers and tools for the Building that is
currently being built. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
remove(Locatable locatable)
Removes a Locatable from this Location. |
void |
removeGoods(Goods goods)
|
void |
removeGoods(int type,
int amount)
Removes a specified amount of a type of Goods from this containter. |
void |
setCurrentlyBuilding(int type)
Sets the type of building to be built. |
void |
setExportLevel(int[] newExportLevel)
Set the ExportLevel value. |
void |
setExports(Goods goods,
boolean value)
Sets whether the custom house should export these goods. |
void |
setExports(int type,
boolean value)
Sets whether the custom house should export these goods. |
void |
setHighLevel(int[] newHighLevel)
Set the HighLevel value. |
void |
setLowLevel(int[] newLowLevel)
Set the LowLevel value. |
void |
setName(java.lang.String newName)
Sets the name of this Colony. |
void |
setOwner(Player owner)
Sets the owner of this Colony, including all units
within, and change main tile nation ownership. |
void |
setUnitCount(int unitCount)
Sets the number of units inside the colony, used in enemy colonies |
void |
stopBuilding()
Sets the type of building to None, so no building is done. |
java.lang.String |
toString()
Gets a string representation of the Colony. |
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. |
void |
updatePopulation()
Updates SoL and builds stockade if possible. |
| Methods inherited from class net.sf.freecol.common.model.Settlement |
|---|
getGoodsContainer, getLineOfSight, getOwner, getRadius, getTile, getTile |
| 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, 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 |
|---|
getGoodsContainer, getID, getTile |
| 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 BUILDING_UNIT_ADDITION
| Constructor Detail |
|---|
public Colony(Game game,
Player owner,
java.lang.String name,
Tile tile)
Colony.
game - The Game in which this object belongs.owner - The Player owning this Colony.name - The name of the new Colony.tile - The location of the Colony.
public Colony(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
Colony from an XML representation.
game - The Game this object belongs to.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if an error occured during parsing.
public Colony(Game game,
org.w3c.dom.Element e)
Colony from an XML representation.
game - The Game this object belongs to.e - An XML-element that will be used to initialize this object.
public Colony(Game game,
java.lang.String id)
Colony 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 void updatePopulation()
public int[] getHighLevel()
HighLevel value.
int[] valuepublic void setHighLevel(int[] newHighLevel)
HighLevel value.
newHighLevel - The new HighLevel value.public int[] getLowLevel()
LowLevel value.
int[] valuepublic void setLowLevel(int[] newLowLevel)
LowLevel value.
newLowLevel - The new LowLevel value.public int[] getExportLevel()
ExportLevel value.
int[] valuepublic void setExportLevel(int[] newExportLevel)
ExportLevel value.
newExportLevel - The new ExportLevel value.public boolean isLandLocked()
true if there are no adjacent tiles to this
Colony's tile being ocean tiles.public boolean isUndead()
public void setOwner(Player owner)
Colony, including all units
within, and change main tile nation ownership.
setOwner in interface OwnablesetOwner in class Settlementowner - The Player that shall own this
Settlement.Settlement.getOwner()public void setUnitCount(int unitCount)
unitCount - The units inside the colonygetUnitCount()public void damageAllShips()
Colony's
Tile. That is: they are sent to the closest location for
repair.
Unit.shipDamaged()public Building getBuildingForProducing(int goodsType)
goodsType - The type of goods.
Building which produces the given type of
goods, or null if such a building cannot be found.public Building getBuildingForConsuming(int goodsType)
goodsType - The goods type.
goodsType, or
null if not exists or not fully built.Goodspublic java.util.Iterator<WorkLocation> getWorkLocationIterator()
Iterator of every location in this
Colony where a Unit can work.
Iterator.WorkLocationpublic java.util.Iterator<Building> getBuildingIterator()
Iterator of every Building in this
Colony.
Iterator.Buildingpublic java.util.Iterator<ColonyTile> getColonyTileIterator()
Iterator of every ColonyTile in this
Colony.
Iterator.ColonyTilepublic Building getBuilding(int type)
Building of the specified type.
type - The type of building to get.
Building.
public ColonyTile getColonyTile(int x,
int y)
ColonyTile.
x - The x-coordinate of the Tile.y - The y-coordinate of the Tile.
ColonyTile for the Tile
returned by Settlement.getTile(int, int).public ColonyTile getColonyTile(Tile t)
ColonyTile matching the given
Tile.
t - The Tile to get the ColonyTile
for.
ColonyTilepublic WorkLocation getVacantWorkLocationFor(Unit locatable)
WorkLocation for the given Unit.
locatable - The Unit
WorkLocation for the given
Unit or null if there is no such
location.public void add(Locatable locatable)
Locatable to this Location.
add in interface Locationadd in class Settlementlocatable - The Locatable to add to this Location.public void remove(Locatable locatable)
Locatable from this Location.
remove in interface Locationremove in class Settlementlocatable - The Locatable to remove from this
Location.public int getUnitCount()
WorkLocation in this Colony.
getUnitCount in interface LocationgetUnitCount in class Settlementpublic int getFoodConsumption()
public int getGoodsCount(int type)
type - The type of goods to look for.
public void removeGoods(int type,
int amount)
type - The type of Goods to remove from this container.amount - The amount of Goods to remove from this container.public void removeGoods(Goods goods)
public void addGoods(int type,
int amount)
public java.util.List<Unit> getUnitList()
Location
getUnitList in interface Locationpublic java.util.Iterator<Unit> getUnitIterator()
LocationIterator of every Unit directly
located on this Location.
getUnitIterator in interface LocationIterator.public java.util.Iterator<Goods> getGoodsIterator()
public java.util.Iterator<Goods> getCompactGoodsIterator()
Iterator of every Goods in this
Colony. There is only one Goods for each
type of goods.
Iterator.public boolean getExports(int type)
type - The type of goods.
public boolean getExports(Goods goods)
goods - The goods.
public void setExports(int type,
boolean value)
type - the type of goods.value - a boolean value
public void setExports(Goods goods,
boolean value)
goods - the goods.value - a boolean valuepublic boolean contains(Locatable locatable)
LocationLocation contains the specified
Locatable.
contains in interface Locationcontains in class Settlementlocatable - The Locatable to test the presence of.
Locatable is
on this Location and
public boolean canAdd(Locatable locatable)
LocationLocation.
canAdd in interface LocationcanAdd in class Settlementlocatable - The Locatable to add.
public Unit getDefendingUnit(Unit attacker)
Unit that is currently defending this
Colony.
Note! Several callers fail to handle null as a return value. Return an arbitrary unarmed land unit unless Paul Revere is present as founding father, in which case the unit can be armed as well. Also note that the colony would typically be defended by a unit outside it.
getDefendingUnit in class Settlementattacker - The target that would be attacking this colony.
Unit that has been choosen to defend this
colony.Tile.getDefendingUnit(Unit)public void addHammers(int amount)
amount - The number of hammers to add.public java.util.Iterator<java.lang.Integer> getBuildableUnitIterator()
Iterator of every unit type this colony may
build.
Iterator on Integer -objects
where the values are the unit type values.public boolean canBuildUnit(int unitType)
unitType - The unit type to test against.
public int getHammers()
public int getCurrentlyBuilding()
public void setCurrentlyBuilding(int type)
type - The type of building to be built.public void stopBuilding()
public void addBells(int amount)
amount - The number of bells to add.public void addSoL(int amount)
amount - The percentage of SoL to add.public int getBells()
public int getSoL()
public int getMembers()
public int getTory()
public int getProductionBonus()
public java.lang.String toString()
Colony, but that may change
later.
toString in class FreeColGameObjectgetName()public java.lang.String getName()
Colony.
getName in interface NameableString.public void setName(java.lang.String newName)
Colony.
setName in interface NameablenewName - The new name of this Colony.public java.lang.String getLocationName()
getLocationName in interface Locationpublic int getFoodProduction()
getProductionOf(Goods.FOOD).public int getProductionOf(int goodsType)
goodsType - The type of goods to get the production for.
Colony's buildings and
tiles.
public ColonyTile getVacantColonyTileFor(Unit unit,
int goodsType)
ColonyTile where the given
unit produces the maximum output of the given
goodsType.
unit - The Unit to find a vacant
ColonyTile for.goodsType - The type of goods that should be produced.
ColonyTile giving the highest production of
the given goods for the given unit or null if
there is no available ColonyTile for producing
that goods.
public int getVacantColonyTileProductionFor(Unit unit,
int goodsType)
ColonyTile where the
given unit produces the maximum output of the given
goodsType.
unit - The Unit to find the highest possible
ColonyTile-production for.goodsType - The type of goods that should be produced.
ColonyTile for the given goods and the given unit.public int getPotentialHorseProduction()
public int getHorseProduction()
Colony.
Colony.public int getProductionNetOf(int goodsType)
goodsType - The goods' type.
public int getPriceForBuilding()
Building that is currently being built.
payForBuilding()public void payForBuilding()
Building that is
currently being built.
java.lang.IllegalStateException - If the owner of this Colony
has an insufficient amount of gold.getPriceForBuilding()
public void bombard(Unit defender,
int result)
defender - The Unit defending against bombardment.result - The result of the bombardment.public Unit getRandomUnit()
Colony. This
Unit will either be working in a Building
or a ColonyTile.public void newTurn()
Colony for a new turn.
newTurn in class Settlementpublic int getWarehouseCapacity()
Goods.FOOD, will be removed when calling
newTurn().
Colony's warehouse.public void dispose()
Colony. All WorkLocations
owned by this Colony will also be destroyed.
dispose in class Settlement
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 | ||||||||