net.sf.freecol.common.model
Class Player

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.Player
All Implemented Interfaces:
Nameable, Named
Direct Known Subclasses:
ServerPlayer

public class Player
extends FreeColGameObject
implements Nameable

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.PlayerType
           
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
private  boolean admin
           
private  boolean ai
          True if this is an AI player.
private  java.util.Set<FoundingFather> allFathers
           
private  boolean attackedByPrivateers
          True if player has been attacked by privateers.
protected  boolean[][] canSeeTiles
           
private  java.awt.Color color
           
private  FoundingFather currentFather
           
private  boolean dead
           
private  Location entryLocation
           
protected  Europe europe
          The European port/location for this player.
private  FeatureContainer featureContainer
          Contains the abilities and modifiers of this type.
private static java.lang.String FOUNDING_FATHER_TAG
          The XML tag name for the set of founding fathers.
private  int gold
          The amount of gold this player owns.
protected  java.util.List<HistoryEvent> history
          Describe history here.
private  int immigration
          The number of immigration points.
private  int immigrationRequired
           
private  java.lang.String independentNationName
          Describe independentNationName here.
private  int index
          The index of this player
private  int liberty
          The number of liberty points.
private static java.util.logging.Logger logger
           
private  Market market
          The market for Europe.
private  java.util.List<ModelMessage> modelMessages
           
protected  Monarch monarch
          The monarch for this player.
private  java.lang.String name
          The name of this player.
private  java.lang.String nationID
          The nation ID of this player, e.g.
private  NationType nationType
          The NationType of this player.
private  java.lang.String newLandName
          The name this player uses for the New World.
private  java.util.Iterator<Unit> nextActiveUnitIterator
           
private  java.util.Iterator<Unit> nextGoingToUnitIterator
           
private static java.awt.Color noNationColor
           
private  int numberOfSettlements
           
private  int oldSoL
           
static java.util.Comparator<Player> playerComparator
           
private  Player.PlayerType playerType
           
private  boolean ready
           
private  java.util.EnumMap<Region.RegionType,java.lang.Integer> regionNameIndex
           
private  int score
          The current score of this player.
static int SCORE_INDEPENDENCE_DECLARED
           
static int SCORE_INDEPENDENCE_GRANTED
           
static int SCORE_SETTLEMENT_DESTROYED
           
private  int settlementNameIndex
           
private  java.util.List<Settlement> settlements
           
private  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.
private  int tax
          The current tax rate for this player.
private  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.
private  java.util.List<TradeRoute> tradeRoutes
           
private  java.util.Map<java.lang.String,Unit> units
          The Units this player owns.
static java.lang.String UNKNOWN_ENEMY
           
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE
 
Constructor Summary
protected Player()
          This constructor should only be used by subclasses.
  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, java.lang.String name, boolean admin)
          Creates a new Player with specified name.
  Player(Game game, java.lang.String name, boolean admin, boolean ai, Nation nation)
          Creates an new AI Player with the specified name.
  Player(Game game, java.lang.String name, boolean admin, Nation newNation)
          Creates a new (human) Player with specified name.
  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)
          Adds a founding father to this player's continental congress.
 void addModelMessage(ModelMessage modelMessage)
          Adds a ModelMessage for this player.
 void addSettlement(Settlement s)
          Adds the given Settlement to this Player's list of settlements.
 boolean canBuildColonies()
          Checks if this Player can build colonies.
 boolean canHaveFoundingFathers()
          Checks if this Player can get founding fathers.
 boolean canMoveToEurope()
          Checks if this Player can move units to Europe.
 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, int marketAccess)
          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, int marketAccess)
          Returns true if type of goods can be traded at specified place.
 void changeRelationWithPlayer(Player player, Player.Stance newStance)
           
 boolean checkEmigrate()
          Checks to see whether or not a colonist can emigrate, and does so if possible.
static boolean checkForDeath(Player player)
          Checks if the given player has died.
 void clearModelMessages()
          Removes all the model messages for this player.
 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.
 void endTurn()
          Gets called when this player's turn has ended.
 boolean equals(Player o)
          Checks if the given Player equals this object.
private  void exploreAllColonies()
           
 UnitType generateRecruitable()
          Generates a random unit type recruitable by this player.
 java.util.List<RandomChoice<UnitType>> generateRecruitablesList()
          Generate a weighted list of unit types recruitable by this player.
 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.
 java.util.List<Colony> getColonies()
          Returns a 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.
 java.awt.Color getColor()
          Returns the color of this player.
 FoundingFather getCurrentFather()
          Gets the founding father this player is working towards.
 boolean getDead()
          Get the player death state.
 java.lang.String getDefaultRegionName(Region.RegionType regionType)
          Creates a unique region name by fetching a new default name from the list of default names if possible.
 java.lang.String getDefaultSettlementName(boolean capital)
          Creates a unique settlement name.
 DifficultyLevel getDifficulty()
          Returns the difficulty level.
 java.util.List<Player> getDominionsAtWar()
          Gets a list of the players this REF player is currently fighting.
 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 getEuropeName()
          Describe getEuropeName method here.
 int getFatherCount()
          Returns the number of founding fathers in this players congress.
 FeatureContainer getFeatureContainer()
          Get the FeatureContainer value.
 int getGold()
          Returns the amount of gold that this player has.
 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.
 int getIndex()
          Returns the index of this Player.
 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.
 int getLandPrice(Tile tile)
          Returns the price of the given land.
 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.
 java.lang.String 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.
 java.util.List<ModelMessage> getModelMessages()
          Returns all ModelMessages for this player.
 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.
 Nation getNation()
          Return this Player's nation.
 java.lang.String getNationID()
          Return the ID of this Player's nation.
 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()
          Returns the known number of settlements of 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 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.
 Location getRepairLocation(Unit unit)
          Returns the closest Location in which the given ship can get repaired.
 java.lang.String getRulerName()
          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.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.
 Player.Stance getStance(Player player)
          Returns the stance towards a given player.
