net.sf.freecol.common.model
Class IndianSettlement

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.UnitLocation
              extended by net.sf.freecol.common.model.GoodsLocation
                  extended by net.sf.freecol.common.model.Settlement
                      extended by net.sf.freecol.common.model.IndianSettlement
All Implemented Interfaces:
Location, Named, Ownable
Direct Known Subclasses:
ServerIndianSettlement

public class IndianSettlement
extends Settlement

Represents an Indian settlement.


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
 
Field Summary
private  java.util.Map<Player,Tension> alarm
          Stores the alarm levels.
static java.lang.String ALARM_TAG_NAME
           
protected  int convertProgress
          Used for monitoring the progress towards creating a convert.
private  java.util.Comparator<Goods> exportGoodsComparator
           
static int GOODS_BASE_PRICE
           
static java.lang.String IS_VISITED_TAG_NAME
           
static int KEEP_RAW_MATERIAL
          The amount of raw material that should be available before producing manufactured goods.
protected  int lastTribute
          The number of the turn during which the last tribute was paid.
protected  UnitType learnableSkill
          This is the skill that can be learned by Europeans at this settlement.
private static java.util.logging.Logger logger
           
protected  Unit missionary
          The missionary at this settlement.
static java.lang.String MISSIONARY_TAG_NAME
           
static java.lang.String OWNED_UNITS_TAG_NAME
           
protected  java.util.ArrayList<Unit> ownedUnits
          Units that belong to this settlement.
protected  java.util.Set<Player> spokenTo
          A map that tells if a player has spoken to the chief of this settlement.
static int TALES_RADIUS
           
static int TRADE_MINIMUM_PRICE
           
static int TRADE_MINIMUM_SIZE
           
static java.lang.String WANTED_GOODS_TAG_NAME
           
protected  GoodsType[] wantedGoods
          The goods this settlement wants.
private  java.util.Comparator<GoodsType> wantedGoodsComparator
           
 
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 IndianSettlement()
          Constructor for ServerIndianSettlement.
protected IndianSettlement(Game game, Player owner, java.lang.String name, Tile tile)
          Constructor for ServerIndianSettlement.
  IndianSettlement(Game game, java.lang.String id)
          Initiates a new IndianSettlement with the given ID.
  IndianSettlement(Game game, javax.xml.stream.XMLStreamReader in)
          Initiates a new IndianSettlement from an Element.
 
Method Summary
 boolean add(Locatable locatable)
          Adds a Locatable to this Location.
 void addOwnedUnit(Unit unit)
          Adds the given Unit to the list of units that belongs to this IndianSettlement.
 boolean allowContact(Unit unit)
          Is a unit permitted to make contact with this settlement? The unit must be from a nation that has already made contact, or in the first instance, must be arriving by land, with the exception of trading ships.
protected  boolean changeAlarm(Player player, int amount)
          Change the alarm level of this settlement by a given amount.
 void changeMissionary(Unit missionary)
          Changes the missionary for this settlement and updates other players.
 boolean checkForNewMissionaryConvert()
           
 java.util.List<FreeColGameObject> disposeList()
          Dispose of this native settlement.
 Tension getAlarm(Player player)
          Gets the alarm level towards the given player.
 java.lang.String getAlarmLevelMessageId(Player player)
          Gets a messageId for an alarm message associated with the alarm level of this player.
 int getConvertProgress()
          Gets the convert progress status for this settlement.
 Unit getDefendingUnit(Unit attacker)
          Gets the Unit that is currently defending this IndianSettlement.
 int getGoodsCapacity()
          Gets the storage capacity of this settlement.
 java.lang.String getImageKey()
          Gets the image key for this native settlement.
 int getLastTribute()
          Get the year of the last tribute.
 UnitType getLearnableSkill()
          Returns the skill that can be learned at this settlement.
 StringTemplate getLocationName()
          Returns a suitable (non-unique) name.
 StringTemplate getLocationNameFor(Player player)
          Returns a suitable (non-unique) name for a particular player.
 int getMaximumProduction(GoodsType goodsType)
          Gets the maximum possible production of the given type of goods.
private  int getMilitaryGoodsPriceToBuy(GoodsType type, int amount)
          Price some goods that have military value to the settlement.
 Unit getMissionary()
          Gets the missionary from this settlement.
 Unit getMissionary(Player player)
          Gets the missionary from this settlement if there is one and it is owned by a specified player.
 java.lang.String getNameFor(Player player)
          Gets the name of this Settlement for a particular player.
