Skip to content

Commit

Permalink
Agreement popup bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
aybarsaltinisik committed Dec 20, 2020
1 parent 8265d05 commit b19f598
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/controllers/modelcontrollers/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private boolean isCityOwned(City city, Player currentPlayer, int leftOrRight){
}

// will return if agreement need to be offered
private void offerAgreement() {
public void offerAgreement() {
Agreement agreement = game.offerAgreement();
if(agreement != null){
GameSceneController.handleAgreementOfferPopup(agreement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ void submitButtonClicked(ActionEvent event) {

System.out.println(offerType);

Offer offer = getOffer(offerType, city1, moneyField1, percentageField2);
Offer oppositeOffer = getOffer(oppositeOfferType, city2, moneyField2, percentageField2);
Offer offer = getOffer(oppositeOfferType, city1, moneyField1, percentageField2);
Offer oppositeOffer = getOffer(offerType, city2, moneyField2, percentageField2);

// create agreement
GameManager.getInstance().newAgreement(offer, oppositeOffer, currentPlayer, player2, agreementName);
Expand All @@ -223,13 +223,14 @@ void submitButtonClicked(ActionEvent event) {
}

private Offer getOffer(String oppositeOfferType, City city, TextField moneyField, TextField percentageField) {
return switch (oppositeOfferType) {
Offer offer = switch (oppositeOfferType) {
case "Sell Region" -> new SellRegion(city);
case "Give Money" -> new GiveMoney(Integer.parseInt(moneyField.getText()));
case "Pay Rent or Not" -> new PayRentOrNot(city);
case "Take Percentage" -> new TakePercentage(city, Integer.parseInt(percentageField.getText()));
default -> throw new IllegalStateException("Unexpected value: " + oppositeOfferType);
};
return offer;
}

private void assignBoxes(String offer, Player player, City city, VBox chooseOfferVBox, ComboBox<String> chooseOfferBox) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/scenecontrollers/GameSceneController.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ public void handleRollDiceButton() throws IOException {

public void handleEndTurnButton() {
if (GameManager.getInstance().isDiceRolled()) {
GameManager.getInstance().endTurn();
cameraScene.rotateTable();
GameManager.getInstance().endTurn();
} else {
System.out.println("Cannot end turn without rolling a dice.");
}
Expand Down

0 comments on commit b19f598

Please sign in to comment.