static java.lang.String getStanceAsString(Player.Stance stance)
          Returns a string describing the given stance.
 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 id)
          Describe hasAbility method here.
 boolean hasBeenAttackedByPrivateers()
          Returns whether this player has been attacked by privateers.
 boolean hasContacted(Player player)
          Returns whether this player has met with the Player if the given nation.
 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?
 void incrementImmigration(int amount)
           
 void incrementLiberty(int amount)
           
 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.
 void 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.
 void modifyTension(Player player, int addToTension)
          Modifies the hostiliy against the given player.
 void modifyTension(Player player, int addToTension, IndianSettlement origin)
           
 void newTurn()
          Prepares this Player for a new turn.
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.
 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 s)
          Removes the given Settlement from this Player's list of settlements.
 void removeUnit(Unit oldUnit)
          Remove Unit.
 void resetArrears(Goods goods)
          Resets the arrears for these goods to zero.
 void resetArrears(GoodsType goodsType)
          Resets the arrears for this type of goods to zero.
 boolean resetCanSeeTiles()
          Resets this player's "can see"-tiles.
 void resetTradeRouteCounts()
          Reset the TradeRoute counts associated with the player's trade routes.
 void setAI(boolean ai)
          Sets whether this player is an AI player.
 void setArrears(Goods goods)
          Sets the arrears for these goods.
 void setArrears(GoodsType goodsType)
          Sets the arrears for a type of goods.
 void setAttackedByPrivateers()
          Sets the variable attackedByPrivateers to true.
 void setColor(java.awt.Color c)
          Sets the color for this player.
 void setContacted(Player player, boolean contacted)
          Sets whether this player has contacted the given player.
 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 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 setHistory(java.util.List<HistoryEvent> newHistory)
          Set the History value.
 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 setMonarch(Monarch monarch)
          Sets the monarch object this player has.
 void setName(java.lang.String newName)
          Set the Name value.
 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.
 void setNumberOfSettlements(int number)
           
 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.
 void setStance(Player player, Player.Stance newStance)
          Sets the stance towards a given player.
 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 TradeRoutes value.
 void setUnit(Unit newUnit)
          Set the Unit value.
 void surrenderTo(Player player)
          Indian player surrenders
 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.
private  void updateAddTaxToLiberty()
           
 void updateImmigrationRequired()
          Updates the amount of immigration needed to emigrate a Unit from Europe.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addModelMessage, addModelMessage, addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, readFromXMLPartialByClass, setFakeID, setGame, setId, toSavedXML, toXML, toXMLImpl, toXMLPartialByClass, 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, hasAttribute, hasListeners, readAttributes, readChildren, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toArrayElement, toArrayElement, toListElement, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeAttributes, writeChildren, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

SCORE_SETTLEMENT_DESTROYED

public static final int SCORE_SETTLEMENT_DESTROYED
See Also:
Constant Field Values

SCORE_INDEPENDENCE_DECLARED

public static final int SCORE_INDEPENDENCE_DECLARED
See Also:
Constant Field Values

SCORE_INDEPENDENCE_GRANTED

public static final int SCORE_INDEPENDENCE_GRANTED
See Also:
Constant Field Values

FOUNDING_FATHER_TAG

private static final java.lang.String FOUNDING_FATHER_TAG
The XML tag name for the set of founding fathers.

See Also:
Constant Field Values

STANCE_TAG

private static final java.lang.String STANCE_TAG
The XML tag name for the stance array.

See Also:
Constant Field Values

TENSION_TAG

private static final java.lang.String TENSION_TAG
The XML tag name for the tension array.

See Also:
Constant Field Values

index

private int index
The index of this player


tension

private java.util.Map<Player,Tension> tension
Only used by AI - stores the tension levels, 0-1000 with 1000 maximum hostility.


stance

private java.util.Map<java.lang.String,Player.Stance> stance
Stores the stance towards the other players. One of: WAR, CEASE_FIRE, PEACE and ALLIANCE.


noNationColor

private static final java.awt.Color noNationColor

name

private java.lang.String name
The name of this player. This defaults to the user name in case of a human player and the rulerName of the NationType in case of an AI player.


UNKNOWN_ENEMY

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

nationType

private NationType nationType
The NationType of this player.


nationID

private java.lang.String nationID
The nation ID of this player, e.g. "model.nation.dutch".


newLandName

private java.lang.String newLandName
The name this player uses for the New World.


color

private java.awt.Color color

admin

private boolean admin

score

private int score
The current score of this player.


gold

private int gold
The amount of gold this player owns.


