@Override protected String computeValue() { if (sailorState.getNumberOfSailors() > 1) { return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog1", new Object[]{ sailorState.getNumberOfSailors()}, locale.getCurrentLocal()); } else if (sailorState.getNumberOfSailors() == 1) { return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog2", new Object[]{}, locale.getCurrentLocal()); } else { return messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernSailorDialog.dialog3", new Object[]{}, locale.getCurrentLocal()); } } };
@Subscribe public void handleDayChange(ClockTickDayChange event) { for (Entry<ICity, TavernState> entry : cities.entrySet()) { ICity city = entry.getKey(); TavernState state = entry.getValue(); int nbSailors = computeNumbersOfSailors(city); state.getSailors().setNumberOfSailors(nbSailors); handlePersonsBecomingAbsent(state); handlePersonsBecomingPresent(city, state); } } /**
StringBinding firstLineBinding = new StringBinding() { super.bind(sailorState.numberOfSailorsProperty()); final IntegerProperty sailorsInTavern = new SimpleIntegerProperty(sailorState.getNumberOfSailors()); BooleanBinding enableAction = new BooleanBinding() { currentShip.addListener((observableValue, oldValue, newValue) -> { sailorsAdditionalOnShip.set(0); sailorsInTavern.set(sailorState.getNumberOfSailors()); // reset }); sailorNumberListener = (observableValue, oldValue, newValue) -> { sailorState.numberOfSailorsProperty().addListener(new WeakChangeListener<>(sailorNumberListener)); currentShip.get().setNumberOfSailors(hireNbSailors + currentShip.get().getNumberOfSailors()); sailorsAdditionalOnShip.setValue(0); sailorState.setNumberOfSailors(sailorsInTavern.get()); city.getCity().getCityState().getPopUpdateStatistic().hireSailors(hireNbSailors); executeOnCloseButtonClicked();
} else { int nbToHire = neededSailors - onShip; int inTavern = sailorState.getNumberOfSailors(); if (inTavern >= nbToHire) { if (ship instanceof IShip) { for (int i = 0; i < nbToHire; i++) { sailorState.hire(); nbToHire = neededSailors - onShip; for (int i = 0; i < nbToHire; i++) { sailorState.hire(); sailorState.hire(); onShip = vessel.getNumberOfSailors(); neededSailors = vessel.getMinNumberOfSailors(); nbToHire = Math.min(neededSailors - onShip, sailorState.getNumberOfSailors()); for (int i = 0; i < nbToHire; i++) { sailorState.hire();
public void addCity(TavernState state, ICity city) { cities.put(city, state); int nbSailors = computeNumbersOfSailors(city); final ISailorState sailors = state.getSailors(); sailors.setNumberOfSailors(nbSailors); handlePersonsBecomingAbsent(state); handlePersonsBecomingPresent(city, state); }