Skip to content

Commit

Permalink
Simple bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
aybarsaltinisik committed Dec 21, 2020
1 parent 491a64f commit e7acf47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/controllers/scenecontrollers/GameSceneController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
Expand Down Expand Up @@ -260,7 +262,9 @@ public void handleEndTurnButton() {

public void handleSaveGameButton() {
DataManager.saveGame("SaveGame1");

Text text = new Text("Game saved as SaveGame1!");
text.setFont(Font.font("Arial", FontWeight.BOLD, 20));
gameLog.getChildren().add(text);
}

public static void handleChanceRegionPopup() {
Expand Down
13 changes: 9 additions & 4 deletions src/models/Agreement.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public boolean performOffers(City city, Player player){
firstOffer.performOffer(firstPlayer,secondPlayer);
}
}
firstOffer.performOffer(firstPlayer, secondPlayer);
}
}
// if secondOffer instanceof ContinuousOffer
Expand All @@ -77,7 +76,6 @@ public boolean performOffers(City city, Player player){
secondOffer.performOffer(firstPlayer,secondPlayer);
}
}
secondOffer.performOffer(firstPlayer, secondPlayer);
}
}
}
Expand All @@ -87,8 +85,15 @@ public boolean performOffers(City city, Player player){
// check offers if city is involved
public boolean checkOffers(City city) {
if(isOffered) {
return city.getId() == ((ContiuousOffer) firstOffer).getCity().getId()
|| city.getId() == ((ContiuousOffer) secondOffer).getCity().getId();
if(firstOffer instanceof ContiuousOffer){
return city.getId() == ((ContiuousOffer) firstOffer).getCity().getId();
}
else if(secondOffer instanceof ContiuousOffer){
return city.getId() == ((ContiuousOffer) secondOffer).getCity().getId();
}
else {
return false;
}
}
else {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/models/SellRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void performOffer(Player firstPlayer, Player secondPlayer) {
if(secondPlayer.removeCity(city)){
// add city to first player (if possible)
firstPlayer.addCity(city);
city.setOwner(firstPlayer);
return;
}
System.out.println("Second player does not own city: " + city.getName());
Expand Down
2 changes: 1 addition & 1 deletion src/models/TakePercentage.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public TakePercentage(City city, int percentage){
@Override
public void performOffer(Player firstPlayer, Player secondPlayer) {
// get percentage of rent from secondPlayers city
double rate = ((double)percentage)/10;
double rate = ((double)percentage)/100;
firstPlayer.addMoney(city.getRent() * rate);
secondPlayer.addMoney(city.getRent() * (1 - rate));
}
Expand Down

0 comments on commit e7acf47

Please sign in to comment.