|
|||||||||
| 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.Player
public class Player
Represents a player. The player can be either a human player or an
AI-player.
In addition to storing the name, nation e.t.c. of the player, it also stores
various defaults for the player. One example of this is the
entry location.
| Nested Class Summary | |
|---|---|
class |
Player.ActivePredicate
A predicate for determining active units. |
class |
Player.GoingToPredicate
A predicate for determining units going somewhere. |
static class |
Player.NoClaimReason
A variety of reasons why a tile can not be claimed, either to found a settlement or just to be used by one, including the double negative NONE == "no reason" case. |
static class |
Player.PlayerType
The type of player. |
static class |
Player.Stance
Constants for describing the stance towards a player. |
class |
Player.UnitIterator
An Iterator of Units that can be made active. |
class |
Player.UnitPredicate
A predicate that can be applied to a unit. |
| Field Summary | |
|---|---|
protected boolean |
admin
Is this player an admin? |
protected boolean |
ai
True if this is an AI player. |
protected java.util.Set<FoundingFather> |
allFathers
The founding fathers in this Player's congress. |
static java.lang.String |
ASSIGN_SETTLEMENT_NAME
|
protected boolean |
attackedByPrivateers
True if player has been attacked by privateers. |
private java.lang.Object |
canSeeLock
|
private boolean[][] |
canSeeTiles
|
protected java.lang.String |
capitalName
|
protected FoundingFather |
currentFather
Current founding father being recruited. |
protected boolean |
dead
Is this player dead? |
protected Location |
entryLocation
|
protected Europe |
europe
The European port/location for this player. |
protected FeatureContainer |
featureContainer
|
private static java.lang.String |
FOUNDING_FATHER_TAG
The XML tag name for the set of founding fathers. |
protected int |
gold
The amount of gold this player owns. |
static int |
GOLD_NOT_ACCOUNTED
|
protected HighSeas |
highSeas
The HighSeas is a Location that enables Units to travel between the New World and one or several European Ports. |
protected java.util.List<HistoryEvent> |
history
The history events occuring with this player. |
protected int |
immigration
The number of immigration points. |
protected int |
immigrationRequired
|
protected java.lang.String |
independentNationName
The name of this player as an independent nation. |
protected java.util.HashMap<java.lang.String,LastSale> |
lastSales
The last-sale data. |
protected int |
liberty
The number of liberty points. |
private static java.util.logging.Logger |
logger
|
protected Market |
market
The market for Europe. |
private int |
maximumFoodConsumption
|
protected java.util.List<ModelMessage> |
modelMessages
Model messages for this player. |
protected Monarch |
monarch
The monarch for this player. |
protected java.lang.String |
name
The name of this player. |
protected java.util.HashMap<java.lang.String,java.lang.Integer> |
nameIndex
Indices of largest used region name by type. |
protected java.lang.String |
nationID
The nation ID of this player, e.g. |
protected NationType |
nationType
The NationType of this player. |
protected java.lang.String |
newLandName
The name this player uses for the New World. |
private Player.UnitIterator |
nextActiveUnitIterator
|
private Player.UnitIterator |
nextGoingToUnitIterator
|
private static java.lang.String |
OFFERED_FATHER_TAG
The XML tag name for the set of offered founding fathers. |
protected java.util.List<FoundingFather> |
offeredFathers
The offered founding fathers. |
protected int |
oldSoL
SoL from last turn. |
static java.util.Comparator<Player> |
playerComparator
|
protected Player.PlayerType |
playerType
|
protected boolean |
ready
|
protected int |
score
The current score of this player. |
static int |
SCORE_SETTLEMENT_DESTROYED
|
protected java.lang.String |
settlementFallback
|
protected java.util.List<java.lang.String> |
settlementNames
A cache of settlement names, a capital for natives, and a fallback settlement name prefix. |
protected java.util.List<Settlement> |
settlements
The Settlements this player owns. |
protected java.util.Map<java.lang.String,Player.Stance> |
stance
Stores the stance towards the other players. |
private static java.lang.String |
STANCE_TAG
The XML tag name for the stance array. |
protected int |
tax
The current tax rate for this player. |
protected java.util.Map<Player,Tension> |
tension
Only used by AI - stores the tension levels, 0-1000 with 1000 maximum hostility. |
private static java.lang.String |
TENSION_TAG
The XML tag name for the tension array. |
protected java.util.List<TradeRoute> |
tradeRoutes
Trade routes of this player. |
protected java.util.Map<java.lang.String,Unit> |
units
The Units this player owns. |
static java.lang.String |
UNKNOWN_ENEMY
The name of the unknown enemy. |
| 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 |
Player()
Constructor for ServerPlayer. |
protected |
Player(Game game)
Constructor for ServerPlayer. |
|
Player(Game game,
org.w3c.dom.Element e)
Initiates a new Player from an Element and
registers this Player at the specified game. |
|
Player(Game game,
java.lang.String id)
Initiates a new Player with the given ID. |
|
Player(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new Player from an Element and
registers this Player at the specified game. |
| Method Summary | |
|---|---|
void |
addFather(FoundingFather father)
Add a founding father to the congress. |
void |
addHistory(HistoryEvent event)
Add a HistoryEvent to this player. |
void |
addModelMessage(ModelMessage modelMessage)
Adds a ModelMessage for this player. |
void |
addSettlement(Settlement settlement)
Adds a given settlement to this player's list of settlements. |
boolean |
atWarWith(Player player)
Is this player at war with the specified one. |
boolean |
canAcquireForImprovement(Tile tile)
Can a tile be acquired from its owners and used for an improvement? Slightly weakens canClaimForImprovement to allow for purchase and/or stealing. |
boolean |
canBuildColonies()
Checks if this Player can build colonies. |
boolean |
canClaimForImprovement(Tile tile)
Can the ownership of this tile be claimed for the purposes of making an improvement. |
boolean |
canClaimForSettlement(Tile tile)
Checks if a tile can be claimed for use by a settlement. |
Player.NoClaimReason |
canClaimForSettlementReason(Tile tile)
The test for whether a tile can be freely claimed by a player settlement (freely => not by purchase or stealing). |
private boolean |
canClaimFreeCenterTile(Tile tile)
Is this tile claimable for a colony center tile under the special provisions of the model.option.buildOnNativeLand option. |
boolean |
canClaimToFoundSettlement(Tile tile)
Can a tile be claimed to found a settlement on? |
Player.NoClaimReason |
canClaimToFoundSettlementReason(Tile tile)
Can a tile be claimed to found a settlement on? Almost the same as canClaimForSettlement but there is an extra requirement that the tile be of a settleable type, and some relaxations that allow free center tile acquisition |
boolean |
canHaveFoundingFathers()
Checks if this Player can get founding fathers. |
boolean |
canMoveToEurope()
Checks if this Player can move units to
Europe. |
boolean |
canOwnTile(Tile tile)
Can a tile be owned by this player? |
private Player.NoClaimReason |
canOwnTileReason(Tile tile)
Can a tile be owned by this player? This is a test of basic practicality and does not consider the full complexity of tile ownership issues. |
boolean |
canRecruitUnits()
Checks if this Player can recruit units by producing
immigration. |
boolean |
canSee(Tile tile)
Checks if this Player can see the given Tile. |
boolean |
canTrade(Goods goods)
Returns true if type of goods can be traded in Europe. |
boolean |
canTrade(Goods goods,
Market.Access access)
Returns true if type of goods can be traded at specified place |
boolean |
canTrade(GoodsType type)
Returns true if type of goods can be traded in Europe. |
boolean |
canTrade(GoodsType type,
Market.Access access)
Returns true if type of goods can be traded at specified place. |
boolean |
checkEmigrate()
Checks to see whether or not a colonist can emigrate, and does so if possible. |
boolean |
checkGold(int amount)
Checks if the player has enough gold to make a purchase. |
void |
clearModelMessages()
Removes all the model messages for this player. |
void |
clearOfferedFathers()
Clear the set of offered fathers. |
void |
divertModelMessages(FreeColGameObject source,
FreeColGameObject newSource)
Sometimes an event causes the source (and display) fields in an accumulated model message to become invalid (e.g. |
boolean |
equals(Player o)
Checks if the given Player equals this object. |
int |
getArrears(Goods goods)
Returns the arrears due for a type of goods. |
int |
getArrears(GoodsType type)
Returns the arrears due for a type of goods. |
boolean |
getAttackedByPrivateers()
Returns whether this player has been attacked by privateers. |
java.lang.String |
getCapitalName()
Gets the name of this players capital. |
java.util.List<Colony> |
getColonies()
Gets a fresh list of all colonies this player owns. |
int |
getColoniesPopulation()
Returns the sum of units currently working in the colonies of this player. |
Colony |
getColony(java.lang.String name)
Returns the Colony with the given name. |
int |
getColonyValue(Tile t)
Gets the value of building a Colony on the given tile. |
FoundingFather |
getCurrentFather()
Gets the founding father this player is working
towards. |
boolean |
getDead()
Get the player death state. |
java.lang.String |
getDisplayName()
Gets the name to display for this player. |
Location |
getEntryLocation()
Gets the default Location where the units arriving from
Europe will be put. |
Europe |
getEurope()
Returns the europe object that this player has. |
java.lang.String |
getEuropeNameKey()
Describe getEuropeName method here. |
int |
getFatherCount()
Returns the number of founding fathers in this players congress. |
java.util.Set<FoundingFather> |
getFathers()
Returns the founding fathers in this player's congress. |
FeatureContainer |
getFeatureContainer()
Get the FeatureContainer value. |
int |
getGold()
Returns the amount of gold that this player has. |
HighSeas |
getHighSeas()
Get the HighSeas value. |
java.util.List<HistoryEvent> |
getHistory()
Get the History value. |
int |
getImmigration()
Gets the number of immigration this player possess. |
int |
getImmigrationRequired()
Gets the number of immigration required to cause a new colonist to emigrate. |
int |
getIncomeAfterTaxes(GoodsType goodsType)
Returns the current incomeAfterTaxes. |
int |
getIncomeBeforeTaxes(GoodsType goodsType)
Returns the current incomeBeforeTaxes. |
java.lang.String |
getIndependentNationName()
Get the IndependentNationName value. |
IndianSettlement |
getIndianSettlement(java.lang.String name)
Returns the IndianSettlement with the given name. |
java.util.List<IndianSettlement> |
getIndianSettlements()
Returns a list of all IndianSettlements this player owns. |
java.util.List<IndianSettlement> |
getIndianSettlementsWithMission(Player other)
Returns a list of all IndianSettlements this player owns that have missions, optionally owned by a specific player. |
int |
getLandPrice(Tile tile)
Returns the price of the given land. |
LastSale |
getLastSale(Location where,
GoodsType what)
Gets the current sales data for a location and goods type. |
java.lang.String |
getLastSaleString(Location where,
GoodsType what)
Gets the last sale price for a location and goods type as a string. |
int |
getLiberty()
Gets the current amount of liberty this Player has. |
int |
getLibertyProductionNextTurn()
Returns how many total liberty will be produced if no colonies are lost and nothing unexpected happens. |
Market |
getMarket()
Returns this Player's Market. |
StringTemplate |
getMarketName()
What is the name of the player's market? Following a declaration of independence we are assumed to trade broadly with any European market rather than a specific port. |
int |
getMaximumFoodConsumption()
Returns the maximum food consumption of any unit types available to this player. |
java.util.List<ModelMessage> |
getModelMessages()
Returns all ModelMessages for this player. |
java.util.Set<Modifier> |
getModifierSet(java.lang.String id)
Get the modifier set for a given id from the feature container. |
java.util.Set<Modifier> |
getModifierSet(java.lang.String id,
FreeColGameObjectType type)
Get the modifier set for a given id and type from the feature container. |
Monarch |
getMonarch()
Returns the monarch object this player has. |
Goods |
getMostValuableGoods()
Returns the most valuable goods available in one of the player's colonies for the purposes of choosing a threat-to-boycott. |
java.lang.String |
getName()
Returns the name of this player. |
int |
getNameIndex(java.lang.String key)
Gets the name index for a given key. |
java.lang.String |
getNameKey()
|
Nation |
getNation()
Return this Player's nation. |
java.lang.String |
getNationID()
Return the ID of this Player's nation. |
StringTemplate |
getNationName()
Returns the nation of this player as a String. |
java.lang.String |
getNationNameKey()
Gets a nation name suitable for use in message IDs. |
NationType |
getNationType()
Returns the nation type of this player. |
java.lang.String |
getNewLandName()
Gets the name this player has chosen for the new land. |
java.util.List<ModelMessage> |
getNewModelMessages()
Returns all new ModelMessages for this player. |
Unit |
getNextActiveUnit()
Gets a new active unit. |
Unit |
getNextGoingToUnit()
Gets a new going_to unit. |
int |
getNumberOfKingLandUnits()
Gets the number of King's land units. |
int |
getNumberOfSettlements()
Get the number of settlements. |
java.util.List<FoundingFather> |
getOfferedFathers()
Gets the set of offered fathers for this player. |
int |
getOutpostValue(Tile t)
Calculates the value of an outpost-type colony at this tile. |
Player.PlayerType |
getPlayerType()
Returns the type of this player. |
int |
getPrice(AbstractUnit au)
Gets the price to this player for a proposed unit. |
java.util.List<Player> |
getRebels()
Gets a list of the players in rebellion against this (REF) player. |
int |
getRecruitPrice()
Gets the price for a recruit in europe. |
Player |
getREFPlayer()
Gets the Player controlling the "Royal Expeditionary
Force" for this player. |
int |
getRemainingFoundingFatherCost()
Gets the number of liberty points needed to recruit the next founding father. |
java.lang.String |
getRulerNameKey()
Get the RulerName value. |
int |
getSales(GoodsType goodsType)
Returns the current sales. |
int |
getScore()
Returns the current score of the player. |
Settlement |
getSettlement(java.lang.String name)
Find a Settlement by name. |
java.lang.String |
getSettlementName()
Gets a settlement name suitable for this player. |
java.util.List<Settlement> |
getSettlements()
Returns a list of all Settlements this player owns. |
int |
getSoL()
Gets the total percentage of rebels in all this player's colonies. |
java.util.List<Colony> |
getSortedColonies(java.util.Comparator<Colony> c)
Returns a sorted list of all Colonies this player owns. |
Player.Stance |
getStance(Player player)
Returns the stance towards a given player. |
int |
getTax()
Returns the current tax. |
Tension |
getTension(Player player)
Gets the hostility this player has against the given player. |
int |
getTotalFoundingFatherCost()
Returns how many liberty points in total are needed to earn the Founding Father we are trying to recruit. |
java.util.List<TradeRoute> |
getTradeRoutes()
Get the TradeRoutes value. |
Unit |
getUnit(java.lang.String id)
Get the Unit value. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets an Iterator containing all the units this player
owns. |
java.util.List<Unit> |
getUnits()
|
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
hasAbility(java.lang.String ability)
Does a player have a particular ability. |
boolean |
hasContacted(Player player)
Returns whether this player has met with the Player if the
given nation. |
boolean |
hasContactedEuropeans()
Returns whether this player has met with any Europeans at all. |
boolean |
hasContactedIndians()
Returns whether this player has met with any natives at all. |
boolean |
hasExplored(Tile tile)
Checks if this Player has explored the given
Tile. |
boolean |
hasFather(FoundingFather someFather)
Determines whether this player has a certain Founding father. |
boolean |
hasManOfWar()
Checks if this player has a single Man-of-War. |
boolean |
hasNextActiveUnit()
Checks if a new active unit can be made active. |
boolean |
hasNextGoingToUnit()
Checks if a new active unit can be made active. |
boolean |
hasSettlement(Settlement s)
Checks if this player owns the given Settlement. |
boolean |
hasTraded(GoodsType goodsType)
Has a type of goods been traded? |
boolean |
hasVisited(IndianSettlement settlement)
Has a player visited a native settlement? This is needed by the native report and settlement popup to clarify whether the skill at the settlement is null because it has been depleted, or because we just have not found out what it is yet. |
private boolean |
hasZeroSettlements()
The second and third cases of buildOnNative land need to test if the player has no settlements yet. |
void |
incrementImmigration(int amount)
|
void |
incrementLiberty(int amount)
Adds to the current amount of liberty this player has. |
void |
initializeHighSeas()
Initialize the highSeas. |
void |
installSettlementNames(java.util.List<java.lang.String> names,
java.util.Random random)
Installs suitable settlement names (and the capital if native) into the player name cache. |
void |
invalidateCanSeeTiles()
Forces an update of the canSeeTiles. |
boolean |
isAdmin()
Checks if this player is an admin. |
boolean |
isAI()
Determines whether this player is an AI player. |
boolean |
isAtWar()
Checks whether this player is at war with any other player. |
boolean |
isDead()
Checks if this player is dead. |
boolean |
isEuropean()
Checks if this player is european. |
boolean |
isIndian()
Checks if this player is indian. |
boolean |
isNewLandNamed()
Returns true if the player already selected a new name for the discovered land. |
boolean |
isReady()
Checks if this Player is ready to start the game. |
boolean |
isREF()
Checks if this player is a "royal expeditionary force. |
boolean |
isUndead()
Checks if this player is undead. |
boolean |
isUnknownEnemy()
Is this player the unknown enemy? |
boolean |
isWorkForREF()
Checks if this player has work to do if it is a REF-player. |
private boolean[][] |
makeCanSeeTiles(Map map)
Builds a canSeeTiles array. |
static void |
makeContact(Player player1,
Player player2)
Set this player as having made initial contact with another player. |
int |
modifyGold(int amount)
Modifies the amount of gold that this player has. |
void |
modifyIncomeAfterTaxes(GoodsType goodsType,
int amount)
Modifies the current incomeAfterTaxes. |
void |
modifyIncomeBeforeTaxes(GoodsType goodsType,
int amount)
Modifies the current incomeBeforeTaxes. |
void |
modifySales(GoodsType goodsType,
int amount)
Modifies the current sales. |
void |
modifyScore(int value)
Modifies the score of the player by the given value. |
java.util.List<FreeColGameObject> |
modifyTension(Player player,
int addToTension)
Modifies the hostility against the given player. |
java.util.List<FreeColGameObject> |
modifyTension(Player player,
int addToTension,
Settlement origin)
Modifies the hostility against the given player. |
boolean |
owns(Ownable ownable)
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
protected void |
readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
Partial reader for players, so that simple updates to fields such as gold can be brief. |
protected boolean |
recalculateBellsBonus()
Recalculate bells bonus when tax changes. |
void |
reduceImmigration()
Sets the number of immigration this player possess. |
void |
reinitialiseMarket()
Resets this Player's Market. |
void |
removeModelMessages()
Removes all undisplayed model messages for this player. |
void |
removeSettlement(Settlement settlement)
Removes the given settlement from this player's list of settlements. |
void |
removeTension(Player player)
Removes all tension with respect to a given player. |
void |
removeUnit(Unit oldUnit)
Remove Unit. |
private boolean |
resetCanSeeTiles()
Resets this player's "can see"-tiles. |
void |
resetIterators()
Reset the player iterators ready for a new turn. |
void |
saveSale(LastSale sale)
Saves a LastSale record. |
void |
setAI(boolean ai)
Sets whether this player is an AI player. |
void |
setAttackedByPrivateers(boolean attacked)
Sets whether this player has been attacked by privateers. |
void |
setCurrentFather(FoundingFather someFather)
Sets this players liberty bell production to work towards recruiting father to its congress. |
void |
setDead(boolean dead)
Sets this player to be dead or not. |
void |
setEntryLocation(Location entryLocation)
Sets the Location where the units arriving from
Europe will be put as a default. |
void |
setEurope(Europe europe)
Set the europe object for a player. |
void |
setExplored(Tile tile)
Sets the given tile to be explored by this player and updates the player's information about the tile. |
void |
setExplored(Unit unit)
Sets the tiles within the given Unit's line of sight to
be explored by this player. |
void |
setFeatureContainer(FeatureContainer newFeatureContainer)
Set the FeatureContainer value. |
void |
setGold(int newGold)
Set the amount of gold that this player has. |
void |
setImmigration(int immigration)
Sets the number of immigration this player possess. |
void |
setImmigrationRequired(int immigrationRequired)
Sets the number of immigration required to cause a new colonist to emigrate. |
void |
setIndependentNationName(java.lang.String newIndependentNationName)
Set the IndependentNationName value. |
void |
setLiberty(int liberty)
Sets the current amount of liberty this player has. |
void |
setMonarch(Monarch monarch)
Sets the monarch object this player has. |
void |
setName(java.lang.String newName)
Set the Name value. |
void |
setNameIndex(java.lang.String key,
int value)
Gets the name index for a given key. |
void |
setNation(Nation newNation)
Sets the nation for this player. |
void |
setNationType(NationType newNationType)
Sets the nation type of this player. |
void |
setNewLandName(java.lang.String newLandName)
Sets the name this player uses for the new land. |
boolean |
setNextActiveUnit(Unit unit)
Sets a new active unit. |
void |
setOfferedFathers(java.util.List<FoundingFather> fathers)
Sets the set of offered fathers. |
void |
setPlayerType(Player.PlayerType type)
Sets the player type. |
void |
setReady(boolean ready)
Sets this Player to be ready/not ready for starting the
game. |
void |
setScore(int newScore)
Set the current score of the player. |
boolean |
setStance(Player player,
Player.Stance newStance)
Sets the stance towards a given player to one of WAR, CEASE_FIRE, PEACE and ALLIANCE. |
void |
setTax(int amount)
Sets the current tax |
void |
setTension(Player player,
Tension newTension)
Sets the hostility against the given player. |
void |
setTradeRoutes(java.util.List<TradeRoute> newTradeRoutes)
Set the players trade routes. |
void |
setUnit(Unit newUnit)
Set the Unit value. |
java.lang.String |
toString()
Returns the name of this player. |
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 for players, so that simple updates to fields such as gold can be brief. |
void |
updateImmigrationRequired()
Updates the amount of immigration needed to emigrate a Unit
from Europe. |
protected void |
writeAttributes(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
|
protected void |
writeChildren(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
|
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
dispose, disposeList, 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 |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final int GOLD_NOT_ACCOUNTED
public static final int SCORE_SETTLEMENT_DESTROYED
public static final java.lang.String ASSIGN_SETTLEMENT_NAME
private static final java.lang.String FOUNDING_FATHER_TAG
private static final java.lang.String OFFERED_FATHER_TAG
private static final java.lang.String STANCE_TAG
private static final java.lang.String TENSION_TAG
public static final java.lang.String UNKNOWN_ENEMY
protected java.util.Map<Player,Tension> tension
protected java.util.Map<java.lang.String,Player.Stance> stance
protected java.lang.String name
protected java.lang.String independentNationName
protected NationType nationType
protected java.lang.String nationID
protected java.lang.String newLandName
protected boolean admin
protected int score
protected int gold
protected int immigration
protected int liberty
protected Market market
protected Europe europe
protected Monarch monarch
protected boolean ready
protected boolean ai
protected boolean attackedByPrivateers
protected int oldSoL
protected boolean dead
protected final java.util.Set<FoundingFather> allFathers
protected FoundingFather currentFather
protected final java.util.List<FoundingFather> offeredFathers
protected int tax
protected Player.PlayerType playerType
protected int immigrationRequired
protected Location entryLocation
protected final java.util.Map<java.lang.String,Unit> units
protected final java.util.List<Settlement> settlements
protected final java.util.List<TradeRoute> tradeRoutes
protected final java.util.List<ModelMessage> modelMessages
protected final java.util.List<HistoryEvent> history
protected java.util.HashMap<java.lang.String,LastSale> lastSales
protected final java.util.HashMap<java.lang.String,java.lang.Integer> nameIndex
private boolean[][] canSeeTiles
private final java.lang.Object canSeeLock
protected FeatureContainer featureContainer
private int maximumFoodConsumption
private final Player.UnitIterator nextActiveUnitIterator
private final Player.UnitIterator nextGoingToUnitIterator
protected HighSeas highSeas
protected java.util.List<java.lang.String> settlementNames
protected java.lang.String capitalName
protected java.lang.String settlementFallback
public static final java.util.Comparator<Player> playerComparator
| Constructor Detail |
|---|
protected Player()
protected Player(Game game)
public Player(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
Player from an Element and
registers this Player at the specified game.
game - The Game this object belongs to.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
public Player(Game game,
org.w3c.dom.Element e)
Player from an Element and
registers this Player at the specified game.
game - The Game this object belongs to.e - An XML-element that will be used to initialize this object.
public Player(Game game,
java.lang.String id)
Player with the given ID. The object
should later be initialized by calling either FreeColGameObject.readFromXML(XMLStreamReader) or FreeColObject.readFromXMLElement(Element).
game - The Game in which this object belong.id - The unique identifier for this object.| Method Detail |
|---|
public final FeatureContainer getFeatureContainer()
FeatureContainer value.
FeatureContainer valuepublic final void setFeatureContainer(FeatureContainer newFeatureContainer)
FeatureContainer value.
newFeatureContainer - The new FeatureContainer value.public java.util.Set<Modifier> getModifierSet(java.lang.String id)
id - The id to look up.
public java.util.Set<Modifier> getModifierSet(java.lang.String id,
FreeColGameObjectType type)
id - The id to look up.type - The associated type.
public boolean hasAbility(java.lang.String ability)
hasAbility in class FreeColObjectability - The ability to test.
public void addModelMessage(ModelMessage modelMessage)
ModelMessage for this player.
modelMessage - The ModelMessage.public java.util.List<ModelMessage> getModelMessages()
public java.util.List<ModelMessage> getNewModelMessages()
public void removeModelMessages()
public void clearModelMessages()
public void divertModelMessages(FreeColGameObject source,
FreeColGameObject newSource)
source - the source field that has become invalidnewSource - a new source field to replace the old with, or
if null then remove the messagepublic int getMaximumFoodConsumption()
int valuepublic int getScore()
int valuepublic void setScore(int newScore)
newScore - The new score.public void modifyScore(int value)
value - an int valuepublic Market getMarket()
public void reinitialiseMarket()
public StringTemplate getMarketName()
public boolean hasSettlement(Settlement s)
Settlement.
s - The Settlement.
true if this Player owns the given
Settlement.public void addSettlement(Settlement settlement)
settlement - The Settlement to add.public void removeSettlement(Settlement settlement)
settlement - The Settlement to remove.public boolean owns(Ownable ownable)
public java.util.List<Settlement> getSettlements()
public int getNumberOfSettlements()
public java.util.List<Colony> getColonies()
public java.util.List<Colony> getSortedColonies(java.util.Comparator<Colony> c)
c - A comparator to operate on the colony list.
public int getColoniesPopulation()
public Colony getColony(java.lang.String name)
Colony with the given name.
name - The name of the Colony.
Colony or null if this player
does not have a Colony with the specified name.public java.util.List<IndianSettlement> getIndianSettlements()
public IndianSettlement getIndianSettlement(java.lang.String name)
IndianSettlement with the given name.
name - The name of the IndianSettlement.
IndianSettlement or null if this player
does not have a IndianSettlement with the specified name.public java.util.List<IndianSettlement> getIndianSettlementsWithMission(Player other)
other - If non-null, collect only missions established by
this Player
public Settlement getSettlement(java.lang.String name)
Settlement by name.
name - The name of the Settlement.
Settlement, or null if not found.
public void installSettlementNames(java.util.List<java.lang.String> names,
java.util.Random random)
names - A list of settlement names with the fallback prefix first.random - A Random number source.public java.lang.String getCapitalName()
public java.lang.String getSettlementName()
public Player.PlayerType getPlayerType()
public void setPlayerType(Player.PlayerType type)
type - The new player type.getPlayerType()public boolean isEuropean()
public boolean isIndian()
isEuropean().
public boolean isUndead()
public boolean isREF()
true is the given nation is a royal expeditionary
force and false otherwise.public boolean isAI()
public void setAI(boolean ai)
ai - true if this Player is controlled
by the computer.public boolean isAdmin()
public boolean isDead()
Player dies when it
loses the game.
true if this Player is dead.public boolean getDead()
Player is dead.public void setDead(boolean dead)
dead - Should be set to true when this
Player dies.isDead()public boolean isAtWar()
public boolean isWorkForREF()
public java.util.List<Player> getRebels()
public boolean canOwnTile(Tile tile)
tile - The Tile to consider.
private Player.NoClaimReason canOwnTileReason(Tile tile)
tile - The Tile to consider.
public boolean canClaimForSettlement(Tile tile)
tile - The Tile to try to claim.
public Player.NoClaimReason canClaimForSettlementReason(Tile tile)
tile - The Tile to try to claim.
public boolean canClaimToFoundSettlement(Tile tile)
tile - The Tile to try to claim.
public Player.NoClaimReason canClaimToFoundSettlementReason(Tile tile)
tile - The Tile to try to claim.
private boolean canClaimFreeCenterTile(Tile tile)
tile - The Tile to try to claim.
private boolean hasZeroSettlements()
public boolean canClaimForImprovement(Tile tile)
tile - The Tile to consider.
public boolean canAcquireForImprovement(Tile tile)
tile - The Tile to consider.
public final Unit getUnit(java.lang.String id)
Unit value.
List valuepublic final void setUnit(Unit newUnit)
Unit value.
newUnit - The new Units value.public void removeUnit(Unit oldUnit)
oldUnit - an Unit valuepublic int getPrice(AbstractUnit au)
au - The proposed AbstractUnit.
public int getSoL()
public final java.lang.String getIndependentNationName()
IndependentNationName value.
String valuepublic final void setIndependentNationName(java.lang.String newIndependentNationName)
IndependentNationName value.
newIndependentNationName - The new IndependentNationName value.public Player getREFPlayer()
Player controlling the "Royal Expeditionary
Force" for this player.
null if this player does not have a
royal expeditionary force.public java.lang.String getNewLandName()
Player,
or null if none chosen yet.public boolean isNewLandNamed()
public void setNewLandName(java.lang.String newLandName)
newLandName - This Player's name for the new world.public int getLandPrice(Tile tile)
tile - The Tile to get the price for.
public boolean getAttackedByPrivateers()
true if this Player has been
attacked by privateers.public void setAttackedByPrivateers(boolean attacked)
attacked - True if the player has been attacked by privateers.public Location getEntryLocation()
Location where the units arriving from
Europe will be put.
Location.Unit.getEntryLocation()public void setEntryLocation(Location entryLocation)
Location where the units arriving from
Europe will be put as a default.
entryLocation - The Location.getEntryLocation()public boolean hasExplored(Tile tile)
Player has explored the given
Tile.
tile - The Tile.
Tile has been explored and
false otherwise.public void setExplored(Tile tile)
tile - The Tile to set explored.Tile.updatePlayerExploredTile(Player, boolean)public void setExplored(Unit unit)
Unit's line of sight to
be explored by this player.
unit - The Unit.setExplored(Tile),
hasExplored(net.sf.freecol.common.model.Tile)public void invalidateCanSeeTiles()
canSeeTiles. This method should
be used to invalidate the current canSeeTiles. The method
resetCanSeeTiles() will be called whenever it is needed.
public boolean canSee(Tile tile)
Player can see the given Tile.
The Tile can be seen if it is in a Unit's line of
sight.
tile - The given Tile.
Player can see the given
Tile and false otherwise.private boolean resetCanSeeTiles()
Unit and Settlements
line of sight visible. The other tiles are made invisible.
Use invalidateCanSeeTiles() whenever possible.
true if successful false otherwiseprivate boolean[][] makeCanSeeTiles(Map map)
map - The Map to use.
public boolean canBuildColonies()
Player can build colonies.
true if this player is european, not the royal
expeditionary force and not currently fighting the war of
independence.public boolean canHaveFoundingFathers()
Player can get founding fathers.
true if this player is european, not the royal
expeditionary force and not currently fighting the war of
independence.public boolean hasFather(FoundingFather someFather)
someFather - a FoundingFather value
FoundingFatherpublic int getFatherCount()
public java.util.Set<FoundingFather> getFathers()
public void addFather(FoundingFather father)
father - The FoundingFather to add.public FoundingFather getCurrentFather()
founding father this player is working
towards.
setCurrentFather(net.sf.freecol.common.model.FoundingFather),
FoundingFatherpublic void setCurrentFather(FoundingFather someFather)
father to its congress.
someFather - a FoundingFather valueFoundingFatherpublic java.util.List<FoundingFather> getOfferedFathers()
public void clearOfferedFathers()
public void setOfferedFathers(java.util.List<FoundingFather> fathers)
fathers - A list of FoundingFathers to offer.public int getRemainingFoundingFatherCost()
Player
needs in order to recruit the next founding father.incrementLiberty(int)public int getTotalFoundingFatherCost()
Player
needs to recruit the next founding father.incrementLiberty(int)public boolean canMoveToEurope()
Player can move units to
Europe.
true if this Player has an instance
of Europe.public Europe getEurope()
null if
this Player does not have an instance
Europe.public void setEurope(Europe europe)
europe - The new Europe object.public java.lang.String getEuropeNameKey()
getEuropeName method here.
String valuepublic Monarch getMonarch()
null if this
Player does not have an instance
Monarch.public void setMonarch(Monarch monarch)
monarch - The monarch object this player should have.public final HighSeas getHighSeas()
HighSeas value.
HighSeas valuepublic void initializeHighSeas()
public int getGold()
public void setGold(int newGold)
newGold - The new player gold value.public boolean checkGold(int amount)
amount - The purchase price to check.
public int modifyGold(int amount)
amount - The amount of gold to be added to this player.
public java.util.Iterator<Unit> getUnitIterator()
Iterator containing all the units this player
owns.
Iterator.Unitpublic java.util.List<Unit> getUnits()
public int getNumberOfKingLandUnits()
public boolean hasManOfWar()
true if this player owns
a single Man-of-War.public Unit getNextActiveUnit()
Unit that can be made active.public boolean setNextActiveUnit(Unit unit)
unit - A Unit to make the next one to be active.
public Unit getNextGoingToUnit()
Unit that can be made active.public boolean hasNextActiveUnit()
public boolean hasNextGoingToUnit()
public java.lang.String getName()
getName in interface Nameablepublic java.lang.String getNameKey()
public java.lang.String getDisplayName()
public boolean isUnknownEnemy()
public java.lang.String toString()
toString in class FreeColGameObjectpublic void setName(java.lang.String newName)
Name value.
setName in interface NameablenewName - The new Name value.public NationType getNationType()
public void setNationType(NationType newNationType)
newNationType - a NationType valuepublic Nation getNation()
String valuepublic void setNation(Nation newNation)
newNation - The new nation for this player.public java.lang.String getNationID()
String valuepublic java.lang.String getNationNameKey()
String valuepublic StringTemplate getNationName()
public final java.lang.String getRulerNameKey()
RulerName value.
String valuepublic boolean isReady()
Player is ready to start the game.
true if this Player is ready to
start the game.public void setReady(boolean ready)
Player to be ready/not ready for starting the
game.
ready - This indicates if the player is ready to start the game.public void incrementImmigration(int amount)
public void reduceImmigration()
incrementImmigration(int)public int getImmigration()
reduceImmigration()public void setImmigration(int immigration)
immigration - The immigration value for this player.public final java.util.List<TradeRoute> getTradeRoutes()
TradeRoutes value.
List valuepublic final void setTradeRoutes(java.util.List<TradeRoute> newTradeRoutes)
newTradeRoutes - The new list of TradeRoutes.public boolean checkEmigrate()
public int getImmigrationRequired()
public void setImmigrationRequired(int immigrationRequired)
immigrationRequired - The number of immigration required to cause a new
colonist to emigrate.public void updateImmigrationRequired()
Unit
from Europe.
public boolean canRecruitUnits()
Player can recruit units by producing
immigration.
true if units can be recruited by this
Player.
public java.util.List<FreeColGameObject> modifyTension(Player player,
int addToTension)
player - The Player.addToTension - The amount to add to the current tension level.
public java.util.List<FreeColGameObject> modifyTension(Player player,
int addToTension,
Settlement origin)
player - The Player.addToTension - The amount to add to the current tension level.origin - A Settlement where the alarming event
occurred.
public void setTension(Player player,
Tension newTension)
player - The Player.newTension - The Tension.public Tension getTension(Player player)
player - The Player.
public void removeTension(Player player)
player - The Player to remove tension for.public final java.util.List<HistoryEvent> getHistory()
History value.
List valuepublic int getOutpostValue(Tile t)
public int getColonyValue(Tile t)
Colony on the given tile.
This method adds bonuses to the colony value if the tile is close to (but
not overlapping with) another friendly colony. Penalties for enemy
units/colonies are added as well.
t - The Tile
public Player.Stance getStance(Player player)
player - The Player.
public boolean setStance(Player player,
Player.Stance newStance)
player - The Player.newStance - The new Stance.
java.lang.IllegalArgumentException - if player is null or this.public boolean atWarWith(Player player)
player - The Player to check.
public boolean hasContacted(Player player)
Player if the
given nation.
player - The Player.
true if this Player has contacted
the given nation.public boolean hasContactedEuropeans()
true if this Player has contacted
any Europeans.public boolean hasContactedIndians()
true if this Player has contacted
any natives.
public static void makeContact(Player player1,
Player player2)
player1 - a Player valueplayer2 - a Player valuepublic boolean hasVisited(IndianSettlement settlement)
settlement - The IndianSettlement to query.
public int getRecruitPrice()
Europe.public int getLiberty()
Player has.
public void setLiberty(int liberty)
liberty - The new amount of liberty.public void incrementLiberty(int amount)
amount - The additional amount of liberty.public int getLibertyProductionNextTurn()
Player's
Colonys will make.incrementLiberty(int)public void resetIterators()
public int getArrears(GoodsType type)
type - a GoodsType value
public int getArrears(Goods goods)
goods - The goods.
public boolean canTrade(GoodsType type)
type - The goods type.
public boolean canTrade(GoodsType type,
Market.Access access)
type - The GoodsType.access - The way the goods are traded (Europe OR Custom)
true if type of goods can be traded.
public boolean canTrade(Goods goods,
Market.Access access)
goods - The goods.access - Place where the goods are traded (Europe OR Custom)
public boolean canTrade(Goods goods)
goods - The goods.
public int getTax()
public void setTax(int amount)
amount - The new tax.protected boolean recalculateBellsBonus()
public int getSales(GoodsType goodsType)
goodsType - a GoodsType value
public void modifySales(GoodsType goodsType,
int amount)
goodsType - a GoodsType valueamount - The new sales.public boolean hasTraded(GoodsType goodsType)
goodsType - a GoodsType value
public Goods getMostValuableGoods()
public int getIncomeBeforeTaxes(GoodsType goodsType)
goodsType - The GoodsType.
public void modifyIncomeBeforeTaxes(GoodsType goodsType,
int amount)
goodsType - The GoodsType.amount - The new incomeBeforeTaxes.public int getIncomeAfterTaxes(GoodsType goodsType)
goodsType - The GoodsType.
public void modifyIncomeAfterTaxes(GoodsType goodsType,
int amount)
goodsType - The GoodsType.amount - The new incomeAfterTaxes.public void addHistory(HistoryEvent event)
event - The HistoryEvent to add.public boolean equals(Player o)
Player equals this object.
o - The Player to compare against this object.
Player are equal and none
of both have nation == null and false
otherwise.public int getNameIndex(java.lang.String key)
key - The key to use.
public void setNameIndex(java.lang.String key,
int value)
key - The key to use.public void saveSale(LastSale sale)
sale - The LastSale to save.
public LastSale getLastSale(Location where,
GoodsType what)
where - The Location of the sale.what - The GoodsType sold.
LastSaleData record or null.
public java.lang.String getLastSaleString(Location where,
GoodsType what)
where - The Location of the sale.what - The GoodsType sold.
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 writeAttributes(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void writeChildren(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
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 static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||