net.sf.freecol.server.model
Class ServerPlayer

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
              extended by net.sf.freecol.server.model.ServerPlayer
All Implemented Interfaces:
Nameable, ServerModelObject

public class ServerPlayer
extends Player
implements ServerModelObject

A Player with additional (server specific) information. That is: pointers to this player's Connection and Socket


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Player
Player.ActivePredicate, Player.GoingToPredicate, Player.NoClaimReason, Player.PlayerType, Player.Stance, Player.UnitIterator, Player.UnitPredicate
 
Field Summary
static int ALARM_MISSIONARY_PRESENT
           
static int ALARM_RADIUS
           
static int ALARM_TILE_IN_USE
           
private  boolean connected
           
private  Connection connection
          The connection for this player.
private static java.util.logging.Logger logger
           
static int MAX_CONVERT_DISTANCE
           
private  int remainingEmigrants
          Remaining emigrants to select due to a fountain of youth
private  java.net.Socket socket
          The network socket to the player's client.
private  java.util.List<ServerPlayer> stanceDirty
          Players with respect to which stance has changed.
 
Fields inherited from class net.sf.freecol.common.model.Player
admin, ai, allFathers, ASSIGN_SETTLEMENT_NAME, attackedByPrivateers, capitalName, currentFather, dead, entryLocation, europe, featureContainer, gold, GOLD_NOT_ACCOUNTED, highSeas, history, immigration, immigrationRequired, independentNationName, lastSales, liberty, market, modelMessages, monarch, name, nameIndex, nationID, nationType, newLandName, offeredFathers, oldSoL, playerComparator, playerType, ready, score, SCORE_SETTLEMENT_DESTROYED, settlementFallback, settlementNames, settlements, stance, tax, tension, tradeRoutes, units, 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
ServerPlayer(Game game, java.lang.String id)
          Trivial constructor required for all ServerModelObjects.
ServerPlayer(Game game, java.lang.String name, boolean admin, Nation nation, java.net.Socket socket, Connection connection)
          Creates a new ServerPlayer.
 
Method Summary
 void addHistory(HistoryEvent event)
          Add a HistoryEvent to this player.
 void addStanceChange(ServerPlayer other)
          Adds a player to the list of players for whom the stance has changed.
 void buy(GoodsContainer container, GoodsType type, int amount, java.util.Random random)
          Buy goods in Europe.
 boolean canRecruitFoundingFather()
          Checks whether to start recruiting a founding father.
 boolean checkForDeath()
          Checks if this player has died.
 boolean checkForREFDefeat()
          Check if a REF player has been defeated and should surrender.
 FoundingFather checkFoundingFather()
          Checks whether the current founding father has been recruited.
 java.util.List<Unit> createUnits(java.util.List<AbstractUnit> abstractUnits)
          Create units from a list of abstract units.
 void csAddFoundingFather(FoundingFather father, java.util.Random random, ChangeSet cs)
          Adds a founding father to a players continental congress.
 void csAddMercenaries(java.util.List<AbstractUnit> mercs, int price, ChangeSet cs)
          Adds mercenaries that the player has accepted.
private  void csAutoequipUnit(Unit unit, Settlement settlement, ChangeSet cs)
          Notifies of automatic arming.
private  void csBombardEnemyShips(java.util.Random random, ChangeSet cs)
          All player colonies bombard all available targets.
private  void csBurnMissions(Unit attacker, IndianSettlement settlement, ChangeSet cs)
          Burns a players missions.
private  void csCaptureAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
          Defender autoequips but loses and attacker captures the equipment.
private  void csCaptureColony(Unit attacker, Colony colony, java.util.Random random, ChangeSet cs)
          Captures a colony.
private  void csCaptureConvert(Unit attacker, IndianSettlement natives, java.util.Random random, ChangeSet cs)
          Extracts a convert from a native settlement.
private  void csCaptureEquip(Unit winner, Unit loser, ChangeSet cs)
          Captures equipment.
private  void csCaptureEquipment(Unit winner, Unit loser, EquipmentType equip, ChangeSet cs)
          Capture equipment.
