mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-09-14 05:11:55 +02:00
Merge branch 'gui' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02 into gui
This commit is contained in:
@@ -333,7 +333,6 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
@Override
|
||||
public void received(NextPlayerTurn msg) {
|
||||
notifyListeners(new ButtonStatusEvent(true));
|
||||
setState(new ActiveState(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,6 +352,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
notifyListeners(new PopUpEvent("jailpay", msg));
|
||||
} else if (msg.getKeyWord().equals("jailtryagain")) {
|
||||
notifyListeners(new PopUpEvent("jailtryagain", msg));
|
||||
} else if(msg.getKeyWord().equals("ReceivedRent")) {
|
||||
notifyListeners(new PopUpEvent("ReceivedRent", msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -331,6 +331,13 @@ public class Player implements FieldVisitor<Void>{
|
||||
state.useJailCard();
|
||||
}
|
||||
|
||||
private void sendRentNotification(String keyword, Player player, int amount) {
|
||||
NotificationMessage msg = new NotificationMessage(keyword);
|
||||
msg.setRentAmount(amount);
|
||||
msg.setRentOwnerId(player.getName());
|
||||
getHandler().getLogic().send(player, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(BuildingProperty field) {
|
||||
if(field.getOwner() == null) {
|
||||
@@ -340,10 +347,8 @@ public class Player implements FieldVisitor<Void>{
|
||||
int rent = field.calcRent();
|
||||
field.getOwner().earnMoney(rent);
|
||||
pay(rent);
|
||||
NotificationMessage msg = new NotificationMessage("rent");
|
||||
msg.setRentAmount(rent);
|
||||
msg.setRentOwnerId(field.getOwner().getName());
|
||||
getHandler().getLogic().send(this, msg);
|
||||
sendRentNotification("rent", field.getOwner(), rent);
|
||||
sendRentNotification("ReceivedRent", this, rent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -352,18 +357,16 @@ public class Player implements FieldVisitor<Void>{
|
||||
public Void visit(FoodField field) {
|
||||
if(field.getOwner() == null) {
|
||||
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||
} else {
|
||||
int factor = 4;
|
||||
} else if (field.getOwner() != this){
|
||||
int factor = 40;
|
||||
if (field.getOwner().getNumProp(field) == 2) {
|
||||
factor = 10;
|
||||
factor = 100;
|
||||
}
|
||||
int rent = rollResult.calcTotal()*factor;
|
||||
field.getOwner().earnMoney(rent);
|
||||
pay(rent);
|
||||
NotificationMessage msg = new NotificationMessage("rent");
|
||||
msg.setRentAmount(rent);
|
||||
msg.setRentOwnerId(field.getOwner().getName());
|
||||
getHandler().getLogic().send(this, msg);
|
||||
sendRentNotification("rent", field.getOwner(), rent);
|
||||
sendRentNotification("ReceivedRent", this, rent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -372,15 +375,13 @@ public class Player implements FieldVisitor<Void>{
|
||||
public Void visit(GateField field) {
|
||||
if(field.getOwner() == null) {
|
||||
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||
} else {
|
||||
} else if (field.getOwner() != this){
|
||||
int rent = field.calcRent() * field.getOwner().getNumProp(field);
|
||||
|
||||
field.getOwner().earnMoney(rent);
|
||||
pay(rent);
|
||||
NotificationMessage msg = new NotificationMessage("rent");
|
||||
msg.setRentAmount(rent);
|
||||
msg.setRentOwnerId(field.getOwner().getName());
|
||||
getHandler().getLogic().send(this, msg);
|
||||
sendRentNotification("rent", field.getOwner(), rent);
|
||||
sendRentNotification("ReceivedRent", this, rent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -445,6 +446,11 @@ public class Player implements FieldVisitor<Void>{
|
||||
handler.getLogic().send(this, new JailEvent(true));
|
||||
}
|
||||
|
||||
void jail() {
|
||||
state = new JailState();
|
||||
fieldID = 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of Properties of the speciefied fild type
|
||||
* @param field the type of field to search for
|
||||
@@ -482,8 +488,8 @@ public class Player implements FieldVisitor<Void>{
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// private static int c = 0;
|
||||
|
||||
/**
|
||||
* Inner class for dice functionality in the game.
|
||||
* Rolls random dice values.
|
||||
@@ -498,8 +504,8 @@ public class Player implements FieldVisitor<Void>{
|
||||
*/
|
||||
private static int rollDice() {
|
||||
return random.nextInt(6) + 1;
|
||||
|
||||
// c++;
|
||||
// return (c%2 == 0)? 3: 2;
|
||||
// if(c < 7) {
|
||||
// return 3;
|
||||
// } else {
|
||||
@@ -521,12 +527,13 @@ public class Player implements FieldVisitor<Void>{
|
||||
for (PropertyField field : getPropertyFields()) {
|
||||
field.setOwner(null);
|
||||
}
|
||||
properties.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* A interface representing the PlayerStates
|
||||
*/
|
||||
private interface PlayerState {
|
||||
interface PlayerState {
|
||||
/**
|
||||
* Handles the logic for rolling Dice
|
||||
* @return the {@link DiceResult} of this the DiceRoll
|
||||
|
@@ -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());
|
||||
}
|
||||
@@ -412,7 +417,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
for (BuildingProperty field : properties.stream().map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||
if (boardManager.canSell(field)) {
|
||||
field.sell();
|
||||
sender.earnMoney(field.getHousePrice());
|
||||
sender.earnMoney(field.getHousePrice() / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
@@ -9,9 +9,8 @@ import com.jme3.network.serializing.Serializable;
|
||||
public class BuyPropertyResponse extends ClientMessage{
|
||||
|
||||
/**
|
||||
* Constructs a BuyPropertyRequest with the specified property ID.
|
||||
* Constructs a BuyPropertyRequest
|
||||
*
|
||||
* @param propertyId the ID of the property to buy
|
||||
*/
|
||||
public BuyPropertyResponse() {}
|
||||
|
||||
|
@@ -18,11 +18,11 @@ public class PlayerReady extends ClientMessage {
|
||||
private PlayerReady() { /* empty */ }
|
||||
|
||||
/**
|
||||
* Constructs a PlayerReady message.
|
||||
*
|
||||
* @param isReady true if the player is ready, false otherwise
|
||||
* @param name the name of the player
|
||||
* @param color the color of the player (can be null)
|
||||
* Constructs a PlayerReady message
|
||||
* @param isReady is the player ready
|
||||
* @param name the name of the Player
|
||||
* @param figure the figure corresponding to the Player
|
||||
* @param startMoney the initial capital of the game
|
||||
*/
|
||||
public PlayerReady(boolean isReady, String name, String figure, int startMoney) {
|
||||
this.isReady = isReady;
|
||||
|
@@ -19,7 +19,6 @@ public class TradeOffer extends ClientMessage{
|
||||
/**
|
||||
* Constructs a TradeOffer with the specified details.
|
||||
*
|
||||
* @param receiverId the ID of the player receiving the Request
|
||||
* @param tradehandler the tradehandler
|
||||
*/
|
||||
public TradeOffer(TradeHandler tradehandler) {
|
||||
|
@@ -21,7 +21,7 @@ public class TradeResponse extends ClientMessage{
|
||||
* Constructs a TradeResponse with the specified response details.
|
||||
*
|
||||
* @param status the ID of the player who initiated the trade
|
||||
* @param accepted true if the offer is accepted, false if declined
|
||||
* @param tradeHandler the TradeHandler corresponding to the Trade
|
||||
*/
|
||||
public TradeResponse(boolean status, TradeHandler tradeHandler) {
|
||||
this.status = status;
|
||||
|
@@ -21,7 +21,7 @@ public class TradeReply extends ServerMessage{
|
||||
* Constructs a TradeResponse with the specified response details.
|
||||
*
|
||||
* @param status the ID of the player who initiated the trade
|
||||
* @param accepted true if the offer is accepted, false if declined
|
||||
* @param tradeHandler the TradeHandler corresponding to the trade
|
||||
*/
|
||||
public TradeReply(boolean status, TradeHandler tradeHandler) {
|
||||
this.status = status;
|
||||
|
@@ -20,7 +20,6 @@ public class TradeRequest extends ServerMessage{
|
||||
/**
|
||||
* Constructs a TradeRequest with the specified details.
|
||||
*
|
||||
* @param receiverId the ID of the player receiving the Request
|
||||
* @param tradehandler the tradehandler
|
||||
*/
|
||||
public TradeRequest(TradeHandler tradehandler) {
|
||||
|
@@ -19,10 +19,9 @@ public class ViewAssetsResponse extends ServerMessage{
|
||||
private ViewAssetsResponse() { /* empty */ }
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructs a ViewAssetsResponse with the specified properties and account balance.
|
||||
*
|
||||
* @param properties a List of PropertyField objects representing the player's properties
|
||||
* @param accountBalance the player's current account balance
|
||||
* @param board the BoardManager representing the current Status
|
||||
*/
|
||||
public ViewAssetsResponse(BoardManager board) {
|
||||
this.board = board;
|
||||
|
@@ -82,8 +82,7 @@ public class Figure implements Item{
|
||||
/**
|
||||
* Moves the Figure to the specified coordinates.
|
||||
*
|
||||
* @param x the new x-coordinate of the Figure's position
|
||||
* @param y the new y-coordinate of the Figure's position
|
||||
* @param fieldId the position to move to
|
||||
*/
|
||||
public void moveTo(int fieldId) {
|
||||
moveTo(fieldIdToPosition(fieldId));
|
||||
|
@@ -206,7 +206,7 @@ public class DeckHelper{
|
||||
|
||||
private void namensschildTruppenkueche(Player player) {
|
||||
player.setPosition(24);
|
||||
player.pay(25);
|
||||
player.pay(250);
|
||||
}
|
||||
|
||||
private void spendierhosenUnibar(Player player) {
|
||||
|
@@ -118,6 +118,11 @@ public class BoardManager {
|
||||
if (field == null) {
|
||||
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
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ public class GateField extends PropertyField{
|
||||
}
|
||||
|
||||
GateField(String name, int id) {
|
||||
super(name, id, 2000, 25);
|
||||
super(name, id, 2000, 250);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,7 +13,6 @@ import pp.monopoly.model.Item;
|
||||
/**
|
||||
* Event when an item gets removed.
|
||||
*
|
||||
* @param item the destroyed item
|
||||
*/
|
||||
public class ItemRemovedEvent {
|
||||
private final Item item;
|
||||
|
Reference in New Issue
Block a user