mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 00:06:16 +01:00
fix trade reject
This commit is contained in:
parent
f3ec17b0b1
commit
4af08ffffd
@ -256,38 +256,41 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
|
||||
TradeHandler tradeHandler = msg.getTradeHandler();
|
||||
|
||||
|
||||
|
||||
Player receiver = playerHandler.getPlayerById(tradeHandler.getReceiver().getId());
|
||||
Player sender = playerHandler.getPlayerById(tradeHandler.getSender().getId());
|
||||
|
||||
if(msg.isAccepted()) {
|
||||
Set<PropertyField> offered = new HashSet<>();
|
||||
|
||||
Set<PropertyField> offered = new HashSet<>();
|
||||
for (PropertyField propertyField : tradeHandler.getOfferedProperties()) {
|
||||
offered.add( (PropertyField) boardManager.getFieldAtIndex(propertyField.getId()));
|
||||
}
|
||||
|
||||
for (PropertyField propertyField : tradeHandler.getOfferedProperties()) {
|
||||
offered.add( (PropertyField) boardManager.getFieldAtIndex(propertyField.getId()));
|
||||
Set<PropertyField> requested = new HashSet<>();
|
||||
|
||||
for (PropertyField propertyField : tradeHandler.getRequestedProperties()) {
|
||||
requested.add( (PropertyField) boardManager.getFieldAtIndex(propertyField.getId()));
|
||||
}
|
||||
|
||||
executeTrade(sender, receiver, offered, requested);
|
||||
|
||||
sender.earnMoney(tradeHandler.getRequestedAmount());
|
||||
sender.pay(tradeHandler.getOfferedAmount());
|
||||
receiver.earnMoney(tradeHandler.getOfferedAmount());
|
||||
receiver.pay(tradeHandler.getRequestedAmount());
|
||||
|
||||
for (int i = 0; i < tradeHandler.getOfferedJailCards(); i++) {
|
||||
sender.removeJailCard();
|
||||
receiver.addJailCard();
|
||||
}
|
||||
|
||||
for (int i = 0; i < tradeHandler.getRequestedAmount(); i++) {
|
||||
sender.addJailCard();
|
||||
receiver.removeJailCard();
|
||||
}
|
||||
}
|
||||
|
||||
Set<PropertyField> requested = new HashSet<>();
|
||||
|
||||
for (PropertyField propertyField : tradeHandler.getRequestedProperties()) {
|
||||
requested.add( (PropertyField) boardManager.getFieldAtIndex(propertyField.getId()));
|
||||
}
|
||||
|
||||
executeTrade(sender, receiver, offered, requested);
|
||||
|
||||
sender.earnMoney(tradeHandler.getRequestedAmount());
|
||||
sender.pay(tradeHandler.getOfferedAmount());
|
||||
receiver.earnMoney(tradeHandler.getOfferedAmount());
|
||||
receiver.pay(tradeHandler.getRequestedAmount());
|
||||
|
||||
for (int i = 0; i < tradeHandler.getOfferedJailCards(); i++) {
|
||||
sender.removeJailCard();
|
||||
receiver.addJailCard();
|
||||
}
|
||||
|
||||
for (int i = 0; i < tradeHandler.getRequestedAmount(); i++) {
|
||||
sender.addJailCard();
|
||||
receiver.removeJailCard();
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
|
||||
if (receiver != null && sender != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user