Class TradeRouteTradeStrategy
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
-
- ch.sahits.game.openpatrician.engine.player.strategy.TradeRouteTradeStrategy
-
- All Implemented Interfaces:
IAITradeStrategy
public class TradeRouteTradeStrategy extends BasePlayerTradeStrategy
Trade strategy that is based on a preset trade route- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Jun 18, 2016
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private MapService
mapService
private ShipService
shipService
-
Fields inherited from class ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
tradeStrategyType
-
-
Constructor Summary
Constructors Constructor Description TradeRouteTradeStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
destroy()
ICity
getCityToRestartTradeCycle(INavigableVessel vessel)
In the case where the trade cycle must be re-initialized, but the ship is not in a city, determine the city to which the vessel should travel.void
handleShipArrivesInPort(IShipEntersPortEvent event)
Event handler for a ship entering port.private void
init()
void
initializeTradeCycle(IAIPlayer player, INavigableVessel vessel)
Initialize the trade cycle.private TradeRouteMissionData
selectTradeRoute(ICity city)
-
Methods inherited from class ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
addDefaultTradeSteps, append, createAggregatedBuyTradeStep, createAggregatedCheckedBuyTradeStep, createAggregatedCheckedSellStep, createAggregatedDumpStep, createAggregatedSellStep, createCheckAndTakeLoanStep, createCheckedTransferToOfficeTradeStep, createCheckRepairStep, createConditionalAggregatedDumpStep, createHireCaptain, createHireDismissTradeManagerTradeStep, createHireSailorStep, createJoinGuildTradeStep, createPaybackLoanStep, createTransferToOfficeTradeStep, createTransferToShipTradeStep, createTravelToStep, createUpgradeShipTradeStep, createWeaponBuyTradeStep, executeTradeSteps, findCitySupplyingWare, findCityWithAllRequiredWares, findDestinationToBuyRequiredProductionWares, findNextStopForBuying, findNextStopForSelling, findProvidingWares, findWaresOfInterest, getLoadedWares, getMostNeededWares, getMostNeededWares, getNextStep, getWaresNeedIn, handleHireSailors, handleRefitFinished, handleRepairFinished, hasBlockingMission, hasMoreTradeSteps, inject, isMatchingTradeStrategy, isNeeded
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ch.sahits.game.openpatrician.model.player.IAITradeStrategy
isSelectable
-
-
-
-
Field Detail
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
shipService
@Autowired private ShipService shipService
-
mapService
@Autowired private MapService mapService
-
-
Method Detail
-
init
@PostConstruct private void init()
-
destroy
@PreDestroy private void destroy()
-
initializeTradeCycle
public void initializeTradeCycle(IAIPlayer player, INavigableVessel vessel)
Description copied from interface:IAITradeStrategy
Initialize the trade cycle. Based on the strategy the cycle may be closed, meaning at some point this method can be called again or it may be open with destination defining the next one.- Parameters:
player
- for whom to initialize the trade cyclevessel
- for which to initialize the trade cycle
-
getCityToRestartTradeCycle
public ICity getCityToRestartTradeCycle(INavigableVessel vessel)
In the case where the trade cycle must be re-initialized, but the ship is not in a city, determine the city to which the vessel should travel.
The default implementation chooses the closest city.
Choose the nearest city from the set defined in the trade route.- Specified by:
getCityToRestartTradeCycle
in interfaceIAITradeStrategy
- Overrides:
getCityToRestartTradeCycle
in classBasePlayerTradeStrategy
- Parameters:
vessel
- that should travel to a city, so that the trade cycle can be reinitialized- Returns:
-
selectTradeRoute
private TradeRouteMissionData selectTradeRoute(ICity city)
-
handleShipArrivesInPort
public void handleShipArrivesInPort(IShipEntersPortEvent event)
Description copied from interface:IAITradeStrategy
Event handler for a ship entering port. This method is not called by subscription from the event bus, but through direct call from tha AIPlayerEngine.- Parameters:
event
- ship entering port
-
-