@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.model.people.impl.PatrolState.noticeboardTitle", new Object[]{}, locale.getCurrentLocal())); initializeButtons(); IPatrol patrol = (IPatrol) currentPerson.get(); String loadedText = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernPatrolDialog.dialog", new Object[]{}, locale.getCurrentLocal()); HashMap<String, Object> parameters = new HashMap<>(); parameters.put("patrolName", patrol.getName()); parameters.put("price", patrol.getPremium()); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, parameters); getContent().addAll(dt); }
} else if (person instanceof IPatrol) { IPatrol patrol = (IPatrol) person; patrol.setName(firstNameLoader.getRandomName()+" "+lastNameLoader.getRandomName()); patrol.setPremium(rnd.nextInt(2000)+4300); patrol.setBonus(rnd.nextInt(2000)+2000); ICity[] destinations = new ICity[3]; patrol.setDestinations(destinations); fillDestinations(city, destinations); patrol.setCurrentDestIndex(0); } else if (person instanceof IBaseTraveler) { int premium = rnd.nextInt(1543)+324;
@Override protected EventHandler<MouseEvent> createAcceptHandler() { return mouseEvent -> { try { IPatrol patrol = (IPatrol) currentPerson.get(); PatrolInternalState patrolState = new PatrolInternalState(patrol.getPremium(), patrol.getBonus(), patrol.getDestinations()); IShip ship = null; if (city.getActiveShip() instanceof IShip) { ship = (IShip) city.getActiveShip(); } IPlayer player = city.getPlayer(); IAttackListener attackListener = eventHandlerFactory.getAttackListener(ship, patrolState); int minutes = rnd.nextInt(600); LocalDateTime postMessage = date.getCurrentDate().plusMinutes(minutes); String cityName = patrolState.nextDestination().get().getName(); taskFactory.getPostponedDisplayMessage(postMessage, "ch.sahits.game.openpatrician.display.dialog.TavernPatrolDialog.acceptMessage", ship.getName(), cityName); LocalDateTime firstDeadline = date.getCurrentDate().plusDays(6); eventHandlerFactory.getNextPatrolStateion(ship, patrolState.nextDestination().get(), patrolState, player, firstDeadline, attackListener); patrol.leave(); executeOnCloseButtonClicked(); } catch (RuntimeException e) { logger.error("Failed to accept patrol offer", e); } }; }