private  void csCaptureUnit(Unit winner, Unit loser, ChangeSet cs)
          Capture a unit.
 boolean csChangeStance(Player.Stance stance, Player otherPlayer, boolean symmetric, ChangeSet cs)
          Modifies stance.
 void csClaimLand(Tile tile, Settlement settlement, int price, ChangeSet cs)
          Claim land.
 void csCombat(FreeColGameObject attacker, FreeColGameObject defender, java.util.List<CombatModel.CombatResult> crs, java.util.Random random, ChangeSet cs)
          Combat.
 ServerPlayer csContact(ServerPlayer other, Tile tile, ChangeSet cs)
          Make contact between two nations if necessary.
private  void csDamageColonyShips(Unit attacker, Colony colony, ChangeSet cs)
          Damages all ships in a colony in preparation for capture.
private  void csDamageShip(Unit ship, Location repair, ChangeSet cs)
          Damage a ship.
private  void csDamageShipAttack(Unit attacker, Unit ship, ChangeSet cs)
          Damage a ship through normal attack.
private  void csDamageShipBombard(Settlement settlement, Unit ship, ChangeSet cs)
          Damage a ship through bombard.
private  void csDemoteUnit(Unit winner, Unit loser, ChangeSet cs)
          Demotes a unit.
private  void csDestroyColony(Unit attacker, Colony colony, java.util.Random random, ChangeSet cs)
          Destroy a colony.
private  void csDestroySettlement(Unit attacker, IndianSettlement settlement, java.util.Random random, ChangeSet cs)
          Destroys an Indian settlement.
private  void csDisposeSettlement(Settlement settlement, ChangeSet cs)
          Disposes of a settlement and reassign its tiles.
 void csEmigrate(int slot, Europe.MigrationType type, java.util.Random random, ChangeSet cs)
          A unit migrates from Europe.
private  void csEvadeAttack(Unit attacker, Unit defender, ChangeSet cs)
          Evade a normal attack.
private  void csEvadeBombard(Settlement settlement, Unit defender, ChangeSet cs)
          Evade a bombardment.
 void csFlushMarket(GoodsType type, ChangeSet cs)
          Flush any market price changes for a specified goods type.
 void csKill(ChangeSet cs)
          Kill off a player and clear out its remains.
 void csKillMissionary(IndianSettlement settlement, ChangeSet cs)
          Kills the missionary in a settlement.
private  void csLootShip(Unit winner, Unit loser, ChangeSet cs)
          Loot a ship.
private  void csLoseAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
          Unit autoequips but loses equipment.
private  void csLoseEquip(Unit winner, Unit loser, ChangeSet cs)
          Unit drops some equipment.
 void csNewTurn(java.util.Random random, ChangeSet cs)
          New turn for this player.
private  void csPillageColony(Unit attacker, Colony colony, java.util.Random random, ChangeSet cs)
          Damage a building or a ship or steal some goods or gold.
private  void csPromoteUnit(Unit winner, Unit loser, ChangeSet cs)
          Promotes a unit.
 void csRaiseTax(int tax, Goods goods, boolean accepted, ChangeSet cs)
          Raises the players tax rate, or handles a goods party.
 void csSeeNewTiles(java.util.List<Tile> newTiles, ChangeSet cs)
          Updates the PlayerExploredTile for each new tile on a supplied list, and update a changeset as well.
 void csSetTax(int tax, ChangeSet cs)
          Set the player tax rate.
private  void csSinkColonyShips(Unit attacker, Colony colony, ChangeSet cs)
          Sinks all ships in a colony.
private  void csSinkShip(Unit ship, ServerPlayer attackerPlayer, ChangeSet cs)
          Sink the ship.
private  void csSinkShipAttack(Unit attacker, Unit ship, ChangeSet cs)
          Sinks this ship as result of a normal attack.
private  void csSinkShipBombard(Settlement settlement, Unit ship, ChangeSet cs)
          Sinks this ship as result of a bombard.
private  void csSlaughterUnit(Unit winner, Unit loser, ChangeSet cs)
          Slaughter a unit.
 void csStartTurn(java.util.Random random, ChangeSet cs)
          Starts a new turn for a player.
 void csWithdraw(ChangeSet cs)
          Withdraw a player from the new world.
 void csYearlyGoodsAdjust(java.util.Random random, ChangeSet cs)
          Add or remove a standard yearly amount of storable goods, and a random extra amount of a random type.
 java.util.List<RandomChoice<UnitType>> generateRecruitablesList()
          Generate a weighted list of unit types recruitable by this player.
 Connection getConnection()
          Gets the connection of this player.
