Class NextCourierPatrolStation
- java.lang.Object
-
- ch.sahits.game.openpatrician.event.handler.ShipEntersPortEventListener
-
- ch.sahits.game.openpatrician.display.event.handler.impl.NextCourierPatrolStation
-
public class NextCourierPatrolStation extends ShipEntersPortEventListener
- Author:
- Andi Hotz, (c) Sahits GmbH, 2014 Created on Feb 16, 2014
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.eventbus.AsyncEventBus
clientEventBus
private ClientServerFactory
clientServerFactory
private Date
date
private java.time.LocalDateTime
deadline
private DialogTemplateFactory
dialogTemplateFactory
private Locale
locale
private org.springframework.context.MessageSource
messageSource
private IPlayer
player
private java.util.Random
rnd
private CourierPatrolStateInternal
state
Next station may be null if it is the lastprivate ClientTaskFactory
taskFactory
-
Fields inherited from class ch.sahits.game.openpatrician.event.handler.ShipEntersPortEventListener
clientServerEventBus
-
-
Constructor Summary
Constructors Constructor Description NextCourierPatrolStation(IShip ship, ICity city, CourierPatrolStateInternal state, IPlayer player, java.time.LocalDateTime deadline)
Create the next patrol station listener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
execute(ICity city)
Execute an action.void
handleShipEntersPort(ShipEntersPortEvent event)
private void
initializeEventBus()
private void
unregisterEventBus()
-
Methods inherited from class ch.sahits.game.openpatrician.event.handler.ShipEntersPortEventListener
ignoreEventCity
-
-
-
-
Field Detail
-
state
private final CourierPatrolStateInternal state
Next station may be null if it is the last
-
player
private final IPlayer player
-
deadline
private final java.time.LocalDateTime deadline
-
date
@Autowired private Date date
-
taskFactory
@Autowired private ClientTaskFactory taskFactory
-
rnd
@Autowired private java.util.Random rnd
-
clientEventBus
@Autowired @Qualifier("clientEventBus") private com.google.common.eventbus.AsyncEventBus clientEventBus
-
clientServerFactory
@Autowired private ClientServerFactory clientServerFactory
-
dialogTemplateFactory
@Autowired private DialogTemplateFactory dialogTemplateFactory
-
locale
@Autowired private Locale locale
-
messageSource
@Autowired private org.springframework.context.MessageSource messageSource
-
-
Constructor Detail
-
NextCourierPatrolStation
public NextCourierPatrolStation(IShip ship, ICity city, CourierPatrolStateInternal state, IPlayer player, java.time.LocalDateTime deadline)
Create the next patrol station listener. This listener adds itself to the event queue and removes the first city from the patrol state- Parameters:
ship
- for which to construct the next patrol stationcity
- of the next patrol stationstate
- internal patrol stateplayer
- patroling playerdeadline
- until when the patrol has to reach the city.
-
-
Method Detail
-
initializeEventBus
@PostConstruct private void initializeEventBus()
-
unregisterEventBus
@PreDestroy private void unregisterEventBus()
-
handleShipEntersPort
public void handleShipEntersPort(ShipEntersPortEvent event)
- Overrides:
handleShipEntersPort
in classShipEntersPortEventListener
-
execute
public boolean execute(ICity city)
Description copied from class:ShipEntersPortEventListener
Execute an action.- Specified by:
execute
in classShipEntersPortEventListener
- Parameters:
city
- current city.- Returns:
- flag indicating if the execution was successful and therefor the event listener can be removed.
-
-