Class TradingOffice

    • Field Detail

      • owner

        private final IPlayer owner
        Reference to the player
      • city

        private final ICity city
        Reference to the city the trading office is located in
      • baseValue

        private final int baseValue
        Value of the building (building costs
      • weaponStorage

        @Autowired
        private IWeaponStorage weaponStorage
        Weapons storage
      • propertyTax

        @DependentValue("propertytax.tradingoffice")
        private int propertyTax
      • steward

        private javafx.beans.property.ObjectProperty<ISteward> steward
      • establishedDate

        private java.time.LocalDateTime establishedDate
      • date

        @Autowired
        private Date date
      • capacity

        private javafx.beans.property.IntegerProperty capacity
      • storageManagerPresent

        private javafx.beans.binding.BooleanBinding storageManagerPresent
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • destroy

        @PreDestroy
        public void destroy()
        Description copied from interface: IBuilding
        Execute when the building is destroyed.
        Specified by:
        destroy in interface IBuilding
      • initWares

        private void initWares()
        Init the amount of wares available in the city This method is protected so it can be overriden by subclasses for testing
      • bindWares

        private void bindWares()
      • capacityProperty

        public javafx.beans.property.IntegerProperty capacityProperty()
        Description copied from interface: ITradingOffice
        Retrieve the storage capacity of the trading office and all other storages in the same city
        Specified by:
        capacityProperty in interface ITradingOffice
        Returns:
        storage capacity in barrels
      • hasWeapons

        public boolean hasWeapons()
        Description copied from interface: ITradingOffice
        check if there are any weapons in storage
        Specified by:
        hasWeapons in interface ITradingOffice
        Returns:
        true if weapons are stored.
      • move

        public int move​(IWeapon weapon,
                        int amount)
        /** Add or remove weapon from the storage. If the amount is negative it will be removed. If the full amount is not available only the available will be moved and returned. The amount is in the ware specific size. This method is thread save.
        Specified by:
        move in interface ITradingOffice
        Parameters:
        weapon - weapon that should be moved
        amount - of weapons that should be moved
        Returns:
        actual amount moved
      • computeAVGPrice

        protected int computeAVGPrice​(IWare ware,
                                      int amount)
        Description copied from class: WareHolding
        Compute the average price for ware that is to be purchased in the specified amount. The additional variable of the available amount is supplied by WareHolding.getWare(IWare). Subclasses may override this method.
        Overrides:
        computeAVGPrice in class WareHolding
        Parameters:
        ware - for which the average price is to be computed
        amount - amount that is bought
        Returns:
        average price for the amount of ware.
      • move

        public int move​(IWare ware,
                        int amount,
                        int avgPrice)
        Move the ware into/from the storage with a price attached.
        Specified by:
        move in interface ITradingOffice
        Parameters:
        ware - to be moved
        amount - amount to be moved. Negative values indicate removal of the ware from the trading office.
        avgPrice - average price to use on the amount of ware
        Returns:
        the amount that was actually moved. If the ware was to be removed the returned value is <= 0.
      • getSteward

        public java.util.Optional<ISteward> getSteward()
        Description copied from interface: ITradingOffice
        Retrieve the steward of the trading office (manager). May be null if no manager is employed
        Specified by:
        getSteward in interface ITradingOffice
        Returns:
        Optional steward. Empty if none is hired.
      • setSteward

        public void setSteward​(ISteward steward)
        Description copied from interface: ITradingOffice
        Setting the steward. May be null to indicate firing the steward
        Specified by:
        setSteward in interface ITradingOffice
        Parameters:
        steward - to set/unset (null)
      • stewardProperty

        public javafx.beans.property.ObjectProperty<ISteward> stewardProperty()
        Description copied from interface: ITradingOffice
        Property holding the steward.
        Specified by:
        stewardProperty in interface ITradingOffice
        Returns:
        object property for the steward
      • replaceBalanceSheet

        public void replaceBalanceSheet​(IBalanceSheet newWeek)
        Description copied from interface: ITradingOffice
        Replace the last weeks balance sheet with the current week and set the new balance sheet for this week.
        Specified by:
        replaceBalanceSheet in interface ITradingOffice
        Parameters:
        newWeek - balance sheet to replace the old one.
      • move

        public int move​(IWare ware,
                        int amount)
        Description copied from interface: ITradingOffice
        Add or remove ware from the storage. If the amount is negative it will be removed. If the full amount is not available only the available will be moved and returned. The amount is in the ware specific size. The price of the wares is computed based on the amount
        Specified by:
        move in interface ITradingOffice
        Parameters:
        ware - to be moved in/out of the trading office
        amount - of ware to be moved.
        Returns:
        amount that is acctualy moved
      • getValue

        public int getValue()
        Description copied from interface: IBuilding
        Retrieve the value of the building
        Specified by:
        getValue in interface IBuilding
        Returns:
        value of the building
      • storageManagerPresentBinding

        public javafx.beans.binding.BooleanBinding storageManagerPresentBinding()
        Description copied from interface: ITradingOffice
        Binding indicating the presence of a steward.
        Specified by:
        storageManagerPresentBinding in interface ITradingOffice
        Returns:
        boolean binding for the presence of a steward.
      • setOwner

        public void setOwner​(IPlayer newOwner)
        Description copied from interface: IBuilding
        Some buildings may be sold to other players.
        Specified by:
        setOwner in interface IBuilding
        Parameters:
        newOwner - owner of the building