Class EventEngine


  • @Service
    @Lazy
    @DependentInitialisation(StartNewGameBean.class)
    public class EventEngine
    extends AbstractEngine
    This event engine triggers the various random events as well as handling the messages from the event bus that result from such an event.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2016 Created on Dec 09, 2016
    • 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
      • date

        @Autowired
        private Date date
      • executor

        @Autowired
        @Qualifier("serverTimer")
        private java.util.concurrent.ScheduledExecutorService executor
      • shipFactory

        @Autowired
        private ShipFactory shipFactory
      • map

        @Autowired
        private IMap map
      • dateService

        @Autowired
        private DateService dateService
      • eventService

        @Autowired
        private EventService eventService
      • stateFactory

        @Autowired
        private StateFactory stateFactory
    • Constructor Detail

      • EventEngine

        public EventEngine()
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • unregister

        @PreDestroy
        private void unregister()
      • 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.
      • handleWrappedStateEvents

        public void handleWrappedStateEvents​(TargetedDialogStateWrapper dialogState)
        Handle events that are targeted at a player and contain a dialog state.
        Parameters:
        dialogState - wrapped dialog state that is to be handled
      • postToHumanPlayer

        private void postToHumanPlayer​(TargetedDialogStateWrapper dialogState,
                                       java.lang.String messageKey,
                                       java.lang.Object... messageParams)
      • handleShipEntersPort

        public void handleShipEntersPort​(ShipEntersPortEvent event)
        Trigger the event for a marriage broker.
        Parameters:
        event - ship entered port
      • handleEndOfWeekUpdates

        public void handleEndOfWeekUpdates​(PeriodicalTimeWeekEndUpdate event)
        Trigger events to be checked at the end of week like sending the bill statement.
        Parameters:
        event - week ended
      • handleEndOfMonthUpdates

        public void handleEndOfMonthUpdates​(PeriodicalTimeMonthEndUpdate event)
        Trigger events at the end of month like rank update.
        Parameters:
        event - month end
      • handleDailyUpdates

        public void handleDailyUpdates​(ClockTickDayChange event)
        Trigger events that can happen any day like plague, fire, child birth
        Parameters:
        event - daily updates
      • handleChildDeathEvent

        boolean handleChildDeathEvent​(boolean catastopheEvent,
                                      IPlayer player,
                                      boolean childBirth,
                                      boolean spouseDeath)
      • handleCatastropheEvents

        boolean handleCatastropheEvents()
      • calculateChildDeathLimit

        private int calculateChildDeathLimit​(IPlayer player)
      • filterNonAdultChildren

        private java.util.List<IChild> filterNonAdultChildren​(IPlayer player)