Package net.sf.freecol.server.control
Class InGameController
- java.lang.Object
-
- net.sf.freecol.server.control.FreeColServerHolder
-
- net.sf.freecol.server.control.Controller
-
- net.sf.freecol.server.control.InGameController
-
public final class InGameController extends Controller
The main server controller.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.function.Predicate<Player>
coronadoPred
private Monarch.MonarchAction
debugMonarchAction
private ServerPlayer
debugMonarchPlayer
private int
debugOnlyAITurns
Debug helpers, do not serialize.private static java.util.logging.Logger
logger
private java.util.Random
random
The server random number source.
-
Constructor Summary
Constructors Constructor Description InGameController(FreeColServer freeColServer)
The constructor to use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangeSet
abandonSettlement(ServerPlayer serverPlayer, Settlement settlement)
Abandon a settlement.void
addFoundingFather(Player player, FoundingFather father)
Public version of csAddFoundingFather so it can be used in the test code and DebugMenu.ChangeSet
askLearnSkill(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Ask about learning a skill at a native settlement.ChangeSet
assignTeacher(ServerPlayer serverPlayer, Unit student, Unit teacher)
Assign a student to a teacher.ChangeSet
assignTradeRoute(ServerPlayer serverPlayer, Unit unit, TradeRoute tradeRoute)
Assign a trade route to a unit.ChangeSet
buildSettlement(ServerPlayer serverPlayer, Unit unit, java.lang.String name)
Build a settlement.private ChangeSet
buyGoods(ServerPlayer serverPlayer, GoodsType type, int amount, Unit carrier)
Buy goods in Europe.ChangeSet
cashInTreasureTrain(ServerPlayer serverPlayer, Unit unit)
Cash in a treasure train.void
changeStance(Player player, Stance stance, Player other, boolean symmetric)
Public change stance and inform all routine.ChangeSet
changeState(ServerPlayer serverPlayer, Unit unit, Unit.UnitState state)
Change a units state.ChangeSet
changeWorkImprovementType(ServerPlayer serverPlayer, Unit unit, TileImprovementType type)
Change improvement work type.ChangeSet
changeWorkType(ServerPlayer serverPlayer, Unit unit, GoodsType type)
Change work type.ChangeSet
chat(ServerPlayer serverPlayer, java.lang.String message, boolean pri)
Chat.ChangeSet
chooseFoundingFather(ServerPlayer serverPlayer, FoundingFather ff)
Choose a founding father.ChangeSet
claimLand(ServerPlayer serverPlayer, Tile tile, Settlement settlement, int price)
Claim land.ChangeSet
clearSpeciality(ServerPlayer serverPlayer, Unit unit)
Clear the specialty of a unit.ChangeSet
combat(ServerPlayer attackerPlayer, FreeColGameObject attacker, FreeColGameObject defender, java.util.List<CombatModel.CombatResult> crs)
Combat.ChangeSet
continuePlaying(ServerPlayer serverPlayer)
Continue playing after winning.ServerPlayer
createREFPlayer(ServerPlayer serverPlayer)
Create the Royal Expeditionary Force player corresponding to a given player that is about to rebel.private void
csBuy(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Buy goods from a native settlement.private void
csGift(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Give goods to a native settlement.private void
csGiveIndependence(ServerPlayer serverPlayer, Player independent, ChangeSet cs)
Give independence.private void
csLaunchREF(ServerPlayer serverPlayer, boolean teleport, ChangeSet cs)
Launch the REF.private void
csMonarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action, ChangeSet cs)
Performs a monarch action.private void
csSell(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Sell goods to a native settlement.int
debugApplyDisaster(ServerColony colony, Disaster disaster)
Apply a disaster to a colony.void
debugChangeOwner(ServerColony colony, ServerPlayer serverPlayer)
Change colony owner.void
debugChangeOwner(ServerUnit unit, ServerPlayer serverPlayer)
Change unit owner.ChangeSet
declareIndependence(ServerPlayer serverPlayer, java.lang.String nationName, java.lang.String countryName)
Declare independence.ChangeSet
declineMounds(ServerPlayer serverPlayer, Tile tile)
Decline to investigate strange mounds.ChangeSet
deleteTradeRoute(ServerPlayer serverPlayer, TradeRoute tradeRoute)
Delete a trade route.ChangeSet
deliverGiftToSettlement(ServerPlayer serverPlayer, ServerUnit unit, Settlement settlement, Goods goods)
Deliver gift to settlement.ChangeSet
demandTribute(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Demand a tribute from a native settlement.ChangeSet
denounceMission(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Denounce an existing mission.ChangeSet
diplomacy(ServerPlayer serverPlayer, Colony ourColony, Unit otherUnit, DiplomaticTrade agreement)
Diplomacy.ChangeSet
diplomacy(ServerPlayer serverPlayer, Unit ourUnit, Colony otherColony, DiplomaticTrade agreement)
Diplomacy.ChangeSet
disbandUnit(ServerPlayer serverPlayer, Unit unit)
Disband a unit.ChangeSet
disconnect(ServerPlayer serverPlayer)
Disconnect the client.ChangeSet
disembarkUnit(ServerPlayer serverPlayer, ServerUnit serverUnit)
Disembark unit from a carrier.ChangeSet
embarkUnit(ServerPlayer serverPlayer, ServerUnit serverUnit, Unit carrier)
Embark a unit onto a carrier.ChangeSet
emigrate(ServerPlayer serverPlayer, int slot, Europe.MigrationType type)
A unit migrates from Europe.ChangeSet
endTurn(ServerPlayer serverPlayer)
Ends the turn of the given player.ChangeSet
enterRevengeMode(ServerPlayer serverPlayer)
Enters revenge mode against those evil AIs.ChangeSet
equipForRole(ServerPlayer serverPlayer, Unit unit, Role role, int roleCount)
Equip a unit for a specific role.ChangeSet
establishMission(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Establish a new mission.ChangeSet
europeanFirstContact(ServerPlayer serverPlayer, Unit ourUnit, Colony ourColony, Unit otherUnit, Colony otherColony, DiplomaticTrade agreement)
Handle first contact between European players.ChangeSet
gameState()
Get the game state.ChangeSet
getHighScores(ServerPlayer serverPlayer, java.lang.String key)
Gets the list of high scores.int
getSkippedTurns()
Gets the number of AI turns to skip through.private long
getTimeout()
Get the timeout for this game.ChangeSet
incite(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is, Player enemy, int gold)
Incite a settlement against an enemy.ChangeSet
indianDemand(ServerPlayer serverPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result)
Indians making demands of a colony.ChangeSet
joinColony(ServerPlayer serverPlayer, Unit unit, Colony colony)
Join a colony.ChangeSet
learnFromIndianSettlement(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Learn a skill at an IndianSettlement.ChangeSet
loadGoods(ServerPlayer serverPlayer, Location loc, GoodsType goodsType, int amount, Unit carrier)
Load goods.ChangeSet
lootCargo(ServerPlayer serverPlayer, Unit winner, java.lang.String loserId, java.util.List<Goods> loot)
Loot cargo.ChangeSet
monarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action, boolean result)
Respond to a monarch action.ChangeSet
move(ServerPlayer serverPlayer, ServerUnit unit, Tile newTile)
Move a unit.ChangeSet
moveTo(ServerPlayer serverPlayer, Unit unit, Location destination)
Move a unit across the high seas.ChangeSet
nationSummary(ServerPlayer serverPlayer, Player player)
Get a nation summary.ChangeSet
nativeFirstContact(ServerPlayer serverPlayer, Player other, Tile tile, boolean result)
Handle first contact between European and native player.ChangeSet
nativeGift(ServerPlayer serverPlayer, Unit unit, Colony colony)
A native unit delivers its gift to a colony.ChangeSet
nativeTrade(ServerPlayer serverPlayer, NativeTrade.NativeTradeAction action, NativeTrade nt)
Handle native trade sessions.ChangeSet
newTradeRoute(ServerPlayer serverPlayer)
Create a new trade route for a player.ChangeSet
payArrears(ServerPlayer serverPlayer, GoodsType type)
Pay arrears.ChangeSet
payForBuilding(ServerPlayer serverPlayer, Colony colony)
Pay for a building.ChangeSet
putOutsideColony(ServerPlayer serverPlayer, Unit unit)
Put outside colony.ChangeSet
rearrangeColony(ServerPlayer serverPlayer, Colony colony, java.util.List<RearrangeColonyMessage.Arrangement> arrangements)
Rearrange a colony.ChangeSet
renameObject(ServerPlayer serverPlayer, Nameable object, java.lang.String newName)
Rename an object.ChangeSet
retire(ServerPlayer serverPlayer)
Handle a player retiring.ChangeSet
scoutIndianSettlement(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Scout a native settlement, that is, the contacting action that generates the greeting dialog.ChangeSet
scoutSpeakToChief(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Speak to the chief at a native settlement.private ChangeSet
sellGoods(ServerPlayer serverPlayer, GoodsType type, int amount, Unit carrier)
Sell goods in Europe.ChangeSet
setBuildQueue(ServerPlayer serverPlayer, Colony colony, java.util.List<BuildableType> queue)
Set build queue.ChangeSet
setCurrentStop(ServerPlayer serverPlayer, Unit unit, int index)
Set a unit stop.ChangeSet
setDestination(ServerPlayer serverPlayer, Unit unit, Location destination)
Set a unit destination.ChangeSet
setGoodsLevels(ServerPlayer serverPlayer, Colony colony, ExportData exportData)
Set goods levels.void
setMonarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action)
Sets a monarch action to debug/test.ChangeSet
setNewLandName(ServerPlayer serverPlayer, Unit unit, java.lang.String name)
Set land name.ChangeSet
setNewRegionName(ServerPlayer serverPlayer, Unit unit, Region region, java.lang.String name)
Set region name.void
setRandom(java.util.Random random)
Set the PRNG.void
setSkippedTurns(int turns)
Sets the number of AI turns to skip through as a debug helper.ChangeSet
spySettlement(ServerPlayer serverPlayer, Unit unit, Settlement settlement)
Spy on a settlement.int
stepRandom()
Debug convenience to step the random number generator.ChangeSet
trainUnitInEurope(ServerPlayer serverPlayer, UnitType type)
Train a unit in Europe.private StringTemplate
unitTemplate(java.lang.String base, java.util.List<Unit> units)
ChangeSet
unloadGoods(ServerPlayer serverPlayer, GoodsType goodsType, int amount, Unit carrier)
Unload goods.ChangeSet
updateTradeRoute(ServerPlayer serverPlayer, TradeRoute tradeRoute)
Update a trade route for a player.ChangeSet
work(ServerPlayer serverPlayer, Unit unit, WorkLocation workLocation)
Change work location.-
Methods inherited from class net.sf.freecol.server.control.Controller
shutdown
-
Methods inherited from class net.sf.freecol.server.control.FreeColServerHolder
getFreeColServer, getGame
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
coronadoPred
private static final java.util.function.Predicate<Player> coronadoPred
-
random
private java.util.Random random
The server random number source.
-
debugOnlyAITurns
private int debugOnlyAITurns
Debug helpers, do not serialize.
-
debugMonarchAction
private Monarch.MonarchAction debugMonarchAction
-
debugMonarchPlayer
private ServerPlayer debugMonarchPlayer
-
-
Constructor Detail
-
InGameController
public InGameController(FreeColServer freeColServer)
The constructor to use.- Parameters:
freeColServer
- The main server object.
-
-
Method Detail
-
setRandom
public void setRandom(java.util.Random random)
Set the PRNG.- Parameters:
random
- The newRandom
to use in this controller.
-
getTimeout
private long getTimeout()
Get the timeout for this game.- Returns:
- A timeout.
-
getSkippedTurns
public int getSkippedTurns()
Gets the number of AI turns to skip through.- Returns:
- The number of terms to skip.
-
setSkippedTurns
public void setSkippedTurns(int turns)
Sets the number of AI turns to skip through as a debug helper.- Parameters:
turns
- The number of turns to skip through.
-
setMonarchAction
public void setMonarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action)
Sets a monarch action to debug/test.- Parameters:
serverPlayer
- TheServerPlayer
whose monarch should act.action
- TheMonarchAction
to be taken.
-
stepRandom
public int stepRandom()
Debug convenience to step the random number generator.- Returns:
- The next random number in series, in the range 0-99.
-
addFoundingFather
public void addFoundingFather(Player player, FoundingFather father)
Public version of csAddFoundingFather so it can be used in the test code and DebugMenu.- Parameters:
player
- ThePlayer
who gains a father.father
- TheFoundingFather
to add.
-
changeStance
public void changeStance(Player player, Stance stance, Player other, boolean symmetric)
Public change stance and inform all routine. Mostly used in the test suite, but the AIs also call it.- Parameters:
player
- The originatingPlayer
.stance
- The newStance
.other
- ThePlayer
wrt which the stance changes.symmetric
- If true, change the otherPlayer stance as well.
-
debugChangeOwner
public void debugChangeOwner(ServerColony colony, ServerPlayer serverPlayer)
Change colony owner. Public for DebugUtils.- Parameters:
colony
- TheServerColony
to change.serverPlayer
- TheServerPlayer
to change to.
-
debugChangeOwner
public void debugChangeOwner(ServerUnit unit, ServerPlayer serverPlayer)
Change unit owner. Public for DebugUtils.- Parameters:
unit
- TheServerUnit
to change.serverPlayer
- TheServerPlayer
to change to.
-
debugApplyDisaster
public int debugApplyDisaster(ServerColony colony, Disaster disaster)
Apply a disaster to a colony. Public for DebugUtils.- Parameters:
colony
- TheColony
to apply the disaster to.disaster
- TheDisaster
to apply.- Returns:
- The number of messages generated.
-
createREFPlayer
public ServerPlayer createREFPlayer(ServerPlayer serverPlayer)
Create the Royal Expeditionary Force player corresponding to a given player that is about to rebel. Public for the test suite. FIXME: this should eventually generate changes for the REF player.- Parameters:
serverPlayer
- TheServerPlayer
about to rebel.- Returns:
- The REF player.
-
csBuy
private void csBuy(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Buy goods from a native settlement.- Parameters:
unit
- TheUnit
that is buying.goods
- TheGoods
to buy.price
- The price to pay.sis
- TheServerIndianSettlement
to give to.cs
- AChangeSet
to update.
-
csSell
private void csSell(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Sell goods to a native settlement.- Parameters:
unit
- TheUnit
that is selling.goods
- TheGoods
to sell.price
- The price to charge.sis
- TheServerIndianSettlement
to sell to.cs
- AChangeSet
to update.
-
csGift
private void csGift(ServerUnit unit, Goods goods, int price, ServerIndianSettlement sis, ChangeSet cs)
Give goods to a native settlement.- Parameters:
unit
- TheUnit
that is giving.goods
- TheGoods
to give.price
- A price that the natives might have been willing to pay.sis
- TheServerIndianSettlement
to give to.cs
- AChangeSet
to update.
-
csLaunchREF
private void csLaunchREF(ServerPlayer serverPlayer, boolean teleport, ChangeSet cs)
Launch the REF.- Parameters:
serverPlayer
- The REFServerPlayer
.teleport
- If true, teleport the REF in.cs
- AChangeSet
to update.
-
csGiveIndependence
private void csGiveIndependence(ServerPlayer serverPlayer, Player independent, ChangeSet cs)
Give independence. Note that the REF player is granting, but most of the changes happen to the newly independent player. hence the special handling.- Parameters:
serverPlayer
- The REFServerPlayer
that is granting.independent
- The newly independentPlayer
.cs
- AChangeSet
to update.
-
unitTemplate
private StringTemplate unitTemplate(java.lang.String base, java.util.List<Unit> units)
-
csMonarchAction
private void csMonarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action, ChangeSet cs)
Performs a monarch action. Note that CHANGE_LATE is used so that these actions follow setting the current player, so that it is the players turn when they respond to a monarch action.- Parameters:
serverPlayer
- TheServerPlayer
being acted upon.action
- The monarch action.cs
- AChangeSet
to update.
-
abandonSettlement
public ChangeSet abandonSettlement(ServerPlayer serverPlayer, Settlement settlement)
Abandon a settlement.- Parameters:
serverPlayer
- TheServerPlayer
that is abandoning.settlement
- TheSettlement
to abandon.- Returns:
- A
ChangeSet
encapsulating this action.
-
askLearnSkill
public ChangeSet askLearnSkill(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Ask about learning a skill at a native settlement.- Parameters:
serverPlayer
- TheServerPlayer
that is learning.unit
- TheUnit
that is learning.is
- TheIndianSettlement
to learn from.- Returns:
- A
ChangeSet
encapsulating this action.
-
assignTeacher
public ChangeSet assignTeacher(ServerPlayer serverPlayer, Unit student, Unit teacher)
Assign a student to a teacher.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.student
- The studentUnit
.teacher
- The teacherUnit
.- Returns:
- A
ChangeSet
encapsulating this action.
-
assignTradeRoute
public ChangeSet assignTradeRoute(ServerPlayer serverPlayer, Unit unit, TradeRoute tradeRoute)
Assign a trade route to a unit.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- The unitUnit
to assign to.tradeRoute
- TheTradeRoute
to assign.- Returns:
- A
ChangeSet
encapsulating this action.
-
buildSettlement
public ChangeSet buildSettlement(ServerPlayer serverPlayer, Unit unit, java.lang.String name)
Build a settlement. +til: Resolves many tile appearance changes.- Parameters:
serverPlayer
- TheServerPlayer
that is building.unit
- TheUnit
that is building.name
- The new settlement name.- Returns:
- A
ChangeSet
encapsulating this action.
-
buyGoods
private ChangeSet buyGoods(ServerPlayer serverPlayer, GoodsType type, int amount, Unit carrier)
Buy goods in Europe.- Parameters:
serverPlayer
- TheServerPlayer
that is buying.type
- TheGoodsType
to buy.amount
- The amount of goods to buy.carrier
- TheUnit
to carry the goods.- Returns:
- A
ChangeSet
encapsulating this action.
-
cashInTreasureTrain
public ChangeSet cashInTreasureTrain(ServerPlayer serverPlayer, Unit unit)
Cash in a treasure train.- Parameters:
serverPlayer
- TheServerPlayer
that is cashing in.unit
- The treasure trainUnit
to cash in.- Returns:
- A
ChangeSet
encapsulating this action.
-
changeState
public ChangeSet changeState(ServerPlayer serverPlayer, Unit unit, Unit.UnitState state)
Change a units state.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to change the state of.state
- The newUnitState
.- Returns:
- A
ChangeSet
encapsulating this action.
-
changeWorkImprovementType
public ChangeSet changeWorkImprovementType(ServerPlayer serverPlayer, Unit unit, TileImprovementType type)
Change improvement work type.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to change the work type of.type
- The newTileImprovementType
to produce.- Returns:
- A
ChangeSet
encapsulating this action.
-
changeWorkType
public ChangeSet changeWorkType(ServerPlayer serverPlayer, Unit unit, GoodsType type)
Change work type.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to change the work type of.type
- The newGoodsType
to produce.- Returns:
- A
ChangeSet
encapsulating this action.
-
chat
public ChangeSet chat(ServerPlayer serverPlayer, java.lang.String message, boolean pri)
Chat.- Parameters:
serverPlayer
- TheServerPlayer
that is chatting.message
- The chat message.pri
- A privacy setting, currently a noop.- Returns:
- A
ChangeSet
encapsulating this action.
-
chooseFoundingFather
public ChangeSet chooseFoundingFather(ServerPlayer serverPlayer, FoundingFather ff)
Choose a founding father.- Parameters:
serverPlayer
- TheServerPlayer
that is choosing.ff
- AFoundingFather
to select.- Returns:
- A
ChangeSet
encapsulating this action.
-
claimLand
public ChangeSet claimLand(ServerPlayer serverPlayer, Tile tile, Settlement settlement, int price)
Claim land.- Parameters:
serverPlayer
- TheServerPlayer
claiming.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.- Returns:
- A
ChangeSet
encapsulating this action.
-
clearSpeciality
public ChangeSet clearSpeciality(ServerPlayer serverPlayer, Unit unit)
Clear the specialty of a unit. FIXME: why not clear speciality in the open? You can disband! If we implement this remember to fix the visibility.- Parameters:
serverPlayer
- The owner of the unit.unit
- TheUnit
to clear the speciality of.- Returns:
- A
ChangeSet
encapsulating this action.
-
combat
public ChangeSet combat(ServerPlayer attackerPlayer, FreeColGameObject attacker, FreeColGameObject defender, java.util.List<CombatModel.CombatResult> crs)
Combat. Public for the test suite.- Parameters:
attackerPlayer
- TheServerPlayer
who is attacking.attacker
- TheFreeColGameObject
that is attacking.defender
- TheFreeColGameObject
that is defending.crs
- A list ofCombatResult
s defining the result.- Returns:
- A
ChangeSet
encapsulating this action.
-
continuePlaying
public ChangeSet continuePlaying(ServerPlayer serverPlayer)
Continue playing after winning.- Parameters:
serverPlayer
- TheServerPlayer
that plays on.- Returns:
- Null.
-
declareIndependence
public ChangeSet declareIndependence(ServerPlayer serverPlayer, java.lang.String nationName, java.lang.String countryName)
Declare independence.- Parameters:
serverPlayer
- TheServerPlayer
that is declaring.nationName
- The new name for the independent nation.countryName
- The new name for its residents.- Returns:
- A
ChangeSet
containing the response.
-
declineMounds
public ChangeSet declineMounds(ServerPlayer serverPlayer, Tile tile)
Decline to investigate strange mounds.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.tile
- TheTile
where the mounds are.- Returns:
- A
ChangeSet
encapsulating this action.
-
deleteTradeRoute
public ChangeSet deleteTradeRoute(ServerPlayer serverPlayer, TradeRoute tradeRoute)
Delete a trade route.- Parameters:
serverPlayer
- TheServerPlayer
to delete a trade route for.tradeRoute
- TheTradeRoute
to delete.- Returns:
- A
ChangeSet
encapsulating this action.
-
deliverGiftToSettlement
public ChangeSet deliverGiftToSettlement(ServerPlayer serverPlayer, ServerUnit unit, Settlement settlement, Goods goods)
Deliver gift to settlement. Note that this includes both European and native gifts.- Parameters:
serverPlayer
- TheServerPlayer
that is delivering.unit
- TheUnit
that is delivering.settlement
- TheSettlement
to deliver to.goods
- TheGoods
to deliver.- Returns:
- A
ChangeSet
encapsulating this action.
-
demandTribute
public ChangeSet demandTribute(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Demand a tribute from a native settlement. FIXME: Move TURNS_PER_TRIBUTE magic number to the spec.- Parameters:
serverPlayer
- TheServerPlayer
demanding the tribute.unit
- TheUnit
that is demanding the tribute.is
- TheIndianSettlement
demanded of.- Returns:
- A
ChangeSet
encapsulating this action.
-
denounceMission
public ChangeSet denounceMission(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Denounce an existing mission.- Parameters:
serverPlayer
- TheServerPlayer
that is denouncing.sUnit
- TheServerUnit
denouncing.is
- TheIndianSettlement
containing the mission to denounce.- Returns:
- A
ChangeSet
encapsulating this action.
-
diplomacy
public ChangeSet diplomacy(ServerPlayer serverPlayer, Unit ourUnit, Colony otherColony, DiplomaticTrade agreement)
Diplomacy.- Parameters:
serverPlayer
- TheServerPlayer
that is trading.ourUnit
- TheUnit
that is trading.otherColony
- TheColony
to trade with.agreement
- TheDiplomaticTrade
to consider.- Returns:
- A
ChangeSet
encapsulating this action.
-
diplomacy
public ChangeSet diplomacy(ServerPlayer serverPlayer, Colony ourColony, Unit otherUnit, DiplomaticTrade agreement)
Diplomacy.- Parameters:
serverPlayer
- TheServerPlayer
that is trading.ourColony
- OurColony
.otherUnit
- The otherUnit
that is trading.agreement
- TheDiplomaticTrade
to consider.- Returns:
- A
ChangeSet
encapsulating this action.
-
disbandUnit
public ChangeSet disbandUnit(ServerPlayer serverPlayer, Unit unit)
Disband a unit.- Parameters:
serverPlayer
- The owner of the unit.unit
- TheUnit
to disband.- Returns:
- A
ChangeSet
encapsulating this action.
-
disconnect
public ChangeSet disconnect(ServerPlayer serverPlayer)
Disconnect the client.- Parameters:
serverPlayer
- TheServerPlayer
to disconnect.- Returns:
- Null, we never reply to a disconnect.
-
disembarkUnit
public ChangeSet disembarkUnit(ServerPlayer serverPlayer, ServerUnit serverUnit)
Disembark unit from a carrier.- Parameters:
serverPlayer
- TheServerPlayer
whose unit is embarking.serverUnit
- TheServerUnit
that is disembarking.- Returns:
- A
ChangeSet
encapsulating this action.
-
embarkUnit
public ChangeSet embarkUnit(ServerPlayer serverPlayer, ServerUnit serverUnit, Unit carrier)
Embark a unit onto a carrier. Checking that the locations are appropriate is not done here.- Parameters:
serverPlayer
- TheServerPlayer
embarking.serverUnit
- TheServerUnit
that is embarking.carrier
- TheUnit
to embark onto.- Returns:
- A
ChangeSet
encapsulating this action.
-
emigrate
public ChangeSet emigrate(ServerPlayer serverPlayer, int slot, Europe.MigrationType type)
A unit migrates from Europe.- Parameters:
serverPlayer
- TheServerPlayer
whose unit it will be.slot
- The slot withinEurope
to select the unit from.type
- The type of migration occurring.- Returns:
- A
ChangeSet
encapsulating this action.
-
endTurn
public ChangeSet endTurn(ServerPlayer serverPlayer)
Ends the turn of the given player. Note: sends messages to other players.- Parameters:
serverPlayer
- TheServerPlayer
to end the turn of.- Returns:
- A
ChangeSet
encapsulating the end of turn changes.
-
enterRevengeMode
public ChangeSet enterRevengeMode(ServerPlayer serverPlayer)
Enters revenge mode against those evil AIs.- Parameters:
serverPlayer
- TheServerPlayer
entering revenge mode.- Returns:
- A
ChangeSet
encapsulating this action.
-
equipForRole
public ChangeSet equipForRole(ServerPlayer serverPlayer, Unit unit, Role role, int roleCount)
Equip a unit for a specific role. Currently the unit is either in Europe or in a settlement. Might one day allow the unit to be on a tile co-located with an equipment-bearing wagon.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to equip.role
- TheRole
to equip for.roleCount
- The role count.- Returns:
- A
ChangeSet
encapsulating this action.
-
establishMission
public ChangeSet establishMission(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Establish a new mission.- Parameters:
serverPlayer
- TheServerPlayer
that is establishing.sUnit
- The missionaryServerUnit
.is
- TheIndianSettlement
to establish at.- Returns:
- A
ChangeSet
encapsulating this action.
-
europeanFirstContact
public ChangeSet europeanFirstContact(ServerPlayer serverPlayer, Unit ourUnit, Colony ourColony, Unit otherUnit, Colony otherColony, DiplomaticTrade agreement)
Handle first contact between European players.- Parameters:
serverPlayer
- TheServerPlayer
making contact.ourUnit
- TheUnit
making contact (may be null).ourColony
- TheColony
making contact (may be null).otherUnit
- The otherUnit
making contact (may be null).otherColony
- The otherColony
making contact (may be null).agreement
- TheDiplomaticTrade
to consider.- Returns:
- A
ChangeSet
encapsulating this action.
-
gameState
public ChangeSet gameState()
Get the game state.- Returns:
- A
ChangeSet
encapsulating this action.
-
getHighScores
public ChangeSet getHighScores(ServerPlayer serverPlayer, java.lang.String key)
Gets the list of high scores.- Parameters:
serverPlayer
- TheServerPlayer
querying the scores.key
- A score category key.- Returns:
- A
ChangeSet
encapsulating this action.
-
incite
public ChangeSet incite(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is, Player enemy, int gold)
Incite a settlement against an enemy.- Parameters:
serverPlayer
- TheServerPlayer
that is inciting.unit
- The missionaryUnit
inciting.is
- TheIndianSettlement
to incite.enemy
- ThePlayer
to be incited against.gold
- The amount of gold in the bribe.- Returns:
- A
ChangeSet
encapsulating this action.
-
indianDemand
public ChangeSet indianDemand(ServerPlayer serverPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result)
Indians making demands of a colony.- Parameters:
serverPlayer
- TheServerPlayer
that sent the message.unit
- TheUnit
making the demands.colony
- TheColony
that is demanded of.type
- TheGoodsType
being demanded, null implies gold.amount
- The amount of goods/gold being demanded.result
- The demand result (null initially).- Returns:
- A
ChangeSet
encapsulating this action.
-
joinColony
public ChangeSet joinColony(ServerPlayer serverPlayer, Unit unit, Colony colony)
Join a colony.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
that is joining.colony
- TheColony
to join.- Returns:
- A
ChangeSet
encapsulating this action.
-
learnFromIndianSettlement
public ChangeSet learnFromIndianSettlement(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Learn a skill at an IndianSettlement.- Parameters:
serverPlayer
- TheServerPlayer
that is learning.sUnit
- TheServerUnit
that is learning.is
- TheIndianSettlement
to learn from.- Returns:
- A
ChangeSet
encapsulating this action.
-
loadGoods
public ChangeSet loadGoods(ServerPlayer serverPlayer, Location loc, GoodsType goodsType, int amount, Unit carrier)
Load goods.- Parameters:
serverPlayer
- TheServerPlayer
that is loading.loc
- TheLocation
where the goods are.goodsType
- TheGoodsType
to load.amount
- The amount of goods to load.carrier
- TheUnit
to load.- Returns:
- A
ChangeSet
encapsulating this action.
-
lootCargo
public ChangeSet lootCargo(ServerPlayer serverPlayer, Unit winner, java.lang.String loserId, java.util.List<Goods> loot)
Loot cargo. Note loser is passed by identifier, as by the time we get here the unit may have been sunk.- Parameters:
serverPlayer
- TheServerPlayer
that owns the winner.winner
- TheUnit
that looting.loserId
- The object identifier of theUnit
that is looted.loot
- TheGoods
to loot.- Returns:
- A
ChangeSet
encapsulating this action.
-
monarchAction
public ChangeSet monarchAction(ServerPlayer serverPlayer, Monarch.MonarchAction action, boolean result)
Respond to a monarch action.- Parameters:
serverPlayer
- TheServerPlayer
that is to respond.action
- TheMonarchAction
to respond to.result
- The player response.- Returns:
- A
ChangeSet
containing the response.
-
move
public ChangeSet move(ServerPlayer serverPlayer, ServerUnit unit, Tile newTile)
Move a unit.- Parameters:
serverPlayer
- TheServerPlayer
that is moving.unit
- TheServerUnit
to move.newTile
- TheTile
to move to.- Returns:
- A
ChangeSet
encapsulating this action.
-
moveTo
public ChangeSet moveTo(ServerPlayer serverPlayer, Unit unit, Location destination)
Move a unit across the high seas.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to move.destination
- TheLocation
to move to.- Returns:
- A
ChangeSet
encapsulating this action.
-
nationSummary
public ChangeSet nationSummary(ServerPlayer serverPlayer, Player player)
Get a nation summary.- Parameters:
serverPlayer
- TheServerPlayer
to make the summary for.player
- ThePlayer
to summarize.- Returns:
- A
ChangeSet
encapsulating this action.
-
nativeFirstContact
public ChangeSet nativeFirstContact(ServerPlayer serverPlayer, Player other, Tile tile, boolean result)
Handle first contact between European and native player. Note that we check for a diplomacy session, but only bother in the case of tile!=null as that is the only possibility for some benefit.- Parameters:
serverPlayer
- TheServerPlayer
making contact.other
- The nativePlayer
to contact.tile
- ATile
on offer at first landing.result
- Whether the initial peace treaty was accepted.- Returns:
- A
ChangeSet
encapsulating this action.
-
nativeGift
public ChangeSet nativeGift(ServerPlayer serverPlayer, Unit unit, Colony colony)
A native unit delivers its gift to a colony.- Parameters:
serverPlayer
- TheServerPlayer
that is delivering.unit
- TheUnit
that is delivering.colony
- TheColony
to deliver to.- Returns:
- A
ChangeSet
encapsulating this action.
-
nativeTrade
public ChangeSet nativeTrade(ServerPlayer serverPlayer, NativeTrade.NativeTradeAction action, NativeTrade nt)
Handle native trade sessions.- Parameters:
serverPlayer
- TheServerPlayer
that is trading.action
- TheNativeTradeAction
to perform.nt
- TheNativeTrade
underway.- Returns:
- A
ChangeSet
encapsulating this action.
-
newTradeRoute
public ChangeSet newTradeRoute(ServerPlayer serverPlayer)
Create a new trade route for a player.- Parameters:
serverPlayer
- TheServerPlayer
that needs a new route.- Returns:
- A
ChangeSet
encapsulating this action.
-
payArrears
public ChangeSet payArrears(ServerPlayer serverPlayer, GoodsType type)
Pay arrears.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.type
- TheGoodsType
to pay the arrears for.- Returns:
- A
ChangeSet
encapsulating this action.
-
payForBuilding
public ChangeSet payForBuilding(ServerPlayer serverPlayer, Colony colony)
Pay for a building.- Parameters:
serverPlayer
- TheServerPlayer
that owns the colony.colony
- TheColony
that is building.- Returns:
- A
ChangeSet
encapsulating this action.
-
putOutsideColony
public ChangeSet putOutsideColony(ServerPlayer serverPlayer, Unit unit)
Put outside colony.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to be put out.- Returns:
- A
ChangeSet
encapsulating this action.
-
rearrangeColony
public ChangeSet rearrangeColony(ServerPlayer serverPlayer, Colony colony, java.util.List<RearrangeColonyMessage.Arrangement> arrangements)
Rearrange a colony.- Parameters:
serverPlayer
- TheServerPlayer
that is querying.colony
- TheColony
to rearrange.arrangements
- A list ofArrangement
s to apply.- Returns:
- A
ChangeSet
encapsulating this action.
-
renameObject
public ChangeSet renameObject(ServerPlayer serverPlayer, Nameable object, java.lang.String newName)
Rename an object.- Parameters:
serverPlayer
- TheServerPlayer
that is naming.object
- TheNameable
to rename.newName
- The new name.- Returns:
- A
ChangeSet
encapsulating this action.
-
retire
public ChangeSet retire(ServerPlayer serverPlayer)
Handle a player retiring.- Parameters:
serverPlayer
- TheServerPlayer
that is retiring.- Returns:
- A
ChangeSet
containing the response.
-
scoutIndianSettlement
public ChangeSet scoutIndianSettlement(ServerPlayer serverPlayer, ServerUnit unit, IndianSettlement is)
Scout a native settlement, that is, the contacting action that generates the greeting dialog.- Parameters:
serverPlayer
- TheServerPlayer
that is scouting.unit
- The scoutUnit
.is
- TheIndianSettlement
to scout.- Returns:
- A
ChangeSet
encapsulating this action.
-
scoutSpeakToChief
public ChangeSet scoutSpeakToChief(ServerPlayer serverPlayer, ServerUnit sUnit, IndianSettlement is)
Speak to the chief at a native settlement.- Parameters:
serverPlayer
- TheServerPlayer
that is scouting.sUnit
- The scoutServerUnit
.is
- TheIndianSettlement
to scout.- Returns:
- A
ChangeSet
encapsulating this action.
-
sellGoods
private ChangeSet sellGoods(ServerPlayer serverPlayer, GoodsType type, int amount, Unit carrier)
Sell goods in Europe.- Parameters:
serverPlayer
- TheServerPlayer
that is selling.type
- TheGoodsType
to sell.amount
- The amount of goods to sell.carrier
- TheUnit
carrying the goods.- Returns:
- A
ChangeSet
encapsulating this action.
-
setBuildQueue
public ChangeSet setBuildQueue(ServerPlayer serverPlayer, Colony colony, java.util.List<BuildableType> queue)
Set build queue.- Parameters:
serverPlayer
- TheServerPlayer
that owns the colony.colony
- TheColony
to set the queue of.queue
- The new build queue.- Returns:
- A
ChangeSet
encapsulating this action.
-
setCurrentStop
public ChangeSet setCurrentStop(ServerPlayer serverPlayer, Unit unit, int index)
Set a unit stop.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to set the destination for.index
- The stop index.- Returns:
- A
ChangeSet
encapsulating this action.
-
setDestination
public ChangeSet setDestination(ServerPlayer serverPlayer, Unit unit, Location destination)
Set a unit destination.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to set the destination for.destination
- TheLocation
to set as destination.- Returns:
- A
ChangeSet
encapsulating this action.
-
setGoodsLevels
public ChangeSet setGoodsLevels(ServerPlayer serverPlayer, Colony colony, ExportData exportData)
Set goods levels.- Parameters:
serverPlayer
- TheServerPlayer
that owns the colony.colony
- TheColony
to set the goods levels in.exportData
- The newExportData
.- Returns:
- A
ChangeSet
encapsulating this action.
-
setNewLandName
public ChangeSet setNewLandName(ServerPlayer serverPlayer, Unit unit, java.lang.String name)
Set land name.- Parameters:
serverPlayer
- TheServerPlayer
who landed.unit
- TheUnit
that has come ashore.name
- The new land name.- Returns:
- A
ChangeSet
encapsulating this action.
-
setNewRegionName
public ChangeSet setNewRegionName(ServerPlayer serverPlayer, Unit unit, Region region, java.lang.String name)
Set region name.- Parameters:
serverPlayer
- TheServerPlayer
discovering.unit
- TheUnit
that is discovering.region
- TheRegion
to discover.name
- The new region name.- Returns:
- A
ChangeSet
encapsulating this action.
-
spySettlement
public ChangeSet spySettlement(ServerPlayer serverPlayer, Unit unit, Settlement settlement)
Spy on a settlement.- Parameters:
serverPlayer
- TheServerPlayer
that is spying.unit
- TheUnit
that is spying.settlement
- TheSettlement
to spy on.- Returns:
- A
ChangeSet
encapsulating this action.
-
trainUnitInEurope
public ChangeSet trainUnitInEurope(ServerPlayer serverPlayer, UnitType type)
Train a unit in Europe.- Parameters:
serverPlayer
- TheServerPlayer
that is demanding.type
- TheUnitType
to train.- Returns:
- A
ChangeSet
encapsulating this action.
-
unloadGoods
public ChangeSet unloadGoods(ServerPlayer serverPlayer, GoodsType goodsType, int amount, Unit carrier)
Unload goods.- Parameters:
serverPlayer
- TheServerPlayer
that is unloading.goodsType
- TheGoodsType
to unload.amount
- The amount of goods to unload.carrier
- TheUnit
to unload.- Returns:
- A
ChangeSet
encapsulating this action.
-
updateTradeRoute
public ChangeSet updateTradeRoute(ServerPlayer serverPlayer, TradeRoute tradeRoute)
Update a trade route for a player.- Parameters:
serverPlayer
- TheServerPlayer
to set trade routes for.tradeRoute
- An uninternedTradeRoute
to update.- Returns:
- A
ChangeSet
encapsulating this action.
-
work
public ChangeSet work(ServerPlayer serverPlayer, Unit unit, WorkLocation workLocation)
Change work location.- Parameters:
serverPlayer
- TheServerPlayer
that owns the unit.unit
- TheUnit
to change the work location of.workLocation
- TheWorkLocation
to change to.- Returns:
- A
ChangeSet
encapsulating this action.
-
-