added the playeringamenotification to be created from the right dataset

This commit is contained in:
Hanno Fleischer
2024-12-03 16:48:08 +01:00
parent db50986f3f
commit 69865bb504
2 changed files with 16 additions and 5 deletions

View File

@@ -3,8 +3,10 @@
import pp.mdga.client.gameState.*;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.message.client.LeaveGameMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.InterruptNotification;
import pp.mdga.notification.StartDialogNotification;
public class GameState extends ClientState {
@@ -105,6 +107,13 @@ public void received(PauseGameMessage msg){
logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
}
@Override
public void selectLeave(){
logic.send(new LeaveGameMessage());
logic.addNotification(new StartDialogNotification());
logic.setState(logic.getDialogs());
}
/**
* This method is used to call the received method of the current state
*

View File

@@ -5,6 +5,7 @@
import pp.mdga.client.DialogsState;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.game.Player;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.*;
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
@@ -74,14 +75,15 @@ public void selectStart(){
@Override
public void received(ServerStartGameMessage msg){
logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
for (Map.Entry<Color, PlayerData> entry : logic.getGame().getBoard().getPlayerData().entrySet()) {
List<UUID> pieceList = new ArrayList<>();
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
entry.getValue().initialize();
List<UUID> pieces = new ArrayList<>();
for(Piece piece : entry.getValue().getPieces()){
System.out.println(piece.getUuid());
pieceList.add(piece.getUuid());
pieces.add(piece.getUuid());
}
logic.addNotification(new PlayerInGameNotification(entry.getKey(), pieceList , logic.getGame().getPlayerByColor(entry.getKey()).getName()));
logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName()));
}
logic.setState(logic.getGameState());
}