@Override protected boolean computeValue() { return !city.getPlayer().findTradingOffice(city.getCity()).isPresent(); } };
private Table createModel() { Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); if ( optOffice.isPresent()) { final ITradingOffice office = optOffice.get(); Optional<ISteward> steward = office.getSteward(); if (steward.isPresent()) { return createAutomaticTradingModel(); } } return null; }
@PostConstruct private void initializeDialog() { ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity()).get(); // Office must be present otherwise the dialog should not be accessible. weaponStorage = office.getWeaponStorage(); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponInventoryDialog.title", new Object[]{}, locale.getCurrentLocal())); Table model = createModel(); setModel(model); } private Table createModel() {
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); } }
@PostConstruct private void initializeDialog() { // Office must be present otherwise the dialog should not be accessible. office = proxy.getPlayer().findTradingOffice(proxy.getCity()).get(); weaponStorage = office.getWeaponStorage(); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponTransferDialog.title", new Object[]{}, locale.getCurrentLocal())); Group subTitle = createSubTitle(proxy); subTitle.setLayoutX(2*FRAME_BORDER); subTitle.setLayoutY(80); getContent().add(subTitle); Table model = createModel(); setModel(model); }
@PostConstruct private void initializeModelAndDialog() { Table model = createModel(); if (model != null) { setModel(model); } final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); Preconditions.checkArgument(optOffice.isPresent(), "Ther must be a trading office present."); final ITradingOffice office = optOffice.get(); HBox box = new HBox(); box.setSpacing(15); box.setLayoutX(2*FRAME_BORDER); box.setLayoutY(CLOSE_BTN_Y_POS); Text label = new Text(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.AutomaticTradingOverviewDialog.office.manager", new Object[]{}, locale.getCurrentLocal())); label.getStyleClass().add("dialogText"); box.getChildren().add(label); OpenPatricianLargeWaxButton hireButton = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.AutomaticTradingOverviewDialog.hire", new Object[]{}, locale.getCurrentLocal())); hireButton.getStyleClass().add("actionButton"); hireButton.textProperty().bind(new HireButtonTextBinding(office)); hireButton.onActionProperty().bind(new HireActionBinding(office)); box.getChildren().add(hireButton); getContent().add(box); } private Table createModel() {
@Override protected boolean computeValue() { Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); IShip ship = null; if (city.getActiveShip() instanceof IShip) { ship = (IShip) city.getActiveShip(); } int barrelAmountFactor = 1; if (!trader.getWare().isBarrelSizedWare()) { barrelAmountFactor = 10; } return optOffice.isPresent() && ship == null && ship.getCapacity() < trader.getAmount() * barrelAmountFactor; } };
entry.disabledProperty().bind(proxy.activeShipProperty().isNull()); entries.add(entry); if (proxy.getPlayer().findTradingOffice(proxy.getCity()).isPresent()) { s = messageSource.getMessage("ch.sahits.game.openpatrician.display.notice.NoticeBoardFactory.ship2tradingOffice", new Object[]{}, locale.getCurrentLocal()); if (proxy.getActiveShip() instanceof IConvoy) {
@Override protected EventHandler<MouseEvent> getAction() { return mouseEvent -> { try { ICity city = getCity(); Optional<ITradingOffice> office = getPlayer().findTradingOffice(getCity()); Preconditions.checkArgument(office.isPresent(), "Trading office must be present"); for (EWare ware : MATERIALS) { int buyAmount = requirementsMap.get(ware).getBuyAmount().intValue(); city.move(ware, -buyAmount, getPlayer()); int needed = requirementsMap.get(ware).requiredProperty().get(); int fromWarhouse = needed - buyAmount; office.get().move(ware, -fromWarhouse, 0); } ShipyardOrderBuild event = new ShipyardOrderBuild(city.getCityState().getShipyardState(), getCurrentShipType(), getPlayer()); clientServerEventBus.post(event); getPlayer().getCompany().updateCash(-calculateTotalBuildCosts()); executeOnCloseButtonClicked(); } catch (RuntimeException e) { logger.error("Failed to order ship construction", e); } }; }
@PostConstruct private void initializeDialog() { Optional<ITradingOffice> office = city.getPlayer().findTradingOffice(city.getCity()); office.ifPresent(iTradingOffice -> storage = iTradingOffice.getWeaponStorage()); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernWeaponsDealerDialog.title", new Object[]{}, locale.getCurrentLocal()));
@Override protected EventHandler<MouseEvent> createAcceptHandler() { return mouseEvent -> { try { final IPlayer player = city.getPlayer(); final IWarehouseTenant tenant = (IWarehouseTenant) currentPerson.get(); final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); if (optOffice.isPresent()) { ITradingOffice office = optOffice.get(); office.setOccupiedSpace(office.getOccupiedSpace() + tenant.getAmount()); int weeks = rnd.nextInt(15) + 5; LocalDateTime currentDate = date.getCurrentDate(); for (int i = 0; i < weeks; i++) { currentDate = currentDate.plusWeeks(1); TimedTask task = taskFactory.getWarehouseTenantPayment(player, tenant, currentDate); list.add(task); } TimedTask task = taskFactory.getWarehouseTenantLeaving(office, tenant, date.getCurrentDate().plusWeeks(weeks)); list.add(task); tenant.leave(); } executeOnCloseButtonClicked(); } catch (RuntimeException e) { logger.error("Failed to accept warehouse tentants offer offer", e); } }; }
@Override protected EventHandler<MouseEvent> getAction() { return mouseEvent -> { Optional<ITradingOffice> office = getPlayer().findTradingOffice(getCity()); Preconditions.checkArgument(office.isPresent(), "Trading office must be present"); for (EWare ware : MATERIALS) { int buyAmount = requirementsMap.get(ware).getBuyAmount().intValue(); getCity().move(ware, -buyAmount, getPlayer()); int needed = shipFactory.getUpgradeAmount(currentShip.get().getShipType(), ware); int fromWarhouse = needed - buyAmount; office.get().move(ware, -fromWarhouse, 0); } ShipyardOrderRefit event = new ShipyardOrderRefit(getCity().getCityState().getShipyardState(),currentShip.get(), currentShip.get().getShipUpgradeLevel().nextLevel(), city); clientServerEventBus.post(event); city.getPlayersShips().remove(currentShip.get()); getPlayer().getCompany().updateCash(-calculateTotalUpgradeCosts()); executeOnCloseButtonClicked(); }; }
protected void initializeRequirements() { ICity city = getCity(); Optional<ITradingOffice> optOffice = getPlayer().findTradingOffice(city); for (EWare material : MATERIALS) { int requiredAmount = shipFactory.getUpgradeAmount(currentShip.get().getShipType(), material);
protected void initializeRequirements() { ICity city = getCity(); Optional<ITradingOffice> optOffice = getPlayer().findTradingOffice(city); for (EWare material : MATERIALS) { int requiredAmount = shipFactory.getConstructionAmount(getCurrentShipType(), material);
@Override public void run() { Optional<ITradingOffice> optOffice = player.findTradingOffice(city); int amountRequired = amountable.getAmount(); int retrieved = 0;
g.setManaged(false); final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); ImageView barrel = new BarrelIconView(); barrel.setLayoutX(200 - 26);
g.setManaged(false); final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); ImageView barrel = new BarrelIconView(); barrel.setLayoutX(200 - 26);
model.setColumnWidth(110, 60, 72, 72, 60, 70); ICity city = cityProxy.getCity(); Optional<ITradingOffice> optOffice = cityProxy.getPlayer().findTradingOffice(city); if (optOffice.isPresent()) { ITradingOffice office = optOffice.get();
model.setColumnWidth(130, 40, 72, 72, 60, 70); ICity city = cityProxy.getCity(); Optional<ITradingOffice> optOffice = cityProxy.getPlayer().findTradingOffice(city); if (optOffice.isPresent()) { ITradingOffice office = optOffice.get();
private Table createModel() { Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); Preconditions.checkArgument(optOffice.isPresent(), "The trading office must be present."); Table model = new Table();