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.Settlement
              extended by net.sf.freecol.common.model.IndianSettlement
All Implemented Interfaces:
Location, Named, Ownable

public class IndianSettlement
extends Settlement

Represents an Indian settlement.


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Settlement
Settlement.SettlementType
 
Field Summary
static int ALARM_NEW_MISSIONARY
           
static int ALARM_RADIUS
           
static java.lang.String ALARM_TAG_NAME
           
static int ALARM_TILE_IN_USE
           
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.
static int MAX_CONVERT_DISTANCE
           
static int MAX_HORSES_PER_TURN
           
static java.lang.String MISSIONARY_TAG_NAME
           
static int MISSIONARY_TENSION
           
static java.lang.String OWNED_UNITS_TAG_NAME
           
static int TURNS_PER_TRIBUTE
           
static java.lang.String UNITS_TAG_NAME
           
static java.lang.String WANTED_GOODS_TAG_NAME
           
 
Fields inherited from class net.sf.freecol.common.model.Settlement
FOOD_CONSUMPTION, RADIUS
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
IndianSettlement(Game game, org.w3c.dom.Element e)
          Initiates a new IndianSettlement from an Element.
IndianSettlement(Game game, Player player, Tile tile, java.lang.String name, boolean isCapital, UnitType learnableSkill, java.util.Set<Player> isVisited, Unit missionary)
          The constructor to use.
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
 void 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 contact with this settlement? The unit must be from a nation that has already contacted, or in the first instance must be arriving by land (apparently including ships in adjacent ports in Col1).
 boolean canAdd(Locatable locatable)
          Checks whether or not the specified locatable may be added to this Location.
 boolean checkForNewMissionaryConvert()
           
 boolean contains(Locatable locatable)
          Checks if this Location contains the specified Locatable.
 void createGoodsContainer()
          Creates the GoodsContainer.
 void dispose()
          Disposes this settlement and removes its claims to adjacent tiles.
 void equipBraves()
          Equips braves with horses and muskets.
 java.util.Map<Player,Tension> getAlarm()
          Returns the alarm Map.
 Tension getAlarm(Player player)
          Gets the alarm level towards the given player.
 java.lang.String getAlarmLevelMessage(Player player)
          Gets the ID of the alarm message associated with the alarm level of this player.
 int getBonusMultiplier()
          Get general bonus multiplier.
 Colony getColony()
          An Indian settlement is no colony.
 Unit getDefendingUnit(Unit attacker)
          Gets the Unit that is currently defending this IndianSettlement.
 Unit getFirstUnit()
           
 int getGeneratedUnitCount()
          Provide some variation in unit count for different types of IndianSettlement.
 Unit getLastUnit()
           
 UnitType getLearnableSkill()
          Returns the skill that can be learned at this settlement.
 int getMaximumProduction(GoodsType goodsType)
          Gets the maximum possible production of the given type of goods.
 Unit getMissionary()
          Returns the missionary from this settlement if there is one or null if there is none.
 java.util.Iterator<Unit> getOwnedUnitsIterator()
          Gets an iterator over all the units this IndianSettlement is owning.
 int getPrice(Goods goods)
          Gets the amount of gold this IndianSettlment is willing to pay for the given Goods.
 int getPrice(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 pay for the given Goods.
 int getPriceToSell(GoodsType type, int amount)
          Gets the amount of gold this IndianSettlment is willing to pay for the given Goods.
 int getProductionOf(GoodsType type)
          Returns the production of the given type of goods.
 java.lang.String getResponseToMissionaryAttempt(Tension.Level tension, java.lang.String success)
          Gets the response to an attempt to create a mission
 java.util.List<Goods> getSellGoods()
          Returns an array with goods to sell
 int getTribute(Player player)
          Returns the amount of gold this settlement pays as a tribute.
 Settlement.SettlementType getTypeOfSettlement()
          Gets the kind of Indian settlement.
 int getUnitCount()
          Returns the amount of Units at this Location.
 java.util.Iterator<Unit> getUnitIterator()
          Gets a Iterator of every Unit directly located on this Location.
 java.util.List<Unit> getUnitList()
          Returns a list containing all the Units present at this Location.
 GoodsType[] getWantedGoods()
           
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean hasBeenVisited()
          Returns true if a European player has visited this settlement to speak with the chief.
 boolean hasBeenVisited(Player player)
          Returns true if a the given player has visited this settlement to speak with the chief.
 void modifyAlarm(Player player, int addToAlarm)
          Modifies the alarm level towards the given player.
 void newTurn()
           
 void propagatedAlarm(Player player, int addToAlarm)
          Propagates the tension felt towards a given nation from the tribe down to each settlement that has already met that nation.
 void remove(Locatable locatable)
          Removes a Locatable from this Location.
 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 setLearnableSkill(UnitType skill)
          Sets the learnable skill for this Indian settlement.
 void setMissionary(Unit missionary)
          Sets the missionary for this settlement.
 void setVisited(Player player)
          Sets the visited status of this settlement to true, indicating that a European has had a chat with the chief.
 void setWantedGoods(int index, GoodsType type)
           
 java.lang.String toString()
          Returns a string representation of the object.
 void tradeGoodsWithSetlement(IndianSettlement settlement)
          Allows spread of horses and arms between settlements
 void updateWantedGoods()
          Updates the variable wantedGoods.
 
Methods inherited from class net.sf.freecol.common.model.Settlement
addGoods, addGoods, canBuildEquipment, claimTile, getCompactGoods, getFeatureContainer, getFoodConsumption, getFoodConsumptionByType, getFoodCount, getGoodsContainer, getGoodsCount, getGoodsIterator, getLineOfSight, getName, getOwner, getRadius, getTile, getTile, isCapital, placeSettlement, removeGoods, removeGoods, removeGoods, setCapital, setName, setOwner
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addToRemoveElement, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toXML, updateFreeColGameObject, updateID
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.common.model.Location
getId
 

Field Detail

MISSIONARY_TENSION

public static final int MISSIONARY_TENSION
See Also:
Constant Field Values

MAX_CONVERT_DISTANCE

public static final int MAX_CONVERT_DISTANCE
See Also:
Constant Field Values

TURNS_PER_TRIBUTE

public static final int TURNS_PER_TRIBUTE
See Also:
Constant Field Values

ALARM_RADIUS

public static final int ALARM_RADIUS
See Also:
Constant Field Values

ALARM_TILE_IN_USE

public static final int ALARM_TILE_IN_USE
See Also:
Constant Field Values

ALARM_NEW_MISSIONARY

public static final int ALARM_NEW_MISSIONARY
See Also:
Constant Field Values

MAX_HORSES_PER_TURN

public static final int MAX_HORSES_PER_TURN
See Also:
Constant Field Values

UNITS_TAG_NAME

public static final java.lang.String UNITS_TAG_NAME
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

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
Constructor Detail

IndianSettlement

public IndianSettlement(Game game,
                        Player player,
                        Tile tile,
                        java.lang.String name,
                        boolean isCapital,
                        UnitType learnableSkill,
                        java.util.Set<Player> isVisited,
                        Unit missionary)
The constructor to use.

Parameters:
game - The Game in which this object belong.
player - The Player owning this settlement.
name - The name for this settlement.
tile - The location of the IndianSettlement.
isCapital - True if settlement is tribe's capital
learnableSkill - The skill that can be learned by Europeans at this settlement.
isVisited - Indicates if any European scout has asked to speak with the chief.
missionary - The missionary in this settlement (or null).
Throws:
java.lang.IllegalArgumentException - if an invalid tribe or kind is given

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,
                        org.w3c.dom.Element e)
