Package net.sf.freecol.server.ai
Class AIMessage
- java.lang.Object
-
- net.sf.freecol.server.ai.AIMessage
-
public class AIMessage extends java.lang.Object
Wrapper class for AI message handling.
-
-
Constructor Summary
Constructors Constructor Description AIMessage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
askAttack(AIUnit aiUnit, Direction direction)
An AIUnit attacks in the given direction.static boolean
askBuildColony(AIUnit aiUnit, java.lang.String name)
An AIUnit builds a colony.static boolean
askCashInTreasureTrain(AIUnit aiUnit)
An AIUnit cashes in.static boolean
askChangeState(AIUnit aiUnit, Unit.UnitState state)
An AIUnit changes state.static boolean
askChangeWorkImprovementType(AIUnit aiUnit, TileImprovementType type)
An AIUnit changes its work improvement type.static boolean
askChangeWorkType(AIUnit aiUnit, GoodsType type)
An AIUnit changes its work type.static boolean
askChooseFoundingFather(AIPlayer aiPlayer, java.util.List<FoundingFather> fathers, FoundingFather father)
Choose a founding father for an AI player.static boolean
askClaimLand(Tile tile, AIColony aic, int price)
Claims a tile for a colony.static boolean
askClaimLand(Tile tile, AIUnit aiUnit, int price)
Claims a tile.static boolean
askClearSpeciality(AIUnit aiUnit)
Clears the speciality of a unit.static boolean
askDiplomacy(AIPlayer aiPlayer, FreeColGameObject our, FreeColGameObject other, DiplomaticTrade dt)
Do some diplomacy.static boolean
askDisband(AIUnit aiUnit)
An AIUnit disbands.static boolean
askDisembark(AIUnit aiUnit)
An AIUnit disembarks.static boolean
askEmbark(AIUnit aiUnit, Unit unit, Direction direction)
An AIUnit embarks.static boolean
askEmigrate(AIPlayer aiPlayer, int slot)
A unit in Europe emigrates.static boolean
askEndTurn(AIPlayer aiPlayer)
Ends the player turn.static boolean
askEquipForRole(AIUnit aiUnit, Role role, int roleCount)
Change the role of a unit.static boolean
askEstablishMission(AIUnit aiUnit, Direction direction, boolean denounce)
Establishes a mission in the given direction.static boolean
askFirstContact(AIPlayer aiPlayer, Player contactor, Player contactee, Tile tile, boolean ack)
Handle a first contact.static boolean
askIndianDemand(AIPlayer aiPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result)
Makes demands to a colony.static boolean
askLoadGoods(Location loc, GoodsType type, int amount, AIUnit aiUnit)
An AI unit loads some cargo.static boolean
askLoot(AIUnit aiUnit, java.lang.String defenderId, java.util.List<Goods> goods)
An AI unit loots some cargo.static boolean
askMonarchAction(AIPlayer aiPlayer, Monarch.MonarchAction action, boolean accept)
Handle answering the monarch.static boolean
askMove(AIUnit aiUnit, Direction direction)
Moves an AIUnit in the given direction.static boolean
askMoveTo(AIUnit aiUnit, Location destination)
Moves an AIUnit across the high seas.static boolean
askNationSummary(AIPlayer owner, Player player)
Gets a nation summary for a player.static boolean
askNativeGift(AIUnit aiUnit, Colony colony)
A native AIUnit delivers a gift to a colony.static boolean
askNativeTrade(AIPlayer aiPlayer, NativeTrade.NativeTradeAction action, NativeTrade nt)
Respond to a native trade offer.static boolean
askNewLandName(AIPlayer aiPlayer, Unit unit, java.lang.String name)
Response to discovering the new world.static boolean
askNewRegionName(AIPlayer aiPlayer, Region region, Tile tile, Unit unit, java.lang.String name)
Response to discovering a new region.static boolean
askPutOutsideColony(AIUnit aiUnit)
An AIUnit is put outside a colony.static boolean
askRearrangeColony(AIColony aiColony, java.util.List<Unit> workers, Colony scratch)
Rearrange an AI colony.static boolean
askScoutSpeakToChief(AIUnit aiUnit, IndianSettlement is)
An AI unit speaks to the chief of a native settlement.static boolean
askSetBuildQueue(AIColony aiColony, java.util.List<BuildableType> queue)
Set the build queue in a colony.static boolean
askTrainUnitInEurope(AIPlayer aiPlayer, UnitType type)
Train unit in Europe.static boolean
askUnloadGoods(GoodsType type, int amount, AIUnit aiUnit)
An AI unit unloads some cargo.static boolean
askWork(AIUnit aiUnit, WorkLocation workLocation)
Set a unit to work in a work location.
-
-
-
Method Detail
-
askAttack
public static boolean askAttack(AIUnit aiUnit, Direction direction)
An AIUnit attacks in the given direction.- Parameters:
aiUnit
- TheAIUnit
to attack with.direction
- TheDirection
to attack in.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askBuildColony
public static boolean askBuildColony(AIUnit aiUnit, java.lang.String name)
An AIUnit builds a colony.- Parameters:
aiUnit
- TheAIUnit
to build the colony.name
- The name of the colony.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askCashInTreasureTrain
public static boolean askCashInTreasureTrain(AIUnit aiUnit)
An AIUnit cashes in.- Parameters:
aiUnit
- TheAIUnit
cashing in.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askChangeState
public static boolean askChangeState(AIUnit aiUnit, Unit.UnitState state)
An AIUnit changes state.- Parameters:
aiUnit
- TheAIUnit
to change the state of.state
- The newUnitState
.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askChangeWorkType
public static boolean askChangeWorkType(AIUnit aiUnit, GoodsType type)
An AIUnit changes its work type.- Parameters:
aiUnit
- TheAIUnit
to change the work type of.type
- TheGoodsType
to produce.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askChangeWorkImprovementType
public static boolean askChangeWorkImprovementType(AIUnit aiUnit, TileImprovementType type)
An AIUnit changes its work improvement type.- Parameters:
aiUnit
- TheAIUnit
to change the work type of.type
- TheTileImprovementType
to produce.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askChooseFoundingFather
public static boolean askChooseFoundingFather(AIPlayer aiPlayer, java.util.List<FoundingFather> fathers, FoundingFather father)
Choose a founding father for an AI player.- Parameters:
aiPlayer
- TheAIPlayer
that is choosing.fathers
- A list ofFoundingFather
s to choose from.father
- TheFoundingFather
that has been chosen.- Returns:
- True if the message was sent.
-
askClaimLand
public static boolean askClaimLand(Tile tile, AIColony aic, int price)
Claims a tile for a colony.- Parameters:
tile
- TheTile
to claim.aic
- TheAIColony
that is claiming.price
- The price to pay.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askClaimLand
public static boolean askClaimLand(Tile tile, AIUnit aiUnit, int price)
Claims a tile.- Parameters:
tile
- TheTile
to claim.aiUnit
- TheAIUnit
that is claiming.price
- The price to pay.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askClearSpeciality
public static boolean askClearSpeciality(AIUnit aiUnit)
Clears the speciality of a unit.- Parameters:
aiUnit
- TheAIUnit
to clear.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askDiplomacy
public static boolean askDiplomacy(AIPlayer aiPlayer, FreeColGameObject our, FreeColGameObject other, DiplomaticTrade dt)
Do some diplomacy.- Parameters:
aiPlayer
- TheAIPlayer
being diplomatic.our
- Our object (Unit
orColony
) conducting the diplomacy.other
- The other object (Unit
orColony
) to negotiate with.dt
- TheDiplomaticTrade
agreement to propose.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askDisband
public static boolean askDisband(AIUnit aiUnit)
An AIUnit disbands.- Parameters:
aiUnit
- TheAIUnit
to disband.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askDisembark
public static boolean askDisembark(AIUnit aiUnit)
An AIUnit disembarks.- Parameters:
aiUnit
- TheAIUnit
disembarking.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askEmbark
public static boolean askEmbark(AIUnit aiUnit, Unit unit, Direction direction)
An AIUnit embarks.- Parameters:
aiUnit
- TheAIUnit
carrier.unit
- TheUnit
that is embarking.direction
- TheDirection
to embark in (may be null).- Returns:
- True if the message was sent, and a non-error reply returned.
-
askEmigrate
public static boolean askEmigrate(AIPlayer aiPlayer, int slot)
A unit in Europe emigrates.- Parameters:
aiPlayer
- TheAIPlayer
requiring emigration.slot
- The slot to emigrate from.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askEndTurn
public static boolean askEndTurn(AIPlayer aiPlayer)
Ends the player turn.- Parameters:
aiPlayer
- TheAIPlayer
ending the turn.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askEquipForRole
public static boolean askEquipForRole(AIUnit aiUnit, Role role, int roleCount)
Change the role of a unit.- Parameters:
aiUnit
- TheAIUnit
to equip.role
- TheRole
to equip for.roleCount
- The role count.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askEstablishMission
public static boolean askEstablishMission(AIUnit aiUnit, Direction direction, boolean denounce)
Establishes a mission in the given direction.- Parameters:
aiUnit
- TheAIUnit
establishing the mission.direction
- TheDirection
to move the unit.denounce
- Is this a denunciation?- Returns:
- True if the message was sent, and a non-error reply returned.
-
askFirstContact
public static boolean askFirstContact(AIPlayer aiPlayer, Player contactor, Player contactee, Tile tile, boolean ack)
Handle a first contact.- Parameters:
aiPlayer
- TheAIPlayer
being contacted.contactor
- The contactingPlayer
.contactee
- The contactedPlayer
.tile
- The contactTile
.ack
- The treaty acceptance state.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askIndianDemand
public static boolean askIndianDemand(AIPlayer aiPlayer, Unit unit, Colony colony, GoodsType type, int amount, Constants.IndianDemandAction result)
Makes demands to a colony. One and only one of goods or gold is valid.- Parameters:
aiPlayer
- TheAIPlayer
that is demanding or responding.unit
- TheUnit
that is demanding.colony
- TheColony
to demand of.type
- TheGoodsType
to demand.amount
- The amount of goods to demand.result
- Null if this is the initial demand, true/false if this is a response.- Returns:
- True if the message was sent, a non-error reply returned, and the demand was accepted.
-
askLoadGoods
public static boolean askLoadGoods(Location loc, GoodsType type, int amount, AIUnit aiUnit)
An AI unit loads some cargo.- Parameters:
loc
- TheLocation
where the goods are.type
- TheGoodsType
to load.amount
- The amount of goods to load.aiUnit
- TheAIUnit
that is loading.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askLoot
public static boolean askLoot(AIUnit aiUnit, java.lang.String defenderId, java.util.List<Goods> goods)
An AI unit loots some cargo.- Parameters:
aiUnit
- TheAIUnit
that is looting.defenderId
- The object identifier of the defending unit.goods
- A list ofGoods
to loot.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askMonarchAction
public static boolean askMonarchAction(AIPlayer aiPlayer, Monarch.MonarchAction action, boolean accept)
Handle answering the monarch.- Parameters:
aiPlayer
- TheAIPlayer
that is responding.action
- TheMonarchAction
responded to.accept
- Whether the action is accepted or not.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askMove
public static boolean askMove(AIUnit aiUnit, Direction direction)
Moves an AIUnit in the given direction.- Parameters:
aiUnit
- TheAIUnit
to move.direction
- TheDirection
to move the unit.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askMoveTo
public static boolean askMoveTo(AIUnit aiUnit, Location destination)
Moves an AIUnit across the high seas.- Parameters:
aiUnit
- TheAIUnit
to move.destination
- TheLocation
to move to.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askNationSummary
public static boolean askNationSummary(AIPlayer owner, Player player)
Gets a nation summary for a player.- Parameters:
owner
- TheAIPlayer
making the inquiry.player
- ThePlayer
to summarize.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askNativeGift
public static boolean askNativeGift(AIUnit aiUnit, Colony colony)
A native AIUnit delivers a gift to a colony.- Parameters:
aiUnit
- TheAIUnit
delivering the gift.colony
- TheColony
to give to.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askNativeTrade
public static boolean askNativeTrade(AIPlayer aiPlayer, NativeTrade.NativeTradeAction action, NativeTrade nt)
Respond to a native trade offer.- Parameters:
aiPlayer
- TheAIPlayer
that is trading.action
- TheNativeTradeAction
to take.nt
- The proposedNativeTrade
.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askNewLandName
public static boolean askNewLandName(AIPlayer aiPlayer, Unit unit, java.lang.String name)
Response to discovering the new world.- Parameters:
aiPlayer
- The discoveringAIPlayer
.unit
- TheUnit
that made the discovery.name
- The new land name.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askNewRegionName
public static boolean askNewRegionName(AIPlayer aiPlayer, Region region, Tile tile, Unit unit, java.lang.String name)
Response to discovering a new region.- Parameters:
aiPlayer
- The discoveringAIPlayer
.region
- TheRegion
that was discovered.tile
- TheTile
of discovery.unit
- TheUnit
that was discovering.name
- The new region name.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askPutOutsideColony
public static boolean askPutOutsideColony(AIUnit aiUnit)
An AIUnit is put outside a colony.- Parameters:
aiUnit
- TheAIUnit
to put out.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askRearrangeColony
public static boolean askRearrangeColony(AIColony aiColony, java.util.List<Unit> workers, Colony scratch)
Rearrange an AI colony.- Parameters:
aiColony
- TheAIColony
to rearrange.workers
- A list of workerUnit
s that may change.scratch
- A copy of the underlyingColony
with the workers arranged as required.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askScoutSpeakToChief
public static boolean askScoutSpeakToChief(AIUnit aiUnit, IndianSettlement is)
An AI unit speaks to the chief of a native settlement.- Parameters:
aiUnit
- TheAIUnit
that is scouting.is
- TheIndianSettlement
to scout.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askSetBuildQueue
public static boolean askSetBuildQueue(AIColony aiColony, java.util.List<BuildableType> queue)
Set the build queue in a colony.- Parameters:
aiColony
- TheAIColony
that is building.queue
- The list ofBuildableType
s to build.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askTrainUnitInEurope
public static boolean askTrainUnitInEurope(AIPlayer aiPlayer, UnitType type)
Train unit in Europe.- Parameters:
aiPlayer
- TheAIPlayer
requiring training.type
- TheUnitType
to train.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askUnloadGoods
public static boolean askUnloadGoods(GoodsType type, int amount, AIUnit aiUnit)
An AI unit unloads some cargo.- Parameters:
type
- TheGoodsType
to unload.amount
- The amount of goods to unload.aiUnit
- TheAIUnit
that is unloading.- Returns:
- True if the message was sent, and a non-error reply returned.
-
askWork
public static boolean askWork(AIUnit aiUnit, WorkLocation workLocation)
Set a unit to work in a work location.- Parameters:
aiUnit
- TheAIUnit
to work.workLocation
- TheWorkLocation
to work in.- Returns:
- True if the message was sent, and a non-error reply returned.
-
-