|
|||||||||
| 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.GoodsLocation
net.sf.freecol.common.model.Settlement
net.sf.freecol.common.model.Colony
public class Colony
Represents a colony. A colony contains Buildings and
ColonyTiles. The latter represents the tiles around the
Colony where working is possible.
| Nested Class Summary | |
|---|---|
static class |
Colony.ColonyChangeEvent
|
static class |
Colony.NoBuildReason
|
private class |
Colony.Occupation
|
| Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
UnitLocation.NoAddReason |
| Field Summary | |
|---|---|
static java.lang.String |
BUILD_QUEUE_TAG
|
protected java.util.Map<java.lang.String,Building> |
buildingMap
A map of Buildings, indexed by the Id of their basic type. |
protected BuildQueue<BuildableType> |
buildQueue
A list of Buildable items. |
protected java.util.List<ColonyTile> |
colonyTiles
A list of ColonyTiles. |
protected Turn |
established
The turn in which this colony was established. |
protected java.util.Map<java.lang.String,ExportData> |
exportData
A map of ExportData, indexed by the Ids of GoodsTypes. |
static Ability |
HAS_PORT
|
protected int |
immigration
The number of immigration points. |
protected boolean |
landLocked
|
protected int |
liberty
The number of liberty points. |
static int |
LIBERTY_PER_REBEL
|
private static java.util.logging.Logger |
logger
|
protected int |
oldSonsOfLiberty
The SoL membership last turn. |
protected int |
oldTories
The number of tories last turn. |
static java.lang.String |
POPULATION_QUEUE_TAG
|
protected BuildQueue<UnitType> |
populationQueue
The colonists that may be born. |
protected int |
productionBonus
The current production bonus. |
private ProductionCache |
productionCache
Contains information about production and consumption. |
static java.lang.String |
REARRANGE_WORKERS
|
static FreeColGameObjectType |
SOL_MODIFIER_SOURCE
|
protected int |
sonsOfLiberty
The SoL membership this turn. |
protected java.lang.String |
stockadeKey
|
protected int |
tories
The number of tories this turn. |
protected int |
unitCount
|
| Fields inherited from class net.sf.freecol.common.model.Settlement |
|---|
FOOD_PER_COLONIST, owner, tile |
| 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 |
| Constructor Summary | |
|---|---|
protected |
Colony()
|
|
Colony(Game game,
org.w3c.dom.Element e)
Initiates a new Colony from an XML representation. |
protected |
Colony(Game game,
Player owner,
java.lang.String name,
Tile tile)
Constructor for ServerColony. |
|
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 | |
|---|---|
boolean |
add(Locatable locatable)
Adds a Locatable to this Location. |
void |
addBuilding(Building building)
Add a Building to this Colony. |
boolean |
addGoods(AbstractGoods goods)
Add goods to this colony; |
boolean |
addGoods(GoodsType type,
int amount)
Add goods to this colony. |
private void |
addInsufficientProductionMessage(java.util.List<StringTemplate> warnings,
ProductionInfo info)
adds a message about insufficient production for a building |
void |
addLiberty(int amount)
Adds to the liberty points of the colony. |
boolean |
addUnit(Unit unit,
WorkLocation loc)
Adds a Unit to an optional
WorkLocation in this Colony. |
int |
calculateMembership(int units)
Returns the SoL membership of the colony based on the liberty value and the number of colonists given. |
boolean |
canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to this Location. |
boolean |
canBePillaged(Unit attacker)
Determines whether this colony is sufficiently unprotected and contains something worth pillaging. |
boolean |
canBePlundered()
Checks if this colony can be plundered. |
boolean |
canBombardEnemyShip()
Verify if colony has the ability to bombard an enemy ship adjacent to it. |
boolean |
canBreed(GoodsType goodsType)
Returns true if this Colony can breed the given
type of Goods. |
boolean |
canBuild()
Describe canBuild method here. |
boolean |
canBuild(BuildableType buildableType)
Returns true if this Colony can build the given BuildableType. |
boolean |
canPayToFinishBuilding()
Check if the owner can buy the remaining hammers and tools for the Building that is currently being built. |
boolean |
canPayToFinishBuilding(BuildableType buildableType)
Check if the owner can buy the remaining hammers and tools for the Building given. |
boolean |
canReducePopulation()
Returns true if the colony can reduce its population voluntarily. |
boolean |
canTrain(Unit unit)
Returns true if this colony has a schoolhouse and the unit type is a skilled unit type with a skill level not exceeding the level of the schoolhouse. |
boolean |
canTrain(UnitType unitType)
Returns true if this colony has a schoolhouse and the unit type is a skilled unit type with a skill level not exceeding the level of the schoolhouse. |
void |
changeOwner(Player owner)
Sets the owner of this Colony, including all units
within, and change main tile nation ownership. |
ModelMessage |
checkForGovMgtChangeMessage()
|
boolean |
contains(Locatable locatable)
Checks if this Location contains the specified
Locatable. |
void |
dispose()
Disposes this Colony. |
java.util.List<FreeColGameObject> |
disposeList()
Dispose of this colony. |
Unit |
findStudent(Unit teacher)
Find a student for the specified teacher. |
Unit |
findTeacher(Unit student)
Find a teacher for the specified student. |
int |
getAdjustedNetProductionOf(GoodsType goodsType)
Returns the net production of the given GoodsType adjusted by the possible consumption of BuildQueues. |
Unit |
getBetterExpert(Unit expert)
Finds another unit in this colony that would be better at doing the job of the specified unit. |
java.util.List<UnitType> |
getBuildableUnits()
Returns a List with every unit type this colony may
build. |
Building |
getBuilding(BuildingType type)
Gets a Building of the specified type. |
Building |
getBuildingFor(Unit unit)
Return the Building best suited for the given Unit. |
Building |
getBuildingForConsuming(GoodsType goodsType)
Find a building for consuming the given type of goods. |
Building |
getBuildingForProducing(GoodsType goodsType)
Find a building for producing the given type of goods. |
java.util.List<Building> |
getBuildings()
Gets a List of every Building in this
Colony. |
java.util.List<Building> |
getBuildingsForConsuming(GoodsType goodsType)
Collect the buildings for consuming the given type of goods. |
java.util.List<Building> |
getBuildingsForProducing(GoodsType goodsType)
Collect the buildings for producing the given type of goods. |
Building |
getBuildingWithAbility(java.lang.String ability)
Returns a Building with the given
Ability, or null, if none exists. |
java.util.List<BuildableType> |
getBuildQueue()
Get the BuildQueue value. |
java.util.List<Building> |
getBurnableBuildingList()
Gets the buildings in this colony that could be burned by a raid. |
Colony |
getColony()
Returns just this Colony itself. |
ColonyTile |
getColonyTile(Tile t)
Returns the ColonyTile matching the given
Tile. |
java.util.List<ColonyTile> |
getColonyTiles()
Gets a List of every ColonyTile in this
Colony. |
void |
getColonyTileTodo(java.util.List<Tile> exploreTiles,
java.util.List<Tile> clearTiles,
java.util.List<Tile> plowTiles,
java.util.List<Tile> roadTiles)
Collects tiles that need exploring, plowing or road building which may depend on current use within the colony. |
java.util.List<Consumer> |
getConsumers()
Returns a list of all Consumers in the colony sorted by
priority. |
int |
getConsumptionOf(GoodsType goodsType)
Returns the number of goods of a given type used by the settlement each turn. |
BuildableType |
getCurrentlyBuilding()
Returns the type of building currently being built. |
Unit |
getDefendingUnit(Unit attacker)
Gets the Unit that is currently defending this
Colony. |
Turn |
getEstablished()
Get the Established value. |
int |
getExportAmount(GoodsType goodsType)
How much of a goods type can be exported from this colony? |
ExportData |
getExportData(GoodsType goodsType)
Describe getExportData method here. |
int |
getFoodProduction()
Gets the combined production of all food types. |
int |
getGoodsCapacity()
Returns the capacity of this colony's warehouse. |
java.util.HashMap<GoodsType,java.lang.Integer> |
getGoodsForBuilding(BuildableType type)
Gets a map of the types of goods and amount thereof required to finish a buildable in this colony. |
java.lang.String |
getImageKey()
Gets the image key for this colony. |
int |
getImmigration()
Return the number of immigration points. |
int |
getImportAmount(GoodsType goodsType)
How much of a goods type can be imported into this colony? |
int |
getLiberty()
Describe getLiberty method here. |
StringTemplate |
getLocationName()
Returns the name of this location. |
StringTemplate |
getLocationNameFor(Player player)
Returns a suitable name for this colony for a particular player. |
java.util.List<Goods> |
getLootableGoodsList()
Gets a list of all stored goods in this colony, suitable for being looted. |
int |
getMembers()
Return the number of sons of liberty |
java.util.Set<Modifier> |
getModifierSet(java.lang.String id)
Get the Modifier value. |
java.lang.String |
getNameFor(Player player)
Gets the name of this Settlement for a particular player. |
int |
getNetProductionOf(GoodsType goodsType)
Returns the net production of the given GoodsType. |
Colony.NoBuildReason |
getNoBuildReason(BuildableType buildableType)
Return the reason why the give BuildableType can
not be built. |
private Colony.Occupation |
getOccupationFor(Unit unit)
Returns an Occupation for the given Unit. |
RandomRange |
getPlunderRange(Unit attacker)
Gets the plunder range for this colony. |
int |
getPriceForBuilding()
Returns the price for the remaining hammers and tools for the Building that is currently being built. |
int |
getPriceForBuilding(BuildableType type)
Gets the price for the remaining resources to build a given buildable. |
int |
getProductionBonus()
Returns the production bonus, if any, of the colony. |
ProductionInfo |
getProductionInfo(java.lang.Object object)
Returns the ProductionInfo for the given Object. |
protected TypeCountMap<GoodsType> |
getProductionMap()
Gets a copy of the current production map. |
Modifier |
getProductionModifier(GoodsType goodsType)
Returns the current production Modifier, which is
generated from the current production bonus. |
int |
getProductionOf(GoodsType goodsType)
Returns the production of the given type of goods. |
java.util.List<Unit> |
getShipList()
Gets a list of all ships in this colony (although they are really located on the colony tile). |
int |
getSoL()
Returns the current SoL membership of the colony. |
Building |
getStockade()
Returns the stockade building |
java.lang.String |
getStockadeKey()
Gets the stockade key. |
java.util.List<Unit> |
getTeachers()
Returns a list of all teachers currently present in the school building. |
int |
getTory()
Returns the Tory membership of the colony. |
java.lang.String |
getTrueStockadeKey()
Gets the true stockade key, as should be visible to the owner or a player that can see this colony. |
int |
getTurnsToComplete(BuildableType buildable)
Returns how many turns it would take to build the given BuildableType. |
int |
getTurnsToComplete(BuildableType buildable,
AbstractGoods needed)
Returns how many turns it would take to build the given BuildableType. |
int |
getUnitCount()
Gets the number of units at this colony. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets a Iterator of every Unit directly
located on this Location. |
java.util.List<Unit> |
getUnitList()
Gets a list of all units in working in this colony. |
ColonyTile |
getVacantColonyTileFor(Unit unit,
boolean allowClaim,
GoodsType... goodsTypes)
Returns a vacant ColonyTile where the given
unit produces the maximum output of the given
goodsType. |
WorkLocation |
getVacantWorkLocationFor(Unit unit)
Gets a vacant WorkLocation for the given Unit. |
Building |
getWarehouse()
|
java.util.Collection<StringTemplate> |
getWarnings(GoodsType goodsType,
int amount,
int production)
determine if there is a problem with the production of the specified good |
WorkLocation |
getWorkLocationFor(Unit unit)
Gets a work location within this colony to put a unit in. |
java.util.List<WorkLocation> |
getWorkLocations()
Gets a List of every WorkLocation in this
Colony. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
int |
governmentChange(int unitCount)
Returns 1, 0, or -1 to indicate that government would improve, remain the same, or deteriorate if the colony had the given population. |
boolean |
hasAbility(java.lang.String id)
Returns true if the Colony, or its owner has the ability identified by id. |
boolean |
hasAbility(java.lang.String id,
FreeColGameObjectType type)
Returns true if the Colony, or its owner has the ability identified by id. |
boolean |
hasStockade()
Returns true when colony has a stockade |
void |
incrementImmigration(int amount)
Increment immigration points by amount given. |
void |
incrementLiberty(int amount)
Increment liberty points by amount given. |
void |
invalidateCache()
Invalidates the production cache. |
boolean |
isAutomaticBuild(BuildingType buildingType)
Is a building type able to be automatically built at no cost. |
boolean |
isConnected()
Return whether this colony is connected to the HighSeas, or not. |
boolean |
isLandLocked()
Returns whether this colony is landlocked, or has access to water. |
boolean |
isProductive(WorkLocation workLocation)
|
boolean |
isTileInUse(Tile tile)
Is a tile actually in use by this colony? |
boolean |
isUndead()
Returns whether this colony has undead units. |
boolean |
isUnderSiege()
Returns true if the number of enemy combat units
on all tiles that belong to the colony exceeds the number of
friendly combat units. |
protected void |
modifySpecialGoods(GoodsType goodsType,
int amount)
|
int |
priceGoodsForBuilding(java.util.HashMap<GoodsType,java.lang.Integer> required)
Gets a price for a map of resources to build a given buildable. |
boolean |
propagateAlarm(Player player,
int addToAlarm)
Propagates a global change in tension down to a settlement. |
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 a Locatable from this Location. |
boolean |
removeBuilding(Building building)
Remove a building from this Colony. |
Goods |
removeGoods(AbstractGoods goods)
Removes the given Goods from the Settlement. |
Goods |
removeGoods(GoodsType type)
Removes all Goods of the given type from the Settlement. |
Goods |
removeGoods(GoodsType type,
int amount)
Removes a specified amount of a type of Goods from this Settlement. |
boolean |
removeUnit(Unit unit)
Removes a Unit from this Colony. |
void |
setBuildQueue(java.util.List<BuildableType> newBuildQueue)
Set the BuildQueue value. |
void |
setCurrentlyBuilding(BuildableType buildable)
Sets the current type of buildable to be built and if it is a building insist that there is only one in the queue. |
void |
setEstablished(Turn newEstablished)
Set the Established value. |
void |
setExportData(ExportData newExportData)
Describe setExportData method here. |
void |
setUnitCount(int unitCount)
Sets the number of units inside the colony, used in enemy colonies |
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. |
protected void |
toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
java.lang.String[] fields)
Partial writer, so that "remove" messages can be brief. |
void |
updatePopulation(int difference)
Updates SoL and builds Buildings that are free if possible. |
protected void |
updateProductionBonus()
Update the colony's production bonus. |
void |
updateSoL()
Calculates the current SoL membership of the colony based on the liberty value and colonists. |
| Methods inherited from class net.sf.freecol.common.model.Settlement |
|---|
canBuildEquipment, getConsumptionOf, getFeatureContainer, getFoodConsumption, getLineOfSight, getName, getNameKey, getOwnedTiles, getOwner, getPlunder, getRadius, getSettlement, getTile, getType, isCapital, placeSettlement, readAttributes, setCapital, setFeatureContainer, setName, setOwner, setType, writeAttributes |
| Methods inherited from class net.sf.freecol.common.model.GoodsLocation |
|---|
getCompactGoods, getGoodsContainer, getGoodsCount, getGoodsIterator, getNoAddReason, getWarehouseCapacity, readChild, setGoodsContainer, writeChildren |
| Methods inherited from class net.sf.freecol.common.model.UnitLocation |
|---|
getSpaceTaken, getUnitCapacity, isEmpty, isFull, readChildren, 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.Nameable |
|---|
getName, setName |
| 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 BUILD_QUEUE_TAG
public static final java.lang.String POPULATION_QUEUE_TAG
public static final java.lang.String REARRANGE_WORKERS
public static final int LIBERTY_PER_REBEL
public static final Ability HAS_PORT
public static final FreeColGameObjectType SOL_MODIFIER_SOURCE
protected final java.util.List<ColonyTile> colonyTiles
protected final java.util.Map<java.lang.String,Building> buildingMap
protected final java.util.Map<java.lang.String,ExportData> exportData
protected int sonsOfLiberty
protected int oldSonsOfLiberty
protected int tories
protected int oldTories
protected int productionBonus
protected int immigration
protected int liberty
protected boolean landLocked
protected int unitCount
protected java.lang.String stockadeKey
protected Turn established
protected BuildQueue<BuildableType> buildQueue
protected BuildQueue<UnitType> populationQueue
private ProductionCache productionCache
| Constructor Detail |
|---|
protected Colony()
protected Colony(Game game,
Player owner,
java.lang.String name,
Tile tile)
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 occurred 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
FreeColObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public java.lang.String getNameFor(Player player)
Settlement for a particular player.
getNameFor in class Settlementplayer - A Player to return the name for.
String.public java.lang.String getImageKey()
getImageKey in class Settlementpublic boolean isAutomaticBuild(BuildingType buildingType)
buildingType - a BuildingType value
public void addBuilding(Building building)
building - a Building valuepublic boolean removeBuilding(Building building)
building - The Building to remove.
public boolean canReducePopulation()
boolean valuepublic void updatePopulation(int difference)
difference - an int valuepublic ExportData getExportData(GoodsType goodsType)
getExportData method here.
goodsType - a GoodsType value
ExportData valuepublic final void setExportData(ExportData newExportData)
setExportData method here.
newExportData - an ExportData valuepublic int getExportAmount(GoodsType goodsType)
goodsType - The GoodsType to export.
public int getImportAmount(GoodsType goodsType)
goodsType - The GoodsType to import.
public boolean isLandLocked()
true if there are no adjacent tiles to this
Colony's tile being water tiles.public boolean isConnected()
isConnected in class Settlementboolean valuepublic boolean isUndead()
public void changeOwner(Player owner)
Colony, including all units
within, and change main tile nation ownership.
changeOwner in class Settlementowner - The Player that shall own this
Settlement.Settlement.getOwner()public void setUnitCount(int unitCount)
unitCount - The units inside the colonygetUnitCount()public java.util.List<Building> getBuildingsForProducing(GoodsType goodsType)
goodsType - The type of goods.
List of Buildings which produce
the given type of goods.public java.util.List<Building> getBuildingsForConsuming(GoodsType goodsType)
goodsType - The type of goods.
List of Buildings which consume
the given type of goods.Goodspublic Building getBuildingForProducing(GoodsType goodsType)
goodsType - The type of goods.
Building which produces the given type of goods,
or null if such a building can not be found.public Building getBuildingForConsuming(GoodsType goodsType)
goodsType - The type of goods.
Building which consumes the given type of goods,
or null if such a building can not be found.public java.util.List<WorkLocation> getWorkLocations()
List of every WorkLocation in this
Colony.
List.WorkLocationpublic java.util.List<Building> getBuildings()
List of every Building in this
Colony.
List.Buildingpublic java.util.List<ColonyTile> getColonyTiles()
List of every ColonyTile in this
Colony.
List.ColonyTilepublic boolean isTileInUse(Tile tile)
tile - The Tile to test.
public Building getBuilding(BuildingType type)
Building of the specified type.
type - The type of the building to get.
Building.public Building getBuildingWithAbility(java.lang.String ability)
Building with the given
Ability, or null, if none exists.
ability - a String value
Building valuepublic ColonyTile getColonyTile(Tile t)
ColonyTile matching the given
Tile.
t - The Tile to get the ColonyTile
for.
ColonyTilepublic void incrementLiberty(int amount)
amount - an int valuepublic void incrementImmigration(int amount)
amount - an int valuepublic Turn getEstablished()
Established value.
Turn valuepublic void setEstablished(Turn newEstablished)
Established value.
newEstablished - The new Established value.public boolean add(Locatable locatable)
Locatable to this Location.
add in interface Locationadd in class GoodsLocationlocatable - The Locatable to add to this Location.public boolean remove(Locatable locatable)
Locatable from this Location.
remove in interface Locationremove in class GoodsLocationlocatable - The Locatable to remove from this Location.
public WorkLocation getWorkLocationFor(Unit unit)
unit - The Unit to place.
public boolean addUnit(Unit unit,
WorkLocation loc)
Unit to an optional
WorkLocation in this Colony.
unit - The Unit to add.loc - The WorkLocation to add to (if null,
one is chosen.
public boolean removeUnit(Unit unit)
Unit from this Colony.
unit - The Unit to remove.
public boolean addGoods(AbstractGoods goods)
addGoods in class GoodsLocationgoods - an AbstractGoods value
public boolean addGoods(GoodsType type,
int amount)
addGoods in class GoodsLocationtype - a GoodsType valueamount - an int value
public Goods removeGoods(GoodsType type,
int amount)
removeGoods in class GoodsLocationtype - The type of Goods to remove from this settlement.amount - The amount of Goods to remove from this settlement.public Goods removeGoods(AbstractGoods goods)
removeGoods in class GoodsLocationgoods - a Goods valuepublic Goods removeGoods(GoodsType type)
removeGoods in class GoodsLocationtype - a GoodsType value
protected void modifySpecialGoods(GoodsType goodsType,
int amount)
public int getUnitCount()
WorkLocations.
getUnitCount in interface LocationgetUnitCount in class UnitLocationUnits in this colony.public java.util.List<Unit> getUnitList()
getUnitList in interface LocationgetUnitList in class UnitLocationUnits in this colony.public java.util.Iterator<Unit> getUnitIterator()
UnitLocationIterator of every Unit directly
located on this Location.
getUnitIterator in interface LocationgetUnitIterator in class UnitLocationIterator.public boolean contains(Locatable locatable)
GoodsLocationLocation contains the specified
Locatable.
contains in interface Locationcontains in class GoodsLocationlocatable - The Locatable to test the presence of.
Locatable is
on this Location and
public boolean canAdd(Locatable locatable)
UnitLocationLocation.
canAdd in interface LocationcanAdd in class UnitLocationlocatable - The Locatable to add.
public boolean canTrain(Unit unit)
unit - The unit to add as a teacher.
true if this unit type could be added.public boolean canTrain(UnitType unitType)
unitType - The unit type to add as a teacher.
true if this unit type could be added.public java.util.List<Unit> getTeachers()
public Unit findTeacher(Unit student)
student - The student Unit that needs a teacher.
public Unit findStudent(Unit teacher)
teacher - The teacher Unit that needs a student.
public Unit getDefendingUnit(Unit attacker)
Unit that is currently defending this
Colony.
Note that this function will only return a unit working inside the colony. Typically, colonies are also defended by units outside the colony on the same tile. To consider units outside the colony as well, use (@see Tile#getDefendingUnit) instead.
Returns an arbitrary unarmed land unit unless Paul Revere is present as founding father, in which case the unit can be armed as well.
getDefendingUnit in class Settlementattacker - The unit that would be attacking this colony.
Unit that has been chosen to defend this
colony, or null if the colony belongs to another
player and client is not permitted to view contents.
java.lang.IllegalStateException - if there are units in the colonyTile.getDefendingUnit(Unit)public boolean canBePillaged(Unit attacker)
attacker - The Unit that has defeated the defender.
public boolean canBePlundered()
public boolean isUnderSiege()
true if the number of enemy combat units
on all tiles that belong to the colony exceeds the number of
friendly combat units. At the moment, only the colony owner's
own units are considered friendly, but that could be extended
to include the units of allied players.
TODO: if a colony is under siege, it should not be possible to
put units outside the colony, unless those units are armed.
boolean valuepublic java.util.List<Building> getBurnableBuildingList()
public java.util.List<Unit> getShipList()
public java.util.List<Goods> getLootableGoodsList()
public RandomRange getPlunderRange(Unit attacker)
getPlunderRange in class Settlementattacker - An attacking Unit.
public java.util.List<UnitType> getBuildableUnits()
List with every unit type this colony may
build.
List with UnitTypepublic BuildableType getCurrentlyBuilding()
public void setCurrentlyBuilding(BuildableType buildable)
buildable - The BuildableType to build.public int getTurnsToComplete(BuildableType buildable)
BuildableType.
buildable - The BuildableType to build.
public int getTurnsToComplete(BuildableType buildable,
AbstractGoods needed)
BuildableType.
buildable - The BuildableType to build.needed - The AbstractGoods needed to continue
the build.
public java.util.List<BuildableType> getBuildQueue()
BuildQueue value.
List valuepublic void setBuildQueue(java.util.List<BuildableType> newBuildQueue)
BuildQueue value.
newBuildQueue - The new BuildQueue value.public int getLiberty()
getLiberty method here.
int valuepublic void addLiberty(int amount)
amount - The number of liberty to add.public int getImmigration()
int valuepublic int getConsumptionOf(GoodsType goodsType)
getConsumptionOf in class SettlementgoodsType - GoodsType values
int valuepublic int getSoL()
getSoL in class Settlementpublic void updateSoL()
public int calculateMembership(int units)
units - an int value
int valuepublic int getMembers()
public int getTory()
public int getProductionBonus()
public Modifier getProductionModifier(GoodsType goodsType)
Modifier, which is
generated from the current production bonus.
goodsType - a GoodsType value
Modifier valuepublic java.lang.String toString()
Colony, but that may change
later.
toString in class FreeColGameObjectSettlement.getName()public StringTemplate getLocationName()
getLocationName in interface LocationgetLocationName in class UnitLocationpublic StringTemplate getLocationNameFor(Player player)
getLocationNameFor in interface LocationgetLocationNameFor in class UnitLocationplayer - The Player to prepare the name for.
public int getFoodProduction()
int valuepublic int getProductionOf(GoodsType goodsType)
getProductionOf in class SettlementgoodsType - The type of goods to get the production for.
Colony's buildings and
tiles.public WorkLocation getVacantWorkLocationFor(Unit unit)
WorkLocation for the given Unit.
unit - The Unit
WorkLocation for the given
Unit or null if there is no such
location.private Colony.Occupation getOccupationFor(Unit unit)
Occupation for the given Unit.
unit - The Unit
Occupation for the given
Unit or null if there is none.public Building getBuildingFor(Unit unit)
unit - an Unit value
Building value
public ColonyTile getVacantColonyTileFor(Unit unit,
boolean allowClaim,
GoodsType... goodsTypes)
ColonyTile where the given
unit produces the maximum output of the given
goodsType.
unit - The Unit to find a vacant
ColonyTile for.allowClaim - Allow claiming free tiles from other settlements.goodsTypes - The types 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 boolean canBreed(GoodsType goodsType)
true if this Colony can breed the given
type of Goods. Only animals (such as horses) are expected to be
breedable.
goodsType - a GoodsType value
boolean valuepublic boolean canBuild()
canBuild method here.
boolean valuepublic boolean canBuild(BuildableType buildableType)
buildableType - a BuildableType value
boolean valuepublic Colony.NoBuildReason getNoBuildReason(BuildableType buildableType)
BuildableType can
not be built.
buildableType - a BuildableType value
NoBuildReason valuepublic int getPriceForBuilding()
Building that is currently being built.
InGameController.payForBuilding(net.sf.freecol.common.model.Colony)public int getPriceForBuilding(BuildableType type)
type - The BuildableType to build.
InGameController.payForBuilding(net.sf.freecol.common.model.Colony)public int priceGoodsForBuilding(java.util.HashMap<GoodsType,java.lang.Integer> required)
required - The map of resources required.
InGameController.payForBuilding(net.sf.freecol.common.model.Colony)public java.util.HashMap<GoodsType,java.lang.Integer> getGoodsForBuilding(BuildableType type)
type - The BuildableType to build.
public boolean canPayToFinishBuilding()
Building that is currently being built.
java.lang.IllegalStateException - If the owner of this Colony
has an insufficient amount of gold.getPriceForBuilding()public boolean canPayToFinishBuilding(BuildableType buildableType)
Building given.
buildableType - a BuildableType value
boolean value
java.lang.IllegalStateException - If the owner of this Colony
has an insufficient amount of gold.getPriceForBuilding()
public java.util.Collection<StringTemplate> getWarnings(GoodsType goodsType,
int amount,
int production)
goodsType - for this goodamount - warehouse amountproduction - production per turn
private void addInsufficientProductionMessage(java.util.List<StringTemplate> warnings,
ProductionInfo info)
warnings - where to add the warningsinfo - the ProductionInfo for this buildingpublic int governmentChange(int unitCount)
unitCount - The proposed population for the colony.
public ModelMessage checkForGovMgtChangeMessage()
protected void updateProductionBonus()
public boolean propagateAlarm(Player player,
int addToAlarm)
propagateAlarm in class Settlementplayer - The Player towards whom the alarm is felt.addToAlarm - The amount to add to the current alarm level.
public int getGoodsCapacity()
getGoodsCapacity in class GoodsLocationColony's warehouse.public Building getWarehouse()
public Colony getColony()
getColony in interface LocationgetColony in class UnitLocationpublic boolean hasStockade()
public Building getStockade()
Buildingpublic java.lang.String getStockadeKey()
public java.lang.String getTrueStockadeKey()
public final java.util.Set<Modifier> getModifierSet(java.lang.String id)
Modifier value.
getModifierSet in class Settlementid - a String value
Modifier valuepublic boolean hasAbility(java.lang.String id)
id.
hasAbility in class FreeColObjectid - a String value
boolean value
public boolean hasAbility(java.lang.String id,
FreeColGameObjectType type)
id.
id - a String valuetype - a FreeColGameObjectType value
boolean valuepublic boolean canBombardEnemyShip()
public java.util.List<FreeColGameObject> disposeList()
disposeList in class Settlementpublic void dispose()
Colony. All WorkLocations
owned by this Colony will also be destroyed.
dispose in class GoodsLocationpublic int getNetProductionOf(GoodsType goodsType)
goodsType - a GoodsType value
int valuepublic boolean isProductive(WorkLocation workLocation)
public int getAdjustedNetProductionOf(GoodsType goodsType)
goodsType - a GoodsType value
int valuepublic ProductionInfo getProductionInfo(java.lang.Object object)
object - an Object value
ProductionInfo valuepublic void invalidateCache()
protected TypeCountMap<GoodsType> getProductionMap()
public java.util.List<Consumer> getConsumers()
Consumers in the colony sorted by
priority. Consumers include all object that consume goods,
e.g. Units, Buildings and BuildQueues.
public void getColonyTileTodo(java.util.List<Tile> exploreTiles,
java.util.List<Tile> clearTiles,
java.util.List<Tile> plowTiles,
java.util.List<Tile> roadTiles)
exploreTiles - A list of Tiles to update with tiles
to explore.clearTiles - A list of Tiles to update with tiles
to clear.plowTiles - A list of Tiles to update with tiles
to plow.roadTiles - A list of Tiles to update with tiles
to build roads on.public Unit getBetterExpert(Unit expert)
expert - The Unit to consider.
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 static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||