Package net.sf.freecol.server.model
Class ServerPlayer
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.Player
-
- net.sf.freecol.server.model.ServerPlayer
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Nameable
,ObjectWithId
,TurnTaker
public class ServerPlayer extends Player implements TurnTaker
APlayer
with additional (server specific) information, notably this player'sConnection
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServerPlayer.DeadCheck
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.Player
Player.ColonyValueCategory, Player.NoClaimReason, Player.NoValueType, Player.PlayerType
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALARM_RADIUS
static int
ALARM_TILE_IN_USE
private Connection
connection
The connection for this player.private java.util.List<AbstractGoods>
extraTrades
Accumulate extra trades here.private static java.util.logging.Logger
logger
private int
remainingEmigrants
Remaining emigrants to select due to a fountain of youthstatic int
SCORE_FOUNDING_FATHER
static double
SCORE_GOLD
static int
SCORE_INDEPENDENCE_BONUS_FIRST
static int
SCORE_INDEPENDENCE_BONUS_SECOND
static int
SCORE_INDEPENDENCE_BONUS_THIRD
static int
SCORE_NATION_DESTROYED
static int
SCORE_SETTLEMENT_DESTROYED
private java.util.List<Player>
stanceDirty
Players with respect to which stance has changed.-
Fields inherited from class net.sf.freecol.common.model.Player
admin, ai, ASSIGN_SETTLEMENT_NAME, attackedByPrivateers, bannedMissions, currentFather, dead, entryTile, europe, featureContainer, foundingFathers, gold, GOLD_NOT_ACCOUNTED, highSeas, history, immigration, immigrationRequired, independentNationName, interventionBells, lastSales, liberty, market, modelMessages, monarch, name, nationId, nationType, newLandName, offeredFathers, oldSoL, playerComparator, playerType, ready, score, settlements, stance, TAG, tax, tension, tradeRoutes
-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description ServerPlayer(Game game, boolean admin, Nation nation)
Creates a new ServerPlayer.ServerPlayer(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.ServerPlayer(Game game, Connection connection)
Special constructor to make a simple stub player with only the connection information valid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtraTrade(AbstractGoods ag)
Accumulate extra trades.void
addHistory(HistoryEvent event)
Add a HistoryEvent to this player.private void
addStanceChange(Player other)
Adds a player to the list of players for whom the stance has changed.int
buyInEurope(java.util.Random random, GoodsContainer container, GoodsType type, int amount)
Buy goods in Europe.boolean
canRecruitFoundingFather()
Checks whether to start recruiting a founding father.ServerPlayer.DeadCheck
checkForDeath()
Checks if this player has died.private boolean
checkForREFDefeat()
Check if a REF player has been defeated and should surrender.private FoundingFather
checkFoundingFather()
Checks whether the current founding father has been recruited.java.util.Set<Tile>
collectNewTiles(java.util.Collection<Tile> collection)
Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.java.util.Set<Tile>
collectNewTiles(java.util.stream.Stream<Tile> tiles)
Given a stream of tiles, explore unexplored tiles and return those plus the previously invisible tiles.java.util.Set<Tile>
collectNewTiles(Tile center, int radius)
Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.java.util.List<Unit>
createUnits(java.util.List<AbstractUnit> abstractUnits, Location location, java.util.Random random)
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, java.util.Random random, ChangeSet cs)
Adds mercenaries that the player has accepted.java.util.List<ModelMessage>
csApplyDisaster(java.util.Random random, Colony colony, Disaster disaster, ChangeSet cs)
Apply the effects of the givenDisaster
to the givenColony
, or thePlayer
if theColony
isnull
, and return a list of appropriateModelMessage
s.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 is, ChangeSet cs)
Burns a players missions.private void
csCaptureAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
Defender auto equips but loses and attacker captures the equipment.private void
csCaptureColony(Unit attacker, ServerColony colony, java.util.Random random, ChangeSet cs)
Captures a colony.private void
csCaptureConvert(Unit attacker, IndianSettlement is, 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, Role role, ChangeSet cs)
Capture equipment.private void
csCaptureUnit(Unit winner, Unit loser, ChangeSet cs)
Capture a unit.boolean
csChangeOwner(Unit unit, Player newOwner, java.lang.String change, Location loc, ChangeSet cs)
Change the owner of a unit or dispose of it if the change is impossible.boolean
csChangeStance(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.void
csCompleteNativeDemand(ServerPlayer demandPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result, ChangeSet cs)
Accept the native demand at a players colony.boolean
csContact(Player other, ChangeSet cs)
Make contact between two nations if necessary.private void
csDamageBuilding(Building building, ChangeSet cs)
Damage a building in a colony by downgrading it if possible and destroying it otherwise.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 is, java.util.Random random, ChangeSet cs)
Destroys an Indian settlement.void
csDiplomacy(DiplomacySession session, DiplomaticTrade agreement, ChangeSet cs)
Process European diplomacy according to an agreement.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.void
csEndTurn(ChangeSet cs)
Things to do just before ending the turn for a player.void
csEuropeanFirstContact(Unit unit, Settlement settlement, Unit otherUnit, ChangeSet cs)
Initiate first contact between this European and another European player.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.boolean
csFlushMarket(GoodsType type, ChangeSet cs)
Flush any market price changes for a specified goods type.boolean
csFlushMarket(ChangeSet cs)
Flush any market price changes.private void
csKill(ChangeSet cs)
Kill off a player and clear out its remains.private void
csLootShip(Unit winner, Unit loser, ChangeSet cs)
Loot a ship.private void
csLoseAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
Unit auto equips but loses equipment.private void
csLoseEquip(Unit winner, Unit loser, ChangeSet cs)
Unit drops some equipment.void
csLoseLocation(Location loc, ChangeSet cs)
Hook for when a player loses access to a location for whatever reason.void
csMercenaries(int price, java.util.List<AbstractUnit> mercenaries, Monarch.MonarchAction action, java.util.Random random, ChangeSet cs)
Add an independent (non-monarch) mercenary offer to the player.void
csModifyTension(Player player, int add, Settlement origin, ChangeSet cs)
Modifies the hostility against the given player.void
csModifyTension(Player player, int add, ChangeSet cs)
Modifies the hostility against the given player.void
csNativeFirstContact(Player other, Tile tile, ChangeSet cs)
Initiate first contact between this European and native player.private void
csNaturalDisasters(java.util.Random random, ChangeSet cs, int probability)
Check for natural disasters.void
csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this player.private void
csPayUpkeep(java.util.Random random, ChangeSet cs)
Pay upkeep on the player resources.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, 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.Collection<? extends Tile> newTiles, ChangeSet cs)
Updates the player view 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, Player 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, ModelMessage mm, HistoryEvent he)
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.Set<Tile>
exploreForSettlement(Settlement settlement)
Sets the tiles visible to a given settlement to be explored by this player and updates the player's information about the tiles.java.util.Set<Tile>
exploreForUnit(Unit unit)
Sets the tiles within the givenUnit
's line of sight to be explored by this player.java.util.Set<Tile>
exploreMap(boolean reveal)
Makes the entire map visible or invisible.boolean
exploreTile(Tile tile)
Sets the given tile to be explored by this player and updates the player's information about the tile.java.util.Set<Tile>
exploreTiles(java.util.Collection<? extends Tile> tiles)
Sets the tiles within the givenUnit
's line of sight to be explored by this player.void
flushExtraTrades(java.util.Random random)
Flush the extra trades.private Building
getBuildingForEffect(Colony colony, Effect effect, java.util.Random random)
Connection
getConnection()
Gets the connection of this player.java.util.List<BuildingType>
getFreeBuildingTypes()
Get a list of free building types this player has access to through its choice of founding fathers.private java.util.List<FoundingFather>
getRandomFoundingFathers(java.util.Random random)
Build a list of random FoundingFathers, one per type.int
getRemainingEmigrants()
private int
getSlaughterTension(Unit loser)
Gets the amount to raise tension by when a unit is slaughtered.private Unit
getUnitForEffect(Colony colony, Effect effect, java.util.Random random)
boolean
hasExplored(Tile tile)
Checks if thisPlayer
has explored the givenTile
.void
ignoreMercenaries(ChangeSet cs)
Handle the end of a session where the player has ignored an offer of mercenaries.void
ignoreTax(int tax, Goods goods, ChangeSet cs)
Handle the end of a session where the player has ignored a tax increase demand.void
initialize(Game game, boolean admin, Nation nation)
Complete initialization for this server player.java.util.List<Unit>
loadShips(java.util.List<Unit> landUnits, java.util.List<Unit> navalUnits, java.util.Random random)
Embark the land units.Modifier
makeTeaPartyModifier()
Make a tea party modifier for the current turn.TradeRoute
newTradeRoute()
Get a new trade route.void
propagateToEuropeanMarkets(GoodsType type, int amount, java.util.Random random)
Propagate an European market trade to the other European markets.void
randomizeGame(java.util.Random random)
Performs initial randomizations for this player.void
reassignTiles(java.util.Collection<Tile> tiles, Settlement avoid)
Try to reassign the ownership of a collection of tiles, preferring this player.int
sellInEurope(java.util.Random random, GoodsContainer container, GoodsType type, int amount)
Sell goods in Europe.boolean
send(ChangeSet cs)
Send a change set across the connection.void
setConnection(Connection connection)
Sets the connection of this player.void
setRemainingEmigrants(int emigrants)
java.lang.String
toString()
void
updateCurrentFather(FoundingFather ff)
Update the current father.private boolean
updateScore()
Update the current score for this player.-
Methods inherited from class net.sf.freecol.common.model.Player
addFather, addLastSale, addMissionBan, addModelMessage, addOwnable, addSettlement, addStartGameMessage, addTradeRoute, addUnit, atWarWith, calculateStrength, canAcquireForImprovement, canBuildColonies, canClaimForImprovement, canClaimForSettlement, canClaimForSettlementReason, canClaimToFoundSettlement, canClaimToFoundSettlementReason, canHaveFoundingFathers, canMoveToEurope, canOwnTile, canSee, canSeeUnit, canTrade, canTrade, changeNationType, changePlayerType, checkDeclareIndependence, checkEmigrate, checkGold, checkIntegrity, clearModelMessages, clearNationCache, clearNationSummary, clearOfferedFathers, clientError, clientError, copyIn, divertModelMessages, getAllColonyValues, getArrears, getAttackedByPrivateers, getBankrupt, getBannedMissions, getCapitalName, getCarriersForUnit, getClaimableTiles, getClassIndex, getClosestPortForEurope, getColonies, getColoniesPopulation, getColonyByName, getColonyList, getColonyValue, getConnectedPortList, getConnectedPorts, getCountryLabel, getCurrentFather, getDead, getDebugName, getDisplayObject, getElectionTurns, getEmigrationMessage, getEntryTile, getEurope, getEuropeanPurchasePrice, getEuropeanRecruitPrice, getEuropeNameKey, getFallbackTile, getFatherCount, getFeatureContainer, getForcesLabel, getFoundingFathers, getGold, getHighSeas, getHistory, getImmigration, getImmigrationRequired, getIncomeAfterTaxes, getIncomeBeforeTaxes, getIndependentNationName, getIndianSettlementByName, getIndianSettlementList, getIndianSettlements, getIndianSettlementsWithMissionary, getIndianSettlementsWithMissionaryList, getInterventionBells, getLabel, getLandPrice, getLastSale, getLastSales, getLastSaleString, getLastSaleTip, getLiberty, getLibertyProductionNextTurn, getMarket, getMarketName, getMaximumFoodConsumption, getMercenaryHirePrice, getMilitaryUnits, getModelMessages, getMonarch, getMostValuableGoods, getName, getNameForNewLand, getNameForRegion, getNameForTradeRoute, getNameForUnit, getNation, getNationColor, getNationId, getNationLabel, getNationResourceKey, getNationSummary, getNationType, getNewestTradeRoute, getNewLandName, getNewModelMessages, getNextActiveUnit, getNextGoingToUnit, getNumberOfKingLandUnits, getNumberOfPorts, getOfferedFathers, getOldSoL, getOurFreeColGameObject, getPlayerType, getRank, getReady, getRebels, getRebelStrengthRatio, getREFPlayer, getREFUnits, getRemainingFoundingFatherCost, getRulerNameKey, getSales, getScore, getSettlementByName, getSettlementCount, getSettlementList, getSettlementName, getSettlements, getSoL, getSortedColonies, getSpanishSuccessionScore, getStance, getStances, getStrengthRatio, getTax, getTension, getTension, getTotalFoundingFatherCost, getTotalImmigrationProduction, getTradeRouteByName, getTradeRouteCount, getTradeRoutes, getUnitByName, getUnitCount, getUnitCount, getUnits, getUnitSet, getVisibleTileSet, getWaitingLabel, getXMLTagName, hasContacted, hasContactedEuropeans, hasContactedIndians, hasFather, hasNextActiveUnit, hasNextGoingToUnit, hasSettlement, hasSettlements, hasTraded, hasUnit, hasUnitType, initializeHighSeas, invalidateCanSeeTiles, isAdmin, isAI, isAtWar, isColonial, isConnected, isDead, isEuropean, isIndian, isNewLandNamed, isPotentialEnemy, isPotentialFriend, isReady, isRebel, isREF, isUndead, isUnknownEnemy, isWorkForREF, logCheat, makeContact, missionsBanned, modifyGold, modifyImmigration, modifyIncomeAfterTaxes, modifyIncomeBeforeTaxes, modifyLiberty, modifySales, owns, putNationSummary, putSettlementName, readAttributes, readChild, readChildren, recalculateBellsBonus, reduceImmigration, refilterModelMessages, reinitialiseMarket, removeDisplayedModelMessages, removeMissionBan, removeOwnable, removeSettlement, removeTension, removeTradeRoute, removeUnit, resetIterators, restoreActiveUnit, setAI, setAttackedByPrivateers, setBankrupt, setBannedMissions, setColonyComparator, setCurrentFather, setDead, setEntryTile, setEurope, setFoundingFathers, setGold, setHistory, setImmigration, setImmigrationRequired, setIndependentNationName, setLastSales, setLiberty, setModelMessages, setMonarch, setName, setNation, setNationType, setNewLandName, setNextGoingToUnit, setOfferedFathers, setReady, setScore, setStance, setStances, setTax, setTension, setTension, strengthRatio, updateImmigrationRequired, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, disposeResources, equals, fundamentalDispose, getDisposables, getGame, getLinkTarget, getSpecification, hashCode, intern, internId, isDisposed, isInitialized, isInternable, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
-
-
-
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
-
SCORE_SETTLEMENT_DESTROYED
public static final int SCORE_SETTLEMENT_DESTROYED
- See Also:
- Constant Field Values
-
SCORE_NATION_DESTROYED
public static final int SCORE_NATION_DESTROYED
- See Also:
- Constant Field Values
-
SCORE_GOLD
public static final double SCORE_GOLD
- See Also:
- Constant Field Values
-
SCORE_FOUNDING_FATHER
public static final int SCORE_FOUNDING_FATHER
- See Also:
- Constant Field Values
-
SCORE_INDEPENDENCE_BONUS_FIRST
public static final int SCORE_INDEPENDENCE_BONUS_FIRST
- See Also:
- Constant Field Values
-
SCORE_INDEPENDENCE_BONUS_SECOND
public static final int SCORE_INDEPENDENCE_BONUS_SECOND
- See Also:
- Constant Field Values
-
SCORE_INDEPENDENCE_BONUS_THIRD
public static final int SCORE_INDEPENDENCE_BONUS_THIRD
- See Also:
- Constant Field Values
-
connection
private Connection connection
The connection for this player.
-
remainingEmigrants
private int remainingEmigrants
Remaining emigrants to select due to a fountain of youth
-
stanceDirty
private final java.util.List<Player> stanceDirty
Players with respect to which stance has changed.
-
extraTrades
private final java.util.List<AbstractGoods> extraTrades
Accumulate extra trades here.
-
-
Constructor Detail
-
ServerPlayer
public ServerPlayer(Game game, java.lang.String id)
Trivial constructor for Game.newInstance.- Parameters:
game
- TheGame
this object belongs to.id
- The object identifier.
-
ServerPlayer
public ServerPlayer(Game game, Connection connection)
Special constructor to make a simple stub player with only the connection information valid. Needed when a new player logs in.- Parameters:
game
- TheGame
this player belongs to.connection
- The initialConnection
.
-
-
Method Detail
-
initialize
public final void initialize(Game game, boolean admin, Nation nation)
Complete initialization for this server player. Used above and for the stub players created at login.- Parameters:
game
- TheGame
this object belongs to.admin
- Whether the player is the game administrator or not.nation
- The nation for this player.
-
getConnection
public final Connection getConnection()
Gets the connection of this player.- Overrides:
getConnection
in classPlayer
- Returns:
- The
Connection
.
-
setConnection
public final void setConnection(Connection connection)
Sets the connection of this player.- Overrides:
setConnection
in classPlayer
- Parameters:
connection
- TheConnection
.
-
send
public boolean send(ChangeSet cs)
Send a change set across the connection.
-
updateCurrentFather
public void updateCurrentFather(FoundingFather ff)
Update the current father.- Parameters:
ff
- TheFoundingFather
to recruit.
-
newTradeRoute
public TradeRoute newTradeRoute()
Get a new trade route.- Returns:
- The new
TradeRoute
.
-
addExtraTrade
public void addExtraTrade(AbstractGoods ag)
Accumulate extra trades.- Parameters:
ag
- TheAbstractGoods
describing the sale.
-
flushExtraTrades
public void flushExtraTrades(java.util.Random random)
Flush the extra trades.- Parameters:
random
- A pseudo-random number source.
-
randomizeGame
public void randomizeGame(java.util.Random random)
Performs initial randomizations for this player.- Parameters:
random
- A pseudo-random number source.
-
checkForDeath
public ServerPlayer.DeadCheck checkForDeath()
Checks if this player has died.- Returns:
- The appropriate
DeadCheck
value.
-
checkForREFDefeat
private boolean checkForREFDefeat()
Check if a REF player has been defeated and should surrender.- Returns:
- True if this REF player has been defeated.
-
csKill
private void csKill(ChangeSet cs)
Kill off a player and clear out its remains. +vis: Albeit killing the player makes visibility changes moot. +til: Fixes the appearance changes too.- Parameters:
cs
- AChangeSet
to update.
-
csWithdraw
public void csWithdraw(ChangeSet cs, ModelMessage mm, HistoryEvent he)
Withdraw a player from the new world. Called from the standard endTurn processing when a player is found to have died, and from the Spanish Succession routine.- Parameters:
mm
- AModelMessage
explaining why the player is leaving, or null if the standard death message should be used.he
- A correspondingHistoryEvent
, or null if the standard death message should be used.cs
- AChangeSet
to update.
-
getRemainingEmigrants
public int getRemainingEmigrants()
-
setRemainingEmigrants
public void setRemainingEmigrants(int emigrants)
-
checkFoundingFather
private 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
private 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.
-
addHistory
public void addHistory(HistoryEvent event)
Add a HistoryEvent to this player.- Overrides:
addHistory
in classPlayer
- Parameters:
event
- TheHistoryEvent
to add.
-
updateScore
private boolean updateScore()
Update the current score for this player. Known incompatibility with the Col1 manual: ``In addition, you get one point per liberty bell produced after foreign intervention'' However you are already getting a point per liberty bell produced, so this implies you get no further liberty after declaring independence!?, but it can then start again if the foreign intervention happens (penalizing players who quickly thrash the REF:-S). Whatever this really means, it is incompatible with our extensions to allow playing on (and defeating other Europeans), so for now at least just leave the simple liberty==score rule in place.- Returns:
- True if the player score changed.
-
hasExplored
public boolean hasExplored(Tile tile)
Checks if thisPlayer
has explored the givenTile
.- Overrides:
hasExplored
in classPlayer
- Parameters:
tile
- TheTile
.- Returns:
- true if the
Tile
has been explored and false otherwise.
-
exploreTile
public boolean exploreTile(Tile tile)
Sets the given tile to be explored by this player and updates the player's information about the tile. +til: Exploring the tile also updates the pet.- Parameters:
tile
- TheTile
to explore.- Returns:
- True if the tile is newly explored by this action.
-
exploreTiles
public java.util.Set<Tile> exploreTiles(java.util.Collection<? extends Tile> tiles)
Sets the tiles within the givenUnit
's line of sight to be explored by this player.- Parameters:
tiles
- A list ofTile
s.- Returns:
- A list of newly explored
Tile
s. - See Also:
hasExplored(net.sf.freecol.common.model.Tile)
-
exploreForSettlement
public java.util.Set<Tile> exploreForSettlement(Settlement settlement)
Sets the tiles visible to a given settlement to be explored by this player and updates the player's information about the tiles. Note that the player does not necessarily own the settlement (e.g. missionary at native settlement).- Parameters:
settlement
- TheSettlement
that is exploring.- Returns:
- A list of newly explored
Tile
s.
-
exploreForUnit
public java.util.Set<Tile> exploreForUnit(Unit unit)
Sets the tiles within the givenUnit
's line of sight to be explored by this player.- Parameters:
unit
- TheUnit
.- Returns:
- A list of newly explored
Tile
s. - See Also:
hasExplored(net.sf.freecol.common.model.Tile)
-
exploreMap
public java.util.Set<Tile> exploreMap(boolean reveal)
Makes the entire map visible or invisible.- Parameters:
reveal
- If true, reveal the map, if false, hide it.- Returns:
- A list of tiles whose visibility changed.
-
collectNewTiles
public java.util.Set<Tile> collectNewTiles(Tile center, int radius)
Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.- Parameters:
center
- The centerTile
to explore from.radius
- A radius to explore to.- Returns:
- A set of newly explored or currently invisible
Tile
s.
-
collectNewTiles
public java.util.Set<Tile> collectNewTiles(java.util.Collection<Tile> collection)
Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.- Parameters:
collection
- ACollection
of tiles to check.- Returns:
- A set of newly explored or currently invisible
Tile
s.
-
collectNewTiles
public java.util.Set<Tile> collectNewTiles(java.util.stream.Stream<Tile> tiles)
Given a stream of tiles, explore unexplored tiles and return those plus the previously invisible tiles.- Parameters:
tiles
- A stream ofTile
s to check.- Returns:
- A set of newly explored or currently invisible
Tile
s.
-
reassignTiles
public void reassignTiles(java.util.Collection<Tile> tiles, Settlement avoid)
Try to reassign the ownership of a collection of tiles, preferring this player. Do it in two passes so the first successful claim does not give a large advantage.- Parameters:
tiles
- The collection ofTile
s to reassign.avoid
- An optionalSettlement
to consider last when making claims.
-
createUnits
public java.util.List<Unit> createUnits(java.util.List<AbstractUnit> abstractUnits, Location location, java.util.Random random)
Create units from a list of abstract units. Only used by Europeans at present. -vis: Visibility issues depending on location. -til: Tile appearance issue if created in a colony (not ATM)- Parameters:
abstractUnits
- The list ofAbstractUnit
s to create.location
- TheLocation
where the units will be created.random
- A pseudo-random number source.- Returns:
- A list of units created.
-
loadShips
public java.util.List<Unit> loadShips(java.util.List<Unit> landUnits, java.util.List<Unit> navalUnits, java.util.Random random)
Embark the land units. For all land units, find a naval unit to carry it. Fill greedily, so as if there is excess naval capacity then the naval units at the end of the list will tend to be empty or very lightly filled, allowing them to defend the whole fleet at full strength. Returns a list of units that could not be placed on ships. -vis: Has visibility implications depending on the initial location of the loaded units. Usually ATM this is Europe which is safe, but beware. -til: Safe while in Europe though.- Parameters:
landUnits
- A list of land units to put on ships.navalUnits
- A list of ships to put land units on.random
- An optional pseudo-random number source.- Returns:
- a list of units left over
-
csFlushMarket
public boolean csFlushMarket(ChangeSet cs)
Flush any market price changes.- Parameters:
cs
- AChangeSet
to update.- Returns:
- True if the market has changed.
-
csFlushMarket
public boolean csFlushMarket(GoodsType type, ChangeSet cs)
Flush any market price changes for a specified goods type.- Parameters:
type
- TheGoodsType
to check.cs
- AChangeSet
to update.- Returns:
- True if the market price had changed.
-
buyInEurope
public int buyInEurope(java.util.Random random, GoodsContainer container, GoodsType type, int amount)
Buy goods in Europe.- Parameters:
random
- A pseudo-random number source.container
- TheGoodsContainer
to carry the goods.type
- TheGoodsType
to buy.amount
- The amount of goods to buy.- Returns:
- The amount actually removed from the market, or negative on failure.
-
sellInEurope
public int sellInEurope(java.util.Random random, GoodsContainer container, GoodsType type, int amount)
Sell goods in Europe.- Parameters:
random
- A pseudo-random number source.container
- An optionalGoodsContainer
carrying the goods.type
- TheGoodsType
to sell.amount
- The amount of goods to sell.- Returns:
- The amount actually added to the market, or negative on failure.
-
addStanceChange
private void addStanceChange(Player other)
Adds a player to the list of players for whom the stance has changed.- Parameters:
other
- ThePlayer
to add.
-
csChangeStance
public boolean csChangeStance(Stance stance, Player otherPlayer, boolean symmetric, ChangeSet cs)
Modifies stance.- Parameters:
stance
- The newStance
.otherPlayer
- ThePlayer
wrt which the stance changes.symmetric
- If true, change the otherPlayer stance as well.cs
- AChangeSet
to update.- Returns:
- True if there was a change in stance at all.
-
csModifyTension
public void csModifyTension(Player player, int add, ChangeSet cs)
Modifies the hostility against the given player. +til: Handles tile modifications.- Parameters:
player
- ThePlayer
.add
- The amount to add to the current tension level.cs
- AChangeSet
to update.
-
csModifyTension
public void csModifyTension(Player player, int add, Settlement origin, ChangeSet cs)
Modifies the hostility against the given player. +til: Handles tile modifications.- Parameters:
player
- ThePlayer
.add
- The amount to add to the current tension level.origin
- ASettlement
where the alarming event occurred.cs
- AChangeSet
to update.
-
csPayUpkeep
private void csPayUpkeep(java.util.Random random, ChangeSet cs)
Pay upkeep on the player resources.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csNaturalDisasters
private void csNaturalDisasters(java.util.Random random, ChangeSet cs, int probability)
Check for natural disasters.- Parameters:
random
- ARandom
number source.cs
- AChangeSet
to update.probability
- The percentage probability of a disaster occuring.
-
csApplyDisaster
public java.util.List<ModelMessage> csApplyDisaster(java.util.Random random, Colony colony, Disaster disaster, ChangeSet cs)
Apply the effects of the givenDisaster
to the givenColony
, or thePlayer
if theColony
isnull
, and return a list of appropriateModelMessage
s. Note that a disaster might have no effect on a particular colony. In that case, the returned list is empty.- Parameters:
random
- ARandom
number source.colony
- AColony
, ornull
.disaster
- ADisaster
value.cs
- AChangeSet
to update.- Returns:
- A list of
ModelMessage
s, possibly empty.
-
getBuildingForEffect
private Building getBuildingForEffect(Colony colony, Effect effect, java.util.Random random)
-
getUnitForEffect
private Unit getUnitForEffect(Colony colony, Effect effect, java.util.Random random)
-
propagateToEuropeanMarkets
public void propagateToEuropeanMarkets(GoodsType type, int amount, java.util.Random random)
Propagate an European market trade to the other European markets.- Parameters:
type
- The type of goods that was traded.amount
- The amount of goods that was traded.random
- A pseudo-random number source (note: may be null in some cases).
-
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. Then push out all the accumulated trades. Public for the test suite.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csStartTurn
public void csStartTurn(java.util.Random random, ChangeSet cs)
Starts a new turn for a player.- Parameters:
random
- A pseudo-random number source.cs
- AChangeSet
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
- AChangeSet
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
- TheFoundingFather
to add.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
getFreeBuildingTypes
public java.util.List<BuildingType> getFreeBuildingTypes()
Get a list of free building types this player has access to through its choice of founding fathers. Used to upgrade newly captured colonies.- Returns:
- A list of free
BuildingType
s.
-
csClaimLand
public void csClaimLand(Tile tile, Settlement settlement, int price, ChangeSet cs)
Claim land.- Parameters:
tile
- TheTile
to claim.settlement
- TheSettlement
to claim for.price
- The price to pay for the land, which must agree with the owner valuation, unless negative which denotes stealing.cs
- AChangeSet
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 withinEurope
to select the unit from.type
- The type of migration occurring.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csCombat
public void csCombat(FreeColGameObject attacker, FreeColGameObject defender, java.util.List<CombatModel.CombatResult> crs, java.util.Random random, ChangeSet cs)
Combat.- Parameters:
attacker
- TheFreeColGameObject
that is attacking.defender
- TheFreeColGameObject
that is defending.crs
- A list ofCombatResult
s defining the result.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
getSlaughterTension
private int getSlaughterTension(Unit loser)
Gets the amount to raise tension by when a unit is slaughtered.- Parameters:
loser
- TheUnit
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
- TheUnit
that is auto-equipping.settlement
- TheSettlement
being defended.cs
- AChangeSet
to update.
-
csBurnMissions
private void csBurnMissions(Unit attacker, IndianSettlement is, ChangeSet cs)
Burns a players missions.- Parameters:
attacker
- TheUnit
that attacked.is
- TheIndianSettlement
that was attacked.cs
- TheChangeSet
to update.
-
csCaptureAutoEquip
private void csCaptureAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
Defender auto equips but loses and attacker captures the equipment.- Parameters:
attacker
- TheUnit
that attacked.defender
- TheUnit
that defended and loses equipment.cs
- AChangeSet
to update.
-
csCaptureColony
private void csCaptureColony(Unit attacker, ServerColony colony, java.util.Random random, ChangeSet cs)
Captures a colony.- Parameters:
attacker
- The attackingUnit
.colony
- TheServerColony
to capture.random
- A pseudo-random number source.cs
- TheChangeSet
to update.
-
csCaptureConvert
private void csCaptureConvert(Unit attacker, IndianSettlement is, java.util.Random random, ChangeSet cs)
Extracts a convert from a native settlement.- Parameters:
attacker
- TheUnit
that is attacking.is
- TheIndianSettlement
under attack.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csCaptureEquip
private void csCaptureEquip(Unit winner, Unit loser, ChangeSet cs)
Captures equipment.- Parameters:
winner
- TheUnit
that captures equipment.loser
- TheUnit
that defended and loses equipment.cs
- AChangeSet
to update.
-
csCaptureEquipment
private void csCaptureEquipment(Unit winner, Unit loser, Role role, ChangeSet cs)
Capture equipment.- Parameters:
winner
- TheUnit
that is capturing equipment.loser
- TheUnit
that is losing equipment.role
- TheRole
wrest from the loser.cs
- AChangeSet
to update.
-
csCaptureUnit
private void csCaptureUnit(Unit winner, Unit loser, ChangeSet cs)
Capture a unit.- Parameters:
winner
- AUnit
that is capturing.loser
- AUnit
to capture.cs
- AChangeSet
to update.
-
csDamageColonyShips
private void csDamageColonyShips(Unit attacker, Colony colony, ChangeSet cs)
Damages all ships in a colony in preparation for capture.- Parameters:
attacker
- TheUnit
that is damaging.colony
- TheColony
to damage ships in.cs
- AChangeSet
to update.
-
csDamageShipAttack
private void csDamageShipAttack(Unit attacker, Unit ship, ChangeSet cs)
Damage a ship through normal attack.- Parameters:
attacker
- The attackerUnit
.ship
- TheUnit
which is a ship to damage.cs
- AChangeSet
to update.
-
csDamageShipBombard
private void csDamageShipBombard(Settlement settlement, Unit ship, ChangeSet cs)
Damage a ship through bombard.- Parameters:
settlement
- The attackerSettlement
.ship
- TheUnit
which is a ship to damage.cs
- AChangeSet
to update.
-
csDamageShip
private void csDamageShip(Unit ship, Location repair, ChangeSet cs)
Damage a ship.- Parameters:
ship
- The navalUnit
to damage.repair
- TheLocation
to send it to.cs
- AChangeSet
to update.
-
csDemoteUnit
private void csDemoteUnit(Unit winner, Unit loser, ChangeSet cs)
Demotes a unit.- Parameters:
winner
- TheUnit
that won.loser
- TheUnit
that lost and should be demoted.cs
- AChangeSet
to update.
-
csDestroyColony
private void csDestroyColony(Unit attacker, Colony colony, java.util.Random random, ChangeSet cs)
Destroy a colony.- Parameters:
attacker
- TheUnit
that attacked.colony
- TheColony
that was attacked.random
- A pseudo-random number source.cs
- TheChangeSet
to update.
-
csDestroySettlement
private void csDestroySettlement(Unit attacker, IndianSettlement is, java.util.Random random, ChangeSet cs)
Destroys an Indian settlement.- Parameters:
attacker
- The attackingUnit
.is
- AnIndianSettlement
to destroy.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csDisposeSettlement
public void csDisposeSettlement(Settlement settlement, ChangeSet cs)
Disposes of a settlement and reassign its tiles. +vis,til: Resolves the whole mess.- Parameters:
settlement
- TheSettlement
under attack.cs
- AChangeSet
to update.
-
csEvadeAttack
private void csEvadeAttack(Unit attacker, Unit defender, ChangeSet cs)
Evade a normal attack.- Parameters:
attacker
- The attackerUnit
.defender
- A navalUnit
that evades the attacker.cs
- AChangeSet
to update.
-
csEvadeBombard
private void csEvadeBombard(Settlement settlement, Unit defender, ChangeSet cs)
Evade a bombardment.- Parameters:
settlement
- The attackerSettlement
.defender
- A navalUnit
that evades the attacker.cs
- AChangeSet
to update.
-
csLootShip
private void csLootShip(Unit winner, Unit loser, ChangeSet cs)
Loot a ship.- Parameters:
winner
- The winning navalUnit
.loser
- The losing navalUnit
cs
- AChangeSet
to update.
-
csLoseAutoEquip
private void csLoseAutoEquip(Unit attacker, Unit defender, ChangeSet cs)
Unit auto equips but loses equipment.- Parameters:
attacker
- TheUnit
that attacked.defender
- TheUnit
that defended and loses equipment.cs
- AChangeSet
to update.
-
csLoseEquip
private void csLoseEquip(Unit winner, Unit loser, ChangeSet cs)
Unit drops some equipment.- Parameters:
winner
- TheUnit
that won.loser
- TheUnit
that lost and loses equipment.cs
- AChangeSet
to update.
-
csLoseLocation
public void csLoseLocation(Location loc, ChangeSet cs)
Hook for when a player loses access to a location for whatever reason. Useful for disabling trade routes.- Parameters:
loc
- TheLocation
that was lost.cs
- AChangeSet
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 attackingUnit
.colony
- TheColony
to pillage.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csDamageBuilding
private void csDamageBuilding(Building building, ChangeSet cs)
Damage a building in a colony by downgrading it if possible and destroying it otherwise. This is called as a result of pillaging, which always updates the colony tile.- Parameters:
building
- TheBuilding
to damage.cs
- aChangeSet
value
-
csPromoteUnit
private void csPromoteUnit(Unit winner, ChangeSet cs)
Promotes a unit.- Parameters:
winner
- TheUnit
that won and should be promoted.cs
- AChangeSet
to update.
-
csSinkColonyShips
private void csSinkColonyShips(Unit attacker, Colony colony, ChangeSet cs)
Sinks all ships in a colony.- Parameters:
attacker
- The attackerUnit
.colony
- TheColony
to sink ships in.cs
- AChangeSet
to update.
-
csSinkShipAttack
private void csSinkShipAttack(Unit attacker, Unit ship, ChangeSet cs)
Sinks this ship as result of a normal attack.- Parameters:
attacker
- The attackerUnit
.ship
- The navalUnit
to sink.cs
- AChangeSet
to update.
-
csSinkShipBombard
private void csSinkShipBombard(Settlement settlement, Unit ship, ChangeSet cs)
Sinks this ship as result of a bombard.- Parameters:
settlement
- The bombardingSettlement
.ship
- The navalUnit
to sink.cs
- AChangeSet
to update.
-
csSinkShip
private void csSinkShip(Unit ship, Player attackerPlayer, ChangeSet cs)
Sink the ship.- Parameters:
ship
- The navalUnit
to sink.attackerPlayer
- ThePlayer
that attacked, or nullcs
- AChangeSet
to update.
-
csSlaughterUnit
private void csSlaughterUnit(Unit winner, Unit loser, ChangeSet cs)
Slaughter a unit.- Parameters:
winner
- TheUnit
that is slaughtering.loser
- TheUnit
to slaughter.cs
- AChangeSet
to update.
-
csSeeNewTiles
public void csSeeNewTiles(java.util.Collection<? extends Tile> newTiles, ChangeSet cs)
Updates the player view for each new tile on a supplied list, and update a ChangeSet as well.- Parameters:
newTiles
- A list ofTile
s to update.cs
- AChangeSet
to update.
-
makeTeaPartyModifier
public Modifier makeTeaPartyModifier()
Make a tea party modifier for the current turn. Public for the test suite.- Returns:
- A tea party
Modifier
.
-
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
- TheGoods
to use in a goods party.accepted
- Whether the tax raise was accepted.cs
- AChangeSet
to update.
-
ignoreTax
public void ignoreTax(int tax, Goods goods, ChangeSet cs)
Handle the end of a session where the player has ignored a tax increase demand.- Parameters:
tax
- The new tax rate.goods
- TheGoods
to use in a goods party.cs
- AChangeSet
to update.
-
ignoreMercenaries
public void ignoreMercenaries(ChangeSet cs)
Handle the end of a session where the player has ignored an offer of mercenaries.- Parameters:
cs
- AChangeSet
to update.
-
csMercenaries
public void csMercenaries(int price, java.util.List<AbstractUnit> mercenaries, Monarch.MonarchAction action, java.util.Random random, ChangeSet cs)
Add an independent (non-monarch) mercenary offer to the player.- Parameters:
price
- The price to charge for the mercenaries.mercenaries
- A list of mercenary units.action
- The monarch action that caused the offer.random
- A pseudo-random number source.cs
- AChangeSet
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
- AChangeSet
to update.
-
csAddMercenaries
public void csAddMercenaries(java.util.List<AbstractUnit> mercs, int price, java.util.Random random, ChangeSet cs)
Adds mercenaries that the player has accepted.- Parameters:
mercs
- A list of mercenaries.price
- The price to be charged for them.random
- A pseudo-random number source.cs
- AChangeSet
to update.
-
csContact
public boolean csContact(Player other, ChangeSet cs)
Make contact between two nations if necessary.- Parameters:
other
- The otherPlayer
.cs
- AChangeSet
to update.- Returns:
- True if this was a first contact.
-
csNativeFirstContact
public void csNativeFirstContact(Player other, Tile tile, ChangeSet cs)
Initiate first contact between this European and native player.- Parameters:
other
- The nativePlayer
.tile
- TheTile
contact is made at if this is a first landing in the new world and it is owned by the other player.cs
- AChangeSet
to update.
-
csEuropeanFirstContact
public void csEuropeanFirstContact(Unit unit, Settlement settlement, Unit otherUnit, ChangeSet cs)
Initiate first contact between this European and another European player.- Parameters:
unit
- TheUnit
making contact.settlement
- TheSettlement
being contacted.otherUnit
- The otherUnit
being contacted.cs
- AChangeSet
to update.
-
csChangeOwner
public boolean csChangeOwner(Unit unit, Player newOwner, java.lang.String change, Location loc, ChangeSet cs)
Change the owner of a unit or dispose of it if the change is impossible. Move the unit to a new location if necessary. Also handle disappearance of any carried units that will now be invisible to the new owner. -vis(owner,newOwner)- Parameters:
unit
- TheUnit
to change ownership of.newOwner
- The new owningPlayer
.change
- An optional accompanying change type.loc
- A optional newLocation
for the unit.cs
- AChangeSet
to update.- Returns:
- True if the new owner can have this unit.
-
csCompleteNativeDemand
public void csCompleteNativeDemand(ServerPlayer demandPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result, ChangeSet cs)
Accept the native demand at a players colony.- Parameters:
demandPlayer
- TheServerPlayer
that is demanding.unit
- TheUnit
that demanded.colony
- TheColony
that was demanded of.type
- TheGoodsType
demanded, or null for gold.amount
- The amount demanded.result
- The result of the demand.cs
- AChangeSet
to update.
-
csDiplomacy
public void csDiplomacy(DiplomacySession session, DiplomaticTrade agreement, ChangeSet cs)
Process European diplomacy according to an agreement.- Parameters:
session
- TheDiplomacySession
underway.agreement
- TheDiplomaticTrade
to consider.cs
- AChangeSet
to update.
-
csEndTurn
public void csEndTurn(ChangeSet cs)
Things to do just before ending the turn for a player.- Parameters:
cs
- AChangeSet
to update.
-
csNewTurn
public void csNewTurn(java.util.Random random, LogBuilder lb, ChangeSet cs)
New turn for this player.
-
-