private  java.lang.String getContactKey(ServerPlayer other)
          Check for a special contact panel for a nation.
 java.util.List<FoundingFather> getRandomFoundingFathers(java.util.Random random)
          Build a list of random FoundingFathers, one per type.
 int getRemainingEmigrants()
           
 java.lang.String getServerXMLElementTagName()
          Returns the tag name of the root element representing this object.
private  int getSlaughterTension(Unit loser)
          Gets the amount to raise tension by when a unit is slaughtered.
 java.net.Socket getSocket()
          Gets the socket of this player.
 boolean hasExplored(Tile tile)
          Checks if this Player has explored the given Tile.
 boolean isConnected()
          Checks if this player is currently connected to the server.
 int priceMercenaries(java.util.List<AbstractUnit> mercenaries)
          Calculates the price of a group of mercenaries for this player.
private  void propagateToEuropeanMarkets(GoodsType type, int amount, java.util.Random random)
          Propagate an European market change to the other European markets.
 void resetExploredTiles(Map map)
          Resets this player's explored tiles.
 void revealMap()
          Makes the entire map visible.
 void sell(GoodsContainer container, GoodsType type, int amount, java.util.Random random)
          Sell goods in Europe.
 void setConnected(boolean connected)
          Sets the "connected"-status of this player.
 void setConnection(Connection connection)
          Sets the connection of this 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 setRemainingEmigrants(int emigrants)
           
 void startGame(java.util.Random random)
          Performs initial randomizations for this player.
 java.lang.String toString()
          Returns the name of this player.
 
Methods inherited from class net.sf.freecol.common.model.Player
addFather, addModelMessage, addSettlement, atWarWith, canAcquireForImprovement, canBuildColonies, canClaimForImprovement, canClaimForSettlement, canClaimForSettlementReason, canClaimToFoundSettlement, canClaimToFoundSettlementReason, canHaveFoundingFathers, canMoveToEurope, canOwnTile, canRecruitUnits, canSee, canTrade, canTrade, canTrade, canTrade, checkEmigrate, checkGold, clearModelMessages, clearOfferedFathers, divertModelMessages, equals, getArrears, getArrears, getAttackedByPrivateers, getCapitalName, getColonies, getColoniesPopulation, getColony, getColonyValue, getCurrentFather, getDead, getDisplayName, getEntryLocation, getEurope, getEuropeNameKey, getFatherCount, getFathers, getFeatureContainer, getGold, getHighSeas, getHistory, getImmigration, getImmigrationRequired, getIncomeAfterTaxes, getIncomeBeforeTaxes, getIndependentNationName, getIndianSettlement, getIndianSettlements, getIndianSettlementsWithMission, getLandPrice, getLastSale, getLastSaleString, getLiberty, getLibertyProductionNextTurn, getMarket, getMarketName, getMaximumFoodConsumption, getModelMessages, getModifierSet, getModifierSet, getMonarch, getMostValuableGoods, getName, getNameIndex, getNameKey, getNation, getNationID, getNationName, getNationNameKey, getNationType, getNewLandName, getNewModelMessages, getNextActiveUnit, getNextGoingToUnit, getNumberOfKingLandUnits, getNumberOfSettlements, getOfferedFathers, getOutpostValue, getPlayerType, getPrice, getRebels, getRecruitPrice, getREFPlayer, getRemainingFoundingFatherCost, getRulerNameKey, getSales, getScore, getSettlement, getSettlementName, getSettlements, getSoL, getSortedColonies, getStance, getTax, getTension, getTotalFoundingFatherCost, getTradeRoutes, getUnit, getUnitIterator, getUnits, getXMLElementTagName, hasAbility, hasContacted, hasContactedEuropeans, hasContactedIndians, hasFather, hasManOfWar, hasNextActiveUnit, hasNextGoingToUnit, hasSettlement, hasTraded, hasVisited, incrementImmigration, incrementLiberty, initializeHighSeas, installSettlementNames, invalidateCanSeeTiles, isAdmin, isAI, isAtWar, isDead, isEuropean, isIndian, isNewLandNamed, isReady, isREF, isUndead, isUnknownEnemy, isWorkForREF, makeContact, modifyGold, modifyIncomeAfterTaxes, modifyIncomeBeforeTaxes, modifySales, modifyScore, modifyTension, modifyTension, owns, readFromXMLImpl, readFromXMLPartialImpl, recalculateBellsBonus, reduceImmigration, reinitialiseMarket, removeModelMessages, removeSettlement, removeTension, removeUnit, resetIterators, saveSale, setAI, setAttackedByPrivateers, setCurrentFather, setDead, setEntryLocation, setEurope, setFeatureContainer, setGold, setImmigration, setImmigrationRequired, setIndependentNationName, setLiberty, setMonarch, setName, setNameIndex, setNation, setNationType, setNewLandName, setNextActiveUnit, setOfferedFathers, setPlayerType, setReady, setScore, setStance, setTax, setTension, setTradeRoutes, setUnit, toXMLImpl, toXMLPartialImpl, updateImmigrationRequired, writeAttributes, writeChildren
 
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 net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setSpecification, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeAttributes, writeChildren
 
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

