Class ComputablePriceV2
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.product.ComputablePriceV2
-
public class ComputablePriceV2 extends java.lang.ObjectEcapsulate the price computation.- Author:
- Andi Hotz, (c) Sahits GmbH, 2013 Created on Jan 25, 2013
-
-
Constructor Summary
Constructors Constructor Description ComputablePriceV2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbuyPrice(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToBuy)Integer binding calculation for the buy price.intcalculateAffordableAmount(ITradable tradable, int availableAmount, int maxAmount, long cash)Calculate the amount that can be afforded based on available cash.intcalculateBuyAmount(ITradable tradable, int availableAmount, int maxPrice, int maxAmount, long maxCash)Calculate the amount between 0 andmaxAmountthat can be bought for at maxmaxPriceintcalculateSellAmount(ITradable tradable, int availableAmount, int minPrice, int maxSellAmount)Calculate the amount that can be sold while maintaining a minimal average price per item.intsellPrice(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToSell)Integer binding calculation of the sell price.
-
-
-
Method Detail
-
calculateSellAmount
public int calculateSellAmount(ITradable tradable, int availableAmount, int minPrice, int maxSellAmount)
Calculate the amount that can be sold while maintaining a minimal average price per item.- Parameters:
tradable- good that is to be soldavailableAmount- available amount in the target oftradableminPrice- minimal avg price that may not be transgressed.maxSellAmount- maximal amount that should be sold.- Returns:
- amount that can be sold while maintaining a minimal avg price.
-
buyPrice
public int buyPrice(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToBuy)
Integer binding calculation for the buy price.- Parameters:
tradable- good that is to be tradedavailableAmount- amount of the good that is in storeamountToBuy- amount to be bought- Returns:
- buy price for one item of that good.
-
calculateBuyAmount
public int calculateBuyAmount(ITradable tradable, int availableAmount, int maxPrice, int maxAmount, long maxCash)
Calculate the amount between 0 andmaxAmountthat can be bought for at maxmaxPrice- Parameters:
tradable- that should be boughtavailableAmount- amount that is availablemaxPrice- maximum buy price per itemmaxAmount- maximum amount to be boughtmaxCash- maximum amount of cash available.- Returns:
- maximal amount that can be bought
-
calculateAffordableAmount
public int calculateAffordableAmount(ITradable tradable, int availableAmount, int maxAmount, long cash)
Calculate the amount that can be afforded based on available cash.- Parameters:
tradable- that should be boughtavailableAmount- amount that is availablemaxAmount- maximum amount that should be boughtcash- available cash reserves.- Returns:
- number of items that can be bought between [0,
maxAmount].
-
sellPrice
public int sellPrice(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToSell)
Integer binding calculation of the sell price.- Parameters:
tradable- good that is tradedavailableAmount- amount of the good that is in storeamountToSell- amount to be sold- Returns:
- sell price for one item of that good
-
-