Package net.sf.freecol.server.model
Class ServerIndianSettlement
- java.lang.Object
-
- net.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.IndianSettlement
-
- net.sf.freecol.server.model.ServerIndianSettlement
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Location
,Nameable
,Ownable
,TradeLocation
,ObjectWithId
,TurnTaker
public class ServerIndianSettlement extends IndianSettlement implements TurnTaker
The server version of an Indian Settlement.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.IndianSettlement
IndianSettlement.ContactLevel
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALARM_NEW_MISSIONARY
Alarm added when a new missionary is added.private static java.util.logging.Logger
logger
static int
MAX_CONVERT_DISTANCE
How far to search for a colony to add an Indian convert to.static int
MAX_HORSES_PER_TURN
-
Fields inherited from class net.sf.freecol.common.model.IndianSettlement
alarm, contactLevels, convertProgress, GIFT_MAXIMUM, GIFT_MINIMUM, GIFT_THRESHOLD, GOODS_BASE_PRICE, KEEP_RAW_MATERIAL, lastTribute, LEARNABLE_SKILL_TAG, learnableSkill, missionary, mostHated, NATIVE_PRODUCTION_EFFICIENCY, ownedUnits, TAG, TALES_RADIUS, TRADE_MINIMUM_PRICE, TRADE_MINIMUM_SIZE, WANTED_GOODS_COUNT, WANTED_GOODS_TAG, wantedGoods
-
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 ServerIndianSettlement(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.ServerIndianSettlement(Game game, Player owner, java.lang.String name, Tile tile, boolean isCapital, UnitType learnableSkill, Unit missionary)
Creates a new ServerIndianSettlement.ServerIndianSettlement(Game game, Player owner, Tile tile, IndianSettlement template)
Creates a new ServerIndianSettlement from a template.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUnits(int count)
Add a given number of units to the settlement.void
addUnits(java.util.Random random)
Add a standard number of units to this settlement and tile.private boolean
changeAlarm(Player player, int amount)
Change the alarm level of this settlement by a given amount.private void
consumeGoods(GoodsType type, int amount)
Convenience function to remove an amount of goods.private boolean
csChangeAlarm(Player player, int add, boolean propagate, ChangeSet cs)
Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe.void
csChangeMissionary(Unit missionary, ChangeSet cs)
Changes the missionary for this settlement and updates other players.void
csCheckTension(Player enemy, Tension.Level oldLevel, ChangeSet cs)
Check if tension has increased with respect to an enemy.boolean
csEquipForRole(Unit unit, Role role, int roleCount, java.util.Random random, ChangeSet cs)
Equip a unit for a specific role.void
csKillMissionary(java.lang.Boolean destroy, ChangeSet cs)
Kills the missionary at this settlement.boolean
csModifyAlarm(Player player, int add, boolean propagate, ChangeSet cs)
Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe.void
csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this native settlement.void
csStartTurn(java.util.Random random, ChangeSet cs)
Starts a new turn for a player.void
removeAlarm(Player player)
Removes all alarm towards the given player.void
setAlarm(Player player, Tension newAlarm)
Sets alarm towards the given player.private boolean
updateMostHated()
Updates the most hated nation of this settlement.-
Methods inherited from class net.sf.freecol.common.model.IndianSettlement
add, addOwnedUnit, addRandomGoods, allowContact, calculateSettlementValue, checkIntegrity, copyIn, disposeResources, getAlarm, getAlarm, getAlarmLevelKey, getAlarmLevelLabel, getAvailableGoodsCount, getContactLevel, getConvertProgress, getDefenceRatio, getDefendingUnit, getExportAmount, getGoodsCapacity, getGoodsForSale, getImportAmount, getIndianSettlement, getLastTribute, getLearnableSkill, getLearnableSkillLabel, getLocationLabelFor, getLocationName, getMaximumProduction, getMissionary, getMissionaryLineOfSight, getMissionaryVisibleTiles, getMostHated, getMostHatedLabel, getOwnedUnitList, getPlunderRange, getPriceToBuy, getPriceToBuy, getPriceToSell, getPriceToSell, getRandomGift, getRequiredDefenders, getSellGoods, getSoL, getTotalProductionOf, getUpkeep, getWantedGoods, getWantedGoods, getWantedGoodsAmount, getWantedGoodsCount, getWantedGoodsLabel, getXMLTagName, hasAnyScouted, hasContacted, hasMissionary, hasMissionary, hasScouted, hasVisited, initializeAlarm, invalidateCache, isBadlyDefended, readAttributes, readChild, readChildren, removeOwnedUnit, setAlarm, setContacted, setContactLevels, setConvertProgress, setGoodsForSale, setLastTribute, setLearnableSkill, setMissionary, setMostHated, setOwnedUnitList, setScouted, setVisited, setWantedGoods, setWantedGoods, toShortString, toString, tradeGoodsWithSettlement, up, updateWantedGoods, willSell, worthScouting, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.model.Settlement
addTile, canBombardEnemyShip, canImproveUnitMilitaryRole, canProvideGoods, changeOwner, equipForRole, exciseSettlement, getAllUnitsList, getConsumptionOf, getConsumptionOf, getFeatureContainer, getFoodConsumption, getHighSeasCount, getImmigration, getLiberty, 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, addGoods, contains, containsGoods, getCompactGoodsList, getDisposables, getGoodsContainer, getGoodsCount, getGoodsList, moveGoods, remove, removeAll, removeGoods, removeGoods, removeGoods, setGoodsContainer
-
Methods inherited from class net.sf.freecol.common.model.UnitLocation
canAdd, clearUnitList, getCarrierForUnit, getColony, getFirstUnit, getLastUnit, getNavalUnits, getSpaceTaken, getTotalUnitCount, getUnitCapacity, getUnitCount, getUnitList, getUnits, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, equals, fundamentalDispose, getClassIndex, 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, 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
canBeInput, getNameAsJlabel
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
ALARM_NEW_MISSIONARY
public static final int ALARM_NEW_MISSIONARY
Alarm added when a new missionary is added.- See Also:
- Constant Field Values
-
MAX_CONVERT_DISTANCE
public static final int MAX_CONVERT_DISTANCE
How far to search for a colony to add an Indian convert to.- See Also:
- Constant Field Values
-
MAX_HORSES_PER_TURN
public static final int MAX_HORSES_PER_TURN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServerIndianSettlement
public ServerIndianSettlement(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.- Parameters:
game
- TheGame
in which this object belong.id
- The object identifier.
-
ServerIndianSettlement
public ServerIndianSettlement(Game game, Player owner, java.lang.String name, Tile tile, boolean isCapital, UnitType learnableSkill, Unit missionary)
Creates a new ServerIndianSettlement.- Parameters:
game
- TheGame
in which this object belong.owner
- ThePlayer
owning this settlement.name
- The name for this settlement.tile
- The location of theIndianSettlement
.isCapital
- True if settlement is tribe's capitallearnableSkill
- The skill that can be learned by Europeans at this settlement.missionary
- The missionary in this settlement (or null).
-
ServerIndianSettlement
public ServerIndianSettlement(Game game, Player owner, Tile tile, IndianSettlement template)
Creates a new ServerIndianSettlement from a template.- Parameters:
game
- TheGame
in which this object belong.owner
- ThePlayer
owning this settlement.tile
- The location of theIndianSettlement
.template
- The templateIndianSettlement
to copy.
-
-
Method Detail
-
csStartTurn
public void csStartTurn(java.util.Random random, ChangeSet cs)
Starts a new turn for a player.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
addUnits
public void addUnits(java.util.Random random)
Add a standard number of units to this settlement and tile. If a pseudo-random number source is provided use it to pick a random number of units within the ranges provided by the settlement type, otherwise use the average.- Parameters:
random
- An optional pseudo-random number source.
-
addUnits
public void addUnits(int count)
Add a given number of units to the settlement.- Parameters:
count
- The number of units to add.
-
consumeGoods
private void consumeGoods(GoodsType type, int amount)
Convenience function to remove an amount of goods.- Parameters:
type
- TheGoodsType
to remove.amount
- The amount of goods to remove.
-
setAlarm
public void setAlarm(Player player, Tension newAlarm)
Sets alarm towards the given player. -til: Might change tile appearance through most hated state- Overrides:
setAlarm
in classIndianSettlement
- Parameters:
player
- ThePlayer
to set the alarm level for.newAlarm
- The new alarm value.
-
removeAlarm
public void removeAlarm(Player player)
Removes all alarm towards the given player. Used the a player leaves the game. -til: Might change tile appearance through most hated state- Parameters:
player
- ThePlayer
to remove the alarm for.
-
updateMostHated
private boolean updateMostHated()
Updates the most hated nation of this settlement. Needs to be public so it can be set by backwards compatibility code in FreeColServer.loadGame. -til: This might change the tile appearance.- Returns:
- True if the most hated nation changed.
-
changeAlarm
private boolean changeAlarm(Player player, int amount)
Change the alarm level of this settlement by a given amount. -til: Might change tile appearance through most hated state- Parameters:
player
- ThePlayer
the alarm level changes wrt.amount
- The amount to change the alarm by.- Returns:
- True if the
Tension.Level
of the settlement alarm changes as a result of this change.
-
csChangeAlarm
private boolean csChangeAlarm(Player player, int add, boolean propagate, ChangeSet cs)
Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe. -til: Might change tile appearance through most hated state- Parameters:
player
- ThePlayer
to modify alarm for.add
- The amount to add to the current alarm level.propagate
- If true, propagate the alarm change upward to the owning player.cs
- AChangeSet
to update.- Returns:
- True if the alarm changed.
-
csModifyAlarm
public boolean csModifyAlarm(Player player, int add, boolean propagate, ChangeSet cs)
Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe. +til: Handles tile visibility changes.- Parameters:
player
- ThePlayer
to modify alarm for.add
- The amount to add to the current alarm level.propagate
- If true, propagate the alarm change upward to the owning player.cs
- AChangeSet
to update.- Returns:
- True if the alarm changed and the tile added.
-
csChangeMissionary
public void csChangeMissionary(Unit missionary, ChangeSet cs)
Changes the missionary for this settlement and updates other players. +vis: Handles the visibility implications. +til: Handles the tile appearance change.- Parameters:
missionary
- The new missionary for this settlement.cs
- AChangeSet
to update.
-
csKillMissionary
public void csKillMissionary(java.lang.Boolean destroy, ChangeSet cs)
Kills the missionary at this settlement.- Parameters:
destroy
- If true, the settlement is destroyed, if false the missionary is denounced, if null do not generate a message.cs
- AChangeSet
to update.
-
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.
-
csCheckTension
public void csCheckTension(Player enemy, Tension.Level oldLevel, ChangeSet cs)
Check if tension has increased with respect to an enemy.- Parameters:
enemy
- The enemyPlayer
.oldLevel
- The previous tensionLevel
.cs
- AChangeSet
to update.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this native settlement.
-
-