private void checkForHire() { if (!(player.getShip().getCrewSize() < player.getShip().getMaxCrew())) { hire_button.setDisable(true); no_space_label.setVisible(true); } else { no_space_label.setVisible(false); if (!name_field.getText().isEmpty()) { hire_button.setDisable(false); } else { hire_button.setDisable(true); } } }
@Override public void initialize(URL url, ResourceBundle rb) { player = GameController.getGameData().getPlayer(); dailyCost = 0; selectedSkill = pilot_button; pilot_button.requestFocus(); checkForHire(); Button[] buttons = { pilot_button, fighter_button, engineer_button, trader_button, investor_button }; for (Button b : buttons) { b.setOnMouseClicked( (MouseEvent t) -> { selectedSkill = b; generateCostAndStat(); }); } name_field.addEventFilter( KeyEvent.KEY_TYPED, (KeyEvent event) -> { if (name_field.getText().length() >= 18) { event.consume(); } }); power_slider .valueProperty() .addListener( (ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> { generateCostAndStat(); }); hire_button.setOnMouseClicked( (MouseEvent t) -> { Mercenary merc = new Mercenary(name_field.getText(), selectedSkill.getText(), power, dailyCost); player.getShip().addCrew(merc); checkForHire(); }); }