ALARM_RADIUS

public static final int ALARM_RADIUS
See Also:
Constant Field Values

ALARM_TILE_IN_USE

public static final int ALARM_TILE_IN_USE
See Also:
Constant Field Values

ALARM_MISSIONARY_PRESENT

public static final int ALARM_MISSIONARY_PRESENT
See Also:
Constant Field Values

MAX_CONVERT_DISTANCE

public static final int MAX_CONVERT_DISTANCE
See Also:
Constant Field Values

socket

private java.net.Socket socket
The network socket to the player's client.


connection

private Connection connection
The connection for this player.


connected

private boolean connected

remainingEmigrants

private int remainingEmigrants
Remaining emigrants to select due to a fountain of youth


stanceDirty

private java.util.List<ServerPlayer> stanceDirty
Players with respect to which stance has changed.

Constructor Detail

ServerPlayer

public ServerPlayer(Game game,
                    java.lang.String id)
Trivial constructor required for all ServerModelObjects.


ServerPlayer

public ServerPlayer(Game game,
                    java.lang.String name,
                    boolean admin,
                    Nation nation,
                    java.net.Socket socket,
                    Connection connection)
Creates a new ServerPlayer.

Parameters:
game - The Game this object belongs to.
name - The player name.
admin - Whether the player is the game administrator or not.
nation - The nation of the Player.
socket - The socket to the player's client.
connection - The Connection for the socket.
Method Detail

isConnected

public boolean isConnected()
Checks if this player is currently connected to the server.

Returns:
true if this player is currently connected to the server and false otherwise.

setConnected

public void setConnected(boolean connected)
Sets the "connected"-status of this player.

Parameters:
connected - Should be true if this player is currently connected to the server and false otherwise.
See Also:
isConnected()

getSocket

public java.net.Socket getSocket()
Gets the socket of this player.

Returns:
The Socket.

getConnection

public Connection getConnection()
Gets the connection of this player.

Returns:
The Connection.

setConnection

public void setConnection(Connection connection)
Sets the connection of this player.

Parameters:
connection - The Connection.

startGame

public void startGame(java.util.Random random)
Performs initial randomizations for this player.

Parameters:
random - A pseudo-random number source.

checkForDeath

public boolean checkForDeath()
Checks if this player has died.

Returns:
True if this player should die.

checkForREFDefeat

public boolean checkForREFDefeat()
Check if a REF player has been defeated and should surrender.

Returns:
True if this REF player has been defeated.

csKillMissionary

public void csKillMissionary(IndianSettlement settlement,
                             ChangeSet cs)
Kills the missionary in a settlement.

Parameters:
settlement - The IndianSettlement to kill the missionary from.
cs - A ChangeSet to update.

csKill

public void csKill(ChangeSet cs)
Kill off a player and clear out its remains.

Parameters:
cs - A ChangeSet to update.

csWithdraw

public void csWithdraw(ChangeSet cs)
Withdraw a player from the new world.

Parameters:
cs - A ChangeSet to update.

getRemainingEmigrants

