@Override public boolean execute() { int minSellPrice = vessel.getWare(ware).getAVGPrice(); IAIPlayer player = (IAIPlayer) vessel.getOwner(); tradeService.sellWareShipToCity(vessel, player, city, ware, maxAmount, Optional.of(minSellPrice)); return executeNext; } }
@Override public boolean execute() { int maxSellAmount = vessel.getWare(ware).getAmount(); int minSellPrice = vessel.getWare(ware).getAVGPrice(); IAIPlayer player = (IAIPlayer) vessel.getOwner(); tradeService.sellWareShipToCity(vessel, player, city, ware, maxSellAmount, Optional.of(minSellPrice)); return executeNext; } }
/** * Transfer the wares in the specified amounts from the ship into the storage.<br> * PRE: there is a trading office in the city. * @param vessel from which the wares are transfered * @param player owner of the trading office and the vessel * @param city in which the transfer happens * @param amounts map of wares and the amounts that should be transfered. */ public void transferFromVesselToStorage(INavigableVessel vessel, IPlayer player, ICity city, Map<IWare, Integer> amounts) { Optional<ITradingOffice> optOffice = player.findTradingOffice(city); Preconditions.checkArgument(optOffice.isPresent(), "There is no trading office for "+player.getName()+" "+player.getLastName()+" in "+city.getName()); for (IWare ware : amounts.keySet()) { int amount = amounts.get(ware); int avgPrice = vessel.getWare(ware).getAVGPrice(); amount = vessel.unload(ware, amount); optOffice.get().move(ware, amount, avgPrice); if (vessel instanceof IConvoy) { distributeIncomeToConvoyParticipants((IConvoy) vessel, player, avgPrice, amount); } } }
.append(amountable.getAmount()) .append(" @ ") .append(amountable.getAVGPrice()) .append("\n"); .append(amountable.getAmount()) .append(" @ ") .append(amountable.getAVGPrice()) .append("\n");
/** * Move <code>amount</code> of <code>ware</code> from the <code>office</code> onto the <code>vessel</code>. If the * vessel is a convoy the distribution to not player ships is considered by a cash transfer. * @param office where the wares are stored * @param vessel to which the wares are transfered * @param player owner of the trading office and vessel * @param ware to be transferred * @param amount to be transferred * @return amount that is actually moved */ public int transferFromStorageToVessel(ITradingOffice office, INavigableVessel vessel, IPlayer player, IWare ware, int amount) { final AmountablePrice<IWare> amountable = office.getWare(ware); int avgPrice = amountable.getAVGPrice(); int moved = office.move(ware, -amount, avgPrice); moved = vessel.load(ware, moved, avgPrice); if (vessel instanceof IConvoy) { // Handle this for any other ship in the convoy as if the ware was bought from the convoy owner at cost. distributeCostToConvoyParticipants((IConvoy) vessel, player, avgPrice, moved); } return moved; }
AmountablePrice<IWare> amountable = tradingOffice.getWare(ware); if (amountable.getAmount()>0) { retrieved = tradingOffice.move(ware, -amountRequired, amountable.getAVGPrice()); player.getCompany().updateCash(amountable.getAVGPrice() * retrieved); int toRetrieve = amountRequired - retrieved; if (optOffice.isPresent()) { retrieved += optOffice.get().move(ware, -toRetrieve, amountable.getAVGPrice()); player.getCompany().updateCash(amountable.getAVGPrice() * retrieved); if (retrieved >= amountRequired) { break;
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernBuyerDialog.title", new Object[]{}, locale.getCurrentLocal())); initializeButtons(); IBuyer buyer = (IBuyer) currentPerson.get(); int p = buyer.getAmountablePrice().getAVGPrice()*buyer.getAmountablePrice().getAmount(); Object[] args = new Object[]{buyer.getName(), buyer.getAmountablePrice().getAmount(), translator.getLocalDisplayName((EWare)buyer.getWare()), p}; String key = "ch.sahits.game.openpatrician.display.dialog.TavernBuyerDialog.bale.dialog"; if (buyer.getWare().isBarrelSizedWare()) { key = "ch.sahits.game.openpatrician.display.dialog.TavernBuyerDialog.barrel.dialog"; } String loadedText = messageSource.getMessage(key, args, locale.getCurrentLocal()); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, new HashMap<>()); getContent().addAll(dt); }
private void setupCurrentContent() { removeDecoratedContent(); if (notices.size() > 0) { final ICityHallNotice notice = notices.get(currentIndex.get()); EWare ware = (EWare) notice.getRequiredWare(); ICity destination = notice.getDestination(); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.PublicNoticeDialog.title", new Object[]{modelTranslator.getLocalDisplayName(ware), destination.getName()}, locale.getCurrentLocal())); String key; if (ware.isBarrelSizedWare()) { key = "ch.sahits.game.openpatrician.display.dialog.cityhall.PublicNoticeDialog.barrelMessage"; } else { key = "ch.sahits.game.openpatrician.display.dialog.cityhall.PublicNoticeDialog.baleMessage"; } AmountablePrice<IWare> amountPrice = notice.getWareAndAmount(); final LocalDateTime dueDate1 = notice.getDueDate(); String dueDate = modelTranslator.toDisplayString(dueDate1); int premium = amountPrice.getAVGPrice() * amountPrice.getAmount(); Object[] args = new Object[]{modelTranslator.getLocalDisplayName(ware), amountPrice.getAmount(), dueDate, premium, amountPrice.getAVGPrice(), 1}; String template = messageSource.getMessage(key, args, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); getContent().add(text); } }
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.GuildTradeAgreementDialog.title", new Object[]{}, locale.getCurrentLocal())); IMediterreanMap map = guildSettings.getMediterreanMap(); List<ITradeAgreement> agreements = map.getTradeAgreements(city.getPlayer()); VBox box = new VBox(10); for (ITradeAgreement agreement : agreements) { String cityName = agreement.getTradeLocation().getName(); String ware = modelTranslations.getLocalDisplayName((EWare) agreement.getWare()); int price = agreement.getWareAndAmount().getAVGPrice(); int amount = agreement.getWareAndAmount().getAmount(); String till = modelTranslations.toDisplayString(agreement.getValidTill()); String template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.GuildTradeAgreementDialog.agreement", new Object[]{cityName, amount, ware, price, till}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); box.getChildren().add(text); } box.setLayoutX(2 * FRAME_BORDER); box.setLayoutY(CLOSE_BTN_Y_POS - 500); getContent().add(box); } }
for (IWare ware : loaded) { AmountablePrice<IWare> ap = ship.getWare(ware); newCompanyValue+=ap.getAVGPrice()*ap.getAmount(); for (IWare ware : EWare.values()) { AmountablePrice<IWare> ap = office.getWare(ware); newCompanyValue+=ap.getAVGPrice()*ap.getAmount();
tradeService.buyFromCityToStorage(office, player, city, ware, amount2Buy, Optional.empty(), Optional.empty()); int avgPrice = office.getWare(ware).getAVGPrice(); int moved = office.move(ware, -amount2Transfer, avgPrice); storage.transfer(ware, -moved, avgPrice);
for (EWare ware : EWare.values()) { AmountablePrice<IWare> amountable = trOffice.getWare(ware); trOffice.move(ware, -amountable.getAmount(), amountable.getAVGPrice()); city.move(ware,amountable.getAmount(), cityHall.getMayor());