private  int getNormalGoodsPriceToBuy(GoodsType type, int amount)
          Price some goods according to the amount present in the settlement.
 java.util.List<Unit> getOwnedUnits()
          Gets a list of the units native to this settlement.
 java.util.Iterator<Unit> getOwnedUnitsIterator()
          Gets an iterator over all the units this IndianSettlement is owning.
 RandomRange getPlunderRange(Unit attacker)
          Gets the range of gold plunderable when this settlement is captured.
 int getPriceToBuy(Goods goods)
          Gets the amount of gold this IndianSettlment is willing to pay for the given Goods.
 int getPriceToBuy(GoodsType type, int amount)
          Gets the amount of gold this IndianSettlment is willing to pay for the given Goods.
 int getPriceToSell(Goods goods)
          Gets the amount of gold this IndianSettlment is willing to sell the given Goods for.
 int getPriceToSell(GoodsType type, int amount)
          Gets the amount of gold this IndianSettlment is willing to sell the given Goods for.
 int getProductionOf(GoodsType type)
          Gets the production of a specified goods type for this settlement.
 java.util.List<Goods> getSellGoods(int limit, Unit unit)
          Gets the goods this settlement is willing to sell.
 java.lang.String getShortAlarmLevelMessageId(Player player)
          Gets a messageId for a short alarm message associated with the alarm level of this player.
 int getSoL()
          Native settlements do not generate SoL.
 GoodsType[] getWantedGoods()
           
protected  int getWantedGoodsAmount(GoodsType type)
          Calculates how much of the given goods type this settlement wants and should retain.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
private  GoodsType goodsToMake()
          Chooses a type of goods for some of the natives in a settlement to manufacture.
 boolean hasContactedSettlement(Player player)
          Has a player contacted this settlement?
 boolean hasSpokenToChief()
          Returns true if a European player has spoken with the chief of this settlement.
 boolean hasSpokenToChief(Player player)
          Returns true if a the given player has spoken with the chief of this settlement.
 boolean makeContactSettlement(Player player)
          Make contact with this settlement (if it has not been previously contacted).
 boolean propagateAlarm(Player player, int addToAlarm)
          Propagates a global change in tension down to a settlement.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
protected  void readChild(javax.xml.stream.XMLStreamReader in)
          Reads a single child object.
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
          Reads the children of this object from an XML stream.
protected  void readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
          Partial reader, so that "remove" messages can be brief.
 void removeAlarm(Player player)
          Removes all alarm towards the given player.
 boolean removeOwnedUnit(Unit unit)
          Removes the given Unit to the list of units that belongs to this IndianSettlement.
 void setAlarm(Player player, Tension newAlarm)
          Sets alarm towards the given player.
 void setConvertProgress(int progress)
          Sets the convert progress status for this settlement.
 void setLastTribute(int lastTribute)
          Set the year of the last tribute.
 void setLearnableSkill(UnitType skill)
          Sets the learnable skill for this Indian settlement.
 void setMissionary(Unit missionary)
          Sets the missionary for this settlement.
 void setSpokenToChief(Player player)
          Sets the spoken-to status of this settlement to true, indicating that a European player has had a chat with the chief.
 void setWantedGoods(int index, GoodsType type)
           
 java.lang.String toString()
          Gets a string representation of the object.
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 tradeGoodsWithSetlement(IndianSettlement settlement)
          Allows spread of horses and arms between settlements
 void updateWantedGoods()
          Updates the goods wanted by this settlement.
 boolean willSell(GoodsType type)
          Will this settlement sell a type of goods.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out, Player player, boolean showAll, boolean toSavedGame)
          Serialize the children of this UnitLocation, i.e.
 
Methods inherited from class net.sf.freecol.common.model.Settlement
addTile, canBuildEquipment, canProvideEquipment, canProvideEquipment, changeOwner, getConsumptionOf, getConsumptionOf, getFeatureContainer, getFoodConsumption, getLineOfSight, getModifierSet, getName, getNameKey, getOwnedTiles, getOwner, getPlunder, getRadius, getSettlement, getTile, getType, isCapital, isConnected, placeSettlement, removeTile, setCapital, setFeatureContainer, setName, setOwner, setType, writeAttributes
 
