Class SupplyHometownAIStrategy

    • Field Detail

      • clientServerEventBus

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

        @Autowired
        private ShipService shipService
    • Constructor Detail

      • SupplyHometownAIStrategy

        public SupplyHometownAIStrategy()
    • 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
      • 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
      • addTradeStepsInHometownToTravelToNextCity

        private void addTradeStepsInHometownToTravelToNextCity​(IAIPlayer player,
                                                               INavigableVessel vessel)
        Add the tradesteps to buy wares in the hometown and travel to the first stop.
        Parameters:
        player - for whom to add the trade steps
        vessel - for which to add the trade steps
      • addTradeStepsSellingInHomeTown

        void addTradeStepsSellingInHomeTown​(IAIPlayer player,
                                            INavigableVessel vessel)
        Add the tradesteps in the hometown to sell the wares and check for repairs
        Parameters:
        player - for whom to add the trade steps
        vessel - for which to add the trade steps
      • addTradeStepTradingNextTown

        void addTradeStepTradingNextTown​(IAIPlayer player,
                                         INavigableVessel vessel)
        Define the trade steps in another town.
        Parameters:
        player - for whom to add the trade steps
        vessel - for which to add the trade steps
      • shouldReturnToHometown

        boolean shouldReturnToHometown​(IAIPlayer player,
                                       INavigableVessel vessel)
        Check weather the vessel should return to the hometown
        Parameters:
        player - for whom to check the returnal to the hometown
        vessel - which should return to the hometown
        Returns:
        true if the vessle should return to the hometown
      • getLoadedWaresToSell

        java.util.List<IWare> getLoadedWaresToSell​(INavigableVessel vessel,
                                                   java.util.List<IWare> waresOfInterest)
        Retrieve the wares that can be soled in another city than the hometown.
        Parameters:
        vessel - from which to retrieve the loaded wares
        waresOfInterest - list of wares that should be sold in the hometown and nowhere else.
        Returns:
        List of wares on the vessel