|
|||||||||
| 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.IndianSettlement
public class IndianSettlement
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 java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.freecol.common.model.Location |
|---|
getId |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final int TALES_RADIUS
public static final java.lang.String OWNED_UNITS_TAG_NAME
public static final java.lang.String IS_VISITED_TAG_NAME
public static final java.lang.String ALARM_TAG_NAME
public static final java.lang.String MISSIONARY_TAG_NAME
public static final java.lang.String WANTED_GOODS_TAG_NAME
public static final int TRADE_MINIMUM_SIZE
public static final int TRADE_MINIMUM_PRICE
public static final int GOODS_BASE_PRICE
public static final int KEEP_RAW_MATERIAL
protected UnitType learnableSkill
protected GoodsType[] wantedGoods
protected java.util.Set<Player> spokenTo
protected java.util.ArrayList<Unit> ownedUnits
protected Unit missionary
protected int convertProgress
protected int lastTribute
private java.util.Map<Player,Tension> alarm
private final java.util.Comparator<GoodsType> wantedGoodsComparator
private final java.util.Comparator<Goods> exportGoodsComparator
| Constructor Detail |
|---|
protected IndianSettlement()
protected IndianSettlement(Game game,
Player owner,
java.lang.String name,
Tile tile)
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.
public IndianSettlement(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
IndianSettlement from an Element.
game - The Game in which this object belong.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public IndianSettlement(Game game,
java.lang.String id)
IndianSettlement
with the given ID. The object should later be
initialized by calling either
FreeColGameObject.readFromXML(XMLStreamReader).
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 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 getLastTribute()
public void setLastTribute(int lastTribute)
lastTribute - The new last tribute year.public Tension getAlarm(Player player)
player - The Player to get the alarm level for.
public void setAlarm(Player player,
Tension newAlarm)
newAlarm - The new alarm value.public void removeAlarm(Player player)
player - The Player to remove the alarm for.
protected boolean changeAlarm(Player player,
int amount)
player - The Player the alarm level changes wrt.amount - The amount to change the alarm by.
Tension.Level of the
settlement alarm changes as a result of this change.public java.lang.String getShortAlarmLevelMessageId(Player player)
player - The other Player.
public java.lang.String getAlarmLevelMessageId(Player player)
player - The other Player.
public boolean hasContactedSettlement(Player player)
player - The Player to check.
public boolean makeContactSettlement(Player player)
player - The Player making contact.
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 boolean hasSpokenToChief()
public boolean hasSpokenToChief(Player player)
player - The Player to check.
public void setSpokenToChief(Player player)
player - The visiting Player.public boolean allowContact(Unit unit)
unit - The Unit that proposes to contact this
settlement.
public void addOwnedUnit(Unit unit)
Unit to the list of units that belongs to this
IndianSettlement.
unit - The Unit to be added.public java.util.List<Unit> getOwnedUnits()
public java.util.Iterator<Unit> getOwnedUnitsIterator()
IndianSettlement is owning.
Iterator.public boolean removeOwnedUnit(Unit unit)
Unit to the list of units that
belongs to this IndianSettlement. Returns true if
the Unit was removed.
unit - The Unit to be removed from the
list of the units this IndianSettlement
owns.
boolean valuepublic UnitType getLearnableSkill()
public Unit getMissionary()
public void setMissionary(Unit missionary)
missionary - The missionary for this settlement.public void changeMissionary(Unit missionary)
missionary - The new missionary for this settlement.public Unit getMissionary(Player player)
player - The player purported to own the missionary
public int getConvertProgress()
public void setConvertProgress(int progress)
progress - The new convert progress status.public GoodsType[] getWantedGoods()
public void setWantedGoods(int index,
GoodsType type)
public void setLearnableSkill(UnitType skill)
skill - The new learnable skill for this Indian settlement.public boolean add(Locatable locatable)
Locatable to this Location.
add in interface Locationadd in class GoodsLocationlocatable - The Locatable to add to this Location.public Unit getDefendingUnit(Unit attacker)
Unit that is currently defending this
IndianSettlement.
getDefendingUnit in class Settlementattacker - The unit that would be attacking this
IndianSettlement.
Unit that has been chosen to defend
this IndianSettlement.public RandomRange getPlunderRange(Unit attacker)
getPlunderRange in class Settlementattacker - The Unit that takes the settlement.
RandomRange encapsulating the range of plunder
available.public int getGoodsCapacity()
getGoodsCapacity in class GoodsLocationpublic int getPriceToBuy(Goods goods)
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.
goods - The Goods to price.
public int getPriceToBuy(GoodsType type,
int amount)
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.
type - The type of Goods to price.amount - The amount of Goods to price.
private int getNormalGoodsPriceToBuy(GoodsType type,
int amount)
type - The type of goods for sale.amount - The amount of goods for sale.
protected int getWantedGoodsAmount(GoodsType type)
type - The GoodsType.
private int getMilitaryGoodsPriceToBuy(GoodsType type,
int amount)
type - The type of goods for sale.amount - The amount of goods for sale.
public int getPriceToSell(Goods goods)
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.
goods - The Goods to price.
public int getPriceToSell(GoodsType type,
int amount)
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.
type - The type of Goods to price.amount - The amount of Goods to price.
public boolean willSell(GoodsType type)
type - The GoodsType to consider.
public java.util.List<Goods> getSellGoods(int limit,
Unit unit)
limit - The maximum number of goods required.unit - The Unit that is trading.
public void tradeGoodsWithSetlement(IndianSettlement settlement)
settlement - public int getMaximumProduction(GoodsType goodsType)
goodsType - The type of goods to check.
public void updateWantedGoods()
GoodsContainer
is hidden from the clients.
private GoodsType goodsToMake()
GoodsType to manufacture, or null if
none suitable.public int getProductionOf(GoodsType type)
getProductionOf in class Settlementtype - The GoodsType to produce.
public int getSoL()
getSoL in class Settlementpublic boolean checkForNewMissionaryConvert()
public java.util.List<FreeColGameObject> disposeList()
disposeList in class Settlement
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 writeChildren(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
writeChildren in class GoodsLocationout - a XMLStreamWriter valueplayer - a Player valueshowAll - a boolean valuetoSavedGame - a boolean value
javax.xml.stream.XMLStreamException - if an error occurs
protected void readAttributes(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readAttributes in class Settlementin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void readChildren(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
UnitLocation
readChildren in class UnitLocationin - The XML input stream.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void readChild(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
GoodsLocation
readChild in class GoodsLocationin - The XML input stream.
javax.xml.stream.XMLStreamException - if an error occurs
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 java.lang.String toString()
FreeColGameObject
toString in class FreeColGameObjectpublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||