Class TradeRouteTradeStrategy

  • All Implemented Interfaces:
    IAITradeStrategy

    public class TradeRouteTradeStrategy
    extends BasePlayerTradeStrategy
    Trade strategy that is based on a preset trade route
    Author:
    Andi Hotz, (c) Sahits GmbH, 2016 Created on Jun 18, 2016
    • Field Detail

      • clientServerEventBus

        @Autowired
        @Qualifier("serverClientEventBus")
        private com.google.common.eventbus.AsyncEventBus clientServerEventBus
      • shipService

        @Autowired
        private ShipService shipService
      • mapService

        @Autowired
        private MapService mapService
    • Constructor Detail

      • TradeRouteTradeStrategy

        public TradeRouteTradeStrategy()
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • destroy

        @PreDestroy
        private void destroy()
      • initializeTradeCycle

        public void initializeTradeCycle​(IAIPlayer player,
                                         INavigableVessel vessel)
        Description copied from interface: IAITradeStrategy
        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

        public 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.
        The default implementation chooses the closest city.
        Choose the nearest city from the set defined in the trade route.
        Specified by:
        getCityToRestartTradeCycle in interface IAITradeStrategy
        Overrides:
        getCityToRestartTradeCycle in class BasePlayerTradeStrategy
        Parameters:
        vessel - that should travel to a city, so that the trade cycle can be reinitialized
        Returns:
      • handleShipArrivesInPort

        public void handleShipArrivesInPort​(IShipEntersPortEvent event)
        Description copied from interface: IAITradeStrategy
        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