Methods inherited from class net.sf.freecol.common.model.GoodsLocation
addGoods, addGoods, contains, dispose, getCompactGoods, getGoodsContainer, getGoodsCount, getGoodsIterator, getNoAddReason, getWarehouseCapacity, remove, removeGoods, removeGoods, removeGoods, setGoodsContainer
 
Methods inherited from class net.sf.freecol.common.model.UnitLocation
canAdd, getColony, getSpaceTaken, getUnitCapacity, getUnitCount, getUnitIterator, getUnitList, isEmpty, isFull
 
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 net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setSpecification, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeChildren
 
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

logger

private static final java.util.logging.Logger logger

TALES_RADIUS

public static final int TALES_RADIUS
See Also:
Constant Field Values

OWNED_UNITS_TAG_NAME

public static final java.lang.String OWNED_UNITS_TAG_NAME
See Also:
Constant Field Values

IS_VISITED_TAG_NAME

public static final java.lang.String IS_VISITED_TAG_NAME
See Also:
Constant Field Values

ALARM_TAG_NAME

public static final java.lang.String ALARM_TAG_NAME
See Also:
Constant Field Values

MISSIONARY_TAG_NAME

public static final java.lang.String MISSIONARY_TAG_NAME
See Also:
Constant Field Values

WANTED_GOODS_TAG_NAME

public static final java.lang.String WANTED_GOODS_TAG_NAME
See Also:
Constant Field Values

TRADE_MINIMUM_SIZE

public static final int TRADE_MINIMUM_SIZE
See Also:
Constant Field Values

TRADE_MINIMUM_PRICE

public static final int TRADE_MINIMUM_PRICE
See Also:
Constant Field Values

GOODS_BASE_PRICE

public static final int GOODS_BASE_PRICE
See Also:
Constant Field Values

KEEP_RAW_MATERIAL

public static final int KEEP_RAW_MATERIAL
The amount of raw material that should be available before producing manufactured goods.

See Also:
Constant Field Values

learnableSkill

protected UnitType learnableSkill
This is the skill that can be learned by Europeans at this settlement. At the server side its value will be null when the skill has already been taught to a European. At the client side the value null is also possible in case the player hasn't checked out the settlement yet.


wantedGoods

protected GoodsType[] wantedGoods
The goods this settlement wants.


spokenTo

protected java.util.Set<Player> spokenTo
A map that tells if a player has spoken to the chief of this settlement. At the client side, only the information regarding the player on that client should be included.


ownedUnits

protected java.util.ArrayList<Unit> ownedUnits
Units that belong to this settlement.


missionary

protected Unit missionary
The missionary at this settlement.


convertProgress

protected int convertProgress
Used for monitoring the progress towards creating a convert.


lastTribute

protected int lastTribute
The number of the turn during which the last tribute was paid.


alarm

private java.util.Map<Player,Tension> alarm
Stores the alarm levels. Only used by AI. "Alarm" means: Tension with respect to a player from an IndianSettlement. Alarm is overloaded with the concept of "contact". If a settlement has never been contacted by a player, alarm.get(player) will be null. Acts causing contact initialize this variable.


wantedGoodsComparator

private final java.util.Comparator<GoodsType> wantedGoodsComparator

exportGoodsComparator

private final java.util.Comparator<Goods> exportGoodsComparator
Constructor Detail

IndianSettlement

protected IndianSettlement()
Constructor for ServerIndianSettlement.


IndianSettlement

protected IndianSettlement(Game game,
                           Player owner,
                           java.lang.String name,
                           Tile tile)
Constructor for ServerIndianSettlement.

Parameters:
game - The Game in which this object belong.
owner - The Player owning this settlement.
name - The name for this settlement.
tile - The location of the IndianSettlement.

IndianSettlement

public IndianSettlement(Game game,
                        javax.xml.stream.XMLStreamReader in)
                 throws javax.xml.stream.XMLStreamException
Initiates a new IndianSettlement from an Element.

Parameters:
game - The Game in which this object belong.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

IndianSettlement

public IndianSettlement(Game game,
                        java.lang.String id)
Initiates a new IndianSettlement with the given ID. The object should later be initialized by calling either FreeColGameObject.readFromXML(XMLStreamReader).

Parameters:
game - The Game in which this object belong.
id - The unique identifier for this object.
Method Detail

getNameFor

public java.lang.String getNameFor(Player player)
Gets the name of this Settlement for a particular player.