public int getRemainingEmigrants()

setRemainingEmigrants

public void setRemainingEmigrants(int emigrants)

checkFoundingFather

public FoundingFather checkFoundingFather()
Checks whether the current founding father has been recruited.

Returns:
The new founding father, or null if none available or ready.

canRecruitFoundingFather

public boolean canRecruitFoundingFather()
Checks whether to start recruiting a founding father.

Returns:
True if a new father should be chosen.

getRandomFoundingFathers

public java.util.List<FoundingFather> getRandomFoundingFathers(java.util.Random random)
Build a list of random FoundingFathers, one per type. Do not include any the player has or are not available.

Parameters:
random - A pseudo-random number source.
Returns:
A list of FoundingFathers.

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.

addHistory

public void addHistory(HistoryEvent event)
Add a HistoryEvent to this player.

Overrides:
addHistory in class Player
Parameters:
event - The HistoryEvent to add.

resetExploredTiles

public void resetExploredTiles(Map map)
Resets this player's explored tiles. This is done by setting all the tiles within a Units line of sight visible. The other tiles are made unvisible.

Parameters:
map - The Map to reset the explored tiles on.
See Also:
hasExplored(net.sf.freecol.common.model.Tile)

hasExplored

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

Overrides:
hasExplored in class Player
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.

Overrides:
setExplored in class Player
Parameters:
tile - The Tile to set explored.
See Also:
Tile.updatePlayerExploredTile(Player, boolean)

setExplored

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

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

createUnits

public java.util.List<Unit> createUnits(java.util.List<AbstractUnit> abstractUnits)
Create units from a list of abstract units. Only used by Europeans at present, so the units are created in Europe.

Parameters:
abstractUnits - The list of AbstractUnits to create.
Returns:
A list of units created.

priceMercenaries

public int priceMercenaries(java.util.List<AbstractUnit> mercenaries)
Calculates the price of a group of mercenaries for this player.

Parameters:
mercenaries - A list of mercenaries to price.
Returns:
The price.

revealMap

public void revealMap()
Makes the entire map visible. Debug mode helper.


propagateToEuropeanMarkets

private void propagateToEuropeanMarkets(GoodsType type,
                                        int amount,
                                        java.util.Random random)
Propagate an European market change to the other European markets.

Parameters:
type - The type of goods that was traded.
amount - The amount of goods that was traded.
random - A Random number source.

csFlushMarket

public void csFlushMarket(GoodsType type,
                          ChangeSet cs)
Flush any market price changes for a specified goods type.

Parameters:
type - The GoodsType to check.
cs - A ChangeSet to update.

buy

public void buy(GoodsContainer container,
                GoodsType type,
                int amount,
                java.util.Random random)
         throws java.lang.IllegalStateException
Buy goods in Europe.

Parameters:
container - The GoodsContainer to carry the goods.
type - The GoodsType to buy.
amount - The amount of goods to buy.
random - A Random number source.
Throws:
java.lang.IllegalStateException - If the player cannot afford to buy the goods.

sell

public void sell(GoodsContainer container,
                 GoodsType type,
                 int amount,
                 java.util.Random random)
Sell goods in Europe.

Parameters:
container - An optional GoodsContainer carrying the goods.
type - The GoodsType to sell.
amount - The amount of goods to sell.
random - A Random number source.

addStanceChange

public void addStanceChange(ServerPlayer other)
Adds a player to the list of players for whom the stance has changed.

Parameters:
other - The ServerPlayer to add.

csChangeStance

public boolean csChangeStance(Player.Stance stance,
                              Player otherPlayer,
                              boolean symmetric,
                              ChangeSet cs)
Modifies stance.

Parameters:
stance - The new Stance.
otherPlayer - The Player wrt which the stance changes.
symmetric - If true, change the otherPlayer stance as well.
cs - A ChangeSet to update.
Returns:
True if there was a change in stance at all.

csNewTurn

public void csNewTurn(java.util.Random random,
                      ChangeSet cs)
New turn for this player.

Specified by:
csNewTurn in interface ServerModelObject
Parameters:
random - A Random number source.
cs - A ChangeSet to update.

csStartTurn

public void csStartTurn(java.util.Random random,
                        ChangeSet cs)
