Merge branch 'dev/model' into dev/client_koppe2

This commit is contained in:
Felix Koppe
2024-12-05 16:25:23 +01:00
108 changed files with 773 additions and 1205 deletions

View File

@@ -144,7 +144,6 @@ private void initializeSerializables() {
Serializer.registerClass(Piece.class); Serializer.registerClass(Piece.class);
Serializer.registerClass(BonusNode.class); Serializer.registerClass(BonusNode.class);
Serializer.registerClass(StartNode.class); Serializer.registerClass(StartNode.class);
Serializer.registerClass(PlayerData.class);
Serializer.registerClass(HomeNode.class); Serializer.registerClass(HomeNode.class);
Serializer.registerClass(Color.class, new EnumSerializer()); Serializer.registerClass(Color.class, new EnumSerializer());

View File

@@ -1,9 +1,8 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.ceremonyState.CeremonyStates; import pp.mdga.client.ceremonystate.CeremonyStates;
import pp.mdga.client.ceremonyState.PodiumState; import pp.mdga.client.ceremonystate.PodiumState;
import pp.mdga.client.ceremonyState.StatisticsState; import pp.mdga.client.ceremonystate.StatisticsState;
import pp.mdga.notification.CeremonyNotification;
public class CeremonyState extends ClientState { public class CeremonyState extends ClientState {

View File

@@ -5,13 +5,13 @@
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Game; import pp.mdga.game.Game;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.ClientMessage; import pp.mdga.message.client.ClientMessage;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.*; import pp.mdga.notification.InfoNotification;
import pp.mdga.notification.Notification;
import pp.mdga.notification.StartDialogNotification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@@ -52,20 +52,21 @@ public ClientGameLogic(ClientSender clientSender) {
* *
* @param msg the message to be sent * @param msg the message to be sent
*/ */
public void send(ClientMessage msg){ public void send(ClientMessage msg) {
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg); LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
clientSender.send(msg); clientSender.send(msg);
} }
/** /**
* This method is used to get a piece by its id * This method is used to get a piece by its id
*
* @param pieceId the UUID of the piece * @param pieceId the UUID of the piece
* @return the piece * @return the piece
*/ */
private Piece getPiece(UUID pieceId){ private Piece getPiece(UUID pieceId) {
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){ for (var player : this.game.getPlayers().values()) {
for(Piece piece : entry.getValue().getPieces()){ for (Piece piece : player.getPieces()) {
if(piece.getUuid().equals(pieceId)){ if (piece.getUuid().equals(pieceId)) {
return piece; return piece;
} }
} }
@@ -78,7 +79,7 @@ private Piece getPiece(UUID pieceId){
* *
* @return the clientSender * @return the clientSender
*/ */
public ClientSender getClientSender(){ public ClientSender getClientSender() {
return clientSender; return clientSender;
} }
@@ -123,7 +124,7 @@ public void setOwnPlayerId(int ownPlayerId) {
* *
* @return the game * @return the game
*/ */
public Game getGame(){ public Game getGame() {
return game; return game;
} }
@@ -132,7 +133,7 @@ public Game getGame(){
* *
* @return the current State * @return the current State
*/ */
public ClientState getState(){ public ClientState getState() {
return state; return state;
} }
@@ -141,7 +142,7 @@ public ClientState getState(){
* *
* @return if the client is a host * @return if the client is a host
*/ */
public boolean isHost(){ public boolean isHost() {
return isHost; return isHost;
} }
@@ -150,8 +151,8 @@ public boolean isHost(){
* *
* @return the calculated moves as int * @return the calculated moves as int
*/ */
public int getCalculatedMoves(){ public int getCalculatedMoves() {
return game.getDiceEyes() * game.getDiceModifier(); return 0;
} }
/** /**
@@ -159,7 +160,7 @@ public int getCalculatedMoves(){
* *
* @param isHost the boolean value * @param isHost the boolean value
*/ */
public void setHost(boolean isHost){ public void setHost(boolean isHost) {
this.isHost = isHost; this.isHost = isHost;
} }
@@ -480,14 +481,14 @@ public void received(SelectPieceMessage msg) {
* *
* @param pieceId the pieceID * @param pieceId the pieceID
*/ */
public void selectPiece(UUID pieceId){ public void selectPiece(UUID pieceId) {
state.selectPiece(getPiece(pieceId)); state.selectPiece(getPiece(pieceId));
} }
/** /**
* This method call the method selectNExt of the state * This method call the method selectNExt of the state
*/ */
public void selectNext(){ public void selectNext() {
state.selectNext(); state.selectNext();
} }
@@ -496,7 +497,7 @@ public void selectNext(){
* *
* @param card the BonusCard to selected * @param card the BonusCard to selected
*/ */
public void selectCard(BonusCard card){ public void selectCard(BonusCard card) {
state.selectCard(card); state.selectCard(card);
} }
@@ -505,7 +506,7 @@ public void selectCard(BonusCard card){
* *
* @param color the Color to be selected * @param color the Color to be selected
*/ */
public void selectTsk(Color color){ public void selectTsk(Color color) {
state.selectTSK(color); state.selectTSK(color);
} }
@@ -514,14 +515,14 @@ public void selectTsk(Color color){
* *
* @param color the color to be deselcted * @param color the color to be deselcted
*/ */
public void deselectTSK(Color color){ public void deselectTSK(Color color) {
state.deselectTSK(color); state.deselectTSK(color);
} }
/** /**
* This method calls the selectDice method of the state * This method calls the selectDice method of the state
*/ */
public void selectDice(){ public void selectDice() {
state.selectDice(); state.selectDice();
} }
@@ -530,7 +531,7 @@ public void selectDice(){
* *
* @param name the name to be set * @param name the name to be set
*/ */
public void selectName(String name){ public void selectName(String name) {
state.setName(name); state.setName(name);
} }
@@ -539,8 +540,8 @@ public void selectName(String name){
* *
* @param ready the value if this method should ready or unready * @param ready the value if this method should ready or unready
*/ */
public void selectReady(boolean ready){ public void selectReady(boolean ready) {
if(ready){ if (ready) {
state.selectReady(); state.selectReady();
} else { } else {
state.selectUnready(); state.selectUnready();
@@ -552,14 +553,14 @@ public void selectReady(boolean ready){
* *
* @param name the name of the player hosting * @param name the name of the player hosting
*/ */
public void selectHost(String name){ public void selectHost(String name) {
state.selectHost(name); state.selectHost(name);
} }
/** /**
* This method calls the selectLeave method of the state * This method calls the selectLeave method of the state
*/ */
public void selectLeave(){ public void selectLeave() {
state.selectLeave(); state.selectLeave();
} }
@@ -568,28 +569,28 @@ public void selectLeave(){
* *
* @param ip the ip to cennect to * @param ip the ip to cennect to
*/ */
public void selectJoin(String ip){ public void selectJoin(String ip) {
state.selectJoin(ip); state.selectJoin(ip);
} }
/** /**
* This method calls the selectAnimationEnd method of the state * This method calls the selectAnimationEnd method of the state
*/ */
public void selectAnimationEnd(){ public void selectAnimationEnd() {
state.selectAnimationEnd(); state.selectAnimationEnd();
} }
/** /**
* This method calls the selectStart method of the state * This method calls the selectStart method of the state
*/ */
public void selectStart(){ public void selectStart() {
state.selectStart(); state.selectStart();
} }
/** /**
* This method calls the selectResume method of the state * This method calls the selectResume method of the state
*/ */
public void selectResume(){ public void selectResume() {
state.selectResume(); state.selectResume();
} }
@@ -598,7 +599,7 @@ public void selectResume(){
* *
* @param state the new state * @param state the new state
*/ */
public void setState(ClientState state){ public void setState(ClientState state) {
this.state.exit(); this.state.exit();
state.enter(); state.enter();
this.state = state; this.state = state;
@@ -607,7 +608,7 @@ public void setState(ClientState state){
/** /**
* This method is used to enter the interrupt state and save the previous state * This method is used to enter the interrupt state and save the previous state
*/ */
public void enterInterrupt(){ public void enterInterrupt() {
interruptState.enter(); interruptState.enter();
interruptState.setPreviousState(state); interruptState.setPreviousState(state);
this.state = interruptState; this.state = interruptState;
@@ -618,7 +619,7 @@ public void enterInterrupt(){
* *
* @return the GameState * @return the GameState
*/ */
public GameState getGameState(){ public GameState getGameState() {
return gameState; return gameState;
} }
@@ -627,7 +628,7 @@ public GameState getGameState(){
* *
* @return the CeremonyState * @return the CeremonyState
*/ */
public CeremonyState getCeremony(){ public CeremonyState getCeremony() {
return ceremonyState; return ceremonyState;
} }
@@ -636,7 +637,7 @@ public CeremonyState getCeremony(){
* *
* @return the InterruptState * @return the InterruptState
*/ */
public InterruptState getInterrupt(){ public InterruptState getInterrupt() {
return interruptState; return interruptState;
} }
@@ -645,7 +646,7 @@ public InterruptState getInterrupt(){
* *
* @return the DialogsState * @return the DialogsState
*/ */
public DialogsState getDialogs(){ public DialogsState getDialogs() {
return dialogsState; return dialogsState;
} }
@@ -654,7 +655,7 @@ public DialogsState getDialogs(){
* *
* @return the SettingsState * @return the SettingsState
*/ */
public SettingsState getSettings(){ public SettingsState getSettings() {
return settingsState; return settingsState;
} }
@@ -663,8 +664,8 @@ public SettingsState getSettings(){
* *
* @return the next notification * @return the next notification
*/ */
public Notification getNotification(){ public Notification getNotification() {
if(!notifications.isEmpty()){ if (!notifications.isEmpty()) {
return notifications.remove(0); return notifications.remove(0);
} else { } else {
return null; return null;
@@ -676,7 +677,7 @@ public Notification getNotification(){
* *
* @param notification the notification to be added * @param notification the notification to be added
*/ */
public void addNotification(Notification notification){ public void addNotification(Notification notification) {
notifications.add(notification); notifications.add(notification);
} }

View File

@@ -1,9 +1,9 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.dialogState.DialogStates; import pp.mdga.client.dialogstate.DialogStates;
import pp.mdga.client.dialogState.LobbyState; import pp.mdga.client.dialogstate.LobbyState;
import pp.mdga.client.dialogState.NetworkDialogState; import pp.mdga.client.dialogstate.NetworkDialogState;
import pp.mdga.client.dialogState.StartDialogState; import pp.mdga.client.dialogstate.StartDialogState;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;

View File

@@ -1,6 +1,6 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.gameState.*; import pp.mdga.client.gamestate.*;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.LeaveGameMessage; import pp.mdga.message.client.LeaveGameMessage;

View File

@@ -1,9 +1,9 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.settingsState.AudioSettingsState; import pp.mdga.client.settingsstate.AudioSettingsState;
import pp.mdga.client.settingsState.MainSettingsState; import pp.mdga.client.settingsstate.MainSettingsState;
import pp.mdga.client.settingsState.SettingStates; import pp.mdga.client.settingsstate.SettingStates;
import pp.mdga.client.settingsState.VideoSettingsState; import pp.mdga.client.settingsstate.VideoSettingsState;
public class SettingsState extends ClientState { public class SettingsState extends ClientState {

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState; package pp.mdga.client.ceremonystate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState; package pp.mdga.client.ceremonystate;
import pp.mdga.client.CeremonyState; import pp.mdga.client.CeremonyState;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.ceremonyState; package pp.mdga.client.ceremonystate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState; package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState; package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -6,16 +6,14 @@
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.Player; import pp.mdga.game.Player;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.*; import pp.mdga.message.client.*;
import pp.mdga.message.server.LobbyPlayerJoinedMessage; import pp.mdga.message.server.*;
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
import pp.mdga.message.server.ServerStartGameMessage;
import pp.mdga.message.server.UpdateReadyMessage;
import pp.mdga.message.server.UpdateTSKMessage;
import pp.mdga.notification.*; import pp.mdga.notification.*;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class LobbyState extends DialogStates { public class LobbyState extends DialogStates {
@@ -58,41 +56,46 @@ public void selectReady() {
} }
@Override @Override
public void selectUnready(){ public void selectUnready() {
logic.send(new LobbyNotReadyMessage()); logic.send(new LobbyNotReadyMessage());
} }
@Override @Override
public void selectStart(){ public void selectStart() {
if(logic.isHost() && logic.getGame().areAllReady()){ if (logic.isHost() && logic.getGame().areAllReady()) {
logic.send(new StartGameMessage(false)); logic.send(new StartGameMessage());
} else if(logic.isHost() && !logic.getGame().areAllReady()) {
logic.send(new StartGameMessage(true));
} else { } else {
LOGGER.log(System.Logger.Level.ERROR, "You are not the host"); LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
} }
} }
@Override @Override
public void received(ServerStartGameMessage msg){ public void received(ServerStartGameMessage msg) {
for (Player player: msg.getPlayers()) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
if (entry.getValue().getColor() == player.getColor()) {
this.logic.getGame().getPlayers().put(entry.getKey(), player);
}
}
}
logic.getGame().setBoard(msg.getBoard()); logic.getGame().setBoard(msg.getBoard());
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor())); logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) { for (var player : logic.getGame().getPlayers().values()) {
List<UUID> pieces = new ArrayList<>(); List<UUID> pieces = new ArrayList<>();
for (Piece piece : logic.getGame().getBoard().getPlayerData().get(entry.getValue().getColor()).getPieces()) { for (Piece piece : player.getPieces()) {
pieces.add(piece.getUuid()); pieces.add(piece.getUuid());
} }
logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName())); logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
} }
logic.setState(logic.getGameState()); logic.setState(logic.getGameState());
} }
@Override @Override
public void received(LobbyPlayerJoinedMessage msg){ public void received(LobbyPlayerJoinedMessage msg) {
if(msg.getPlayer().getName().equals(logic.getOwnPlayerName())){ if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
logic.setOwnPlayerId(msg.getId()); logic.setOwnPlayerId(msg.getId());
} }
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()){ if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
logic.setHost(true); logic.setHost(true);
} }
@@ -101,9 +104,9 @@ public void received(LobbyPlayerJoinedMessage msg){
} }
@Override @Override
public void received(UpdateTSKMessage msg){ public void received(UpdateTSKMessage msg) {
if(msg.isTaken()) { if (msg.isTaken()) {
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId()== msg.getId())); logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
} else { } else {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor())); logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
} }
@@ -112,13 +115,13 @@ public void received(UpdateTSKMessage msg){
} }
@Override @Override
public void received(LobbyPlayerLeaveMessage msg){ public void received(LobbyPlayerLeaveMessage msg) {
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor())); logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
logic.getGame().getPlayers().remove(msg.getId()); logic.getGame().getPlayers().remove(msg.getId());
} }
@Override @Override
public void received(UpdateReadyMessage msg){ public void received(UpdateReadyMessage msg) {
//TODO server sendet kein update on UNready //TODO server sendet kein update on UNready
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady())); logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady()); logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState; package pp.mdga.client.dialogstate;
import pp.mdga.Resources; import pp.mdga.Resources;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.dialogState; package pp.mdga.client.dialogstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,11 +1,14 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates; import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState; import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState; import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.RankingResponseMessage; import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage; import pp.mdga.message.server.RankingRollAgainMessage;
@@ -17,12 +20,33 @@ public class DetermineStartPlayerState extends GameStates {
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic); private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic); private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
private final Intro intro = new Intro(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) { public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
this.parent = (GameState) parent; this.parent = (GameState) parent;
} }
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public Intro getIntro(){
return intro;
}
public GameState getParent() {
return parent;
}
@Override @Override
public void enter() { public void enter() {
this.setState(this.rollRankingDiceState); this.setState(this.rollRankingDiceState);
@@ -46,6 +70,11 @@ public void selectDice() {
state.selectDice(); state.selectDice();
} }
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
state.received(msg); state.received(msg);
@@ -61,19 +90,8 @@ public void received(RankingResponseMessage msg){
state.received(msg); state.received(msg);
} }
public RollRankingDiceState getRollRankingDice() { @Override
return rollRankingDiceState; public void received(ActivePlayerMessage msg){
} state.received(msg);
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
public DetermineStartPlayerStates getState(){
return state;
}
public GameState getParent() {
return parent;
} }
} }

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
@@ -17,10 +17,10 @@ public GameStates(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
} }
protected void handlePowerCard(PlayCardMessage msg){ protected void handlePowerCard(PlayCardMessage msg) {
if (msg.getCard().equals(BonusCard.TURBO)){ if (msg.getCard().equals(BonusCard.TURBO)) {
logic.getGame().setDiceModifier(msg.getDiceModifier()); //logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().equals(BonusCard.SHIELD)){ } else if (msg.getCard().equals(BonusCard.SHIELD)) {
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) { if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED); logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid())); logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
@@ -36,12 +36,12 @@ protected void handlePowerCard(PlayCardMessage msg){
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece); logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
} }
logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard())); logic.getGame().getDiscardPile().add(msg.getCard());
} }
protected void throwPiece(Piece piece){ protected void throwPiece(Piece piece) {
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece); logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
logic.addNotification(new ThrowPieceNotification(piece.getUuid())); logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown(); logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
logic.getGame().getGameStatistics().increasePiecesBeingThrown(); logic.getGame().getGameStatistics().increasePiecesBeingThrown();

View File

@@ -1,11 +1,14 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.*; import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.HomeMoveNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayCardNotification;
public class SpectatorState extends GameStates { public class SpectatorState extends GameStates {
@@ -27,15 +30,15 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); //logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){ if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -43,7 +46,7 @@ public void received(DieMessage msg){
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
@@ -52,26 +55,26 @@ public void received(PlayCardMessage msg){
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove); logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
} else { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown(); logic.getGame().getGameStatistics().increasePiecesThrown();
} }
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){ if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true)); logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } else {

View File

@@ -1,14 +1,14 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.client.gameState.turnState.MovePieceState; import pp.mdga.client.gamestate.turnstate.MovePieceState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState; import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.client.gameState.turnState.RollDiceState; import pp.mdga.client.gamestate.turnstate.RollDiceState;
import pp.mdga.client.gameState.turnState.TurnStates; import pp.mdga.client.gamestate.turnstate.TurnStates;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;

View File

@@ -1,9 +1,10 @@
package pp.mdga.client.gameState; package pp.mdga.client.gamestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.GameState; import pp.mdga.client.GameState;
import pp.mdga.game.*; import pp.mdga.game.Piece;
import pp.mdga.game.PieceState;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.*; import pp.mdga.notification.*;
@@ -27,21 +28,21 @@ public void exit() {
} }
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg) {
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg) {
logic.addNotification(new DiceNowNotification()); logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn()); parent.setState(parent.getTurn());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg) {
logic.getGame().setDiceEyes(msg.getDiceEye()); // logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){ if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();
} }
@@ -49,7 +50,7 @@ public void received(DieMessage msg){
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard())); logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
handlePowerCard(msg); handlePowerCard(msg);
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
@@ -58,21 +59,21 @@ public void received(PlayCardMessage msg){
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg) {
logic.addNotification(new ActivePlayerNotification(msg.getColor())); logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor()); logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if (msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant(); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove); logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
for(int i = msg.getTargetIndex() + 1; i < 4; i++){ for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){ if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
pieceToMove.setState(PieceState.HOME); pieceToMove.setState(PieceState.HOME);
break; break;
} }
@@ -84,7 +85,7 @@ public void received(MoveMessage msg){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
logic.getGame().getGameStatistics().increasePiecesThrown(); logic.getGame().getGameStatistics().increasePiecesThrown();
} }
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){ if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true)); logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove); logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
} else { } else {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.determineStartPlayerState; package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates; import pp.mdga.client.gamestate.GameStates;
public abstract class DetermineStartPlayerStates extends GameStates { public abstract class DetermineStartPlayerStates extends GameStates {
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) { public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -0,0 +1,80 @@
package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Player;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.notification.MovePieceNotification;
import java.util.Map;
public class Intro extends DetermineStartPlayerStates{
private final DetermineStartPlayerState parent;
private int animationCounter = 0;
/**
* Constructor for Intro
*
* @param parent the parent state
* @param logic the client game logic
*/
public Intro(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
/**
* This method is used to get the parent state;
*
* @return the parent state
*/
public DetermineStartPlayerState getParent(){
return parent;
}
/**
* This method is used to enter this state and play all necessary intro animations.
*/
@Override
public void enter() {
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
//logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
animationCounter++;
if(entry.getKey() == logic.getOwnPlayerId()){
//logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0)));
} else {
//logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0)));
}
}
}
/**
* This method i s used to exit this state.
*/
@Override
public void exit() {
animationCounter = 0;
}
/**
* This method is used when the view has completed the animation.
*/
@Override
public void selectAnimationEnd(){
animationCounter--;
if(animationCounter != 0){
return;
}
logic.send(new AnimationEndMessage());
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
parent.getParent().setState(parent.getParent().getTurn());
} else {
parent.getParent().setState(parent.getParent().getWaiting());
}
}
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.determineStartPlayerState; package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.DetermineStartPlayerState; import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.message.client.RequestDieMessage; import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.notification.DiceNowNotification; import pp.mdga.notification.DiceNowNotification;
@@ -28,13 +28,12 @@ public void exit() {
@Override @Override
public void selectDice(){ public void selectDice(){
System.out.println("selectDice");
logic.send(new RequestDieMessage()); logic.send(new RequestDieMessage());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
parent.setState(parent.getWaitRanking()); parent.setState(parent.getWaitRanking());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
} }
} }

View File

@@ -1,8 +1,10 @@
package pp.mdga.client.gameState.determineStartPlayerState; package pp.mdga.client.gamestate.determinestartplayerstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.DetermineStartPlayerState; import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage;
import pp.mdga.message.server.RankingResponseMessage; import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage; import pp.mdga.message.server.RankingRollAgainMessage;
import pp.mdga.notification.ActivePlayerNotification; import pp.mdga.notification.ActivePlayerNotification;
@@ -10,6 +12,7 @@
public class WaitRankingState extends DetermineStartPlayerStates { public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent; private final DetermineStartPlayerState parent;
private boolean canTransition = false;
public WaitRankingState(ClientState parent, ClientGameLogic logic) { public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
@@ -18,7 +21,6 @@ public WaitRankingState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
} }
@Override @Override
@@ -33,8 +35,27 @@ public void received(RankingRollAgainMessage msg){
@Override @Override
public void received(RankingResponseMessage msg){ public void received(RankingResponseMessage msg){
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor())); }
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
parent.getParent().setState(parent.getParent().getWaiting());
@Override
public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
changeToIntro();
}
@Override
public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
changeToIntro();
}
private void changeToIntro(){
if (!canTransition){
canTransition = true;
return;
}
parent.setState(parent.getIntro());
} }
} }

View File

@@ -1,9 +1,9 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gameState.turnState.choosePieceState.*; import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification; import pp.mdga.notification.PlayCardNotification;

View File

@@ -1,12 +1,12 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState; import pp.mdga.client.gamestate.turnstate.powercardstate.ChoosePowerCardState;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates; import pp.mdga.client.gamestate.turnstate.powercardstate.PowerCardStates;
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState; import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
import pp.mdga.client.gameState.turnState.powerCardState.SwapState; import pp.mdga.client.gamestate.turnstate.powercardstate.SwapState;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.DiceNowMessage; import pp.mdga.message.server.DiceNowMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.server.DieMessage; import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.NoTurnMessage; import pp.mdga.message.server.NoTurnMessage;
@@ -22,7 +22,7 @@ public void enter() {
@Override @Override
public void exit() { public void exit() {
logic.getGame().setDiceModifier(1); //logic.getGame().setDiceModifier(1);
} }
public TurnState getParent() { public TurnState getParent() {
@@ -30,7 +30,7 @@ public TurnState getParent() {
} }
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye()); // logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece()); parent.setState(parent.getChoosePiece());
} }

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState; package pp.mdga.client.gamestate.turnstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates; import pp.mdga.client.gamestate.GameStates;
public abstract class TurnStates extends GameStates { public abstract class TurnStates extends GameStates {
public TurnStates(ClientState parent, ClientGameLogic logic) { public TurnStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState; package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.TurnStates; import pp.mdga.client.gamestate.turnstate.TurnStates;
public abstract class ChoosePieceStates extends TurnStates { public abstract class ChoosePieceStates extends TurnStates {
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) { public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,12 +1,11 @@
package pp.mdga.client.gameState.turnState.choosePieceState; package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage; import pp.mdga.message.server.StartPieceMessage;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.SelectableMoveNotification; import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.WaitMoveNotification; import pp.mdga.notification.WaitMoveNotification;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState; package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;
@@ -31,24 +31,24 @@ public void exit() {
} }
public void setPossiblePieces(ArrayList<Piece> possiblePieces){ public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
this.possiblePieces = possiblePieces; this.possiblePieces = possiblePieces;
} }
@Override @Override
public void selectPiece(Piece piece){ public void selectPiece(Piece piece) {
if(possiblePieces.contains(piece)){ if (possiblePieces.contains(piece)) {
logic.send(new SelectedPiecesMessage(piece.getUuid())); logic.send(new SelectedPiecesMessage(piece.getUuid()));
} }
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg) {
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier()); Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
if(msg.isHomeMove()){ if (msg.isHomeMove()) {
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex())); logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant(); logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece); logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
} else { } else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) { if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant()); throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState; package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage; import pp.mdga.message.server.MoveMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.choosePieceState; package pp.mdga.client.gamestate.turnstate.choosepiecestate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState; import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.PieceState; import pp.mdga.game.PieceState;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState; package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.message.client.NoPowerCardMessage; import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage; import pp.mdga.message.client.SelectCardMessage;
@@ -39,7 +39,7 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
possibleCards = new ArrayList<>(); possibleCards = new ArrayList<>();
//TODO: logic.send(new RequestPossibleCardsMessage()); System.out.println("ChoosePowerCardState");
} }
/** /**
@@ -80,7 +80,7 @@ public void selectCard(BonusCard card){
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg){
if(msg.getCard().equals(BonusCard.TURBO)){ if(msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier()); //logic.getGame().setDiceModifier(msg.getDiceModifier());
} else { } else {
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo"); LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
} }

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState; package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.TurnStates; import pp.mdga.client.gamestate.turnstate.TurnStates;
public abstract class PowerCardStates extends TurnStates { public abstract class PowerCardStates extends TurnStates {
public PowerCardStates(ClientState parent, ClientGameLogic logic) { public PowerCardStates(ClientState parent, ClientGameLogic logic) {

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState; package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,8 +1,8 @@
package pp.mdga.client.gameState.turnState.powerCardState; package pp.mdga.client.gamestate.turnstate.powercardstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState; package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState; package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState; package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -1,4 +1,4 @@
package pp.mdga.client.settingsState; package pp.mdga.client.settingsstate;
import pp.mdga.client.ClientGameLogic; import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;

View File

@@ -2,31 +2,38 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import java.util.HashMap;
import java.util.Map;
/** /**
* This class will be used to hold all Board relevant data. * This class will be used to hold all Board relevant data.
*/ */
@Serializable @Serializable
public class Board { public class Board {
private Map<Color, PlayerData> playerData = new HashMap<>(); /**
* The size of the board.
*/
public static final int BOARD_SIZE = 40;
/**
* Create Board attributes.
*/
private final Node[] infield; private final Node[] infield;
/** /**
* This constructor is used to create a new board * This constructor is used to create a new board
*/ */
public Board() { public Board() {
infield = new Node[40]; infield = new Node[BOARD_SIZE];
for (int i = 0; i < 40; i++) { initializeBoard();
if (i % 10 == 0) { }
infield[i] = new StartNode(
i == 0 ? Color.AIRFORCE : /**
i == 10 ? Color.CYBER : * Initializes the board by setting up the nodes.
i == 20 ? Color.NAVY : * Start nodes, bonus nodes, and regular nodes are created based on their positions.
Color.ARMY */
); private void initializeBoard() {
} else if (i == 4 || i == 14 || i == 24 || i == 34) { for (int i = 0; i < BOARD_SIZE; i++) {
if (isStartNode(i)) {
infield[i] = createStartNode(i);
} else if (isBonusNode(i)) {
infield[i] = new BonusNode(); infield[i] = new BonusNode();
} else { } else {
infield[i] = new Node(null); infield[i] = new Node(null);
@@ -35,23 +42,48 @@ public Board() {
} }
/** /**
* This method will be used to add the given color and playerData parameters to the playerData attribute of * Checks if the given index is a start node.
* Board class.
* *
* @param color as the color of the player as a Color enumeration. * @param i the index to check
* @param playerData as the playerData of the player as a PlayerData object. * @return true if the index is a start node, false otherwise
*/ */
public void addPlayerData(Color color, PlayerData playerData) { private boolean isStartNode(int i) {
this.playerData.put(color, playerData); return i % 10 == 0;
} }
/** /**
* This method returns the playerData * Checks if the given index is a bonus node.
* *
* @return the playerData * @param i the index to check
* @return true if the index is a bonus node, false otherwise
*/ */
public Map<Color, PlayerData> getPlayerData() { private boolean isBonusNode(int i) {
return playerData; return i % 10 == 4;
}
/**
* Creates a start node with the appropriate color based on the index.
*
* @param i the index of the start node
* @return a new StartNode with the corresponding color
*/
private StartNode createStartNode(int i) {
return new StartNode(Color.getColor(i));
}
/**
* This method returns the index of a specific piece on the board
*
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
} }
/** /**
@@ -73,18 +105,8 @@ public void setPieceOnBoard(int index, Piece piece) {
infield[index].setOccupant(piece); infield[index].setOccupant(piece);
} }
/** @Override
* This method returns the index of a specific piece on the board public String toString() {
* return "Default Board";
* @param piece the piece to be searched for
* @return the index of the piece
*/
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
} }
} }

View File

@@ -7,7 +7,10 @@
*/ */
@Serializable @Serializable
public class BonusNode extends Node { public class BonusNode extends Node {
BonusNode(){ /**
* Constructor.
*/
BonusNode() {
super(null); super(null);
} }
} }

View File

@@ -3,8 +3,8 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
/** /**
* This enumeration will be used to show the four different TSK which can be picked from a player. * This enumeration represents the four different TSK colors that a player can choose.
* In Addition, the NONE color will be used to show a none color. * Additionally, the NONE color indicates the absence of a color.
*/ */
@Serializable @Serializable
public enum Color { public enum Color {
@@ -58,4 +58,19 @@ public Color next() {
return colors[nextIndex]; return colors[nextIndex];
} }
/**
* This method will be used to return the color of the given index.
*
* @param i as the index of the color as an Integer.
* @return a Color enumeration.
*/
public static Color getColor(int i) {
for (Color color : Color.values()) {
if (color.ordinal() == i) {
return color;
}
}
return null;
}
} }

View File

@@ -1,7 +1,5 @@
package pp.mdga.game; package pp.mdga.game;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.random.RandomGenerator; import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory; import java.util.random.RandomGeneratorFactory;

View File

@@ -3,7 +3,7 @@
import java.util.*; import java.util.*;
/** /**
* The Game class represents the game state of the Ludo game. * The Game class represents the game state of the game.
* It contains all the information needed to play the game. * It contains all the information needed to play the game.
* The game state is updated by the game logic. * The game state is updated by the game logic.
*/ */
@@ -14,38 +14,53 @@ public class Game {
public static final int AMOUNT_OF_TURBO_CARDS = 16; public static final int AMOUNT_OF_TURBO_CARDS = 16;
/** /**
* The number of shield and swap cards available in the game. * The number of shield cards available in the game.
*/ */
public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12; public static final int AMOUNT_OF_SHIELD_CARDS = 12;
// The modifier applied to the dice roll. /**
private int diceModifier = 1; * The number of swap cards available in the game.
*/
public static final int AMOUNT_OF_SWAP_CARDS = 12;
// The number of eyes shown on the dice. /**
private int diceEyes; * A map of player IDs to Player objects.
*/
// A map of player IDs to Player objects.
private Map<Integer, Player> players = new HashMap<>(); private Map<Integer, Player> players = new HashMap<>();
// The statistics of the game. /**
* The statistics of the game.
*/
private Statistic gameStatistics; private Statistic gameStatistics;
// The pile of bonus cards available for drawing. /**
private List<BonusCard> drawPile; * The pile of bonus cards available for drawing.
*/
private List<BonusCard> drawPile = new ArrayList<>();
// The pile of bonus cards that have been discarded. /**
* The pile of bonus cards that have been discarded.
*/
private List<BonusCard> discardPile = new ArrayList<>(); private List<BonusCard> discardPile = new ArrayList<>();
// The game board. /**
* The game board.
*/
private Board board; private Board board;
// The die used in the game. /**
* The die used in the game.
*/
private Die die; private Die die;
// The host of this game /**
* The host of this game
*/
private int host = -1; private int host = -1;
// The color of the active player. /**
* The color of the active player.
*/
private Color activeColor; private Color activeColor;
/** /**
@@ -53,18 +68,30 @@ public class Game {
*/ */
public Game() { public Game() {
gameStatistics = new Statistic(); gameStatistics = new Statistic();
drawPile = new ArrayList<>(); initializeDrawPile();
for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) {
drawPile.add(BonusCard.TURBO);
}
for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) {
drawPile.add(BonusCard.SWAP);
drawPile.add(BonusCard.SHIELD);
}
board = new Board(); board = new Board();
die = new Die(); die = new Die();
} }
/**
* This method initializes the draw pile with the predefined number of bonus cards.
*/
private void initializeDrawPile() {
addBonusCards(BonusCard.TURBO, AMOUNT_OF_TURBO_CARDS);
addBonusCards(BonusCard.SWAP, AMOUNT_OF_SWAP_CARDS);
addBonusCards(BonusCard.SHIELD, AMOUNT_OF_SHIELD_CARDS);
}
/**
* This method adds a number of bonus cards to the draw pile.
*
* @param card the card to add
* @param count the number of cards to add
*/
private void addBonusCards(BonusCard card, int count) {
drawPile.addAll(Collections.nCopies(count, card));
}
/** /**
* This method adds a player to the game. * This method adds a player to the game.
* *
@@ -99,7 +126,7 @@ public void updatePlayerActiveState(int id, boolean active) {
* If yes it will return true, otherwise false. * If yes it will return true, otherwise false.
* *
* @param color as the color which should be checked if taken as a Color enumeration. * @param color as the color which should be checked if taken as a Color enumeration.
* @return true or false. * @return true or false.
*/ */
public boolean isColorTaken(Color color) { public boolean isColorTaken(Color color) {
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) { for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
@@ -152,6 +179,15 @@ public Player getPlayerByColor(Color color) {
return null; return null;
} }
/**
* This method will be used to return all connected players as a list.
*
* @return players as a List of Player objects.
*/
public List<Player> getPlayersAsList() {
return new ArrayList<>(this.players.values());
}
/** /**
* This method will be used to return the id of the active player depending on the activeColor attribute of Game * This method will be used to return the id of the active player depending on the activeColor attribute of Game
* class. * class.
@@ -166,7 +202,7 @@ public int getActivePlayerId() {
* This method will be used to return the id of the Player defined by the given color parameter. * This method will be used to return the id of the Player defined by the given color parameter.
* *
* @param color as the color of the player as a Color enumeration. * @param color as the color of the player as a Color enumeration.
* @return the id of the player as an Integer. * @return the id of the player as an Integer.
*/ */
public int getPlayerIdByColor(Color color) { public int getPlayerIdByColor(Color color) {
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) { for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
@@ -216,8 +252,8 @@ public boolean areAllReady() {
* @return the piece specified by the UUID * @return the piece specified by the UUID
*/ */
public Piece getPieceThroughUUID(UUID pieceId) { public Piece getPieceThroughUUID(UUID pieceId) {
for (var playerData : board.getPlayerData().values()) { for (var player : this.getPlayers().values()) {
for (var piece : playerData.getPieces()) { for (var piece : player.getPieces()) {
if (piece.getUuid().equals(pieceId)) { if (piece.getUuid().equals(pieceId)) {
return piece; return piece;
} }
@@ -235,24 +271,6 @@ public boolean isHost() {
return this.host != -1; return this.host != -1;
} }
/**
* This method returns the dice modifier.
*
* @return the dice modifier
*/
public int getDiceModifier() {
return diceModifier;
}
/**
* This method returns the dice eyes.
*
* @return the dice eyes
*/
public int getDiceEyes() {
return diceEyes;
}
/** /**
* This method returns the players. * This method returns the players.
* *
@@ -325,24 +343,6 @@ public int getHost() {
return this.host; return this.host;
} }
/**
* This method sets the dice modifier.
*
* @param diceModifier the new dice modifier
*/
public void setDiceModifier(int diceModifier) {
this.diceModifier = diceModifier;
}
/**
* This method sets the dice eyes.
*
* @param diceEyes the new dice eyes
*/
public void setDiceEyes(int diceEyes) {
this.diceEyes = diceEyes;
}
/** /**
* This method sets the players. * This method sets the players.
* *

View File

@@ -7,6 +7,9 @@
*/ */
@Serializable @Serializable
public class HomeNode extends Node { public class HomeNode extends Node {
/**
* Constructor.
*/
public HomeNode() { public HomeNode() {
super(null); super(null);
} }

View File

@@ -3,22 +3,33 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
/** /**
* This class will be used the represent a Node on which the pieces can travel along * Represents a node on the board.
*/ */
@Serializable @Serializable
public class Node { public class Node {
/**
* The occupant of the node.
*/
protected Piece occupant; protected Piece occupant;
public Node(Piece piece){ /**
* This constructor is used to create a new node object with a given occupant.
*
* @param piece as the occupant of the node.
*/
public Node(Piece piece) {
occupant = piece; occupant = piece;
} }
private Node(){ /**
* This constructor is used to create a new node object with a default occupant.
*/
private Node() {
occupant = new Piece(Color.AIRFORCE, PieceState.WAITING); occupant = new Piece(Color.AIRFORCE, PieceState.WAITING);
} }
/** /**
* This method is used to get an occupant of the Node. * This method is used to get an occupant of the node.
* *
* @return the current occupant of the node * @return the current occupant of the node
*/ */
@@ -27,7 +38,7 @@ public Piece getOccupant() {
} }
/** /**
* This method is used to set a new Occupant * This method is used to set a new occupant
* *
* @param occupant the new occupant of the node * @param occupant the new occupant of the node
*/ */
@@ -58,9 +69,9 @@ public boolean isOccupied() {
* This method will be used to check if the node is occupied by a piece of the given color. * This method will be used to check if the node is occupied by a piece of the given color.
* *
* @param color as the color of the piece as a Color object. * @param color as the color of the piece as a Color object.
* @return true or false. * @return true or false.
*/ */
public boolean isOccupied(Color color) { public boolean isOccupied(Color color) {
return this.occupant != null && this.occupant.getColor() == color; return isOccupied() && this.occupant.getColor() == color;
} }
} }

View File

@@ -51,72 +51,72 @@ private Piece() {
} }
/** /**
* This method is used to get the color of the piece * Sets the shield state of the piece.
* *
* @return the color of the piece * @param shield the new shield state
*/ */
public void setShield(ShieldState shield) { public void setShield(ShieldState shield) {
this.shield = shield; this.shield = shield;
} }
/** /**
* This method is used to get the color of the piece * Gets the shield state of the piece.
* *
* @return the color of the piece * @return the shield state
*/ */
public ShieldState getShield() { public ShieldState getShield() {
return shield; return shield;
} }
/** /**
* This method is used to get the color of the piece * Sets the state of the piece.
* *
* @param state the state of the piece * @param state the new state
*/ */
public void setState(PieceState state) { public void setState(PieceState state) {
this.state = state; this.state = state;
} }
/** /**
* This method is used to get the color of the piece * Gets the state of the piece.
* *
* @return the color of the piece * @return the state
*/ */
public PieceState getState() { public PieceState getState() {
return state; return state;
} }
/** /**
* This method is used to get the color of the piece * Checks if the piece is shielded.
* *
* @return the color of the piece * @return true if the piece is shielded, false otherwise
*/ */
public boolean isShielded() { public boolean isShielded() {
return shield == ShieldState.ACTIVE; return shield == ShieldState.ACTIVE;
} }
/** /**
* This method is used to get the color of the piece * Checks if the shield of a piece is suppressed.
* *
* @return the color of the piece * @return true if the shield is suppressed, false otherwise
*/ */
public boolean isSuppressed() { public boolean isSuppressed() {
return shield == ShieldState.SUPPRESSED; return shield == ShieldState.SUPPRESSED;
} }
/** /**
* This method is used to get the color of the piece * Gets the color of the piece.
* *
* @return the color of the piece * @return the color
*/ */
public Color getColor() { public Color getColor() {
return color; return color;
} }
/** /**
* This method is used to get the color of the piece * Gets the unique identifier of the piece.
* *
* @return the color of the piece * @return the UUID
*/ */
public UUID getUuid() { public UUID getUuid() {
return uuid; return uuid;

View File

@@ -22,5 +22,5 @@ public enum PieceState {
/** /**
* The piece is finished. * The piece is finished.
*/ */
HOMEFINISHED; HOMEFINISHED
} }

View File

@@ -6,7 +6,7 @@
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* This class will be used to handle general PlayerData * This class represents a player in the game.
*/ */
@Serializable @Serializable
public class Player { public class Player {
@@ -44,10 +44,29 @@ public class Player {
* Node and piece attributes * Node and piece attributes
*/ */
private int startNodeIndex = -1; private int startNodeIndex = -1;
/**
* The home nodes of the player.
*/
private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES]; private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES];
/**
* The waiting area of the player.
*/
private Piece[] waitingArea = new Piece[Resources.MAX_PIECES]; private Piece[] waitingArea = new Piece[Resources.MAX_PIECES];
/**
* The pieces of the player.
*/
private Piece[] pieces = new Piece[Resources.MAX_PIECES]; private Piece[] pieces = new Piece[Resources.MAX_PIECES];
/**
* Constructor.
*/
public Player() {
this("");
}
/** /**
* This constructor constructs a new Player object * This constructor constructs a new Player object
* *
@@ -57,13 +76,6 @@ public Player(String name) {
this.name = name; this.name = name;
} }
/**
* Constructor.
*/
public Player() {
this("");
}
/** /**
* This method will be used to initialize all nodes and pieces of the Player class. * This method will be used to initialize all nodes and pieces of the Player class.
*/ */
@@ -73,6 +85,7 @@ public void initialize() {
this.pieces[index] = new Piece(this.color, PieceState.WAITING); this.pieces[index] = new Piece(this.color, PieceState.WAITING);
this.waitingArea[index] = this.pieces[index]; this.waitingArea[index] = this.pieces[index];
} }
startNodeIndex = color.ordinal() * 10;
} }
/** /**
@@ -81,21 +94,16 @@ public void initialize() {
* @param card the card to be added to the players hand * @param card the card to be added to the players hand
*/ */
public void addHandCard(BonusCard card) { public void addHandCard(BonusCard card) {
handCards.add(card); this.handCards.add(card);
} }
/** /**
* This method returns a BonusCard to be removed from the players hand. * This method will be used to remove the given card parameter from the handCards attribute of Player card.
* *
* @param card the cards type to be removed * @param card as the card which should be removed from the handCards attribute as a PowerCard object.
* @return the removed card or null if there is none of that card type
*/ */
public BonusCard removeHandCard(BonusCard card) { public void removeHandCard(BonusCard card) {
BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null); this.handCards.remove(card);
if (cardToRemove != null) {
handCards.remove(cardToRemove);
}
return cardToRemove;
} }
/** /**
@@ -120,7 +128,12 @@ public void addWaitingPiece(Piece piece) {
* @return true or false. * @return true or false.
*/ */
public boolean isFinished() { public boolean isFinished() {
return false; for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (this.pieces[i].getState() != PieceState.HOMEFINISHED) {
return false;
}
}
return true;
} }
/** /**
@@ -248,4 +261,24 @@ public void setReady(boolean ready) {
public void setActive(boolean active) { public void setActive(boolean active) {
this.active = active; this.active = active;
} }
/**
* This method sets a piece at the given index in the home area
*
* @param index the index of the node
* @param piece the piece to be set at the given index
*/
public void setPieceInHome(int index, Piece piece) {
this.homeNodes[index].setOccupant(piece);
}
/**
* The string representation of the player
*
* @return the string representation of the player
*/
@Override
public String toString() {
return "Player: " + name + " Color: " + color;
}
} }

View File

@@ -1,197 +0,0 @@
package pp.mdga.game;
import com.jme3.network.serializing.Serializable;
import pp.mdga.Resources;
/**
* This class is used to represent PlayerData related to the board
*/
@Serializable
public class PlayerData {
/**
* An array of HomeNode objects representing the home nodes of the player.
*/
private HomeNode[] homeNodes;
/**
* The index of the start node for the player.
*/
private int startNodeIndex;
/**
* An array of Piece objects representing the waiting area of the player.
*/
private Piece[] waitingArea;
/**
* An array of Piece objects representing all the pieces of the player.
*/
private Piece[] pieces;
/**
* This constructor is used to create a new PlayerData object
*
* @param color the color of the player
*/
public PlayerData(Color color) {
homeNodes = new HomeNode[Resources.MAX_PIECES];
pieces = new Piece[Resources.MAX_PIECES];
waitingArea = new Piece[Resources.MAX_PIECES];
for (int i = 0; i < Resources.MAX_PIECES; i++) {
homeNodes[i] = new HomeNode();
pieces[i] = new Piece(color, PieceState.WAITING);
waitingArea[i] = pieces[i];
}
}
/**
* Constructor.
*/
private PlayerData() {
homeNodes = new HomeNode[Resources.MAX_PIECES];
waitingArea = new Piece[Resources.MAX_PIECES];
pieces = new Piece[Resources.MAX_PIECES];
}
/**
* This method will be used to check if the player is finished.
* ToDo: Currently return always false. Implement logic!
*
* @return true or false.
*/
public boolean isFinished() {
return false;
}
/**
* This method returns an Array of HomeNodes
*
* @return the array of HomeNodes
*/
public Node[] getHomeNodes() {
return homeNodes;
}
/**
* This method returns the index of the StartNode
*
* @return the index of the StartNode
*/
public int getStartNodeIndex() {
return startNodeIndex;
}
/**
* This method sets the index of the startNode.
*
* @param startNodeIndex the integer index of the startNode
*/
public void setStartNodeIndex(int startNodeIndex) {
this.startNodeIndex = startNodeIndex;
}
/**
* This method returns an array pieces representing the waiting area.
*
* @return the waiting area
*/
public Piece[] getWaitingArea() {
return waitingArea;
}
/**
* This method returns an array of pieces with all the players pieces
*
* @return the array of pieces
*/
public Piece[] getPieces() {
return pieces;
}
/**
* This method adds a piece to the waiting area
*
* @param piece the piece to be added to the waiting area
*/
public void addWaitingPiece(Piece piece) {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (waitingArea[i] == null) {
waitingArea[i] = piece;
return;
}
}
}
/**
* This method removes a piece from the waiting area
*
* @return the piece that was removed from the waiting area
*/
public Piece removePieceFromWaitingArea() {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (waitingArea[i] != null) {
Piece piece = waitingArea[i];
waitingArea[i] = null;
return piece;
}
}
return null;
}
/**
* This method sets a piece at the given index in the home area
*
* @param index the index of the node
* @param piece the piece to be set at the given index
*/
public void setPieceInHome(int index, Piece piece) {
homeNodes[index].setOccupant(piece);
}
/**
* This method will be used to return if the given piece parameter is inside the homNodes attribute of PlayerData
* class.
* If yes it will return true, otherwise false.
*
* @return true or false.
*/
public boolean homeIncludes(Piece piece) {
for (Node node : this.homeNodes) {
if (node.getOccupant() == piece) {
return true;
}
}
return false;
}
/**
* This method will be used to return the index of the given piece parameter in the homeNodes attribute of
* PlayerData class.
*
* @return index as an Integer.
*/
public int getIndexInHome(Piece piece) {
for (int i = 0; i < Resources.MAX_PIECES; i++) {
if (homeNodes[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
/**
* This method will be usd to check if the waitingArea attribute of PlayerData class is empty.
* If yes it will return false, otherwise true.
*
* @return true or false.
*/
public boolean hasPieceInWaitingArea() {
for (Piece piece : waitingArea) {
if (piece != null) {
return true;
}
}
return false;
}
}

View File

@@ -15,5 +15,5 @@ public enum ShieldState {
/** /**
* The shield is suppressed, when the piece is on a start node. * The shield is suppressed, when the piece is on a start node.
*/ */
SUPPRESSED; SUPPRESSED
} }

View File

@@ -22,6 +22,9 @@ public StartNode(Color color) {
this.color = color; this.color = color;
} }
/**
* Default constructor for serialization.
*/
private StartNode() { private StartNode() {
super(null); super(null);
color = Color.NONE; color = Color.NONE;

View File

@@ -68,7 +68,7 @@ public void setCardsPlayed(int cardsPlayed) {
} }
/** /**
* This method returns the count of enemyPieces Thrown during the game. * This method returns the count of enemyPieces thrown during the game.
* *
* @return the count of enemyPieces thrown * @return the count of enemyPieces thrown
*/ */
@@ -77,7 +77,7 @@ public int getPiecesThrown() {
} }
/** /**
* This method sets the new count of enemyPieces Thrown * This method sets the new count of enemyPieces thrown
* *
* @param piecesThrown the new count of pieces thrown. * @param piecesThrown the new count of pieces thrown.
*/ */
@@ -165,28 +165,28 @@ public void increaseCardsPlayed() {
} }
/** /**
* This method increases the value of cardsPlayed by 1. * This method increases the value of piecesThrown by 1.
*/ */
public void increasePiecesThrown() { public void increasePiecesThrown() {
piecesThrown++; piecesThrown++;
} }
/** /**
* This method increases the value of cardsPlayed by 1. * This method increases the value of piecesBeingThrown by 1.
*/ */
public void increasePiecesBeingThrown() { public void increasePiecesBeingThrown() {
piecesBeingThrown++; piecesBeingThrown++;
} }
/** /**
* This method increases the value of cardsPlayed by 1. * This method increases the value of diced6 by 1.
*/ */
public void increaseDiced6() { public void increaseDiced6() {
diced6++; diced6++;
} }
/** /**
* This method increases the value of cardsPlayed by 1. * This method increases the value of traveledNodes by 1.
*/ */
public void increaseTraveledNodes() { public void increaseTraveledNodes() {
traveledNodes++; traveledNodes++;
@@ -202,7 +202,7 @@ public void increaseTraveledNodes(int nodes) {
} }
/** /**
* This method increases the value of cardsPlayed by 1. * This method increases the value of activatedBonusNodes by 1.
*/ */
public void increaseActivatedBonusNodes() { public void increaseActivatedBonusNodes() {
activatedBonusNodes++; activatedBonusNodes++;

View File

@@ -14,16 +14,6 @@ public AnimationEndMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "AnimationEnd{}";
}
/** /**
* Accepts a visitor for processing this message. * Accepts a visitor for processing this message.
* *

View File

@@ -21,17 +21,17 @@ public interface ClientInterpreter {
void received(DeselectTSKMessage msg, int from); void received(DeselectTSKMessage msg, int from);
/** /**
* Processes a received ForceStartGame message. * Processes a received StartGame message.
* *
* @param msg the ForceStartGame message to be processed * @param msg the StartGame message to be processed
* @param from the connection ID from which the message was received * @param from the connection ID from which the message was received
*/ */
void received(StartGameMessage msg, int from); void received(StartGameMessage msg, int from);
/** /**
* Processes a received JoinServer message. * Processes a received JoinedLobby message.
* *
* @param msg the JoinServer message to be processed * @param msg the JoinedLobby message to be processed
* @param from the connection ID from which the message was received * @param from the connection ID from which the message was received
*/ */
void received(JoinedLobbyMessage msg, int from); void received(JoinedLobbyMessage msg, int from);

View File

@@ -21,4 +21,8 @@ protected ClientMessage() {
* @param from the connection ID of the sender * @param from the connection ID of the sender
*/ */
public abstract void accept(ClientInterpreter interpreter, int from); public abstract void accept(ClientInterpreter interpreter, int from);
public String toString() {
return getClass().getSimpleName() + "{}";
}
} }

View File

@@ -8,22 +8,12 @@
@Serializable @Serializable
public class ClientStartGameMessage extends ClientMessage { public class ClientStartGameMessage extends ClientMessage {
/** /**
* Constructs a new ClientStartGame instance. * Constructor.
*/ */
public ClientStartGameMessage() { public ClientStartGameMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -3,24 +3,17 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
/** /**
* * A message sent by a client to indicate that it has disconnected.
*/ */
@Serializable @Serializable
public class DisconnectedMessage extends ClientMessage { public class DisconnectedMessage extends ClientMessage {
/**
* Constructs a new Disconnected message.
*/
public DisconnectedMessage() { public DisconnectedMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ClientStartGame{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public ForceContinueGameMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ForceContinueGame{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -7,7 +7,9 @@
*/ */
@Serializable @Serializable
public class JoinedLobbyMessage extends ClientMessage { public class JoinedLobbyMessage extends ClientMessage {
/**
* The name of the player that is joining the server.
*/
private final String name; private final String name;
/** /**
@@ -42,7 +44,7 @@ public String getName(){
*/ */
@Override @Override
public String toString() { public String toString() {
return "JoinServer{}"; return "JoinServer {" + "name=" + name + '}';
} }
/** /**

View File

@@ -14,16 +14,6 @@ public LeaveGameMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LeaveGame{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public LobbyNotReadyMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyNotReady{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public LobbyReadyMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyReady{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public NoPowerCardMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "NoPowerCard{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public RequestBriefingMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "RequestBriefing{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -14,16 +14,6 @@ public RequestDieMessage() {
super(); super();
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "RequestDie{}";
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -20,12 +20,15 @@ public class RequestPlayCardMessage extends ClientMessage {
*/ */
private final UUID ownPieceIdentifier; private final UUID ownPieceIdentifier;
/**
* The identifier of the enemy piece.
*/
private final UUID enemyPieceIdentifier; private final UUID enemyPieceIdentifier;
/** /**
* Constructs a new RequestPlayCard instance. * Constructs a new RequestPlayCard instance.
* *
* @param card the bonus card to be played * @param card the bonus card to be played
* @param ownPieceIdentifier the identifier of the piece * @param ownPieceIdentifier the identifier of the piece
*/ */
public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enemyPieceIdentifier) { public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
@@ -46,11 +49,11 @@ private RequestPlayCardMessage() {
/** /**
* Creates a new RequestPlayCard instance for a given bonus card. * Creates a new RequestPlayCard instance for a given bonus card.
* *
* @param ownPieceIdentifier the identifier of the piece * @param ownPieceIdentifier the identifier of the piece
* @param enemyPieceIdentifier the identifier of the enemy piece * @param enemyPieceIdentifier the identifier of the enemy piece
* @return a new RequestPlayCard instance * @return a new RequestPlayCard instance
*/ */
public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier){ public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier); return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
} }
@@ -60,7 +63,7 @@ public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UU
* @param ownPieceIdentifier the identifier of the piece * @param ownPieceIdentifier the identifier of the piece
* @return a new RequestPlayCard instance * @return a new RequestPlayCard instance
*/ */
public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier){ public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier) {
return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null); return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null);
} }
@@ -98,7 +101,8 @@ public UUID getEnemyPieceIdentifier() {
*/ */
@Override @Override
public String toString() { public String toString() {
return "RequestPlayCard={card=" + card.toString() + '}'; assert card != null;
return "RequestPlayCard={card=" + card + '}';
} }
/** /**

View File

@@ -29,6 +29,11 @@ private SelectTSKMessage() {
color = null; color = null;
} }
/**
* Gets the color associated with the TSK to be selected.
*
* @return the color associated with the TSK to be selected
*/
public Color getColor() { public Color getColor() {
return color; return color;
} }

View File

@@ -7,39 +7,11 @@
*/ */
@Serializable @Serializable
public class StartGameMessage extends ClientMessage { public class StartGameMessage extends ClientMessage {
/**
private final boolean forceStartGame; * Constructor.
*/
public StartGameMessage(boolean forceStartGame){ public StartGameMessage() {
super(); super();
this.forceStartGame = forceStartGame;
}
/**
* Constructs a new ForceStartGame message.
*/
private StartGameMessage() {
super();
forceStartGame = false;
}
/**
* Gets whether the game should be force started.
*
* @return whether the game should be force started
*/
public boolean isForceStartGame() {
return forceStartGame;
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "ForceStartGame{}";
} }
/** /**

View File

@@ -58,14 +58,4 @@ public void accept(ServerInterpreter interpreter) {
public String toString() { public String toString() {
return "ActivePlayer{color=" + color + '}'; return "ActivePlayer{color=" + color + '}';
} }
/**
* Returns the key for the informational text associated with this message.
*
* @return the key for the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -61,14 +61,4 @@ public void accept(ServerInterpreter interpreter) {
public String toString() { public String toString() {
return "AnyPiece{piece=" + piece + '}'; return "AnyPiece{piece=" + piece + '}';
} }
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -23,24 +23,4 @@ public BriefingMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -23,24 +23,4 @@ public CeremonyMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -23,24 +23,4 @@ public DiceAgainMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -23,24 +23,4 @@ public DiceNowMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -17,7 +17,7 @@ public class DieMessage extends ServerMessage {
/** /**
* Constructor for Dice * Constructor for Dice
* *
* @param diceEye the eye of the dice * @param diceEye the eye of the dice
*/ */
public DieMessage(int diceEye) { public DieMessage(int diceEye) {
super(); super();
@@ -57,16 +57,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "DieMessage{" + "diceEye=" + diceEye + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -23,24 +23,4 @@ public EndOfTurnMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -15,6 +15,7 @@ public class IncorrectRequestMessage extends ServerMessage {
* @param id as the id of the error message as an Integer. * @param id as the id of the error message as an Integer.
*/ */
public IncorrectRequestMessage(int id) { public IncorrectRequestMessage(int id) {
super();
this.id = id; this.id = id;
} }
@@ -22,6 +23,7 @@ public IncorrectRequestMessage(int id) {
* Constructor. * Constructor.
*/ */
public IncorrectRequestMessage() { public IncorrectRequestMessage() {
super();
this.id = 0; this.id = 0;
} }
@@ -35,17 +37,6 @@ public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Gets the bundle key of the informational text to be shown at the client.
* This key is used to retrieve the appropriate localized text for display.
*
* @return the bundle key of the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
/** /**
* This method will be used to return necessary class information in a more readable format. * This method will be used to return necessary class information in a more readable format.
* *

View File

@@ -39,7 +39,6 @@ public int getHost() {
return this.host; return this.host;
} }
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *
@@ -51,22 +50,12 @@ public void accept(ServerInterpreter interpreter) {
} }
/** /**
* Returns a string representation of this message. * This method will be used to return necessary class information in a more readable format.
* *
* @return a string representation of this message * @return information as a String.
*/ */
@Override @Override
public String toString() { public String toString() {
return "Lobby Accept"; return "LobbyAcceptMessage with host: %d".formatted(this.host);
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -23,24 +23,4 @@ public LobbyDenyMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "LobbyDeny";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -42,6 +42,7 @@ public LobbyPlayerJoinedMessage(int id, Player player, boolean host) {
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private LobbyPlayerJoinedMessage() { private LobbyPlayerJoinedMessage() {
super();
player = null; player = null;
id = 0; id = 0;
host = false; host = false;
@@ -61,7 +62,7 @@ public Player getPlayer() {
* *
* @return the id of the player * @return the id of the player
*/ */
public int getId(){ public int getId() {
return id; return id;
} }
@@ -79,23 +80,8 @@ public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override @Override
public String toString() { public String toString() {
return ""; return "LobbyPlayerJoinedMessage{" + "player=" + player + ", id=" + id + ", host=" + host + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -16,7 +16,7 @@ public class LobbyPlayerLeaveMessage extends ServerMessage {
/** /**
* Constructs a new LobbyPlayerLeave instance with the specified player name and color. * Constructs a new LobbyPlayerLeave instance with the specified player name and color.
* *
* @param id the id of the player leaving the lobby. * @param id the id of the player leaving the lobby.
*/ */
public LobbyPlayerLeaveMessage(int id) { public LobbyPlayerLeaveMessage(int id) {
super(); super();
@@ -27,6 +27,7 @@ public LobbyPlayerLeaveMessage(int id) {
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private LobbyPlayerLeaveMessage() { private LobbyPlayerLeaveMessage() {
super();
id = 0; id = 0;
} }
@@ -56,16 +57,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "LobbyPlayerLeaveMessage{" + "id=" + id + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -40,6 +40,7 @@ public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private MoveMessage() { private MoveMessage() {
super();
pieceUUID = null; pieceUUID = null;
targetIndex = 0; targetIndex = 0;
isHomeMove = false; isHomeMove = false;
@@ -59,7 +60,7 @@ public UUID getIdentifier() {
* *
* @return the target index * @return the target index
*/ */
public int getTargetIndex(){ public int getTargetIndex() {
return targetIndex; return targetIndex;
} }
@@ -68,7 +69,7 @@ public int getTargetIndex(){
* *
* @return the boolean isHomeMove. * @return the boolean isHomeMove.
*/ */
public boolean isHomeMove(){ public boolean isHomeMove() {
return isHomeMove; return isHomeMove;
} }
@@ -89,16 +90,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "MoveMessage{" + "pieceUUID=" + pieceUUID + ", targetIndex=" + targetIndex + ", isHomeMove=" + isHomeMove + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -23,24 +23,4 @@ public NoTurnMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -7,7 +7,6 @@
*/ */
@Serializable @Serializable
public class PauseGameMessage extends ServerMessage { public class PauseGameMessage extends ServerMessage {
/** /**
* the id of the player who has disconnected * the id of the player who has disconnected
*/ */
@@ -54,16 +53,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "PauseGameMessage{" + "playerId=" + playerId + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -20,15 +20,21 @@ public class PlayCardMessage extends ServerMessage {
*/ */
private final UUID ownPieceID; private final UUID ownPieceID;
/**
* The identifier of the enemy piece that should be moved.
*/
private final UUID enemyPieceID; private final UUID enemyPieceID;
/**
* The modifier of the dice.
*/
private final int diceModifier; private final int diceModifier;
/** /**
* Constructs a new PlayCard message. * Constructs a new PlayCard message.
* *
* @param card the card that should be played * @param card the card that should be played
* @param ownPieceID the identifier of the piece that should be moved * @param ownPieceID the identifier of the piece that should be moved
* @param enemyPieceID the identifier of the enemy piece that should be moved * @param enemyPieceID the identifier of the enemy piece that should be moved
* @param diceModifier the new modifier of the dice * @param diceModifier the new modifier of the dice
*/ */
@@ -53,7 +59,7 @@ private PlayCardMessage() {
/** /**
* Creates a new PlayCard message for the given card and piece identifier. * Creates a new PlayCard message for the given card and piece identifier.
* *
* @param ownPieceID the identifier of the piece of the player that should be affected * @param ownPieceID the identifier of the piece of the player that should be affected
* @param enemyPieceID the identifier of the enemy piece that should be affected * @param enemyPieceID the identifier of the enemy piece that should be affected
* @return a new PlayCard message * @return a new PlayCard message
*/ */
@@ -77,7 +83,7 @@ public static PlayCardMessage shield(UUID ownPieceID) {
* @param diceModifier the new modifier of the dice * @param diceModifier the new modifier of the dice
* @return newly constructed message * @return newly constructed message
*/ */
public static PlayCardMessage turbo(int diceModifier){ public static PlayCardMessage turbo(int diceModifier) {
return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier); return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier);
} }
@@ -114,7 +120,7 @@ public UUID getPieceIdentifierEnemy() {
* *
* @return the dice modifier as int * @return the dice modifier as int
*/ */
public int getDiceModifier(){ public int getDiceModifier() {
return diceModifier; return diceModifier;
} }
@@ -135,16 +141,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "PlayCardMessage{" + "card=" + card + ", ownPieceID=" + ownPieceID + ", enemyPieceID=" + enemyPieceID + ", diceModifier=" + diceModifier + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -59,16 +59,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "PossibleCardMessage{" + "possibleCards=" + possibleCards + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -33,7 +33,7 @@ public PossiblePieceMessage() {
/** /**
* Swap the possible pieces * Swap the possible pieces
* *
* @param possibleOwnPieces the list of possible own pieces * @param possibleOwnPieces the list of possible own pieces
* @param possibleEnemyPieces the list of possible enemy pieces * @param possibleEnemyPieces the list of possible enemy pieces
* @return the swapped possible pieces * @return the swapped possible pieces
*/ */
@@ -50,7 +50,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOw
* @param possibleOwnPieces the list of possible own pieces * @param possibleOwnPieces the list of possible own pieces
* @return the possible pieces for the shield * @return the possible pieces for the shield
*/ */
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces){ public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces) {
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage(); PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces); possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePieceMessage; return possiblePieceMessage;
@@ -74,14 +74,18 @@ public void addEnemyPossiblePiece(UUID piece) {
this.possibleEnemyPieces.add(piece); this.possibleEnemyPieces.add(piece);
} }
/** Getter for the list of possible pieces /**
* Getter for the list of possible pieces
*
* @return the list of possible pieces * @return the list of possible pieces
*/ */
public List<UUID> getOwnPossiblePieces() { public List<UUID> getOwnPossiblePieces() {
return possibleOwnPieces; return possibleOwnPieces;
} }
/** Getter for the list of possible enemy pieces /**
* Getter for the list of possible enemy pieces
*
* @return the list of possible enemy pieces * @return the list of possible enemy pieces
*/ */
public List<UUID> getEnemyPossiblePieces() { public List<UUID> getEnemyPossiblePieces() {
@@ -105,16 +109,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "PossiblePieceMessage{" + "possibleOwnPieces=" + possibleOwnPieces + ", possibleEnemyPieces=" + possibleEnemyPieces + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -52,16 +52,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "RankingResponseMessage{" + "startingPlayerId=" + startingPlayerId + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -23,24 +23,4 @@ public RankingRollAgainMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -54,16 +54,6 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "ReconnectBriefingMessage{" + "game=" + game + '}';
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
} }
} }

View File

@@ -23,24 +23,4 @@ public ResumeGameMessage() {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String toString() {
return "";
}
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -5,21 +5,35 @@
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
/**
* A message sent by the server to the active player to select a piece to move.
*/
@Serializable @Serializable
public class SelectPieceMessage extends ServerMessage{ public class SelectPieceMessage extends ServerMessage {
/**
* The list of pieces
*/
private final List<UUID> pieces; private final List<UUID> pieces;
/**
* The list of booleans of isHomeMove of the pieces
*/
private final List<Boolean> isHomeMove; private final List<Boolean> isHomeMove;
/**
* The list of indexes of target nodes of the pieces
*/
private final List<Integer> targetIndex; private final List<Integer> targetIndex;
/** /**
* Constructs a new SelectPiece instance. * Constructs a new SelectPiece instance.
* *
* @param pieces the pieces to be selected * @param pieces the pieces to be selected
* @param isHomeMove the List of booleans of isHomeMove of the pieces * @param isHomeMove the List of booleans of isHomeMove of the pieces
* @param targetIndex the List of indexes of target nodes of the pieces * @param targetIndex the List of indexes of target nodes of the pieces
*/ */
public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){ public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex) {
super();
this.pieces = pieces; this.pieces = pieces;
this.isHomeMove = isHomeMove; this.isHomeMove = isHomeMove;
this.targetIndex = targetIndex; this.targetIndex = targetIndex;
@@ -28,7 +42,8 @@ public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Inte
/** /**
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
public SelectPieceMessage(){ public SelectPieceMessage() {
super();
pieces = null; pieces = null;
isHomeMove = null; isHomeMove = null;
targetIndex = null; targetIndex = null;
@@ -39,7 +54,7 @@ public SelectPieceMessage(){
* *
* @return the pieces * @return the pieces
*/ */
public List<UUID> getPieces(){ public List<UUID> getPieces() {
return pieces; return pieces;
} }
@@ -48,7 +63,7 @@ public List<UUID> getPieces(){
* *
* @return List of boolean values * @return List of boolean values
*/ */
public List<Boolean> getIsHomeMove(){ public List<Boolean> getIsHomeMove() {
return isHomeMove; return isHomeMove;
} }
@@ -57,7 +72,7 @@ public List<Boolean> getIsHomeMove(){
* *
* @return List of integers * @return List of integers
*/ */
public List<Integer> getTargetIndex(){ public List<Integer> getTargetIndex() {
return targetIndex; return targetIndex;
} }
@@ -77,7 +92,7 @@ public void accept(ServerInterpreter interpreter) {
* @return a string representation of this message * @return a string representation of this message
*/ */
@Override @Override
public String getInfoTextKey() { public String toString() {
return ""; return "SelectPieceMessage{" + "pieces=" + pieces + ", isHomeMove=" + isHomeMove + ", targetIndex=" + targetIndex + '}';
} }
} }

View File

@@ -36,7 +36,7 @@ public interface ServerInterpreter {
/** /**
* Handles a Die message received from the server. * Handles a Die message received from the server.
* *
* @param msg the Dice message received * @param msg the Die message received
*/ */
void received(DieMessage msg); void received(DieMessage msg);
@@ -55,16 +55,16 @@ public interface ServerInterpreter {
void received(DiceNowMessage msg); void received(DiceNowMessage msg);
/** /**
* Handles an EndOfGame message received from the server. * Handles an EndOfTurn message received from the server.
* *
* @param msg the EndOfGame message received * @param msg the EndOfTurn message received
*/ */
void received(EndOfTurnMessage msg); void received(EndOfTurnMessage msg);
/** /**
* Handles a GameOver message received from the server. * Handles a LobbyAccept message received from the server.
* *
* @param msg the GameOver message received * @param msg the LobbyAccept message received
*/ */
void received(LobbyAcceptMessage msg); void received(LobbyAcceptMessage msg);
@@ -132,9 +132,9 @@ public interface ServerInterpreter {
void received(PossiblePieceMessage msg); void received(PossiblePieceMessage msg);
/** /**
* Handles a RankingResponce message received from the server. * Handles a RankingResponse message received from the server.
* *
* @param msg the RankingResponce message received * @param msg the RankingResponse message received
*/ */
void received(RankingResponseMessage msg); void received(RankingResponseMessage msg);
@@ -209,9 +209,9 @@ public interface ServerInterpreter {
void received(SelectPieceMessage msg); void received(SelectPieceMessage msg);
/** /**
* Handles a SelectTSK message received from the server. * Handles a Shutdown message received from the server.
* *
* @param msg the SelectTSK message received. * @param msg the Shutdown message received.
*/ */
void received(ShutdownMessage msg); void received(ShutdownMessage msg);

View File

@@ -22,10 +22,12 @@ protected ServerMessage() {
public abstract void accept(ServerInterpreter interpreter); public abstract void accept(ServerInterpreter interpreter);
/** /**
* Gets the bundle key of the informational text to be shown at the client. * Returns a string representation of this message.
* This key is used to retrieve the appropriate localized text for display.
* *
* @return the bundle key of the informational text * @return a string representation of this message
*/ */
public abstract String getInfoTextKey(); @Override
public String toString() {
return getClass().getSimpleName() + "{}";
}
} }

View File

@@ -2,6 +2,10 @@
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Board; import pp.mdga.game.Board;
import pp.mdga.game.Player;
import java.util.ArrayList;
import java.util.List;
/** /**
* A message indicating that the game shall start. * A message indicating that the game shall start.
@@ -9,28 +13,45 @@
@Serializable @Serializable
public class ServerStartGameMessage extends ServerMessage { public class ServerStartGameMessage extends ServerMessage {
/** /**
* Create ServerStartGameMessage attributes. * The list of players.
*/
private final List<Player> players;
/**
* The board of the game.
*/ */
private final Board board; private final Board board;
/** /**
* Constructs a new ServerStartGame instance. * Constructor.
*/ */
public ServerStartGameMessage() { public ServerStartGameMessage() {
super(); super();
this.players = new ArrayList<>();
this.board = new Board(); this.board = new Board();
} }
/** /**
* Constructor. * Constructor.
* *
* @param board as the board of the game as a Board object. * @param players as the connected players as a List of Player objects.
* @param board as the board of the game as a Board object.
*/ */
public ServerStartGameMessage(Board board) { public ServerStartGameMessage(List<Player> players, Board board) {
super(); super();
this.players = players;
this.board = board; this.board = board;
} }
/**
* This method will be used to return players attribute of ServerStartGameMessage class.
*
* @return players as a List of Player objects.
*/
public List<Player> getPlayers() {
return this.players;
}
/** /**
* This method will return board attribute of ServerStartGameMessage class. * This method will return board attribute of ServerStartGameMessage class.
* *
@@ -57,16 +78,7 @@ public void accept(ServerInterpreter interpreter) {
*/ */
@Override @Override
public String toString() { public String toString() {
return ""; return "ServerStartGameMessage{" + "players=" + players + ", board=" + board + '}';
} }
/**
* Returns the key for the info text of this message.
*
* @return the key for the info text of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

View File

@@ -7,6 +7,13 @@
*/ */
@Serializable @Serializable
public class ShutdownMessage extends ServerMessage { public class ShutdownMessage extends ServerMessage {
/**
* Constructs a new Shutdown message.
*/
public ShutdownMessage() {
super();
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *
@@ -16,15 +23,4 @@ public class ShutdownMessage extends ServerMessage {
public void accept(ServerInterpreter interpreter) { public void accept(ServerInterpreter interpreter) {
interpreter.received(this); interpreter.received(this);
} }
/**
* Gets the bundle key of the informational text to be shown at the client.
* This key is used to retrieve the appropriate localized text for display.
*
* @return the bundle key of the informational text
*/
@Override
public String getInfoTextKey() {
return "";
}
} }

Some files were not shown because too many files have changed in this diff Show More