Specified by:
getNameFor in class Settlement
Parameters:
player - A Player to return the name for.
Returns:
The name as a String.

getImageKey

public java.lang.String getImageKey()
Gets the image key for this native settlement.

Specified by:
getImageKey in class Settlement
Returns:
The image key.

getLocationName

public StringTemplate getLocationName()
Returns a suitable (non-unique) name.

Specified by:
getLocationName in interface Location
Overrides:
getLocationName in class UnitLocation
Returns:
The name of this settlement.

getLocationNameFor

public StringTemplate getLocationNameFor(Player player)
Returns a suitable (non-unique) name for a particular player.

Specified by:
getLocationNameFor in interface Location
Overrides:
getLocationNameFor in class UnitLocation
Parameters:
player - The Player to prepare the name for.
Returns:
The name of this settlement.

getLastTribute

public int getLastTribute()
Get the year of the last tribute.

Returns:
The year of the last tribute.

setLastTribute

public void setLastTribute(int lastTribute)
Set the year of the last tribute.

Parameters:
lastTribute - The new last tribute year.

getAlarm

public Tension getAlarm(Player player)
Gets the alarm level towards the given player.

Parameters:
player - The Player to get the alarm level for.
Returns:
The current alarm level or null if the settlement has not encoutered the player.

setAlarm

public void setAlarm(Player player,
                     Tension newAlarm)
Sets alarm towards the given player.

Parameters:
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.

Parameters:
player - The Player to remove the alarm for.

changeAlarm

protected boolean changeAlarm(Player player,
                              int amount)
Change the alarm level of this settlement by a given amount.

Parameters:
player - The Player 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.

getShortAlarmLevelMessageId

public java.lang.String getShortAlarmLevelMessageId(Player player)
Gets a messageId for a short alarm message associated with the alarm level of this player.

Parameters:
player - The other Player.
Returns:
The alarm messageId.

getAlarmLevelMessageId

public java.lang.String getAlarmLevelMessageId(Player player)
Gets a messageId for an alarm message associated with the alarm level of this player.

Parameters:
player - The other Player.
Returns:
The alarm messageId.

hasContactedSettlement

public boolean hasContactedSettlement(Player player)
Has a player contacted this settlement?

Parameters:
player - The Player to check.
Returns:
True if the player has contacted this settlement.

makeContactSettlement

public boolean makeContactSettlement(Player player)
Make contact with this settlement (if it has not been previously contacted). Initialize tension level to the general level with respect to the contacting player--- effectively the average reputation of this player with the overall tribe.

Parameters:
player - The Player making contact.
Returns:
True if this was indeed the first contact between settlement and player.

propagateAlarm

public boolean propagateAlarm(Player player,
                              int addToAlarm)
Propagates a global change in tension down to a settlement. Only apply the change if the settlement is aware of the player causing alarm.

Specified by:
propagateAlarm in class Settlement
Parameters:
player - The Player towards whom the alarm is felt.
addToAlarm - The amount to add to the current alarm level.
Returns:
True if the alarm level changes as a result of this change.

hasSpokenToChief

public boolean hasSpokenToChief()
Returns true if a European player has spoken with the chief of this settlement.

Returns:
True if a European player has spoken with the chief.

hasSpokenToChief

public boolean hasSpokenToChief(Player player)
Returns true if a the given player has spoken with the chief of this settlement.

Parameters:
player - The Player to check.
Returns:
True if the player has visited this settlement to speak with the chief.

setSpokenToChief

public void setSpokenToChief(Player player)
Sets the spoken-to status of this settlement to true, indicating that a European player has had a chat with the chief.

Parameters:
player - The visiting Player.

allowContact

public boolean allowContact(Unit unit)
Is a unit permitted to make contact with this settlement? The unit must be from a nation that has already made contact, or in the first instance, must be arriving by land, with the exception of trading ships.

Parameters:
unit - The Unit that proposes to contact this settlement.
Returns:
True if the settlement accepts such contact.

addOwnedUnit

public void addOwnedUnit(Unit unit)
Adds the given Unit to the list of units that belongs to this IndianSettlement.

Parameters:
unit - The Unit to be added.

getOwnedUnits

public java.util.List<Unit> getOwnedUnits()
Gets a list of the units native to this settlement.

Returns:
The list of units native to this settlement.

getOwnedUnitsIterator

public java.util.Iterator<Unit> getOwnedUnitsIterator()
Gets an iterator over all the units this IndianSettlement is owning.

