Class ShipyardEngine


  • @Service
    @Lazy
    @DependentInitialisation(StartNewGameBean.class)
    public class ShipyardEngine
    extends AbstractEngine
    The shipyard engine handled the activities on a shipyard. This engine is stateless, so it requires the IShipyard to work on.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2014 Created on Mar 01, 2014
    • Field Detail

      • date

        @Autowired
        private Date date
      • rnd

        @Autowired
        private java.util.Random rnd
      • shipUtility

        @Autowired
        private ShipFactory shipUtility
      • clientServerEventBus

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

      • ShipyardEngine

        public ShipyardEngine()
    • Method Detail

      • initializeEventBus

        @PostConstruct
        private void initializeEventBus()
      • unregister

        @PreDestroy
        private void unregister()
      • orderShipBuilding

        private java.time.LocalDateTime orderShipBuilding​(IShipyard shipyard,
                                                          EShipType type,
                                                          IPlayer owner)
        Order a ship of given type to be build. The costs are not deduced. This method is called when the ship building is actually ordered.
        Parameters:
        type - of the ship to build
        owner - of the ship to be built
        shipyard - reference to the state
        Returns:
        date when the ship will be finished.
      • repair

        private void repair​(IShipyard shipyard,
                            IShip ship,
                            ICityPlayerProxyJFX proxy)
        Order the repair of the ship. The costs for the repair not are deduced. With each repair order the crew gets more expierianced.
        Parameters:
        ship - to be repaired.
        shipyard - reference to the state
      • repair

        public void repair​(IShipyard shipyard,
                           IShipGroup shipGroup)
        Order the repair of a group of pirate ship.
        Parameters:
        shipyard - where it should be repaired
        shipGroup - ships that should be repaired
      • repairPirateShip

        public void repairPirateShip​(IShipyard shipyard,
                                     IShip ship)
        Order the repair of a single pirate ship.
        Parameters:
        shipyard - where it should be repaired
        ship - that should be repaired
      • repairAIShip

        public void repairAIShip​(IShipyard shipyard,
                                 IShip ship)
        Order the repair of a single AI owned ship.
        Parameters:
        shipyard - where it should be repaired
        ship - that should be repaired
      • refitAIShip

        public void refitAIShip​(IShipyard shipyard,
                                IShip ship)
      • refit

        private void refit​(IShipyard shipyard,
                           IShip ship,
                           EShipUpgrade upgradeLevel,
                           ICityPlayerProxyJFX proxy)
        Refit the ship to the new level. The costs for the upgrade are not deduced.
        Parameters:
        ship - to be refitted
        upgradeLevel - level to which the ship should be upgraded.
        shipyard - reference to the state
      • 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.
      • handleOrderBuildEvent

        public void handleOrderBuildEvent​(ShipyardOrderBuild event)
        Recieve the event from the event bus and delegate it.
        Parameters:
        event - shipyard order build
      • handleOrderRepair

        public void handleOrderRepair​(ShipyardOrderRepair event)
        Recieve the event from the event bus and delegate it.
        Parameters:
        event - shipyard order repair
      • handleORderRefit

        public void handleORderRefit​(ShipyardOrderRefit event)
        Recieve the event from the event bus and delegate it.
        Parameters:
        event - shipyard order refit
      • findeLatestDate

        java.time.LocalDateTime findeLatestDate​(java.util.List<IShipDueDate> dueDates)