immigration

private int immigration
The number of immigration points. Immigration points are an abstract game concept. They are generated by but are not identical to crosses.


liberty

private int liberty
The number of liberty points. Liberty points are an abstract game concept. They are generated by but are not identical to bells.


numberOfSettlements

private int numberOfSettlements

market

private Market market
The market for Europe.


europe

protected Europe europe
The European port/location for this player.


monarch

protected Monarch monarch
The monarch for this player.


ready

private boolean ready

ai

private boolean ai
True if this is an AI player.


attackedByPrivateers

private boolean attackedByPrivateers
True if player has been attacked by privateers.


oldSoL

private int oldSoL

dead

private boolean dead

allFathers

private final java.util.Set<FoundingFather> allFathers

currentFather

private FoundingFather currentFather

tax

private int tax
The current tax rate for this player.


playerType

private Player.PlayerType playerType

immigrationRequired

private int immigrationRequired

settlementNameIndex

private int settlementNameIndex

regionNameIndex

private java.util.EnumMap<Region.RegionType,java.lang.Integer> regionNameIndex

entryLocation

private Location entryLocation

units

private final java.util.Map<java.lang.String,Unit> units
The Units this player owns.


nextActiveUnitIterator

private final java.util.Iterator<Unit> nextActiveUnitIterator

nextGoingToUnitIterator

private final java.util.Iterator<Unit> nextGoingToUnitIterator

settlements

private final java.util.List<Settlement> settlements

tradeRoutes

private java.util.List<TradeRoute> tradeRoutes

modelMessages

private final java.util.List<ModelMessage> modelMessages

canSeeTiles

protected boolean[][] canSeeTiles

featureContainer

private FeatureContainer featureContainer
Contains the abilities and modifiers of this type.


independentNationName

private java.lang.String independentNationName
Describe independentNationName here.


history

protected java.util.List<HistoryEvent> history
Describe history here.


playerComparator

public static final java.util.Comparator<Player> playerComparator
Constructor Detail

Player

protected Player()
This constructor should only be used by subclasses.


Player

public Player(Game game,
              java.lang.String name,
              boolean admin,
              boolean ai,
              Nation nation)
Creates an new AI Player with the specified name.

Parameters:
game - The Game this Player belongs to.
name - The name that this player will use.
admin - Whether or not this AI player shall be considered an Admin.
ai - Whether or not this AI player shall be considered an AI player (usually true here).
nation - The nation of the Player.

Player

public Player(Game game,
              java.lang.String name,
              boolean admin)
Creates a new Player with specified name.

Parameters:
game - The Game this Player belongs to.
name - The name that this player will use.
admin - 'true' if this Player is an admin, 'false' otherwise.

Player

public Player(Game game,
              java.lang.String name,
              boolean admin,
              Nation newNation)
Creates a new (human) Player with specified name.

Parameters:
game - The Game this Player belongs to.
name - The name that this player will use.
admin - 'true' if this Player is an admin, 'false' otherwise.
newNation - The nation of the Player.

Player

public Player(Game game,
              javax.xml.stream.XMLStreamReader in)
       throws javax.xml.stream.XMLStreamException
Initiates a new Player from an Element and registers this Player at the specified game.

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

Player

public Player(Game game,
              org.w3c.dom.Element e)
Initiates a new Player from an Element and registers this Player at the specified game.

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

Player

public Player(Game game,
              java.lang.String id)
Initiates a new Player 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

getIndex

public int getIndex()
Returns the index of this Player.

Returns:
an int value

getFeatureContainer

public final FeatureContainer getFeatureContainer()
Get the FeatureContainer value.

Returns:
a FeatureContainer value

setFeatureContainer

public final void setFeatureContainer(FeatureContainer newFeatureContainer)
Set the FeatureContainer value.

Parameters:
newFeatureContainer - The new FeatureContainer value.

hasAbility

public boolean hasAbility(java.lang.String id)
Description copied from class: FreeColObject
Describe hasAbility method here.

Overrides:
hasAbility in class FreeColObject
Parameters:
id - a String value
Returns:
a boolean value

addModelMessage

public void addModelMessage(ModelMessage modelMessage)
Adds a ModelMessage for this player.

Overrides:
addModelMessage in class FreeColGameObject
Parameters:
modelMessage - The ModelMessage.
See Also:
Canvas, addModelMessage(ModelMessage), ModelMessage

getModelMessages

public java.util.List<ModelMessage> getModelMessages()
Returns all ModelMessages for this player.

Returns:
all ModelMessages for this player.

getNewModelMessages

public java.util.List<ModelMessage> getNewModelMessages()
Returns all new ModelMessages for this player.

Returns:
all new ModelMessages for this player.

removeModelMessages

public void removeModelMessages()
Removes all undisplayed model messages for this player.


clearModelMessages

public void clearModelMessages()
Removes all the model messages for this player.


divertModelMessages

public 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. Europe disappears on independence. This routine is for cleaning up such cases.

Parameters:
source - the source field that has become invalid
newSource - a new source field to replace the old with, or if null then remove the message

getScore

public int getScore()
Returns the current score of the player.

Returns:
an int value

setScore

public void setScore(int newScore)
Set the current score of the player.

Parameters:
newScore - The new score.

modifyScore