Returns:
The Iterator.

removeOwnedUnit

public boolean removeOwnedUnit(Unit unit)
Removes the given Unit to the list of units that belongs to this IndianSettlement. Returns true if the Unit was removed.

Parameters:
unit - The Unit to be removed from the list of the units this IndianSettlement owns.
Returns:
a boolean value

getLearnableSkill

public UnitType getLearnableSkill()
Returns the skill that can be learned at this settlement.

Returns:
The skill that can be learned at this settlement.

getMissionary

public Unit getMissionary()
Gets the missionary from this settlement.

Returns:
The missionary at this settlement, or null if there is none.

setMissionary

public void setMissionary(Unit missionary)
Sets the missionary for this settlement.

Parameters:
missionary - The missionary for this settlement.

changeMissionary

public void changeMissionary(Unit missionary)
Changes the missionary for this settlement and updates other players.

Parameters:
missionary - The new missionary for this settlement.

getMissionary

public Unit getMissionary(Player player)
Gets the missionary from this settlement if there is one and it is owned by a specified player.

Parameters:
player - The player purported to own the missionary
Returns:
The missionary from this settlement if there is one and it is owned by the specified player, otherwise null.

getConvertProgress

public int getConvertProgress()
Gets the convert progress status for this settlement.

Returns:
The convert progress status.

setConvertProgress

public void setConvertProgress(int progress)
Sets the convert progress status for this settlement.

Parameters:
progress - The new convert progress status.

getWantedGoods

public GoodsType[] getWantedGoods()

setWantedGoods

public void setWantedGoods(int index,
                           GoodsType type)

setLearnableSkill

public void setLearnableSkill(UnitType skill)
Sets the learnable skill for this Indian settlement.

Parameters:
skill - The new learnable skill for this Indian settlement.

add

public boolean add(Locatable locatable)
Adds a Locatable to this Location.

Specified by:
add in interface Location
Overrides:
add in class GoodsLocation
Parameters:
locatable - The Locatable to add to this Location.

getDefendingUnit

public Unit getDefendingUnit(Unit attacker)
Gets the Unit that is currently defending this IndianSettlement.

Specified by:
getDefendingUnit in class Settlement
Parameters:
attacker - The unit that would be attacking this IndianSettlement.
Returns:
The Unit that has been chosen to defend this IndianSettlement.

getPlunderRange

public RandomRange getPlunderRange(Unit attacker)
Gets the range of gold plunderable when this settlement is captured.

Specified by:
getPlunderRange in class Settlement
Parameters:
attacker - The Unit that takes the settlement.
Returns:
A RandomRange encapsulating the range of plunder available.

getGoodsCapacity

public int getGoodsCapacity()
Gets the storage capacity of this settlement.

Specified by:
getGoodsCapacity in class GoodsLocation
Returns:
The storage capacity of this settlement.

getPriceToBuy

public int getPriceToBuy(Goods goods)
Gets the amount of gold this IndianSettlment is willing to pay for the given Goods. It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients.

Parameters:
goods - The Goods to price.
Returns:
The price.

getPriceToBuy

public int getPriceToBuy(GoodsType type,
                         int amount)
Gets the amount of gold this IndianSettlment is willing to pay for the given Goods. It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients. The AI uses it though so it stays here for now. Note that it takes no account of whether the native player actually has the gold. TODO: this is rancid with magic numbers. TODO: the hardwired goods/equipment types are a wart.

Parameters:
type - The type of Goods to price.
amount - The amount of Goods to price.
Returns:
The price.

getNormalGoodsPriceToBuy

private int getNormalGoodsPriceToBuy(GoodsType type,
                                     int amount)
Price some goods according to the amount present in the settlement.

Parameters:
type - The type of goods for sale.
amount - The amount of goods for sale.
Returns:
A price for the goods.

getWantedGoodsAmount

protected int getWantedGoodsAmount(GoodsType type)
Calculates how much of the given goods type this settlement wants and should retain.

Parameters:
type - The GoodsType.
Returns:
The amount of goods wanted.

getMilitaryGoodsPriceToBuy

private int getMilitaryGoodsPriceToBuy(GoodsType type,
                                       int amount)
Price some goods that have military value to the settlement.

Parameters:
type - The type of goods for sale.
amount - The amount of goods for sale.
Returns:
A price for the goods.

getPriceToSell