Starts a new turn for a player. Carefully do any random number generation outside of any threads that start so as to keep random number generation deterministic.

Parameters:
random - A pseudo-random number source.
cs - A ChangeSet to update.

csBombardEnemyShips

private void csBombardEnemyShips(java.util.Random random,
                                 ChangeSet cs)
All player colonies bombard all available targets.

Parameters:
random - A random number source.
cs - A ChangeSet to update.

csYearlyGoodsAdjust

public void csYearlyGoodsAdjust(java.util.Random random,
                                ChangeSet cs)
Add or remove a standard yearly amount of storable goods, and a random extra amount of a random type.

Parameters:
random - A pseudo-random number source.
cs - A ChangeSet to update.

csAddFoundingFather

public void csAddFoundingFather(FoundingFather father,
                                java.util.Random random,
                                ChangeSet cs)
Adds a founding father to a players continental congress.

Parameters:
father - The FoundingFather to add.
random - A pseudo-random number source.
cs - A ChangeSet to update.

csClaimLand

public void csClaimLand(Tile tile,
                        Settlement settlement,
                        int price,
                        ChangeSet cs)
Claim land.

Parameters:
tile - The Tile to claim.
settlement - The Settlement to claim for.
price - The price to pay for the land, which must agree with the owner valuation, unless negative which denotes stealing.
cs - A ChangeSet to update.

csEmigrate

public void csEmigrate(int slot,
                       Europe.MigrationType type,
                       java.util.Random random,
                       ChangeSet cs)
A unit migrates from Europe.

Parameters:
slot - The slot within Europe to select the unit from.
type - The type of migration occurring.
random - A pseudo-random number source.
cs - A ChangeSet to update.

csCombat

public void csCombat(FreeColGameObject attacker,
                     FreeColGameObject defender,
                     java.util.List<CombatModel.CombatResult> crs,
                     java.util.Random random,
                     ChangeSet cs)
              throws java.lang.IllegalStateException
Combat.

Parameters:
attacker - The FreeColGameObject that is attacking.
defender - The FreeColGameObject that is defending.
crs - A list of CombatResults defining the result.
random - A pseudo-random number source.
cs - A ChangeSet to update.
Throws:
java.lang.IllegalStateException

getSlaughterTension

private int getSlaughterTension(Unit loser)
Gets the amount to raise tension by when a unit is slaughtered.

Parameters:
loser - The Unit that dies.
Returns:
An amount to raise tension by.

csAutoequipUnit

private void csAutoequipUnit(Unit unit,
                             Settlement settlement,
                             ChangeSet cs)
Notifies of automatic arming.

Parameters:
unit - The Unit that is auto-equipping.
settlement - The Settlement being defended.
cs - A ChangeSet to update.

csBurnMissions

private void csBurnMissions(Unit attacker,
                            IndianSettlement settlement,
                            ChangeSet cs)
Burns a players missions.

Parameters:
attacker - The Unit that attacked.
settlement - The IndianSettlement that was attacked.
cs - The ChangeSet to update.

csCaptureAutoEquip

private void csCaptureAutoEquip(Unit attacker,
                                Unit defender,
                                ChangeSet cs)
Defender autoequips but loses and attacker captures the equipment.

Parameters:
attacker - The Unit that attacked.
defender - The Unit that defended and loses equipment.
cs - A ChangeSet to update.

csCaptureColony

private void csCaptureColony(Unit attacker,
                             Colony colony,
                             java.util.Random random,
                             ChangeSet cs)
Captures a colony.

Parameters:
attacker - The attacking Unit.
colony - The Colony to capture.
random - A pseudo-random number source.
cs - The ChangeSet to update.

csCaptureConvert

private void csCaptureConvert(Unit attacker,
                              IndianSettlement natives,
                              java.util.Random random,
                              ChangeSet cs)
Extracts a convert from a native settlement.

Parameters:
attacker - The Unit that is attacking.
natives - The IndianSettlement under attack.
random - A pseudo-random number source.
cs - A ChangeSet to update.

csCaptureEquip

private void csCaptureEquip(Unit winner,
                            Unit loser,
                            ChangeSet cs)
Captures equipment.

Parameters:
winner - The Unit that captures equipment.
loser - The Unit that defended and loses equipment.
cs - A ChangeSet to update.

