Class PirateEngine

    • Field Detail

      • rnd

        @Autowired
        private java.util.Random rnd
      • clientServerEventBus

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

        @Autowired
        @Qualifier("timerEventBus")
        private com.google.common.eventbus.AsyncEventBus timerEventBus
      • syncServerClientEventBus

        @Autowired
        @Qualifier("syncServerClientEventBus")
        private com.google.common.eventbus.EventBus syncServerClientEventBus
      • shipFactory

        @Autowired
        private ShipFactory shipFactory
      • cityService

        @Autowired
        private MapService cityService
      • date

        @Autowired
        private Date date
      • schedulableServerThreadPool

        @Autowired
        @Qualifier("schedulableServerThreadPool")
        private java.util.concurrent.ScheduledExecutorService schedulableServerThreadPool
      • shipService

        @Autowired
        private ShipService shipService
      • graphInitialized

        private boolean graphInitialized
    • Constructor Detail

      • PirateEngine

        public PirateEngine()
    • Method Detail

      • initialize

        @PostConstruct
        private void initialize()
      • destroy

        @PreDestroy
        private void destroy()
      • getChildren

        public java.util.List<AbstractEngine> getChildren()
        Description copied from class: AbstractEngine
        Any engine may hold various child engines. This is the way to retrieve them. If there are no child engines, return an empty list. Subclasses have to implement this in the proper way.
        Specified by:
        getChildren in class AbstractEngine
        Returns:
        list of child engines.
      • handleNewPirate

        public void handleNewPirate​(NewPirateEvent pirateEvent)
        Handle the even when a new pirate becomes available.
        Parameters:
        pirateEvent - new pirate emerged
      • handleShipReachesDestination

        public void handleShipReachesDestination​(ShipArrivesAtDestinationEvent event)
        Ship has reached it's destination, select a new one.
        Parameters:
        event - ship arrives at destination
      • selectDestination

        private void selectDestination​(ISeaPirate pirate)
        Select a new destination for the pirate.
        Parameters:
        pirate - free sea pirate
      • handleShipPositionUpdate

        public void handleShipPositionUpdate​(ShipPositionUpdateEvent event)
        Check if there is a ship near the new position and decide if an attack should be initiated.
        Parameters:
        event - ship changes position
      • sendForRepairs

        private void sendForRepairs​(INavigableVessel vessel)
        Send a vessel to be repaired.
        Parameters:
        vessel - to be repaired
      • handleRepairPirateShip

        public void handleRepairPirateShip​(ShipEntersPortEvent event)
        When a pirate ship enters a port it does so for repair.
      • handleRepairFinished

        public void handleRepairFinished​(RepairFinishedEvent event)
        Handle the event for the finished repair.
        Parameters:
        event - repair has finished
      • handleWeeklyUpdate

        public void handleWeeklyUpdate​(PeriodicalTimeWeekEndUpdate event)
        Periodically check if there is a free pirate and if not, create one.
        Parameters:
        event - weekly update
      • createInitialPiratesShip

        private IShip createInitialPiratesShip()
        Create a ship for the pirate
        Returns:
        initial pirate ship
      • handlePirateShip

        private boolean handlePirateShip​(INavigableVessel vessel)
        Check if the vessel should be handled by this engine. Only ships with hissed pirate flag that do not belong to a player should be considered.
        Parameters:
        vessel - to be checked
        Returns:
        true if the vessel is flaged as pirate ship and the owner is not a player.
      • getBigWeaponType

        private EWeapon getBigWeaponType()
      • getSmallWeaponType

        private EWeapon getSmallWeaponType()