public int getPriceToSell(Goods goods)
Gets the amount of gold this IndianSettlment is willing to sell the given Goods for. It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients.

Parameters:
goods - The Goods to price.
Returns:
The price.

getPriceToSell

public int getPriceToSell(GoodsType type,
                          int amount)
Gets the amount of gold this IndianSettlment is willing to sell the given Goods for. It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients.

Parameters:
type - The type of Goods to price.
amount - The amount of Goods to price.
Returns:
The price.

willSell

public boolean willSell(GoodsType type)
Will this settlement sell a type of goods. Placeholder until we have a spec-configured blacklist.

Parameters:
type - The GoodsType to consider.
Returns:
True if the settlement would sell the goods.

getSellGoods

public java.util.List<Goods> getSellGoods(int limit,
                                          Unit unit)
Gets the goods this settlement is willing to sell.

Parameters:
limit - The maximum number of goods required.
unit - The Unit that is trading.
Returns:
A list of goods to sell.

tradeGoodsWithSetlement

public void tradeGoodsWithSetlement(IndianSettlement settlement)
Allows spread of horses and arms between settlements

Parameters:
settlement -

getMaximumProduction

public int getMaximumProduction(GoodsType goodsType)
Gets the maximum possible production of the given type of goods.

Parameters:
goodsType - The type of goods to check.
Returns:
The maximum amount, of the given type of goods, that can be produced in one turn.

updateWantedGoods

public void updateWantedGoods()
Updates the goods wanted by this settlement. It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients.


goodsToMake

private GoodsType goodsToMake()
Chooses a type of goods for some of the natives in a settlement to manufacture. Simple rule: choose the refined goods that is the greatest shortage for which there is a surplus of the raw material.

Returns:
A GoodsType to manufacture, or null if none suitable.

getProductionOf

public int getProductionOf(GoodsType type)
Gets the production of a specified goods type for this settlement.

Specified by:
getProductionOf in class Settlement
Parameters:
type - The GoodsType to produce.
Returns:
The production potention for the goods type.

getSoL

public int getSoL()
Native settlements do not generate SoL.

Specified by:
getSoL in class Settlement
Returns:
0.

checkForNewMissionaryConvert

public boolean checkForNewMissionaryConvert()

disposeList

public java.util.List<FreeColGameObject> disposeList()
Dispose of this native settlement.

Overrides:
disposeList in class Settlement
Returns:
A list of disposed objects.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
                         Player player,
                         boolean showAll,
                         boolean toSavedGame)
                  throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Only attributes visible to the given Player will be added to that representation if showAll is set to false.

Specified by:
toXMLImpl in class FreeColGameObject
Parameters:
out - 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.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeChildren

protected void writeChildren(javax.xml.stream.XMLStreamWriter out,
                             Player player,
                             boolean showAll,
                             boolean toSavedGame)
                      throws javax.xml.stream.XMLStreamException
Serialize the children of this UnitLocation, i.e. the Units themselves.

Overrides:
writeChildren in class GoodsLocation
Parameters:
out - a XMLStreamWriter value
player - a Player value
showAll - a boolean value
toSavedGame - a boolean value
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Overrides:
readAttributes in class Settlement
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Description copied from class: UnitLocation
Reads the children of this object from an XML stream.

Overrides:
readChildren in class UnitLocation
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChild

protected void readChild(javax.xml.stream.XMLStreamReader in)
                  throws javax.xml.stream.XMLStreamException
Description copied from class: GoodsLocation
Reads a single child object. This method does calls readChild with a null specification parameter.

Overrides:
readChild in class GoodsLocation
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

toXMLPartialImpl

protected void toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
                                java.lang.String[] fields)
                         throws javax.xml.stream.XMLStreamException
Partial writer, so that "remove" messages can be brief.

Overrides:
toXMLPartialImpl in class FreeColObject
Parameters:
out - The target stream.
fields - The fields to write.
Throws:
javax.xml.stream.XMLStreamException - If there are problems writing the stream.

readFromXMLPartialImpl

protected void readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
                               throws javax.xml.stream.XMLStreamException
Partial reader, so that "remove" messages can be brief.

Overrides:
readFromXMLPartialImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - If there are problems reading the stream.

toString

public java.lang.String toString()
Description copied from class: FreeColGameObject
Gets a string representation of the object.

Overrides:
toString in class FreeColGameObject
Returns:
A string representation of the object.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"indianSettlement".