csCaptureEquipment

private void csCaptureEquipment(Unit winner,
                                Unit loser,
                                EquipmentType equip,
                                ChangeSet cs)
Capture equipment.

Parameters:
winner - The Unit that is capturing equipment.
loser - The Unit that is losing equipment.
equip - The EquipmentType to capture.
cs - A ChangeSet to update.

csCaptureUnit

private void csCaptureUnit(Unit winner,
                           Unit loser,
                           ChangeSet cs)
Capture a unit.

Parameters:
winner - A Unit that is capturing.
loser - A Unit to capture.
cs - A ChangeSet to update.

csDamageColonyShips

private void csDamageColonyShips(Unit attacker,
                                 Colony colony,
                                 ChangeSet cs)
Damages all ships in a colony in preparation for capture.

Parameters:
attacker - The Unit that is damaging.
colony - The Colony to damage ships in.
cs - A ChangeSet to update.

csDamageShipAttack

private void csDamageShipAttack(Unit attacker,
                                Unit ship,
                                ChangeSet cs)
Damage a ship through normal attack.

Parameters:
attacker - The attacker Unit.
ship - The Unit which is a ship to damage.
cs - A ChangeSet to update.

csDamageShipBombard

private void csDamageShipBombard(Settlement settlement,
                                 Unit ship,
                                 ChangeSet cs)
Damage a ship through bombard.

Parameters:
settlement - The attacker Settlement.
ship - The Unit which is a ship to damage.
cs - A ChangeSet to update.

csDamageShip

private void csDamageShip(Unit ship,
                          Location repair,
                          ChangeSet cs)
Damage a ship.

Parameters:
ship - The naval Unit to damage.
repair - The Location to send it to.
cs - A ChangeSet to update.

csDemoteUnit

private void csDemoteUnit(Unit winner,
                          Unit loser,
                          ChangeSet cs)
Demotes a unit.

Parameters:
winner - The Unit that won.
loser - The Unit that lost and should be demoted.
cs - A ChangeSet to update.

csDestroyColony

private void csDestroyColony(Unit attacker,
                             Colony colony,
                             java.util.Random random,
                             ChangeSet cs)
Destroy a colony.

Parameters:
attacker - The Unit that attacked.
colony - The Colony that was attacked.
random - A pseudo-random number source.
cs - The ChangeSet to update.

csDestroySettlement

private void csDestroySettlement(Unit attacker,
                                 IndianSettlement settlement,
                                 java.util.Random random,
                                 ChangeSet cs)
Destroys an Indian settlement.

Parameters:
attacker - an Unit value
settlement - an IndianSettlement value
random - A pseudo-random number source.
cs - A ChangeSet to update.

csDisposeSettlement

private void csDisposeSettlement(Settlement settlement,
                                 ChangeSet cs)
Disposes of a settlement and reassign its tiles.

Parameters:
settlement - The Settlement under attack.
cs - A ChangeSet to update.

csEvadeAttack

private void csEvadeAttack(Unit attacker,
                           Unit defender,
                           ChangeSet cs)
Evade a normal attack.

Parameters:
attacker - The attacker Unit.
defender - A naval Unit that evades the attacker.
cs - A ChangeSet to update.

csEvadeBombard

private void csEvadeBombard(Settlement settlement,
                            Unit defender,
                            ChangeSet cs)
Evade a bombardment.

Parameters:
settlement - The attacker Settlement.
defender - A naval Unit that evades the attacker.
cs - A ChangeSet to update.

csLootShip

private void csLootShip(Unit winner,
                        Unit loser,
                        ChangeSet cs)
Loot a ship.

Parameters:
winner - The winning naval Unit.
loser - The losing naval Unit
cs - A ChangeSet to update.

csLoseAutoEquip

private void csLoseAutoEquip(Unit attacker,
                             Unit defender,
                             ChangeSet cs)
Unit autoequips but loses equipment.

Parameters:
attacker - The Unit that attacked.
defender - The Unit that defended and loses equipment.
cs - A ChangeSet to update.

csLoseEquip

private void csLoseEquip(Unit winner,
                         Unit loser,
                         ChangeSet cs)
Unit drops some equipment.

