Class NextPatrolStation
- java.lang.Object
-
- ch.sahits.game.openpatrician.event.handler.ShipEntersPortEventListener
-
- ch.sahits.game.openpatrician.display.event.handler.impl.NextPatrolStation
-
class NextPatrolStation extends ShipEntersPortEventListener
- Author:
- Andi Hotz, (c) Sahits GmbH, 2014 Created on Feb 21, 2014
-
-
Field Summary
Fields Modifier and Type Field Description private AttackListener
atackListener
private Date
date
private java.time.LocalDateTime
deadline
private EventHandlerFactory
eventHandlerFactory
private IPlayer
player
private java.util.Random
rnd
private PatrolInternalState
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 NextPatrolStation(INavigableVessel ship, ICity city, PatrolInternalState state, IPlayer player, java.time.LocalDateTime deadline, AttackListener atackListener)
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
initEventBus()
private void
unregisterEventBus()
-
Methods inherited from class ch.sahits.game.openpatrician.event.handler.ShipEntersPortEventListener
ignoreEventCity
-
-
-
-
Field Detail
-
state
private final PatrolInternalState state
Next station may be null if it is the last
-
player
private final IPlayer player
-
deadline
private final java.time.LocalDateTime deadline
-
atackListener
private final AttackListener atackListener
-
date
@Autowired private Date date
-
rnd
@Autowired private java.util.Random rnd
-
taskFactory
@Autowired private ClientTaskFactory taskFactory
-
eventHandlerFactory
@Autowired private EventHandlerFactory eventHandlerFactory
-
-
Constructor Detail
-
NextPatrolStation
public NextPatrolStation(INavigableVessel ship, ICity city, PatrolInternalState state, IPlayer player, java.time.LocalDateTime deadline, AttackListener atackListener)
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
- on patrolcity
- next citystate
- patrol stateplayer
- current player (ship owner)deadline
- until the ship has to arriveatackListener
- attack listener
-
-
Method Detail
-
initEventBus
@PostConstruct private void initEventBus()
-
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.
-
-