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:
@@ -261,10 +261,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
@Override
|
||||
public void received(JailEvent msg) {
|
||||
if (msg.isGoingToJail()) {
|
||||
|
||||
playSound(Sound.GULAG);
|
||||
} else {
|
||||
System.out.println("NO MORE JAIL");
|
||||
notifyListeners(new PopUpEvent("goingToJail", msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +343,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
public void received(NotificationMessage msg) {
|
||||
if (msg.getKeyWord().equals("rent")) {
|
||||
notifyListeners(new PopUpEvent("rent", msg));
|
||||
} else if (msg.getKeyWord().equals("jailpay")) {
|
||||
notifyListeners(new PopUpEvent(msg.getKeyWord(), msg));
|
||||
} else if(msg.getKeyWord().equals("NoMoneyWarning")) {
|
||||
notifyListeners(new PopUpEvent("NoMoneyWarning", msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -158,6 +158,14 @@ public class Player implements FieldVisitor<Void>{
|
||||
return accountBalance >= 0;
|
||||
}
|
||||
|
||||
public PlayerState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(PlayerState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the player by a given number of steps, handling board wrapping.
|
||||
*
|
||||
@@ -324,6 +332,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
public Void visit(BuildingProperty field) {
|
||||
if(field.getOwner() == null) {
|
||||
if (field.getPrice() <= accountBalance) getHandler().getLogic().send(this, new BuyPropertyRequest());
|
||||
else getHandler().getLogic().send(this, new NotificationMessage("NoMoneyWarning"));
|
||||
} else if (field.getOwner() != this){
|
||||
int rent = field.calcRent();
|
||||
field.getOwner().earnMoney(rent);
|
||||
@@ -486,6 +495,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
*/
|
||||
private static int rollDice() {
|
||||
return random.nextInt(6) + 1;
|
||||
// return 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,6 +614,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
remainingAttempts--;
|
||||
if (remainingAttempts <= 0) {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage("jailpay"));
|
||||
if(getOutOfJailCard == 0) payBail();
|
||||
} else {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage("jailtryagain"));
|
||||
}
|
||||
@@ -614,23 +625,15 @@ public class Player implements FieldVisitor<Void>{
|
||||
|
||||
@Override
|
||||
public void payBail() {
|
||||
if (accountBalance >= 500) {
|
||||
pay(500);
|
||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||
state = new ActiveState();
|
||||
} else {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useJailCard() {
|
||||
if (getOutOfJailCard > 0) {
|
||||
removeJailCard();
|
||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||
state = new ActiveState();
|
||||
} else {
|
||||
handler.getLogic().send(Player.this, new NotificationMessage(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,11 +14,13 @@ import pp.monopoly.message.client.AlterProperty;
|
||||
import pp.monopoly.message.client.BuyPropertyResponse;
|
||||
import pp.monopoly.message.client.ClientInterpreter;
|
||||
import pp.monopoly.message.client.EndTurn;
|
||||
import pp.monopoly.message.client.NotificationAnswer;
|
||||
import pp.monopoly.message.client.PlayerReady;
|
||||
import pp.monopoly.message.client.RollDice;
|
||||
import pp.monopoly.message.client.TradeOffer;
|
||||
import pp.monopoly.message.client.TradeResponse;
|
||||
import pp.monopoly.message.client.ViewAssetsRequest;
|
||||
import pp.monopoly.message.server.GameOver;
|
||||
import pp.monopoly.message.server.GameStart;
|
||||
import pp.monopoly.message.server.NextPlayerTurn;
|
||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||
@@ -181,8 +183,14 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
send(next, new NextPlayerTurn());
|
||||
send(next, new PlayerStatusUpdate(playerHandler));
|
||||
send(player, new PlayerStatusUpdate(playerHandler));
|
||||
} else {
|
||||
send(player, new GameOver(false));
|
||||
playerHandler.removePlayer(player);
|
||||
}
|
||||
}
|
||||
if(playerHandler.getPlayers().size() == 1) {
|
||||
send(playerHandler.getPlayerAtIndex(0), new GameOver(true));
|
||||
}
|
||||
updateAllPlayers();
|
||||
}
|
||||
|
||||
@@ -400,5 +408,18 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NotificationAnswer msg, int from) {
|
||||
if(msg.getKeyword().equals("UseJailCard")) {
|
||||
playerHandler.getPlayerById(from).useJailCard();
|
||||
} else if (msg.getKeyword().equals("PayJail")) {
|
||||
playerHandler.getPlayerById(from).payBail();
|
||||
}
|
||||
|
||||
updateAllPlayers();
|
||||
}
|
||||
}
|
||||
|
@@ -74,4 +74,12 @@ public interface ClientInterpreter {
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(AlterProperty msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received NotificationAnswer.
|
||||
*
|
||||
* @param msg the NotificationAnswer to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(NotificationAnswer msg, int from);
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
@Serializable
|
||||
public class NotificationAnswer extends ClientMessage{
|
||||
|
||||
private String keyword;
|
||||
|
||||
private NotificationAnswer() {}
|
||||
|
||||
public NotificationAnswer(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ClientInterpreter interpreter, int from) {
|
||||
interpreter.received(this, from);
|
||||
}
|
||||
|
||||
}
|
@@ -19,7 +19,7 @@ public class Card {
|
||||
return description;
|
||||
} // TODO wird gerade in der EventCard zur erstellung des Popup genutzt
|
||||
|
||||
String getKeyword() {
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user