public void modifyScore(int value)
Modifies the score of the player by the given value.

Parameters:
value - an int value

getMarket

public Market getMarket()
Returns this Player's Market.

Returns:
This Player's Market.

reinitialiseMarket

public void reinitialiseMarket()
Resets this Player's Market.


getMarketName

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

Returns:
A name for the player's market.

hasSettlement

public boolean hasSettlement(Settlement s)
Checks if this player owns the given Settlement.

Parameters:
s - The Settlement.
Returns:
true if this Player owns the given Settlement.

addSettlement

public void addSettlement(Settlement s)
Adds the given Settlement to this Player's list of settlements.

Parameters:
s -

removeSettlement

public void removeSettlement(Settlement s)
Removes the given Settlement from this Player's list of settlements.

Parameters:
s - The Settlement to remove.

getNumberOfSettlements

public int getNumberOfSettlements()
Returns the known number of settlements of this player. Note: For a client, this may differ from settlements.size()!

Returns:
The known number of settlements

setNumberOfSettlements

public void setNumberOfSettlements(int number)

getSettlements

public java.util.List<Settlement> getSettlements()
Returns a list of all Settlements this player owns.

Returns:
The settlements this player owns.

getColonies

public java.util.List<Colony> getColonies()
Returns a list of all Colonies this player owns.

Returns:
The colonies this player owns.

getColoniesPopulation

public int getColoniesPopulation()
Returns the sum of units currently working in the colonies of this player.

Returns:
Sum of units currently working in the colonies.

getColony

public Colony getColony(java.lang.String name)
Returns the Colony with the given name.

Parameters:
name - The name of the Colony.
Returns:
The Colony or null if this player does not have a Colony with the specified name.

getIndianSettlements

public java.util.List<IndianSettlement> getIndianSettlements()
Returns a list of all IndianSettlements this player owns.

Returns:
The indian settlements this player owns.

getIndianSettlement

public IndianSettlement getIndianSettlement(java.lang.String name)
Returns the IndianSettlement with the given name.

Parameters:
name - The name of the IndianSettlement.
Returns:
The IndianSettlement or null if this player does not have a IndianSettlement with the specified name.

getSettlement

public Settlement getSettlement(java.lang.String name)
Find a Settlement by name.

Parameters:
name - The name of the Settlement.
Returns:
The Settlement, or null if not found.

getPlayerType

public Player.PlayerType getPlayerType()
Returns the type of this player.

Returns:
The player type.

setPlayerType

public void setPlayerType(Player.PlayerType type)
Sets the player type.

Parameters:
type - The new player type.
See Also:
getPlayerType()

isEuropean

public boolean isEuropean()
Checks if this player is european. This includes the "Royal Expeditionay Force".

Returns:
true if this player is european and false otherwise.

isIndian

public boolean isIndian()
Checks if this player is indian. This method returns the opposite of isEuropean().

Returns:
true if this player is indian and false otherwise.

isREF

public boolean isREF()
Checks if this player is a "royal expeditionary force.

Returns:
true is the given nation is a royal expeditionary force and false otherwise.

isAI

public boolean isAI()
Determines whether this player is an AI player.

Returns:
Whether this player is an AI player.

setAI

public void setAI(boolean ai)
Sets whether this player is an AI player.

Parameters:
ai - true if this Player is controlled by the computer.

isAdmin

public boolean isAdmin()
Checks if this player is an admin.

Returns:
true if the player is an admin and false otherwise.

checkForDeath

public static boolean checkForDeath(Player player)
Checks if the given player has died.

Parameters:
player - The Player.
Returns:
true if this player should die.

isDead

public boolean isDead()
Checks if this player is dead. A Player dies when it looses the game.

Returns:
true if this Player is dead.

getDead

public boolean getDead()
Get the player death state. This is indeed identical to isDead(), but is needed for partial updates to complement the setDead() function.

Returns:
True if this Player is dead.

setDead

public void setDead(boolean dead)
Sets this player to be dead or not.

Parameters:
dead - Should be set to true when this Player dies.
See Also:
isDead()

isAtWar

public boolean isAtWar()
Checks whether this player is at war with any other player.

Returns:
true if this player is at war with any other.

getDominionsAtWar

public java.util.List<Player> getDominionsAtWar()
Gets a list of the players this REF player is currently fighting.

Returns:
The list. Empty if this is not an REF player.

getUnit

public final Unit getUnit(java.lang.String id)
Get the Unit value.

Returns:
a List value

setUnit

public final void setUnit(Unit newUnit)
Set the Unit value.

Parameters:
newUnit - The new Units value.

removeUnit

public void removeUnit(Unit oldUnit)
Remove Unit.

Parameters:
oldUnit - an Unit value

getSoL

public int getSoL()
Gets the total percentage of rebels in all this player's colonies.

Returns:
The total percentage of rebels in all this player's colonies.

getIndependentNationName

public final java.lang.String getIndependentNationName()
Get the IndependentNationName value.

Returns:
a String value

setIndependentNationName

public final void setIndependentNationName(java.lang.String newIndependentNationName)
Set the IndependentNationName value.

Parameters:
newIndependentNationName - The new IndependentNationName value.

getREFPlayer

public Player getREFPlayer()
Gets the Player controlling the "Royal Expeditionary Force" for this player.

