Class 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
    • Constructor Detail

      • TradeManagerService

        public TradeManagerService()
    • 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.
      • calculateCityNeeds

        private int calculateCityNeeds​(IWare ware,
                                       ICity city)
      • hasCentralStorageStrategy

        private boolean hasCentralStorageStrategy​(ICity city,
                                                  IAIPlayer player)
      • playerProduces

        public boolean playerProduces​(ICity city,
                                      IAIPlayer player,
                                      IWare ware)