Parameters:
winner - The Unit that won.
loser - The Unit that lost and loses equipment.
cs - A ChangeSet to update.

csPillageColony

private void csPillageColony(Unit attacker,
                             Colony colony,
                             java.util.Random random,
                             ChangeSet cs)
Damage a building or a ship or steal some goods or gold.

Parameters:
attacker - The attacking Unit.
colony - The Colony to pillage.
random - A pseudo-random number source.
cs - A ChangeSet to update.

csPromoteUnit

private void csPromoteUnit(Unit winner,
                           Unit loser,
                           ChangeSet cs)
Promotes a unit.

Parameters:
winner - The Unit that won and should be promoted.
loser - The Unit that lost.
cs - A ChangeSet to update.

csSinkColonyShips

private void csSinkColonyShips(Unit attacker,
                               Colony colony,
                               ChangeSet cs)
Sinks all ships in a colony.

Parameters:
attacker - The attacker Unit.
colony - The Colony to sink ships in.
cs - A ChangeSet to update.

csSinkShipAttack

private void csSinkShipAttack(Unit attacker,
                              Unit ship,
                              ChangeSet cs)
Sinks this ship as result of a normal attack.

Parameters:
attacker - The attacker Unit.
ship - The naval Unit to sink.
cs - A ChangeSet to update.

csSinkShipBombard

private void csSinkShipBombard(Settlement settlement,
                               Unit ship,
                               ChangeSet cs)
Sinks this ship as result of a bombard.

Parameters:
settlement - The bombarding Settlement.
ship - The naval Unit to sink.
cs - A ChangeSet to update.

csSinkShip

private void csSinkShip(Unit ship,
                        ServerPlayer attackerPlayer,
                        ChangeSet cs)
Sink the ship.

Parameters:
ship - The naval Unit to sink.
attackerPlayer - The ServerPlayer that attacked.
cs - A ChangeSet to update.

csSlaughterUnit

private void csSlaughterUnit(Unit winner,
                             Unit loser,
                             ChangeSet cs)
Slaughter a unit.

Parameters:
winner - The Unit that is slaughtering.
loser - The Unit to slaughter.
cs - A ChangeSet to update.

csSeeNewTiles

public void csSeeNewTiles(java.util.List<Tile> newTiles,
                          ChangeSet cs)
Updates the PlayerExploredTile for each new tile on a supplied list, and update a changeset as well.

Parameters:
newTiles - A list of Tiles to update.
cs - A ChangeSet to update.

csRaiseTax

public void csRaiseTax(int tax,
                       Goods goods,
                       boolean accepted,
                       ChangeSet cs)
Raises the players tax rate, or handles a goods party.

Parameters:
tax - The new tax rate.
goods - The Goods to use in a goods party.
accepted - Whether the tax raise was accepted.
cs - A ChangeSet to update.

csSetTax

public void csSetTax(int tax,
                     ChangeSet cs)
Set the player tax rate. If this requires a change to the bells bonuses, we have to update the whole player (bah) because we can not yet independently update the feature container.

Parameters:
tax - The new tax rate.
cs - A ChangeSet to update.

csAddMercenaries

public void csAddMercenaries(java.util.List<AbstractUnit> mercs,
                             int price,
                             ChangeSet cs)
Adds mercenaries that the player has accepted.

Parameters:
mercs - A list of mercenaries.
price - The price to be charged for them.
cs - A ChangeSet to update.

getContactKey

private java.lang.String getContactKey(ServerPlayer other)
Check for a special contact panel for a nation. If not found, check for a more general one if allowed. Assumes this player is European.

Parameters:
other - The Player nation to being contacted.
Returns:
An EventPanel key, or null if none appropriate.

csContact

public ServerPlayer csContact(ServerPlayer other,
                              Tile tile,
                              ChangeSet cs)
Make contact between two nations if necessary.

Parameters:
other - The other ServerPlayer.
tile - The Tile contact is made at.
cs - A ChangeSet to update.
Returns:
The other nation if it is welcoming this nation on first landing.

toString

public java.lang.String toString()
Description copied from class: Player
Returns the name of this player.

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

getServerXMLElementTagName

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

Specified by:
getServerXMLElementTagName in interface ServerModelObject
Returns:
"serverPlayer"