Returns:
The player, or null if this player does not have a royal expeditionary force.

getNewLandName

public java.lang.String getNewLandName()
Gets the name this player has chosen for the new land.

Returns:
The name of the new world as chosen by the Player. If no land name was chosen, the default name is returned.

isNewLandNamed

public boolean isNewLandNamed()
Returns true if the player already selected a new name for the discovered land.

Returns:
true if the player already set a name for the newly discovered land, otherwise false.

getDefaultSettlementName

public java.lang.String getDefaultSettlementName(boolean capital)
Creates a unique settlement name. This is done by fetching a new default settlement name from the list of default names.

Parameters:
capital - True if the name should be the national capital.
Returns:
A String containing a new unused name from the list, if any is available, and otherwise an automatically generated name.

getDefaultRegionName

public java.lang.String getDefaultRegionName(Region.RegionType regionType)
Creates a unique region name by fetching a new default name from the list of default names if possible.

Parameters:
regionType - a RegionType value
Returns:
a String value

setNewLandName

public void setNewLandName(java.lang.String newLandName)
Sets the name this player uses for the new land.

Parameters:
newLandName - This Player's name for the new world.

getLandPrice

public int getLandPrice(Tile tile)
Returns the price of the given land.

Parameters:
tile - The Tile to get the price for.
Returns:
The price of the land if it is for sale, zero if it is already ours, unclaimed or unwanted, negative if it is not for sale.

hasContacted

public boolean hasContacted(Player player)
Returns whether this player has met with the Player if the given nation.

Parameters:
player - The Player.
Returns:
true if this Player has contacted the given nation.

setContacted

public void setContacted(Player player,
                         boolean contacted)
Sets whether this player has contacted the given player.

Parameters:
player - The Player.
contacted - true if this Player has contacted the given Player.

hasBeenAttackedByPrivateers

public boolean hasBeenAttackedByPrivateers()
Returns whether this player has been attacked by privateers.

Returns:
true if this Player has been attacked by privateers.

setAttackedByPrivateers

public void setAttackedByPrivateers()
Sets the variable attackedByPrivateers to true.


getEntryLocation

public Location getEntryLocation()
Gets the default Location where the units arriving from Europe will be put.

Returns:
The Location.
See Also:
Unit.getEntryLocation()

setEntryLocation

public void setEntryLocation(Location entryLocation)
Sets the Location where the units arriving from Europe will be put as a default.

Parameters:
entryLocation - The Location.
See Also:
getEntryLocation()

hasExplored

public boolean hasExplored(Tile tile)
Checks if this Player has explored the given Tile.

Parameters:
tile - The Tile.
Returns:
true if the Tile has been explored and false otherwise.

setExplored

public void setExplored(Tile tile)
Sets the given tile to be explored by this player and updates the player's information about the tile.

Parameters:
tile - The Tile to set explored.
See Also:
Tile.updatePlayerExploredTile(Player)

setExplored

public void setExplored(Unit unit)
Sets the tiles within the given Unit's line of sight to be explored by this player.

Parameters:
unit - The Unit.
See Also:
setExplored(Tile), hasExplored(net.sf.freecol.common.model.Tile)

invalidateCanSeeTiles

public void invalidateCanSeeTiles()
Forces an update of the canSeeTiles. This method should be used to invalidate the current canSeeTiles. The method resetCanSeeTiles() will be called whenever it is needed.


resetCanSeeTiles

public boolean resetCanSeeTiles()
Resets this player's "can see"-tiles. This is done by setting all the tiles within a Units line of sight visible. The other tiles are made unvisible.

Use invalidateCanSeeTiles() whenever possible.

Returns:
true if successful false otherwise

canSee

public boolean canSee(Tile tile)
Checks if this Player can see the given Tile. The Tile can be seen if it is in a Unit's line of sight.

Parameters:
tile - The given Tile.
Returns:
true if the Player can see the given Tile and false otherwise.

canBuildColonies

public boolean canBuildColonies()
Checks if this Player can build colonies.

Returns:
true if this player is european, not the royal expeditionary force and not currently fighting the war of independence.

canHaveFoundingFathers

public boolean canHaveFoundingFathers()
Checks if this Player can get founding fathers.

Returns:
true if this player is european, not the royal expeditionary force and not currently fighting the war of independence.

hasFather

public boolean hasFather(FoundingFather someFather)
Determines whether this player has a certain Founding father.

Parameters:
someFather - a FoundingFather value
Returns:
Whether this player has this Founding father
See Also:
FoundingFather

getFatherCount

public int getFatherCount()
Returns the number of founding fathers in this players congress. Used to calculate number of liberty needed to recruit new fathers.

Returns:
The number of founding fathers in this players congress

setCurrentFather

public void setCurrentFather(FoundingFather someFather)
Sets this players liberty bell production to work towards recruiting father to its congress.

Parameters:
someFather - a FoundingFather value
See Also:
FoundingFather

getCurrentFather

public FoundingFather getCurrentFather()
Gets the founding father this player is working towards.

Returns:
The current FoundingFather or null if there is none
See Also:
setCurrentFather(net.sf.freecol.common.model.FoundingFather), FoundingFather

getRemainingFoundingFatherCost

