Class SupplyHometownAIStrategy
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
-
- ch.sahits.game.openpatrician.engine.player.strategy.SupplyHometownAIStrategy
-
- All Implemented Interfaces:
IAITradeStrategy
public class SupplyHometownAIStrategy extends BasePlayerTradeStrategy
AI strategy for trading with the aim to supply the players home town.
-
-
Field Summary
Fields Modifier and Type Field Description private AIPlayerProperties
aiPlayerProperties
private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private ShipService
shipService
-
Fields inherited from class ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
tradeStrategyType
-
-
Constructor Summary
Constructors Constructor Description SupplyHometownAIStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addTradeStepsInHometownToTravelToNextCity(IAIPlayer player, INavigableVessel vessel)
Add the tradesteps to buy wares in the hometown and travel to the first stop.(package private) void
addTradeStepsSellingInHomeTown(IAIPlayer player, INavigableVessel vessel)
Add the tradesteps in the hometown to sell the wares and check for repairs(package private) void
addTradeStepTradingNextTown(IAIPlayer player, INavigableVessel vessel)
Define the trade steps in another town.private void
destroy()
(package private) java.util.List<IWare>
getLoadedWaresToSell(INavigableVessel vessel, java.util.List<IWare> waresOfInterest)
Retrieve the wares that can be soled in another city than the hometown.void
handleShipArrivesInPort(IShipEntersPortEvent event)
Event handler for a ship entering port.private void
init()
void
initializeTradeCycle(IAIPlayer player, INavigableVessel vessel)
Initialize the trade cycle.(package private) boolean
shouldReturnToHometown(IAIPlayer player, INavigableVessel vessel)
Check weather the vessel should return to the hometown-
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, getCityToRestartTradeCycle, 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
-
aiPlayerProperties
@Autowired private AIPlayerProperties aiPlayerProperties
-
-
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
-
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
-
addTradeStepsInHometownToTravelToNextCity
private void addTradeStepsInHometownToTravelToNextCity(IAIPlayer player, INavigableVessel vessel)
Add the tradesteps to buy wares in the hometown and travel to the first stop.- Parameters:
player
- for whom to add the trade stepsvessel
- for which to add the trade steps
-
addTradeStepsSellingInHomeTown
void addTradeStepsSellingInHomeTown(IAIPlayer player, INavigableVessel vessel)
Add the tradesteps in the hometown to sell the wares and check for repairs- Parameters:
player
- for whom to add the trade stepsvessel
- for which to add the trade steps
-
addTradeStepTradingNextTown
void addTradeStepTradingNextTown(IAIPlayer player, INavigableVessel vessel)
Define the trade steps in another town.- Parameters:
player
- for whom to add the trade stepsvessel
- for which to add the trade steps
-
shouldReturnToHometown
boolean shouldReturnToHometown(IAIPlayer player, INavigableVessel vessel)
Check weather the vessel should return to the hometown- Parameters:
player
- for whom to check the returnal to the hometownvessel
- which should return to the hometown- Returns:
- true if the vessle should return to the hometown
-
getLoadedWaresToSell
java.util.List<IWare> getLoadedWaresToSell(INavigableVessel vessel, java.util.List<IWare> waresOfInterest)
Retrieve the wares that can be soled in another city than the hometown.- Parameters:
vessel
- from which to retrieve the loaded wareswaresOfInterest
- list of wares that should be sold in the hometown and nowhere else.- Returns:
- List of wares on the vessel
-
-