mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-02-22 22:49:36 +01:00
mortage house interaction
This commit is contained in:
parent
0acb23ab8b
commit
09ea8a046e
@ -19,6 +19,7 @@ import pp.monopoly.client.gui.SettingsMenu;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.notification.Sound;
|
||||
@ -157,6 +158,11 @@ public class TakeMortage extends Dialog {
|
||||
|
||||
// Populate the dropdown with property names
|
||||
for (PropertyField property : playerProperties) {
|
||||
if(property instanceof BuildingProperty) {
|
||||
if (((BuildingProperty)property).getHouses()!=0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
propertyOptions.add(property.getName());
|
||||
}
|
||||
|
||||
|
@ -391,6 +391,11 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
|
||||
if (msg.getKeyword().equals("TakeMortage")) {
|
||||
for (PropertyField field : properties) {
|
||||
if(field instanceof BuildingProperty) {
|
||||
if (((BuildingProperty)field).getHouses()!=0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
field.setMortgaged(true);
|
||||
sender.earnMoney(field.getHypo());
|
||||
}
|
||||
@ -431,7 +436,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
bp.setOwner(playerHandler.getPlayerById(0));
|
||||
playerHandler.getPlayerById(0).addProperty(bp.getId());
|
||||
}
|
||||
playerHandler.getPlayerAtIndex(0).earnMoney(20000);
|
||||
playerHandler.getPlayerById(0).earnMoney(20000);
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
|
@ -119,6 +119,11 @@ public class BoardManager {
|
||||
return false; // Null check for safety
|
||||
}
|
||||
|
||||
//Check for mortage
|
||||
// if (field.isMortgaged()) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// Get the color group of the property
|
||||
FieldColor groupColor = field.getColor();
|
||||
|
||||
@ -130,7 +135,7 @@ public class BoardManager {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Check if the player owns all properties in the color group
|
||||
if (!groupProperties.stream().allMatch(bp -> bp.getOwner() != null && bp.getOwner().getId() == field.getOwner().getId())) {
|
||||
if (!groupProperties.stream().allMatch(bp -> bp.getOwner() != null && !bp.isMortgaged() && bp.getOwner().getId() == field.getOwner().getId())) {
|
||||
return false; // The player must own all properties in the color group
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user