Class CheapProductionTradeStrategy
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.strategy.BasePlayerTradeStrategy
-
- ch.sahits.game.openpatrician.engine.player.strategy.CheapProductionTradeStrategy
-
- All Implemented Interfaces:
IAITradeStrategy
public class CheapProductionTradeStrategy extends BasePlayerTradeStrategy
This trade strategy focuses on the cheap production of wares and sells them in the nearest city where there is a need.
-
-
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 CheapProductionTradeStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
destroy()
private java.util.Optional<ICity>
findNearestCityWithNeed(ICity city, IAIPlayer player, IWare ware, INavigableVessel vessel, ICity excludeCity)
private java.util.Optional<IWare>
findWareToBuy(ICity city, IAIPlayer player)
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 void
moveToNextStopEmpty(IAIPlayer player, INavigableVessel vessel, 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, 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
-
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
-
moveToNextStopEmpty
private void moveToNextStopEmpty(IAIPlayer player, INavigableVessel vessel, ICity city)
-
findNearestCityWithNeed
private java.util.Optional<ICity> findNearestCityWithNeed(ICity city, IAIPlayer player, IWare ware, INavigableVessel vessel, ICity excludeCity)
-
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
-
-