Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
Fleischer Hanno
2024-12-01 23:42:56 +01:00
3 changed files with 28 additions and 2 deletions

View File

@@ -107,7 +107,7 @@ public void simpleInitApp() {
gameView = new GameView(this); gameView = new GameView(this);
ceremonyView = new CeremonyView(this); ceremonyView = new CeremonyView(this);
enter(MdgaState.GAME); enter(MdgaState.MAIN);
} }
/** /**

View File

@@ -1,17 +1,33 @@
package pp.mdga.message.server; package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Board;
/** /**
* A message indicating that the game shall start. * A message indicating that the game shall start.
*/ */
@Serializable @Serializable
public class ServerStartGameMessage extends ServerMessage { public class ServerStartGameMessage extends ServerMessage {
/**
* Create ServerStartGameMessage attributes.
*/
private final Board board;
/** /**
* Constructs a new ServerStartGame instance. * Constructs a new ServerStartGame instance.
*/ */
public ServerStartGameMessage() { public ServerStartGameMessage() {
super(); super();
this.board = null;
}
/**
* Constructor.
*
* @param board as the complete board of this game as a Board object.
*/
public ServerStartGameMessage(Board board) {
this.board = board;
} }
/** /**
@@ -24,6 +40,15 @@ public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* This method will be used to return board attribute of ServerStartGameMessage class.
*
* @return board as a Board object.
*/
public Board getBoard() {
return this.board;
}
/** /**
* Returns a string representation of this message. * Returns a string representation of this message.
* *

View File

@@ -109,6 +109,7 @@ public void received(LobbyReadyMessage msg, int from) {
} }
this.logic.getGame().setAllReady(true); this.logic.getGame().setAllReady(true);
this.logic.getServerSender().broadcast(new ServerStartGameMessage(this.logic.getGame().getBoard()));
} }
/** /**
@@ -149,7 +150,7 @@ public void received(LeaveGameMessage msg, int from) {
@Override @Override
public void received(StartGameMessage msg, int from) { public void received(StartGameMessage msg, int from) {
if (msg.isForceStartGame() || this.logic.getGame().allReady()) { if (msg.isForceStartGame() || this.logic.getGame().allReady()) {
this.logic.getServerSender().broadcast(new ServerStartGameMessage()); this.logic.getServerSender().broadcast(new ServerStartGameMessage(this.logic.getGame().getBoard()));
this.logic.setCurrentState(this.logic.getGameState()); this.logic.setCurrentState(this.logic.getGameState());
} }
} }