Class EventEngine
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.AbstractEngine
-
- ch.sahits.game.openpatrician.engine.event.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 Summary
Fields Modifier and Type Field Description private IAIEventHandler
aiEventHandler
private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private Date
date
private DateService
dateService
private DialogTemplateFactory
dialogTemplateFactory
private DisableProperties
disableService
private EventService
eventService
private EventEngineState
eventState
private java.util.concurrent.ScheduledExecutorService
executor
private static RandomNameLoader
femaleFirstNameLoader
private static RandomNameLoader
lastNameLoader
private static RandomNameLoader
maleFirstNameLoader
private IMap
map
private PlayerList
players
private SocialRankChecker
rankChecker
private java.util.Random
rnd
private ShipFactory
shipFactory
private static RandomNameLoader
shipLoader
private StateFactory
stateFactory
private ServerSideTaskFactory
taskFactory
private TimedUpdatableTaskList
taskList
private com.google.common.eventbus.AsyncEventBus
timerEventBus
-
Constructor Summary
Constructors Constructor Description EventEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
calculateChildDeathLimit(IPlayer player)
private MarriageBrokerAnnouncementState
createMarriageBrokerAnnouncementState(ShipEntersPortEvent event, INavigableVessel ship)
private java.util.List<IChild>
filterNonAdultChildren(IPlayer player)
java.util.List<AbstractEngine>
getChildren()
Any engine may hold various child engines.(package private) boolean
handleCatastropheEvents()
(package private) boolean
handleChildDeathEvent(boolean catastopheEvent, IPlayer player, boolean childBirth, boolean spouseDeath)
void
handleDailyUpdates(ClockTickDayChange event)
Trigger events that can happen any day like plague, fire, child birthvoid
handleEndOfMonthUpdates(PeriodicalTimeMonthEndUpdate event)
Trigger events at the end of month like rank update.void
handleEndOfWeekUpdates(PeriodicalTimeWeekEndUpdate event)
Trigger events to be checked at the end of week like sending the bill statement.(package private) void
handleMarriageState(TargetedDialogStateWrapper wrappedDialogState)
void
handleShipEntersPort(ShipEntersPortEvent event)
Trigger the event for a marriage broker.void
handleWrappedStateEvents(TargetedDialogStateWrapper dialogState)
Handle events that are targeted at a player and contain a dialog state.private void
init()
private void
postToHumanPlayer(TargetedDialogStateWrapper dialogState, java.lang.String messageKey, java.lang.Object... messageParams)
private void
unregister()
-
-
-
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
-
aiEventHandler
@Autowired private IAIEventHandler aiEventHandler
-
rankChecker
@Autowired private SocialRankChecker rankChecker
-
players
@Autowired private PlayerList players
-
map
@Autowired private IMap map
-
taskList
@Autowired private TimedUpdatableTaskList taskList
-
dateService
@Autowired private DateService dateService
-
disableService
@Autowired private DisableProperties disableService
-
taskFactory
@Autowired private ServerSideTaskFactory taskFactory
-
eventService
@Autowired private EventService eventService
-
eventState
@Autowired private EventEngineState eventState
-
dialogTemplateFactory
@Autowired private DialogTemplateFactory dialogTemplateFactory
-
stateFactory
@Autowired private StateFactory stateFactory
-
shipLoader
private static RandomNameLoader shipLoader
-
maleFirstNameLoader
private static RandomNameLoader maleFirstNameLoader
-
femaleFirstNameLoader
private static RandomNameLoader femaleFirstNameLoader
-
lastNameLoader
private static RandomNameLoader lastNameLoader
-
-
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 classAbstractEngine
- 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
-
handleMarriageState
void handleMarriageState(TargetedDialogStateWrapper wrappedDialogState)
-
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
-
createMarriageBrokerAnnouncementState
private MarriageBrokerAnnouncementState createMarriageBrokerAnnouncementState(ShipEntersPortEvent event, INavigableVessel ship)
-
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)
-
-