Class TradeManagerService
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.player.TradeManagerService
-
public class TradeManagerService extends java.lang.Object
Service to handle the setup of autmated trading for AI players.- Author:
- Andi Hotz, (c) Sahits GmbH, 2017 Created on Oct 05, 2017
-
-
Field Summary
Fields Modifier and Type Field Description private PopulationConsume
consume
private ProductionChain
productionChain
private TradeService
tradeService
-
Constructor Summary
Constructors Constructor Description TradeManagerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) int
calculateBuyAmount(IWare ware, ICity city, IAIPlayer player, ETradeReason tradeReason, java.util.List<IWorkShop> workShops)
private int
calculateCityNeeds(IWare ware, ICity city)
(package private) int
calculateSellAmount(IWare ware, ICity city, IAIPlayer player, ETradeReason tradeReason, java.util.List<IWorkShop> workShops)
Calculate the amount of wares that should be retained, when selling.(package private) com.google.common.collect.Multimap<IWare,ETradeReason>
collectTradeReasons(java.util.List<IWorkShop> workShops, ICity city)
(package private) java.util.Map<IWare,ETradeReason>
condense(com.google.common.collect.Multimap<IWare,ETradeReason> reasons)
private java.util.List<java.lang.Object[]>
determineLimits(java.util.Map<IWare,ETradeReason> definiteReasons, ICity city, IAIPlayer player, java.util.List<IWorkShop> workShops)
Determine the limits of wares to be boughtprivate boolean
hasCentralStorageStrategy(ICity city, IAIPlayer player)
void
hireSteward(ITradingOffice tradingOffice)
Hire a steward for the trading office.boolean
playerProduces(ICity city, IAIPlayer player, IWare ware)
void
setupOrUpdateAutomaticTrading(ITradingOffice office)
Ensure that the automated trading values are up to date.
-
-
-
Field Detail
-
productionChain
@Autowired private ProductionChain productionChain
-
consume
@Autowired private PopulationConsume consume
-
tradeService
@Autowired private TradeService tradeService
-
-
Method Detail
-
hireSteward
public void hireSteward(ITradingOffice tradingOffice)
Hire a steward for the trading office.- Parameters:
tradingOffice
- for which the tradeing manager is to be hired
-
setupOrUpdateAutomaticTrading
public void setupOrUpdateAutomaticTrading(ITradingOffice office)
Ensure that the automated trading values are up to date.- Parameters:
office
- for which automatic trading is to be setup.
-
determineLimits
private java.util.List<java.lang.Object[]> determineLimits(java.util.Map<IWare,ETradeReason> definiteReasons, ICity city, IAIPlayer player, java.util.List<IWorkShop> workShops)
Determine the limits of wares to be bought- Returns:
- list ob object arrays of size 3: ware, amount, max price
-
calculateSellAmount
int calculateSellAmount(IWare ware, ICity city, IAIPlayer player, ETradeReason tradeReason, java.util.List<IWorkShop> workShops)
Calculate the amount of wares that should be retained, when selling.
-
calculateBuyAmount
int calculateBuyAmount(IWare ware, ICity city, IAIPlayer player, ETradeReason tradeReason, java.util.List<IWorkShop> workShops)
-
condense
java.util.Map<IWare,ETradeReason> condense(com.google.common.collect.Multimap<IWare,ETradeReason> reasons)
-
collectTradeReasons
com.google.common.collect.Multimap<IWare,ETradeReason> collectTradeReasons(java.util.List<IWorkShop> workShops, ICity city)
-
-