public int getRemainingFoundingFatherCost()
Gets the number of liberty points needed to recruit the next founding father.

Returns:
How many more liberty points the Player needs in order to recruit the next founding father.
See Also:
Goods.BELLS, incrementLiberty(int)

getTotalFoundingFatherCost

public int getTotalFoundingFatherCost()
Returns how many liberty points in total are needed to earn the Founding Father we are trying to recruit. The description of the algorithm was taken from http://t-a-w.blogspot.com/2007/05/colonization-tips.html

Returns:
Total number of liberty points the Player needs to recruit the next founding father.
See Also:
Goods.BELLS, incrementLiberty(int)

addFather

public void addFather(FoundingFather father)
Adds a founding father to this player's continental congress.

Parameters:
father - a FoundingFather value
See Also:
FoundingFather

endTurn

public void endTurn()
Gets called when this player's turn has ended.


canMoveToEurope

public boolean canMoveToEurope()
Checks if this Player can move units to Europe.

Returns:
true if this Player has an instance of Europe.

getEurope

public Europe getEurope()
Returns the europe object that this player has.

Returns:
The europe object that this player has or null if this Player does not have an instance Europe.

getEuropeName

public java.lang.String getEuropeName()
Describe getEuropeName method here.

Returns:
a String value

getMonarch

public Monarch getMonarch()
Returns the monarch object this player has.

Returns:
The monarch object this player has or null if this Player does not have an instance Monarch.

setMonarch

public void setMonarch(Monarch monarch)
Sets the monarch object this player has.

Parameters:
monarch - The monarch object this player should have.

getGold

public int getGold()
Returns the amount of gold that this player has.

Returns:
The amount of gold that this player has or -1 if the amount of gold is unknown.

setGold

public void setGold(int newGold)
Set the amount of gold that this player has.

Parameters:
newGold - The new player gold value.

modifyGold

public void modifyGold(int amount)
Modifies the amount of gold that this player has. The argument can be both positive and negative.

Parameters:
amount - The amount of gold that should be added to this player's gold amount (can be negative!).
Throws:
java.lang.IllegalArgumentException - if the player gets a negative amount of gold after adding amount.

getUnitIterator

public java.util.Iterator<Unit> getUnitIterator()
Gets an Iterator containing all the units this player owns.

Returns:
The Iterator.
See Also:
Unit

getUnits

public java.util.List<Unit> getUnits()

getNumberOfKingLandUnits

public int getNumberOfKingLandUnits()
Gets the number of King's land units.

Returns:
The number of units

hasManOfWar

public boolean hasManOfWar()
Checks if this player has a single Man-of-War.

Returns:
true if this player owns a single Man-of-War.

getNextActiveUnit

public Unit getNextActiveUnit()
Gets a new active unit.

Returns:
A Unit that can be made active.

getNextGoingToUnit

public Unit getNextGoingToUnit()
Gets a new going_to unit.

Returns:
A Unit that can be made active.

hasNextActiveUnit

public boolean hasNextActiveUnit()
Checks if a new active unit can be made active.

Returns:
true if this is the case and false otherwise.

hasNextGoingToUnit

public boolean hasNextGoingToUnit()
Checks if a new active unit can be made active.

Returns:
true if this is the case and false otherwise.

getName

public java.lang.String getName()
Returns the name of this player.

Specified by:
getName in interface Named
Returns:
The name of this player.

toString

public java.lang.String toString()
Returns the name of this player.

Overrides:
toString in class FreeColGameObject
Returns:
The name of this player.

setName

public void setName(java.lang.String newName)
Set the Name value.

Specified by:
setName in interface Nameable
Parameters:
newName - The new Name value.

getNationType

public NationType getNationType()
Returns the nation type of this player.

Returns:
The nation type of this player.

setNationType

public void setNationType(NationType newNationType)
Sets the nation type of this player.

Parameters:
newNationType - a NationType value

getNation

public Nation getNation()
Return this Player's nation.

Returns:
a String value

setNation

public void setNation(Nation newNation)
Sets the nation for this player.

Parameters:
newNation - The new nation for this player.

getNationID

public java.lang.String getNationID()
Return the ID of this Player's nation.

Returns:
a String value

getRulerName

public final java.lang.String getRulerName()
Get the RulerName value.

Returns:
a String value

getColor

public java.awt.Color getColor()
Returns the color of this player.

Returns:
The color of this player.

setColor

public void setColor(java.awt.Color c)
Sets the color for this player.

Parameters:
c - The new color for this player.

isReady

public boolean isReady()
Checks if this Player is ready to start the game.

Returns:
true if this Player is ready to start the game.

setReady

public void setReady(boolean ready)
Sets this Player to be ready/not ready for starting the game.

Parameters:
ready - This indicates if the player is ready to start the game.

getRepairLocation

public Location getRepairLocation(Unit unit)
Returns the closest Location in which the given ship can get repaired. This is the closest Colony with a drydock, or Europe if this player has no colonies with a drydock.

Parameters:
unit - The ship that needs a location to be repaired.
Returns:
The closest Location in which the ship can be repaired.
Throws:
java.lang.IllegalArgumentException - if the unit is not a ship.

incrementLiberty

public void incrementLiberty(int amount)

incrementImmigration

public void incrementImmigration(int amount)

reduceImmigration

