/** * Retrieve the stored amount * @param ware Reference to the ware * @param ship Reference to the ship * @param office Reference to the trading office * @return read only integer property representing the sored amount. */ private ReadOnlyIntegerProperty getStoredAmountProperty(IWare ware, INavigableVessel ship, Optional<ITradingOffice> office){ AmountablePrice<IWare> amounable = getStoredAmountablePrice(ware, ship, office); return amounable.amountProperty(); // differ between ship and convoi } /**
private ReadOnlyIntegerProperty getAvailableAmountProperty(ICity city, IWare ware, Optional<ITradingOffice> office) { AmountablePrice<IWare> available; switch (type) { case PORT_CITY_TO_SHIP: case PORT_CITY_TO_STORAGE: available = city.getWare(ware); break; default: available = office.map(iTradingOffice -> iTradingOffice.getWare(ware)) .orElseGet(() -> (AmountablePrice<IWare>) context.getBean("amountablePrice", 0, 0)); break; } return available.amountProperty(); } /**
public BuyAmountBinding(IWare ware, IntegerBinding requiredAmount) { final Optional<ITradingOffice> office = getPlayer().findTradingOffice(getCity()); if (office.isPresent()) { stored = office.get().getWare(ware).amountProperty(); needed = requiredAmount; super.bind(stored, requiredAmount); } else { stored = new SimpleIntegerProperty(0); needed = requiredAmount; super.bind(requiredAmount); } }
Optional<IWare> ware = state.findMostNeededWare(); if (ware.isPresent()) { int price = computablePrice.sellPrice(ware.get(), iCity.getWare(ware.get()).amountProperty(), new IntegerBinding() { @Override protected int computeValue() {
for (EWare material : MATERIALS) { int requiredAmount = shipFactory.getUpgradeAmount(currentShip.get().getShipType(), material); ReadOnlyIntegerProperty amountInCity = city.getWare(material).amountProperty(); ReadOnlyIntegerProperty amountInStorage; if (optOffice.isPresent()) { ITradingOffice office = optOffice.get(); amountInStorage = office.getWare(material).amountProperty(); } else { amountInStorage = new SimpleIntegerProperty(0);
for (EWare material : MATERIALS) { int requiredAmount = shipFactory.getConstructionAmount(getCurrentShipType(), material); ReadOnlyIntegerProperty amountInCity = city.getWare(material).amountProperty(); ReadOnlyIntegerProperty amountInStorage; if (optOffice.isPresent()) { ITradingOffice office = optOffice.get(); amountInStorage = office.getWare(material).amountProperty(); } else { amountInStorage = new SimpleIntegerProperty(0);
int price = computablePrice.buyPrice(EWare.BRICK, amount.amountProperty(), new IntegerBinding() {
ReadOnlyIntegerProperty amountAvailableProp = city.getCity().getWare(ware).amountProperty(); if (ware.isBarrelSizedWare()) { BarrelAmount barrelAmount = new BarrelAmount();
ReadOnlyIntegerProperty storedAmountProperty = available.amountProperty(); if (ware.isBarrelSizedWare()) { BarrelAmount barrelAmount = new BarrelAmount();
row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware))); final ReadOnlyIntegerProperty stored = office != null ? office.getWare(ware).amountProperty() : new SimpleIntegerProperty(0); if (ware.isBarrelSizedWare()) { BarrelAmountAlwaysVisible barrelAmount = new BarrelAmountAlwaysVisible();
row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware))); ReadOnlyIntegerProperty amountAvailableProp = getAvailableAmountProperty(city, ware, optOffice); IntegerBinding amountToTransfer = getAmountProperty(city.getWare(ware).amountProperty()); if (ware.isBarrelSizedWare()) { BarrelAmount barrelAmount = new BarrelAmount();