Class PlayerProductionService


  • public class PlayerProductionService
    extends java.lang.Object
    Service that provides the produced wares by a player by consuming the input and producing an output. This service is intended to be called on a daily basis per player.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2017 Created on Oct 07, 2017
    • Constructor Detail

      • PlayerProductionService

        public PlayerProductionService()
    • Method Detail

      • buyWareForProductionOneDay

        public void buyWareForProductionOneDay​(ITradingOffice office)
        Buy wares needed for the production in the workshops for the next day. Try to move the wares from the storage before buying from the city.
        Parameters:
        office - for which the production wares are to be bought.
      • produceWares

        public void produceWares​(ITradingOffice office)
        Produce the wares in the workshops and move it to storage. This method takes care of bonuses in the production.
        Parameters:
        office - of the player in the city where the wares are produced.
      • calculateWareCost

        double calculateWareCost​(IWare producedWare,
                                 ProductionStorage storage,
                                 double requiredWareFactor,
                                 IWare ware)
        Calculate the cost of wares that are consumed in one days production. The ware is removed from storage in the process.
        Parameters:
        producedWare - the ware that is produced.
        storage - where the ware is stored.
        requiredWareFactor - adjustment factor considering, that there may not be a full production due to missing wares or under staffing.
        ware - that is required for the production
        Returns:
        the average price of the consumed ware, with the amount taken into account.
      • calculateProducableAmountFactor

        double calculateProducableAmountFactor​(ProductionStorage storage,
                                               IWare requiredWare,
                                               IWare producableWare)
        Calculate the maximal factor for a ware that can be produced based on avalable material.
        Parameters:
        storage - from which to take the required ware
        requiredWare - that's availability is to be checked
        producableWare - output product
        Returns:
        factor that has to be applied to the maximal producable amount.