Class AIMessage


  • public class AIMessage
    extends java.lang.Object
    Wrapper class for AI message handling.
    • Constructor Detail

      • AIMessage

        public AIMessage()
    • Method Detail

      • askAttack

        public static boolean askAttack​(AIUnit aiUnit,
                                        Direction direction)
        An AIUnit attacks in the given direction.
        Parameters:
        aiUnit - The AIUnit to attack with.
        direction - The Direction 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 - The AIUnit 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 - The AIUnit 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 - The AIUnit to change the state of.
        state - The new UnitState.
        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 - The AIUnit to change the work type of.
        type - The GoodsType 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 - The AIUnit to change the work type of.
        type - The TileImprovementType 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 - The AIPlayer that is choosing.
        fathers - A list of FoundingFathers to choose from.
        father - The FoundingFather 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 - The Tile to claim.
        aic - The AIColony 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 - The Tile to claim.
        aiUnit - The AIUnit 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 - The AIUnit 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 - The AIPlayer being diplomatic.
        our - Our object (Unit or Colony) conducting the diplomacy.
        other - The other object (Unit or Colony) to negotiate with.
        dt - The DiplomaticTrade 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 - The AIUnit 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 - The AIUnit 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 - The AIUnit carrier.
        unit - The Unit that is embarking.
        direction - The Direction 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 - The AIPlayer 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 - The AIPlayer 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 - The AIUnit to equip.
        role - The Role 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 - The AIUnit establishing the mission.
        direction - The Direction 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 - The AIPlayer being contacted.
        contactor - The contacting Player.
        contactee - The contacted Player.
        tile - The contact Tile.
        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 - The AIPlayer that is demanding or responding.
        unit - The Unit that is demanding.
        colony - The Colony to demand of.
        type - The GoodsType 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 - The Location where the goods are.
        type - The GoodsType to load.
        amount - The amount of goods to load.
        aiUnit - The AIUnit 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 - The AIUnit that is looting.
        defenderId - The object identifier of the defending unit.
        goods - A list of Goods 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 - The AIPlayer that is responding.
        action - The MonarchAction 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 - The AIUnit to move.
        direction - The Direction 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 - The AIUnit to move.
        destination - The Location 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 - The AIPlayer making the inquiry.
        player - The Player 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 - The AIUnit delivering the gift.
        colony - The Colony 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 - The AIPlayer that is trading.
        action - The NativeTradeAction to take.
        nt - The proposed NativeTrade.
        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 discovering AIPlayer.
        unit - The Unit 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 discovering AIPlayer.
        region - The Region that was discovered.
        tile - The Tile of discovery.
        unit - The Unit 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 - The AIUnit 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 - The AIColony to rearrange.
        workers - A list of worker Units that may change.
        scratch - A copy of the underlying Colony 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 - The AIUnit that is scouting.
        is - The IndianSettlement 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 - The AIColony that is building.
        queue - The list of BuildableTypes 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 - The AIPlayer requiring training.
        type - The UnitType 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 - The GoodsType to unload.
        amount - The amount of goods to unload.
        aiUnit - The AIUnit 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 - The AIUnit to work.
        workLocation - The WorkLocation to work in.
        Returns:
        True if the message was sent, and a non-error reply returned.