Interface IAITradeStrategy


  • public interface IAITradeStrategy
    This interface defines the API for a trading strategy for the AI.
    • Method Detail

      • initializeTradeCycle

        void initializeTradeCycle​(IAIPlayer player,
                                  INavigableVessel vessel)
        Initialize the trade cycle. Based on the strategy the cycle may be closed, meaning at some point this method can be called again or it may be open with destination defining the next one.
        Parameters:
        player - for whom to initialize the trade cycle
        vessel - for which to initialize the trade cycle
      • getCityToRestartTradeCycle

        ICity getCityToRestartTradeCycle​(INavigableVessel vessel)
        In the case where the trade cycle must be re-initialized, but the ship is not in a city, determine the city to which the vessel should travel.
        Parameters:
        vessel - that should travel to a city, so that the trade cycle can be reinitialized
        Returns:
        city to which the vessel travels.
      • executeTradeSteps

        boolean executeTradeSteps​(IAIPlayer player,
                                  INavigableVessel vessel)
        Execute the trad steps defined for the vessel.
        Parameters:
        player - for which to execute trade steps
        vessel - for which to execute trade steps
      • handleShipArrivesInPort

        void handleShipArrivesInPort​(IShipEntersPortEvent event)
        Event handler for a ship entering port. This method is not called by subscription from the event bus, but through direct call from tha AIPlayerEngine.
        Parameters:
        event - ship entering port
      • isSelectable

        default boolean isSelectable​(IAIPlayer player,
                                     INavigableVessel vessel)
        Check if this strategy can be selected in the current setup. This method is called when choosing a new strategy for the vessel.
        Parameters:
        player - for which the strategy is chosen.
        vessel - for which the strategy is chose.
        Returns:
        true if the strategy can be chosen for the player and vessel. The default implementation will always return true.