Class PlayerProductionService
- java.lang.Object
-
- ch.sahits.game.openpatrician.clientserverinterface.service.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
-
-
Field Summary
Fields Modifier and Type Field Description private static double
ONE_DAY_OF_WEEK
private ProductionChain
productionChain
private TradeService
tradeService
-
Constructor Summary
Constructors Constructor Description PlayerProductionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buyWareForProductionOneDay(ITradingOffice office)
Buy wares needed for the production in the workshops for the next day.(package private) double
calculateProducableAmountFactor(ProductionStorage storage, IWare requiredWare, IWare producableWare)
Calculate the maximal factor for a ware that can be produced based on avalable material.(package private) double
calculateWareCost(IWare producedWare, ProductionStorage storage, double requiredWareFactor, IWare ware)
Calculate the cost of wares that are consumed in one days production.void
produceWares(ITradingOffice office)
Produce the wares in the workshops and move it to storage.
-
-
-
Field Detail
-
ONE_DAY_OF_WEEK
private static final double ONE_DAY_OF_WEEK
- See Also:
- Constant Field Values
-
productionChain
@Autowired private ProductionChain productionChain
-
tradeService
@Autowired private TradeService tradeService
-
-
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 warerequiredWare
- that's availability is to be checkedproducableWare
- output product- Returns:
- factor that has to be applied to the maximal producable amount.
-
-