Initiates a new IndianSettlement from an Element.

Parameters:
game - The Game in which this object belong.
e - An XML-element that will be used to initialize this object.

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) or FreeColObject.readFromXMLElement(Element).

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

getAlarm

public java.util.Map<Player,Tension> getAlarm()
Returns the alarm Map.

Returns:
the alarm Map.

getTribute

public int getTribute(Player player)
Returns the amount of gold this settlement pays as a tribute.

Parameters:
player - a Player value
Returns:
an int value

modifyAlarm

public void modifyAlarm(Player player,
                        int addToAlarm)
Modifies the alarm level towards the given player.

Parameters:
player - The Player.
addToAlarm - The amount to add to the current alarm level.

propagatedAlarm

public void propagatedAlarm(Player player,
                            int addToAlarm)
Propagates the tension felt towards a given nation from the tribe down to each settlement that has already met that nation.

Parameters:
player - The Player towards whom the alarm is felt.
addToAlarm - The amount to add to the current alarm level.

setAlarm

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

Parameters:
player - The Player.
newAlarm - The new alarm value.

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:
An object representing the alarm level.

getAlarmLevelMessage

public java.lang.String getAlarmLevelMessage(Player player)
Gets the ID of the alarm message associated with the alarm level of this player.

Parameters:
player - The other player.
Returns:
The ID of an alarm level message.

hasBeenVisited

public boolean hasBeenVisited()
Returns true if a European player has visited this settlement to speak with the chief.

Returns:
true if a European player has visited this settlement to speak with the chief.