public void reduceImmigration()
Sets the number of immigration this player possess.

See Also:
incrementImmigration(int)

getImmigration

public int getImmigration()
Gets the number of immigration this player possess.

Returns:
The number.
See Also:
reduceImmigration()

setImmigration

public void setImmigration(int immigration)
Sets the number of immigration this player possess.

Parameters:
immigration - The immigration value for this player.

generateRecruitablesList

public java.util.List<RandomChoice<UnitType>> generateRecruitablesList()
Generate a weighted list of unit types recruitable by this player.

Returns:
A weighted list of recruitable unit types.

generateRecruitable

public UnitType generateRecruitable()
Generates a random unit type recruitable by this player.

Returns:
A random recruitable unit type.

getTradeRoutes

public final java.util.List<TradeRoute> getTradeRoutes()
Get the TradeRoutes value.

Returns:
a List value

setTradeRoutes

public final void setTradeRoutes(java.util.List<TradeRoute> newTradeRoutes)
Set the TradeRoutes value.

Parameters:
newTradeRoutes - The new TradeRoutes value.

resetTradeRouteCounts

public final void resetTradeRouteCounts()
Reset the TradeRoute counts associated with the player's trade routes.


checkEmigrate

public boolean checkEmigrate()
Checks to see whether or not a colonist can emigrate, and does so if possible.

Returns:
Whether a new colonist should immigrate.

getImmigrationRequired

public int getImmigrationRequired()
Gets the number of immigration required to cause a new colonist to emigrate.

Returns:
The number of immigration required to cause a new colonist to emigrate.

setImmigrationRequired

public void setImmigrationRequired(int immigrationRequired)
Sets the number of immigration required to cause a new colonist to emigrate.

Parameters:
immigrationRequired - The number of immigration required to cause a new colonist to emigrate.

updateImmigrationRequired

public void updateImmigrationRequired()
Updates the amount of immigration needed to emigrate a Unit from Europe.


canRecruitUnits

public boolean canRecruitUnits()
Checks if this Player can recruit units by producing immigration.

Returns:
true if units can be recruited by this Player.

modifyTension

public void modifyTension(Player player,
                          int addToTension)
Modifies the hostiliy against the given player.

Parameters:
player - The Player.
addToTension - The amount to add to the current tension level.

modifyTension

public void modifyTension(Player player,
                          int addToTension,
                          IndianSettlement origin)

setTension

public void setTension(Player player,
                       Tension newTension)
Sets the hostility against the given player.

Parameters:
player - The Player.
newTension - The Tension.

getTension

public Tension getTension(Player player)
Gets the hostility this player has against the given player.

Parameters:
player - The Player.
Returns:
An object representing the tension level.

surrenderTo

public void surrenderTo(Player player)
Indian player surrenders

Parameters:
player - The Player he surrenders to.

getHistory

public final java.util.List<HistoryEvent> getHistory()
Get the History value.

Returns:
a List value

setHistory

public final void setHistory(java.util.List<HistoryEvent> newHistory)
Set the History value.

Parameters:
newHistory - The new History value.

getOutpostValue

public int getOutpostValue(Tile t)
Calculates the value of an outpost-type colony at this tile. An "outpost" is supposed to be a colony containing one worker, exporting its whole production to europe. The value of such colony is the maximum amount of money it can make in one turn, assuming sale of its secondary goods plus farmed goods from one of the surrounding tiles.

Returns:
The value of a future colony located on this tile. This value is used by the AI when deciding where to build a new colony.

getColonyValue

public int getColonyValue(Tile t)
Gets the value of building a 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.

Parameters:
t - The Tile
Returns:
The value of building a colony on the given tile.

getStance

public Player.Stance getStance(Player player)
Returns the stance towards a given player.

One of: WAR, CEASE_FIRE, PEACE and ALLIANCE.

Parameters:
player - The Player.
Returns:
The stance.

getStanceAsString

public static java.lang.String getStanceAsString(Player.Stance stance)
Returns a string describing the given stance.

Parameters:
stance - The stance.
Returns:
A matching string.

setStance

public void setStance(Player player,
                      Player.Stance newStance)
Sets the stance towards a given player.

One of: WAR, CEASE_FIRE, PEACE and ALLIANCE. This only sets this player stance, changeRelationsWithPlayer should be used to set both players

Parameters:
player - The Player.
newStance - The stance.

changeRelationWithPlayer

public void changeRelationWithPlayer(Player player,
                                     Player.Stance newStance)

getRecruitPrice

public int getRecruitPrice()
Gets the price for a recruit in europe.

Returns:
The price of a single recruit in Europe.

getLiberty

public int getLiberty()
Gets the current amount of liberty this Player has.

Returns:
This player's number of liberty earned towards the current Founding Father.
See Also:
Goods.BELLS, incrementLiberty(int)

getLibertyProductionNextTurn

public int getLibertyProductionNextTurn()
Returns how many total liberty will be produced if no colonies are lost and nothing unexpected happens.

Returns:
Total number of liberty this Player's Colonys will make.
See Also:
Goods.BELLS, incrementLiberty(int)

newTurn

public void newTurn()
Prepares this Player for a new turn.


exploreAllColonies

private void exploreAllColonies()

getArrears

public int getArrears(GoodsType type)
Returns the arrears due for a type of goods.

