@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernWarehouseTenantDialog.title", new Object[]{}, locale.getCurrentLocal())); initializeButtons(); IWarehouseTenant tenant = (IWarehouseTenant) currentPerson.get(); String loadedText = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernWarehouseTenantDialog.dialog", new Object[]{tenant.getName()}, locale.getCurrentLocal()); HashMap<String, Object> parameters = new HashMap<>(); parameters.put("amount", tenant.getAmount()); parameters.put("price", tenant.getRentPerWeek()); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, parameters); getContent().addAll(dt); }
@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); } }; }
} else if (person instanceof IWarehouseTenant) { IWarehouseTenant tenant = (IWarehouseTenant) person; tenant.setName(firstNameLoader.getRandomName()+" "+lastNameLoader.getRandomName()); tenant.setAmount(rnd.nextInt(800)+100); } else if (person instanceof IInformant) { IInformant informant = (IInformant) person;
@Override public void run() { if (player instanceof IHumanPlayer) { player.getCompany().updateCash(tenant.getRentPerWeek()); } else { player.getCompany().updateCashDirectly(tenant.getRentPerWeek()); } } }
@Override public void run() { clientEventBus.post(new DisplayMessage("ch.sahits.game.openpatrician.display.dialog.TavernWarehouseTenantDialog.acceptMessage")); office.setOccupiedSpace(office.getOccupiedSpace() - tenant.getAmount()); } }