allowContact

public boolean allowContact(Unit unit)
Is a unit permitted to contact with this settlement? The unit must be from a nation that has already contacted, or in the first instance must be arriving by land (apparently including ships in adjacent ports in Col1).

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

hasBeenVisited

public boolean hasBeenVisited(Player player)
Returns true if a the given player has visited this settlement to speak with the chief.

Parameters:
player - The player to check if has visited the settlement
Returns:
true If a European player has visited this settlement to speak with the chief.

setVisited

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

Parameters:
player - a Player value

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.

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()
Returns the missionary from this settlement if there is one or null if there is none.

Returns:
The missionary from this settlement if there is one 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.

getResponseToMissionaryAttempt

public java.lang.String getResponseToMissionaryAttempt(Tension.Level tension,
                                                       java.lang.String success)
Gets the response to an attempt to create a mission

Returns:
response

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.

getTypeOfSettlement

public Settlement.SettlementType getTypeOfSettlement()
Gets the kind of Indian settlement.


add

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

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

remove

public void remove(Locatable locatable)
Removes a Locatable from this Location.

Specified by:
remove in interface Location
Specified by:
remove in class Settlement
Parameters:
locatable - The Locatable to remove from this Location.

getUnitCount

public int getUnitCount()
Returns the amount of Units at this Location.

Specified by:
getUnitCount in interface Location
Specified by:
getUnitCount in class Settlement
Returns:
The amount of Units at this Location.

getUnitList

public java.util.List<Unit> getUnitList()
Description copied from interface: Location
Returns a list containing all the Units present at this Location.

Returns:
a list containing the Units present at this location.

getUnitIterator

public java.util.Iterator<Unit> getUnitIterator()
Description copied from interface: Location
Gets a Iterator of every Unit directly located on this Location.

Returns:
The Iterator.

getFirstUnit

public Unit getFirstUnit()

getLastUnit

public Unit getLastUnit()

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.

getPrice

public int getPrice(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.

getPrice

public int getPrice(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.

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

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 variable wantedGoods.

It is only meaningful to call this method from the server, since the settlement's GoodsContainer is hidden from the clients.


getBonusMultiplier

public int getBonusMultiplier()
Get general bonus multiplier. This is >1 if this is a LONGHOUSE, CITY or a capital.

Returns:
The bonus multiplier.

getGeneratedUnitCount

public int getGeneratedUnitCount()
Provide some variation in unit count for different types of IndianSettlement.

Returns:
The number of units to generate for this settlement.

contains

public boolean contains(Locatable locatable)
Description copied from interface: Location
Checks if this Location contains the specified Locatable.

Specified by:
contains in interface Location
Specified by:
contains in class Settlement
Parameters:
locatable - The Locatable to test the presence of.
Returns:
  • true if the specified Locatable is on this Location and
  • false otherwise.

canAdd

public boolean canAdd(Locatable locatable)
Description copied from interface: Location
Checks whether or not the specified locatable may be added to this Location.

Specified by:
canAdd in interface Location
Specified by:
canAdd in class Settlement
Parameters:
locatable - The Locatable to add.
Returns:
The result.

getProductionOf

public int getProductionOf(GoodsType type)
Description copied from class: Settlement
Returns the production of the given type of goods.

Specified by:
getProductionOf in class Settlement
Parameters:
type - The type of goods to get the production for.
Returns:
The production of the given type of goods the current turn by the Settlement

newTurn

public void newTurn()
Specified by:
newTurn in class Settlement

checkForNewMissionaryConvert

public boolean checkForNewMissionaryConvert()

equipBraves

public void equipBraves()
Equips braves with horses and muskets. Keeps some for the settlement defense


dispose

public void dispose()
Disposes this settlement and removes its claims to adjacent tiles.

Overrides:
dispose in class Settlement

createGoodsContainer

public void createGoodsContainer()
Creates the GoodsContainer.

DO NOT USE OTHER THAN IN FreeColServer.loadGame(net.sf.freecol.common.io.FreeColSavegameFile): Only for compatibility when loading savegames with pre-0.0.3 protocols.


getXMLElementTagName

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

Returns:
"indianSettlement".

getColony

public Colony getColony()
An Indian settlement is no colony.

Returns:
null

getSellGoods

public java.util.List<Goods> getSellGoods()
Returns an array with goods to sell


getPriceToSell

public int getPriceToSell(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.

getPriceToSell

public int getPriceToSell(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.

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

toString

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

Overrides:
toString in class FreeColGameObject
Returns:
The String

tradeGoodsWithSetlement

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

Parameters:
settlement -