Parameters:
type - a GoodsType value
Returns:
The arrears due for this type of goods.

getArrears

public int getArrears(Goods goods)
Returns the arrears due for a type of goods.

Parameters:
goods - The goods.
Returns:
The arrears due for this type of goods.

setArrears

public void setArrears(GoodsType goodsType)
Sets the arrears for a type of goods.

Parameters:
goodsType - a GoodsType value

setArrears

public void setArrears(Goods goods)
Sets the arrears for these goods.

Parameters:
goods - The goods.

resetArrears

public void resetArrears(GoodsType goodsType)
Resets the arrears for this type of goods to zero.

Parameters:
goodsType - a GoodsType value

resetArrears

public void resetArrears(Goods goods)
Resets the arrears for these goods to zero. This is the same as calling:

resetArrears(goods.getType());

Parameters:
goods - The goods to reset the arrears for.
See Also:
resetArrears(GoodsType)

canTrade

public boolean canTrade(GoodsType type)
Returns true if type of goods can be traded in Europe.

Parameters:
type - The goods type.
Returns:
True if there are no arrears due for this type of goods.

canTrade

public boolean canTrade(GoodsType type,
                        int marketAccess)
Returns true if type of goods can be traded at specified place.

Parameters:
type - The GoodsType.
marketAccess - Way the goods are traded (Europe OR Custom)
Returns:
true if type of goods can be traded.

canTrade

public boolean canTrade(Goods goods,
                        int marketAccess)
Returns true if type of goods can be traded at specified place

Parameters:
goods - The goods.
marketAccess - Place where the goods are traded (Europe OR Custom)
Returns:
True if type of goods can be traded.

canTrade

public boolean canTrade(Goods goods)
Returns true if type of goods can be traded in Europe.

Parameters:
goods - The goods.
Returns:
True if there are no arrears due for this type of goods.

getTax

public int getTax()
Returns the current tax.

Returns:
The current tax.

setTax

public void setTax(int amount)
Sets the current tax. If Thomas Paine has already joined the Continental Congress, the libertyBonus is adjusted accordingly.

Parameters:
amount - The new tax.

updateAddTaxToLiberty

private void updateAddTaxToLiberty()

getSales

public int getSales(GoodsType goodsType)
Returns the current sales.

Parameters:
goodsType - a GoodsType value
Returns:
The current sales.

modifySales

public void modifySales(GoodsType goodsType,
                        int amount)
Modifies the current sales.

Parameters:
goodsType - a GoodsType value
amount - The new sales.

hasTraded

public boolean hasTraded(GoodsType goodsType)
Has a type of goods been traded?

Parameters:
goodsType - a GoodsType value
Returns:
Whether these goods have been traded.

getMostValuableGoods

public Goods getMostValuableGoods()
Returns the most valuable goods available in one of the player's colonies for the purposes of choosing a threat-to-boycott. The goods must not currently be boycotted, the player must have traded in it, and the amount will not exceed 100.

Returns:
A goods object, or null.

getIncomeBeforeTaxes

public int getIncomeBeforeTaxes(GoodsType goodsType)
Returns the current incomeBeforeTaxes.

Parameters:
goodsType - The GoodsType.
Returns:
The current incomeBeforeTaxes.

modifyIncomeBeforeTaxes

public void modifyIncomeBeforeTaxes(GoodsType goodsType,
                                    int amount)
Modifies the current incomeBeforeTaxes.

Parameters:
goodsType - The GoodsType.
amount - The new incomeBeforeTaxes.

getIncomeAfterTaxes

public int getIncomeAfterTaxes(GoodsType goodsType)
Returns the current incomeAfterTaxes.

Parameters:
goodsType - The GoodsType.
Returns:
The current incomeAfterTaxes.

modifyIncomeAfterTaxes

public void modifyIncomeAfterTaxes(GoodsType goodsType,
                                   int amount)
Modifies the current incomeAfterTaxes.

Parameters:
goodsType - The GoodsType.
amount - The new incomeAfterTaxes.

getDifficulty

public DifficultyLevel getDifficulty()
Returns the difficulty level.

Returns:
The difficulty level.

equals

public boolean equals(Player o)
Checks if the given Player equals this object.

Parameters:
o - The Player to compare against this object.
Returns:
true if the two Player are equal and none of both have nation == null and false otherwise.

toXMLImpl

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

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

Specified by:
toXMLImpl in class FreeColGameObject
Parameters:
out - The target stream.
player - The Player this XML-representation should be made for, or null if showAll == true.
showAll - Only attributes visible to player will be added to the representation if showAll is set to false.
toSavedGame - If true then information that is only needed when saving a game is added.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

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

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

toXMLPartialImpl

protected void toXMLPartialImpl(javax.xml.stream.XMLStreamWriter out,
                                java.lang.String[] fields)
                         throws javax.xml.stream.XMLStreamException
Partial writer for players, so that simple updates to fields such as gold can be brief.

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

readFromXMLPartialImpl

protected void readFromXMLPartialImpl(javax.xml.stream.XMLStreamReader in)
                               throws javax.xml.stream.XMLStreamException
Partial reader for players, so that simple updates to fields such as gold can be brief.

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

getXMLElementTagName

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

Returns:
"player"