Class ShipyardEngine
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.AbstractEngine
-
- ch.sahits.game.openpatrician.engine.land.city.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 Summary
Fields Modifier and Type Field Description private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private Date
date
private java.util.Random
rnd
private ShipFactory
shipUtility
private ServerSideTaskFactory
taskFactory
private TimedUpdatableTaskList
taskList
-
Constructor Summary
Constructors Constructor Description ShipyardEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.time.LocalDateTime
findeLatestDate(java.util.List<IShipDueDate> dueDates)
java.util.List<AbstractEngine>
getChildren()
Any engine may hold various child engines.void
handleOrderBuildEvent(ShipyardOrderBuild event)
Recieve the event from the event bus and delegate it.void
handleORderRefit(ShipyardOrderRefit event)
Recieve the event from the event bus and delegate it.void
handleOrderRepair(ShipyardOrderRepair event)
Recieve the event from the event bus and delegate it.private void
initializeEventBus()
private java.time.LocalDateTime
orderShipBuilding(IShipyard shipyard, EShipType type, IPlayer owner)
Order a ship of given type to be build.private void
refit(IShipyard shipyard, IShip ship, EShipUpgrade upgradeLevel, ICityPlayerProxyJFX proxy)
Refit the ship to the new level.void
refitAIShip(IShipyard shipyard, IShip ship)
void
repair(IShipyard shipyard, IShipGroup shipGroup)
Order the repair of a group of pirate ship.private void
repair(IShipyard shipyard, IShip ship, ICityPlayerProxyJFX proxy)
Order the repair of the ship.void
repairAIShip(IShipyard shipyard, IShip ship)
Order the repair of a single AI owned ship.void
repairPirateShip(IShipyard shipyard, IShip ship)
Order the repair of a single pirate ship.private void
unregister()
-
-
-
Field Detail
-
date
@Autowired private Date date
-
rnd
@Autowired private java.util.Random rnd
-
taskList
@Autowired private TimedUpdatableTaskList taskList
-
shipUtility
@Autowired private ShipFactory shipUtility
-
taskFactory
@Autowired private ServerSideTaskFactory taskFactory
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
-
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 buildowner
- of the ship to be builtshipyard
- 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 repairedshipGroup
- 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 repairedship
- 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 repairedship
- that should be repaired
-
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 refittedupgradeLevel
- 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 classAbstractEngine
- 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)
-
-