Skip to content

Commit

Permalink
Agreement Offer popup implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bulutg committed Dec 20, 2020
1 parent da6f341 commit 66f90f5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import models.Agreement;

public class AgreementOfferPopupController extends PopupController {
@FXML
public TextArea description;
@FXML
public Label agreementName;

private Agreement agreement;

@FXML
void closeButtonClicked(ActionEvent event) {
void declineButtonClicked(ActionEvent event) {
agreement.decline();
closeStage(event);
}

@FXML
void acceptButtonClicked(ActionEvent event) {
agreement.accept();
closeStage(event);
}

public void setAgreement(Agreement agreement) {
this.agreement = agreement;
agreementName.setText("Agreement name: " + agreement.getName());
description.setText(agreement.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,4 @@ private Offer getOffer(String oppositeOfferType, City city, TextField moneyField
};
return offer;
}

private void assignBoxes(String offer, Player player, City city, VBox chooseOfferVBox, ComboBox<String> chooseOfferBox) {

}
}
7 changes: 7 additions & 0 deletions src/models/Agreement.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,11 @@ public Player getFirstPlayer(){
// get id
public String getName() { return name; }

@Override
public String toString() {
return "Agreement between " + firstPlayer +
" and " + secondPlayer +
"\n First offer: " + firstOffer +
"\n Second offer: " + secondOffer;
}
}
5 changes: 5 additions & 0 deletions src/models/GiveMoney.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public void performOffer(Player firstPlayer, Player secondPlayer) {
//second player takes specified amount of money from the first player
secondPlayer.addMoney(money);
}

@Override
public String toString() {
return "Give" + money;
}
}
5 changes: 5 additions & 0 deletions src/models/PayRentOrNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public void performOffer(Player firstPlayer, Player secondPlayer) {
//first player does not pay money for the city of second player
//second player does not take any money from the first player for the specified city
}

@Override
public String toString() {
return "Pay Rent Or Not: " + city;
}
}
5 changes: 5 additions & 0 deletions src/models/SellRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public void performOffer(Player firstPlayer, Player secondPlayer) {
}
System.out.println("Second player does not own city: " + city.getName());
}

@Override
public String toString() {
return "SellRegion: " + city;
}
}
5 changes: 5 additions & 0 deletions src/models/TakePercentage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public void performOffer(Player firstPlayer, Player secondPlayer) {
public City getCity(){
return city;
}

@Override
public String toString() {
return "TakePercentage: " + city + " Percentage: " + percentage;
}
}
47 changes: 23 additions & 24 deletions src/views/popupViews/AgreementOfferPopup.fxml
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="400.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="controllers.popupControllers.AgreementOfferPopupController">

<AnchorPane prefHeight="400.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.popupControllers.AgreementOfferPopupController">

<children>
<VBox alignment="CENTER" layoutX="131.0" layoutY="50.0" prefHeight="200.0" prefWidth="100.0"
AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
AnchorPane.topAnchor="5.0">
<VBox alignment="CENTER" layoutX="131.0" layoutY="50.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
<children>
<Label fx:id="cityNameLabel" alignment="CENTER" contentDisplay="CENTER" minWidth="100.0"
text="City Name">
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="100.0" text="City Name">
<font>
<Font size="24.0"/>
<Font size="24.0" />
</font>
<VBox.margin>
<Insets bottom="25.0"/>
<Insets bottom="25.0" />
</VBox.margin>
</Label>
<Label fx:id="cityPriceLabel" alignment="CENTER" contentDisplay="CENTER" minWidth="100.0"
text="City Price">
<Label fx:id="agreementName" alignment="CENTER" contentDisplay="CENTER" minWidth="100.0" text="Agreement name: ">
<font>
<Font size="24.0"/>
<Font size="24.0" />
</font>
<VBox.margin>
<Insets bottom="25.0"/>
<Insets bottom="25.0" />
</VBox.margin>
</Label>
<ListView fx:id="rentView" prefHeight="200.0" prefWidth="200.0">
<VBox.margin>
<Insets bottom="25.0"/>
</VBox.margin>
</ListView>
<Button mnemonicParsing="false" onAction="#closeButtonClicked" text="Close"/>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<right>
<Button mnemonicParsing="false" onAction="#declineButtonClicked" text="Decline" BorderPane.alignment="CENTER" />
</right>
<left>
<Button mnemonicParsing="false" onAction="#acceptButtonClicked" text="Accept" BorderPane.alignment="CENTER" />
</left>
<top>
<TextArea fx:id="description" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</top>
</BorderPane>
</children>
</VBox>
</children>
Expand Down

0 comments on commit 66f90f5

Please sign in to comment.