mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-03 12:37:42 +02:00
event card complete
This commit is contained in:
@@ -26,12 +26,14 @@ import pp.monopoly.model.IntPoint;
|
||||
import pp.monopoly.model.fields.BoardManager;
|
||||
import pp.monopoly.notification.ClientStateEvent;
|
||||
import pp.monopoly.notification.DiceRollEvent;
|
||||
import pp.monopoly.notification.EventCardEvent;
|
||||
import pp.monopoly.notification.GameEvent;
|
||||
import pp.monopoly.notification.GameEventBroker;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.InfoTextEvent;
|
||||
import pp.monopoly.notification.Sound;
|
||||
import pp.monopoly.notification.SoundEvent;
|
||||
import pp.monopoly.notification.UpdatePlayerView;
|
||||
|
||||
/**
|
||||
* Controls the client-side game logic for Monopoly.
|
||||
@@ -225,9 +227,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
*/
|
||||
@Override
|
||||
public void received(EventDrawCard msg) {
|
||||
|
||||
// Kartenlogik
|
||||
playSound(Sound.EVENT_CARD);
|
||||
notifyListeners(new EventCardEvent(msg.getCardDescription()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,8 +283,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
*/
|
||||
@Override
|
||||
public void received(PlayerStatusUpdate msg) {
|
||||
|
||||
|
||||
playerHandler = msg.getPlayerHandler();
|
||||
notifyListeners(new UpdatePlayerView());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -7,12 +7,15 @@
|
||||
|
||||
package pp.monopoly.game.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.message.server.DiceResult;
|
||||
import pp.monopoly.message.server.EventDrawCard;
|
||||
import pp.monopoly.message.server.PlayerStatusUpdate;
|
||||
import pp.monopoly.model.FieldVisitor;
|
||||
import pp.monopoly.model.Figure;
|
||||
import pp.monopoly.model.card.Card;
|
||||
@@ -36,7 +39,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
private String name;
|
||||
private int accountBalance = 15000;
|
||||
private Figure figure;
|
||||
private List<PropertyField> properties;
|
||||
private List<PropertyField> properties = new ArrayList<>();
|
||||
private int getOutOfJailCard;
|
||||
private int fieldID;
|
||||
private DiceResult rollResult;
|
||||
@@ -319,7 +322,9 @@ public class Player implements FieldVisitor<Void>{
|
||||
@Override
|
||||
public Void visit(EventField field) {
|
||||
Card c = getHandler().getLogic().getDeckHelper().drawCard();
|
||||
getHandler().getLogic().getDeckHelper().visit(c, this);
|
||||
getHandler().getLogic().getDeckHelper().visit(c, this); //Logic
|
||||
getHandler().getLogic().send(this, new EventDrawCard(c.getDescription())); // Card notification
|
||||
getHandler().getLogic().send(this, new PlayerStatusUpdate(getHandler())); //update view
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -408,6 +413,10 @@ public class Player implements FieldVisitor<Void>{
|
||||
return state.rollDice();
|
||||
}
|
||||
|
||||
private void visitEvent() {
|
||||
getHandler().getLogic().getBoardManager().getFieldAtIndex(36).accept(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A interface representing the PlayerStates
|
||||
*/
|
||||
@@ -519,6 +528,7 @@ public class Player implements FieldVisitor<Void>{
|
||||
|
||||
@Override
|
||||
public DiceResult rollDice() {
|
||||
visitEvent();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -2,36 +2,24 @@ package pp.monopoly.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.game.server.PlayerColor;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
|
||||
@Serializable
|
||||
public class PlayerStatusUpdate extends ServerMessage{
|
||||
|
||||
private String playerName;
|
||||
private String status;
|
||||
private PlayerColor color;
|
||||
private PlayerHandler playerHandler;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayerStatusUpdate() { /* empty */ }
|
||||
|
||||
public PlayerStatusUpdate(String playerName, String status, PlayerColor color) {
|
||||
this.playerName = playerName;
|
||||
this.status = status;
|
||||
this.color = color;
|
||||
public PlayerStatusUpdate(PlayerHandler playerHandler) {
|
||||
this.playerHandler = playerHandler;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PlayerColor getColor() {
|
||||
return color;
|
||||
public PlayerHandler getPlayerHandler() {
|
||||
return playerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -48,6 +48,8 @@ public class DeckHelper{
|
||||
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500 EUR", "party-gewinn"));
|
||||
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
|
||||
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000 EUR", "jodel-eispenis"));
|
||||
|
||||
shuffle();
|
||||
}
|
||||
|
||||
public void visit(Card card, Player player) {
|
||||
@@ -203,7 +205,7 @@ public class DeckHelper{
|
||||
}
|
||||
|
||||
private void namensschildTruppenkueche(Player player) {
|
||||
//TODO
|
||||
//TODO 10 existiert nicht mehr
|
||||
}
|
||||
|
||||
private void spendierhosenUnibar(Player player) {
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package pp.monopoly.notification;
|
||||
|
||||
public record EventCardEvent(String description) implements GameEvent{
|
||||
|
||||
@Override
|
||||
public void notifyListener(GameEventListener listener) {
|
||||
listener.receivedEvent(this);
|
||||
}
|
||||
|
||||
}
|
@@ -58,5 +58,12 @@ public interface GameEventListener {
|
||||
*
|
||||
* @param event the received event
|
||||
*/
|
||||
default void receivedEvent(UpdatePlayerView event) { /*Do nothing */}
|
||||
default void receivedEvent(UpdatePlayerView event) { /*Do nothing */}
|
||||
|
||||
/**
|
||||
* Indicates that an event card has been drawn
|
||||
*
|
||||
* @param event the received event
|
||||
*/
|
||||
default void receivedEvent(EventCardEvent event) { /*Do nothing */}
|
||||
}
|
||||
|
Reference in New Issue
Block a user