Package net.sf.freecol.server.model
Class ServerColony
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Location
,Nameable
,Ownable
,TradeLocation
,ObjectWithId
,TurnTaker
public class ServerColony extends Colony implements TurnTaker
The server version of a colony.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Colony
Colony.ColonyChangeEvent, Colony.NoBuildReason, Colony.TileImprovementSuggestion
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
-
Fields inherited from class net.sf.freecol.common.model.Colony
buildingMap, buildQueue, CHANGE_UPPER_BOUND, colonyTiles, displayUnitCount, established, exportData, FAMINE_TURNS, immigration, liberty, LIBERTY_PER_REBEL, oldSonsOfLiberty, oldTories, populationQueue, productionBonus, REARRANGE_COLONY, sonsOfLiberty, TAG, tories, TRADE_MARGIN
-
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
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
Fields inherited from interface net.sf.freecol.common.model.Location
LOCATION_RANK_EUROPE, LOCATION_RANK_HIGHSEAS, LOCATION_RANK_NOWHERE
-
-
Constructor Summary
Constructors Constructor Description ServerColony(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.ServerColony(Game game, Player owner, java.lang.String name, Tile tile)
Creates a new ServerColony.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
buildBuilding(Building building)
Build a new building in this colony.void
csAddConvert(Unit brave, ChangeSet cs)
Add a new convert to this colony.private boolean
csBuildBuilding(BuildQueue<? extends BuildableType> buildQueue, ChangeSet cs)
Builds a building from a build queue.private Unit
csBuildUnit(BuildQueue<? extends BuildableType> buildQueue, java.util.Random random, ChangeSet cs)
Build a unit from a build queue.void
csChangeOwner(Player newOwner, boolean reassign, java.lang.String change, ChangeSet cs)
Change the owner of this colony.boolean
csEquipForRole(Unit unit, Role role, int roleCount, java.util.Random random, ChangeSet cs)
Equip a unit for a specific role.void
csEvictUsers(Unit enemyUnit, ChangeSet cs)
Evict the users from a tile used by this colony, due to military action from another unit.void
csFreeBuilding(BuildingType type, ChangeSet cs)
Add a free building to this colony.void
csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this colony.void
csNewTurnWarnings(java.util.Random random, LogBuilder lb, ChangeSet cs)
Do the checks for user warnings that must wait for all player settlements, units and whatever to stabilize.private BuildableType
csNextBuildable(BuildQueue<? extends BuildableType> queue, ChangeSet cs)
Removes a buildable from a build queue, and updates the queue so that a valid buildable is now being built if possible.boolean
destroyBuilding(Building building)
Destroy an existing building in this colony.boolean
ejectUnits(WorkLocation workLocation, java.util.List<Unit> units)
Eject units to any available work location.private boolean
neededForBuildableType(GoodsType goodsType)
Is a goods type needed for a buildable that this colony could be building.-
Methods inherited from class net.sf.freecol.common.model.Colony
add, addBuilding, addGoods, addLiberty, addPortAbility, calculateRebels, calculateSettlementValue, canBeInput, canBePillaged, canBePlundered, canBreed, canBuild, canBuild, canPayToFinishBuilding, canPayToFinishBuilding, canProduce, canProvideGoods, canReducePopulation, canTrain, canTrain, checkBuildQueueIntegrity, checkForGovMgtChangeMessage, checkIntegrity, clearBuildingMap, contains, copyColony, copyIn, evaluateFor, findStudent, findTeacher, getAbilities, getAdjustedNetProductionOf, getAlarmLevelLabel, getAllWorkLocations, getAllWorkLocationsList, getApparentUnitCount, getAvailableGoodsCount, getAvailableWorkLocations, getAvailableWorkLocationsList, getBestDefenderType, getBetterExpert, getBuildableUnits, getBuilding, getBuildings, getBuildQueue, getBurnableBuildings, getClassIndex, getColony, getColonyTile, getColonyTiles, getConsumers, getConsumptionOf, getCorresponding, getCurrentlyBuilding, getCurrentWorkLocations, getCurrentWorkLocationsList, getDefenceRatio, getDefendingUnit, getDisasterChoices, getDisplayUnitCount, getDisposables, getEstablished, getExportAmount, getExportData, getExportData, getFoodProduction, getFullRequiredGoods, getGoodsCapacity, getImmigration, getImportAmount, getLiberty, getLocationLabelFor, getLocationName, getLootableGoodsList, getNetProductionOf, getNewColonistTurns, getNoBuildReason, getOccupationTrace, getOldSonsOfLiberty, getOldTories, getPlunderRange, getPopulationQueue, getPreferredSizeChange, getPriceForBuilding, getPriceForBuilding, getProductionBonus, getProductionInfo, getProductionMap, getProductionModifiers, getProductionWarnings, getReducePopulationMessage, getRequiredGoods, getSoL, getSoLPercentage, getSonsOfLiberty, getStarvationTurns, getStockade, getStockadeKey, getTeachers, getTileImprovementSuggestions, getTories, getTory, getTotalDefencePower, getTotalProductionOf, getTurnsToComplete, getTurnsToComplete, getUnbuildableMessage, getUnitCount, getUnitList, getUnits, getUnitsToAdd, getUnitsToRemove, getUpkeep, getWarehouse, getWorkLocationFor, getWorkLocationFor, getWorkLocationForProducing, getWorkLocationsForConsuming, getWorkLocationsForProducing, getWorkLocationWithAbility, getWorkLocationWithAbility, getWorkLocationWithModifier, getWorkLocationWithModifier, getWorkTypeChoices, getXMLTagName, goodsUseful, governmentChange, hasContacted, hasStockade, invalidateCache, isAutomaticBuild, isBadlyDefended, isConsuming, isProducing, isProductive, isTileInUse, isUndead, isUnderSiege, joinColony, modifyImmigration, modifyLiberty, priceGoodsForBuilding, readAttributes, readChild, readChildren, remove, removeBuilding, removeGoods, setBuildingMap, setBuildQueue, setColonyTiles, setCurrentlyBuilding, setDisplayUnitCount, setEstablished, setExportData, setExportData, setOccupationTrace, setPopulationQueue, setProductionBonus, toShortString, toString, up, updateEducation, updatePopulation, updateProductionBonus, updateProductionTypes, updateSoL, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.model.Settlement
addTile, canBombardEnemyShip, canImproveUnitMilitaryRole, changeOwner, disposeResources, equipForRole, exciseSettlement, getAllUnitsList, getConsumptionOf, getFeatureContainer, getFoodConsumption, getHighSeasCount, getLineOfSight, getLinkTarget, getLocationImageKey, getLocationLabel, getName, getNoAddReason, getOwnedTiles, getOwner, getPlunder, getRadius, getRank, getSettlement, getTile, getType, getVisibleTileSet, getWarehouseCapacity, isCapital, isConnectedPort, isLandLocked, placeSettlement, priceGoods, removeTile, setCapital, setName, setOwnedTiles, setOwner, setType
-
Methods inherited from class net.sf.freecol.common.model.GoodsLocation
addGoods, addGoods, containsGoods, getCompactGoodsList, getGoodsContainer, getGoodsCount, getGoodsList, moveGoods, removeAll, removeGoods, removeGoods, setGoodsContainer
-
Methods inherited from class net.sf.freecol.common.model.UnitLocation
canAdd, clearUnitList, getCarrierForUnit, getFirstUnit, getIndianSettlement, getLastUnit, getNavalUnits, getSpaceTaken, getTotalUnitCount, getUnitCapacity, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, equals, fundamentalDispose, getGame, getSpecification, hashCode, internId, isDisposed, isInitialized, isInternable, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getDisplayObject, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.freecol.common.model.TradeLocation
getNameAsJlabel
-
-
-
-
Constructor Detail
-
ServerColony
public ServerColony(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.- Parameters:
game
- TheGame
in which this object belongs.id
- The object identifier.
-
-
Method Detail
-
neededForBuildableType
private boolean neededForBuildableType(GoodsType goodsType)
Is a goods type needed for a buildable that this colony could be building.- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- True if the goods could be used to build something.
-
csBuildUnit
private Unit csBuildUnit(BuildQueue<? extends BuildableType> buildQueue, java.util.Random random, ChangeSet cs)
Build a unit from a build queue.- Parameters:
buildQueue
- TheBuildQueue
to find the unit in.random
- A pseudo-random number source.cs
- AChangeSet
to update.- Returns:
- The unit that was built.
-
ejectUnits
public boolean ejectUnits(WorkLocation workLocation, java.util.List<Unit> units)
Eject units to any available work location. Called on building type changes, see below and- Parameters:
workLocation
- TheWorkLocation
to eject from.units
- A list ofUnit
s to eject.- Returns:
- True if units were ejected.
- See Also:
-til: Might change the visible colony size.
-
csBuildBuilding
private boolean csBuildBuilding(BuildQueue<? extends BuildableType> buildQueue, ChangeSet cs)
Builds a building from a build queue.- Parameters:
buildQueue
- TheBuildQueue
to build from.cs
- AChangeSet
to update.- Returns:
- True if the build succeeded.
-
csNextBuildable
private BuildableType csNextBuildable(BuildQueue<? extends BuildableType> queue, ChangeSet cs)
Removes a buildable from a build queue, and updates the queue so that a valid buildable is now being built if possible.- Parameters:
queue
- TheBuildQueue
to update.cs
- AChangeSet
to update.- Returns:
- The next buildable that can be built, or null if nothing.
-
csEvictUsers
public void csEvictUsers(Unit enemyUnit, ChangeSet cs)
Evict the users from a tile used by this colony, due to military action from another unit.- Parameters:
enemyUnit
- TheUnit
that has moved in.cs
- AChangeSet
to update.
-
csChangeOwner
public void csChangeOwner(Player newOwner, boolean reassign, java.lang.String change, ChangeSet cs)
Change the owner of this colony. -vis: Owner and new owner- Parameters:
newOwner
- The new owningPlayer
.reassign
- If true, reassign the colony tiles.change
- An optional accompanying change type for the units.cs
- AChangeSet
to update.
-
csFreeBuilding
public void csFreeBuilding(BuildingType type, ChangeSet cs)
Add a free building to this colony. Triggered directly by election of laSalle, or at end of turn.- Parameters:
type
- TheBuildingType
to add.cs
- AChangeSet
to update.
-
buildBuilding
private boolean buildBuilding(Building building)
Build a new building in this colony.- Parameters:
building
- TheBuilding
to build.- Returns:
- True if the building was built.
-
csEquipForRole
public boolean csEquipForRole(Unit unit, Role role, int roleCount, java.util.Random random, ChangeSet cs)
Equip a unit for a specific role.- Parameters:
unit
- TheUnit
to equip.role
- TheRole
to equip for.roleCount
- The role count.random
- A pseudo-random number source.cs
- AChangeSet
to update.- Returns:
- True if the equipping succeeds.
-
csAddConvert
public void csAddConvert(Unit brave, ChangeSet cs)
Add a new convert to this colony.- Parameters:
brave
- The convertUnit
.cs
- AChangeSet
to update.
-
destroyBuilding
public boolean destroyBuilding(Building building)
Destroy an existing building in this colony.- Parameters:
building
- TheBuilding
to destroy.- Returns:
- True if the building was destroyed.
-
csNewTurnWarnings
public void csNewTurnWarnings(java.util.Random random, LogBuilder lb, ChangeSet cs)
Do the checks for user warnings that must wait for all player settlements, units and whatever to stabilize. Along the way, throw away excess goods. For example, a pioneer might clear a colony tile and change the lumber amount.- Parameters:
random
- ARandom
number source.lb
- ALogBuilder
to log to.cs
- AChangeSet
to update.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this colony. Try to find out if the colony is going to survive (last colonist does not starve) before generating lots of production-related messages.
-
-