added transition from Lobby to Game

This commit is contained in:
Fleischer Hanno
2024-12-01 23:50:37 +01:00
parent 8137a727f5
commit 7712a23d00
2 changed files with 10 additions and 5 deletions

View File

@@ -53,6 +53,10 @@ public void setOwnPlayerName(String ownPlayerName) {
this.ownPlayerName = ownPlayerName;
}
public void setOwnPlayerId(int ownPlayerId) {
this.ownPlayerID = ownPlayerId;
}
public LobbyState getLobby() {
return lobbyState;
}

View File

@@ -11,10 +11,7 @@
import pp.mdga.message.server.ServerStartGameMessage;
import pp.mdga.message.server.UpdateReadyMessage;
import pp.mdga.message.server.UpdateTSKMessage;
import pp.mdga.notification.LobbyReadyNotification;
import pp.mdga.notification.StartDialogNotification;
import pp.mdga.notification.TskSelectNotification;
import pp.mdga.notification.TskUnselectNotification;
import pp.mdga.notification.*;
public class LobbyState extends DialogStates {
@@ -74,12 +71,16 @@ public void selectStart(){
@Override
public void received(ServerStartGameMessage msg){
logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayers().get(parent.getOwnPlayerId()).getColor()));
parent.startGame();
}
@Override
public void received(LobbyPlayerJoinedMessage msg){
if(msg.getPlayer().getName().equals(parent.getOwnPlayerName())){
parent.setOwnPlayerId(msg.getId());
}
logic.addNotification(new TskSelectNotification(msg.getPlayer().getColor(), msg.getPlayer().getName(), parent.getOwnPlayerId()== msg.getId()));
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
}