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

# Conflicts:
#	Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java
This commit is contained in:
Benjamin Feyer
2024-11-28 18:44:47 +01:00
110 changed files with 1587 additions and 915 deletions

View File

@@ -2,6 +2,7 @@
import pp.mdga.client.view.GameView;
import pp.mdga.client.view.LobbyView;
import pp.mdga.notification.*;
import java.util.ArrayList;

View File

@@ -5,7 +5,7 @@
import pp.mdga.game.Game;
import pp.mdga.game.Player;
import pp.mdga.message.client.*;
import pp.mdga.message.server.ServerMessage;
import pp.mdga.message.server.*;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.ServerSender;
@@ -86,71 +86,71 @@ private void processNextMessage() {
}
private void initializeSerializables() {
Serializer.registerClass(AnimationEnd.class);
Serializer.registerClass(ClientStartGame.class);
Serializer.registerClass(DeselectTSK.class);
Serializer.registerClass(ForceContinueGame.class);
Serializer.registerClass(StartGame.class);
Serializer.registerClass(JoinServer.class);
Serializer.registerClass(LeaveGame.class);
Serializer.registerClass(LobbyNotReady.class);
Serializer.registerClass(LobbyReady.class);
Serializer.registerClass(NoPowerCard.class);
Serializer.registerClass(RequestBriefing.class);
Serializer.registerClass(RequestDie.class);
Serializer.registerClass(RequestMove.class);
Serializer.registerClass(RequestPlayCard.class);
Serializer.registerClass(SelectCard.class);
Serializer.registerClass(SelectedPieces.class);
Serializer.registerClass(SelectTSK.class);
Serializer.registerClass(AnimationEndMessage.class);
Serializer.registerClass(ClientStartGameMessage.class);
Serializer.registerClass(DeselectTSKMessage.class);
Serializer.registerClass(ForceContinueGameMessage.class);
Serializer.registerClass(StartGameMessage.class);
Serializer.registerClass(JoinServerMessage.class);
Serializer.registerClass(LeaveGameMessage.class);
Serializer.registerClass(LobbyNotReadyMessage.class);
Serializer.registerClass(LobbyReadyMessage.class);
Serializer.registerClass(NoPowerCardMessage.class);
Serializer.registerClass(RequestBriefingMessage.class);
Serializer.registerClass(RequestDieMessage.class);
Serializer.registerClass(RequestMoveMessage.class);
Serializer.registerClass(RequestPlayCardMessage.class);
Serializer.registerClass(SelectCardMessage.class);
Serializer.registerClass(SelectedPiecesMessage.class);
Serializer.registerClass(SelectTSKMessage.class);
Serializer.registerClass(ActivePlayer.class);
Serializer.registerClass(AnyPiece.class);
Serializer.registerClass(Briefing.class);
Serializer.registerClass(ActivePlayerMessage.class);
Serializer.registerClass(AnyPieceMessage.class);
Serializer.registerClass(BriefingMessage.class);
Serializer.registerClass(CeremonyMessage.class);
Serializer.registerClass(Dice.class);
Serializer.registerClass(DiceAgain.class);
Serializer.registerClass(DiceNow.class);
Serializer.registerClass(EndOfTurn.class);
Serializer.registerClass(LobbyAccept.class);
Serializer.registerClass(LobbyDeny.class);
Serializer.registerClass(LobbyPlayerJoin.class);
Serializer.registerClass(LobbyPlayerLeave.class);
Serializer.registerClass(DieMessage.class);
Serializer.registerClass(DiceAgainMessage.class);
Serializer.registerClass(DiceNowMessage.class);
Serializer.registerClass(EndOfTurnMessage.class);
Serializer.registerClass(LobbyAcceptMessage.class);
Serializer.registerClass(LobbyDenyMessage.class);
Serializer.registerClass(LobbyPlayerJoinMessage.class);
Serializer.registerClass(LobbyPlayerLeaveMessage.class);
Serializer.registerClass(MoveMessage.class);
Serializer.registerClass(NoTurn.class);
Serializer.registerClass(PauseGame.class);
Serializer.registerClass(PlayCard.class);
Serializer.registerClass(PossibleCard.class);
Serializer.registerClass(PossiblePiece.class);
Serializer.registerClass(RankingResponse.class);
Serializer.registerClass(RankingRollAgain.class);
Serializer.registerClass(ReconnectBriefing.class);
Serializer.registerClass(ResumeGame.class);
Serializer.registerClass(ServerStartGame.class);
Serializer.registerClass(StartPiece.class);
Serializer.registerClass(UpdateReady.class);
Serializer.registerClass(UpdateTSK.class);
Serializer.registerClass(WaitPiece.class);
Serializer.registerClass(NoTurnMessage.class);
Serializer.registerClass(PauseGameMessage.class);
Serializer.registerClass(PlayCardMessage.class);
Serializer.registerClass(PossibleCardMessage.class);
Serializer.registerClass(PossiblePieceMessage.class);
Serializer.registerClass(RankingResponseMessage.class);
Serializer.registerClass(RankingRollAgainMessage.class);
Serializer.registerClass(ReconnectBriefingMessage.class);
Serializer.registerClass(ResumeGameMessage.class);
Serializer.registerClass(ServerStartGameMessage.class);
Serializer.registerClass(StartPieceMessage.class);
Serializer.registerClass(UpdateReadyMessage.class);
Serializer.registerClass(UpdateTSKMessage.class);
Serializer.registerClass(WaitPieceMessage.class);
}
private void registerListeners() {
myServer.addMessageListener(this, AnimationEnd.class);
myServer.addMessageListener(this, ClientStartGame.class);
myServer.addMessageListener(this, DeselectTSK.class);
myServer.addMessageListener(this, ForceContinueGame.class);
myServer.addMessageListener(this, ForceStartGame.class);
myServer.addMessageListener(this, JoinServer.class);
myServer.addMessageListener(this, LeaveGame.class);
myServer.addMessageListener(this, LobbyNotReady.class);
myServer.addMessageListener(this, LobbyReady.class);
myServer.addMessageListener(this, NoPowerCard.class);
myServer.addMessageListener(this, RequestBriefing.class);
myServer.addMessageListener(this, RequestDie.class);
myServer.addMessageListener(this, RequestMove.class);
myServer.addMessageListener(this, RequestPlayCard.class);
myServer.addMessageListener(this, SelectCard.class);
myServer.addMessageListener(this, SelectedPieces.class);
myServer.addMessageListener(this, SelectTSK.class);
myServer.addMessageListener(this, AnimationEndMessage.class);
myServer.addMessageListener(this, ClientStartGameMessage.class);
myServer.addMessageListener(this, DeselectTSKMessage.class);
myServer.addMessageListener(this, ForceContinueGameMessage.class);
myServer.addMessageListener(this, StartGameMessage.class);
myServer.addMessageListener(this, JoinServerMessage.class);
myServer.addMessageListener(this, LeaveGameMessage.class);
myServer.addMessageListener(this, LobbyNotReadyMessage.class);
myServer.addMessageListener(this, LobbyReadyMessage.class);
myServer.addMessageListener(this, NoPowerCardMessage.class);
myServer.addMessageListener(this, RequestBriefingMessage.class);
myServer.addMessageListener(this, RequestDieMessage.class);
myServer.addMessageListener(this, RequestMoveMessage.class);
myServer.addMessageListener(this, RequestPlayCardMessage.class);
myServer.addMessageListener(this, SelectCardMessage.class);
myServer.addMessageListener(this, SelectedPiecesMessage.class);
myServer.addMessageListener(this, SelectTSKMessage.class);
myServer.addConnectionListener(this);
}
@@ -186,7 +186,7 @@ public void connectionRemoved(Server server, HostedConnection hostedConnection)
* @param id as the id of the disconnected player.
*/
public void handleDisconnect(int id) {
this.logic.received(new Disconnected(), id);
this.logic.received(new DisconnectedMessage(), id);
}
public void exit(int exitValue) { //NON-NLS
@@ -223,7 +223,13 @@ public void send(int id, ServerMessage message) {
*/
public void broadcast(ServerMessage message) {
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
this.send(entry.getValue().getId(), message);
this.send(entry.getKey(), message);
}
}
//TODO:
@Override
public void messageReceived(HostedConnection source, Message m) {
}
}

View File

@@ -1,9 +1,9 @@
package pp.mdga.client;
public class Ceremony extends ClientState {
public class CeremonyState extends ClientState {
public Ceremony(ClientState parent, ClientGameLogic logic) {
public CeremonyState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -1,12 +1,14 @@
package pp.mdga.client;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Game;
import pp.mdga.game.Piece;
import pp.mdga.game.PlayerData;
import pp.mdga.message.client.ClientMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.UUID;
@@ -16,18 +18,17 @@ public class ClientGameLogic implements ServerInterpreter {
private Game game;
private final ClientSender clientSender;
private ClientState state;
private Map<UUID, Piece> pieces;
private Map<UUID, BonusCard> cards;
private final ArrayList<Notification> notifications = new ArrayList<>();
private Dialogs dialogs = new Dialogs(null, this);
private GameState gameState = new GameState(null, this);
private Ceremony ceremony = new Ceremony(null, this);
private Interrupt interrupt = new Interrupt(null, this);
private final DialogsState dialogsState = new DialogsState(null, this);
private final GameState gameState = new GameState(null, this);
private final CeremonyState ceremonyState = new CeremonyState(null, this);
private final InterruptState interruptState = new InterruptState(null, this);
public ClientGameLogic(Game game, ClientSender clientSender) {
this.game = game;
this.clientSender = clientSender;
state = dialogs;
state = dialogsState;
}
public void send(ClientMessage msg){
@@ -35,6 +36,17 @@ public void send(ClientMessage msg){
clientSender.send(msg);
}
private Piece getPiece(UUID pieceId){
for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
for(Piece piece : entry.getValue().getPieces()){
if(piece.getUuid().equals(pieceId)){
return piece;
}
}
}
return null;
}
public ClientSender getClientSender(){
return clientSender;
}
@@ -48,17 +60,17 @@ public ClientState getState(){
}
@Override
public void received(ActivePlayer msg) {
public void received(ActivePlayerMessage msg) {
state.received(msg);
}
@Override
public void received(AnyPiece msg) {
public void received(AnyPieceMessage msg) {
state.received(msg);
}
@Override
public void received(Briefing msg) {
public void received(BriefingMessage msg) {
state.received(msg);
}
@@ -68,42 +80,42 @@ public void received(CeremonyMessage msg) {
}
@Override
public void received(Die msg) {
public void received(DieMessage msg) {
state.received(msg);
}
@Override
public void received(DiceAgain msg) {
public void received(DiceAgainMessage msg) {
state.received(msg);
}
@Override
public void received(DiceNow msg) {
public void received(DiceNowMessage msg) {
state.received(msg);
}
@Override
public void received(EndOfTurn msg) {
public void received(EndOfTurnMessage msg) {
state.received(msg);
}
@Override
public void received(LobbyAccept msg) {
public void received(LobbyAcceptMessage msg) {
state.received(msg);
}
@Override
public void received(LobbyDeny msg) {
public void received(LobbyDenyMessage msg) {
state.received(msg);
}
@Override
public void received(LobbyPlayerJoin msg) {
public void received(LobbyPlayerJoinMessage msg) {
state.received(msg);
}
@Override
public void received(LobbyPlayerLeave msg) {
public void received(LobbyPlayerLeaveMessage msg) {
state.received(msg);
}
@@ -113,81 +125,92 @@ public void received(MoveMessage msg) {
}
@Override
public void received(NoTurn msg) {
public void received(NoTurnMessage msg) {
state.received(msg);
}
@Override
public void received(PauseGame msg) {
public void received(PauseGameMessage msg) {
state.received(msg);
}
@Override
public void received(PlayCard msg) {
public void received(PlayCardMessage msg) {
state.received(msg);
}
@Override
public void received(PossibleCard msg) {
public void received(PossibleCardMessage msg) {
state.received(msg);
}
@Override
public void received(PossiblePiece msg) {
public void received(PossiblePieceMessage msg) {
state.received(msg);
}
@Override
public void received(RankingResponse msg) {
public void received(RankingResponseMessage msg) {
state.received(msg);
}
@Override
public void received(RankingRollAgain msg) {
public void received(RankingRollAgainMessage msg) {
state.received(msg);
}
@Override
public void received(ReconnectBriefing msg) {
public void received(ReconnectBriefingMessage msg) {
state.received(msg);
}
@Override
public void received(ResumeGame msg) {
public void received(ResumeGameMessage msg) {
state.received(msg);
}
@Override
public void received(ServerStartGame msg) {
public void received(ServerStartGameMessage msg) {
state.received(msg);
}
@Override
public void received(StartPiece msg) {
public void received(StartPieceMessage msg) {
state.received(msg);
}
@Override
public void received(UpdateReady msg) {
public void received(UpdateReadyMessage msg) {
state.received(msg);
}
@Override
public void received(UpdateTSK msg) {
public void received(UpdateTSKMessage msg) {
state.received(msg);
}
@Override
public void received(WaitPiece msg) {
public void received(WaitPieceMessage msg) {
state.received(msg);
}
@Override
public void received(SpectatorMessage msg) {
state.received(msg);
}
@Override
public void received(SelectPieceMessage msg) {
}
public void selectPiece(UUID pieceId){
state.selectPiece(pieceId);
state.selectPiece(getPiece(pieceId));
}
//TODO: implement
public void selectCard(UUID cardId){
state.selectCard(cardId);
state.selectCard(null);
}
public void selectTsk(Color color){
@@ -206,16 +229,20 @@ public void selectReady(boolean ready){
state.selectReady();
}
public void selectHost(){
state.selectHost();
public void selectHost(String name){
state.selectHost(name);
}
public void selectLeave(){
state.selectLeave();
}
public void selectJoin(){
state.selectJoin();
public void selectJoin(String name){
state.selectJoin(name);
}
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
public void selectStart(){
@@ -224,6 +251,7 @@ public void selectStart(){
public void setState(ClientState state){
this.state.exit();
state.enter();
this.state = state;
}
@@ -231,15 +259,20 @@ public GameState getGameState(){
return gameState;
}
public Ceremony getCeremony(){
return ceremony;
public CeremonyState getCeremony(){
return ceremonyState;
}
public Interrupt getInterrupt(){
return interrupt;
public InterruptState getInterrupt(){
return interruptState;
}
public Dialogs getDialogs(){
return dialogs;
public DialogsState getDialogs(){
return dialogsState;
}
public Notification getNotification(){
return notifications.remove(0);
}
}

View File

@@ -1,10 +1,11 @@
package pp.mdga.client;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import pp.mdga.message.server.*;
import java.lang.System.Logger.Level;
import java.util.UUID;
public abstract class ClientState implements Observer, ServerInterpreter {
protected static final System.Logger LOGGER = System.getLogger(ClientState.class.getName());
@@ -34,17 +35,17 @@ public String toString(){
}
@Override
public void received(ActivePlayer msg) {
public void received(ActivePlayerMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(AnyPiece msg) {
public void received(AnyPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(Briefing msg) {
public void received(BriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@@ -54,42 +55,42 @@ public void received(CeremonyMessage msg) {
}
@Override
public void received(Die msg) {
public void received(DieMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceAgain msg) {
public void received(DiceAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(DiceNow msg) {
public void received(DiceNowMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(EndOfTurn msg) {
public void received(EndOfTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyAccept msg) {
public void received(LobbyAcceptMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyDeny msg) {
public void received(LobbyDenyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerJoin msg) {
public void received(LobbyPlayerJoinMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(LobbyPlayerLeave msg) {
public void received(LobbyPlayerLeaveMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@@ -99,80 +100,90 @@ public void received(MoveMessage msg) {
}
@Override
public void received(NoTurn msg) {
public void received(NoTurnMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PauseGame msg) {
public void received(PauseGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PlayCard msg) {
public void received(PlayCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossibleCard msg) {
public void received(PossibleCardMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(PossiblePiece msg) {
public void received(PossiblePieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingResponse msg) {
public void received(RankingResponseMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(RankingRollAgain msg) {
public void received(RankingRollAgainMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ReconnectBriefing msg) {
public void received(ReconnectBriefingMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ResumeGame msg) {
public void received(ResumeGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(ServerStartGame msg) {
public void received(ServerStartGameMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(StartPiece msg) {
public void received(StartPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateReady msg) {
public void received(UpdateReadyMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(UpdateTSK msg) {
public void received(UpdateTSKMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(WaitPiece msg) {
public void received(SpectatorMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void selectPiece(UUID id) {
@Override
public void received(SelectPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
@Override
public void received(WaitPieceMessage msg) {
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
}
public void selectPiece(Piece piece) {
LOGGER.log(Level.DEBUG, "Selecting piece not allowed.");
}
public void selectCard(UUID id) {
public void selectCard(BonusCard card) {
LOGGER.log(Level.DEBUG, "Selecting card not allowed.");
}
@@ -192,11 +203,11 @@ public void selectReady() {
LOGGER.log(Level.DEBUG, "Selecting ready not allowed.");
}
public void selectHost() {
public void selectHost(String name) {
LOGGER.log(Level.DEBUG, "Selecting host not allowed.");
}
public void selectJoin() {
public void selectJoin(String name) {
LOGGER.log(Level.DEBUG, "Selecting join not allowed.");
}
@@ -215,4 +226,8 @@ public void selectUnready(){
public void selectStart(){
LOGGER.log(Level.DEBUG, "Starting not allowed");
}
public void selectAnimationEnd(){
LOGGER.log(Level.DEBUG, "Animation end not allowed");
}
}

View File

@@ -1,53 +0,0 @@
package pp.mdga.client;
import pp.mdga.client.dialogState.DialogStates;
import pp.mdga.client.dialogState.Lobby;
import pp.mdga.client.dialogState.NetworkDialog;
import pp.mdga.client.dialogState.StartDialog;
public class Dialogs extends ClientState {
private DialogStates currentState;
private final Lobby lobby = new Lobby(this, logic);
private final NetworkDialog networkDialog = new NetworkDialog(this, logic);
private final StartDialog startDialog = new StartDialog(this, logic);
public Dialogs(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void exit(){
currentState.exit();
}
@Override
public void enter(){
currentState = startDialog;
}
public void setState(DialogStates newState){
currentState.exit();
currentState = newState;
currentState.enter();
}
public Lobby getLobby() {
return lobby;
}
public NetworkDialog getNetworkDialog() {
return networkDialog;
}
public StartDialog getStartDialog() {
return startDialog;
}
public void startGame(){
exit();
logic.setState(logic.getGameState());
}
}

View File

@@ -0,0 +1,72 @@
package pp.mdga.client;
import pp.mdga.client.dialogState.DialogStates;
import pp.mdga.client.dialogState.LobbyState;
import pp.mdga.client.dialogState.NetworkDialogState;
import pp.mdga.client.dialogState.StartDialogState;
import pp.mdga.game.Player;
import pp.mdga.message.server.LobbyPlayerJoinMessage;
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
public class DialogsState extends ClientState {
private DialogStates currentState;
private Player ownPlayer;
private final LobbyState lobbyState = new LobbyState(this, logic);
private final NetworkDialogState networkDialogState = new NetworkDialogState(this, logic);
private final StartDialogState startDialogState = new StartDialogState(this, logic);
public DialogsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void exit(){
currentState.exit();
}
@Override
public void enter(){
currentState = startDialogState;
}
public void setState(DialogStates newState){
currentState.exit();
currentState.enter();
currentState = newState;
}
public Player getOwnPlayer() {
return ownPlayer;
}
public LobbyState getLobby() {
return lobbyState;
}
public NetworkDialogState getNetworkDialog() {
return networkDialogState;
}
public StartDialogState getStartDialog() {
return startDialogState;
}
public void startGame(){
exit();
logic.setState(logic.getGameState());
}
@Override
public void received(LobbyPlayerJoinMessage msg){
currentState.received(msg);
}
@Override
public void received(LobbyPlayerLeaveMessage msg){
currentState.received(msg);
}
}

View File

@@ -6,15 +6,15 @@ public class GameState extends ClientState {
private GameStates state;
private Animation animation = new Animation(this, logic);
private DetermineStartPlayer determineStartPlayer = new DetermineStartPlayer(this, logic);
private Spectator spectator = new Spectator(this, logic);
private Turn turn = new Turn(this, logic);
private Waiting waiting = new Waiting(this, logic);
private final AnimationState animationState = new AnimationState(this, logic);
private final DetermineStartPlayerState determineStartPlayerState = new DetermineStartPlayerState(this, logic);
private final SpectatorState spectatorState = new SpectatorState(this, logic);
private final TurnState turnState = new TurnState(this, logic);
private final WaitingState waitingState = new WaitingState(this, logic);
public GameState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
state = determineStartPlayer;
state = determineStartPlayerState;
}
@Override
@@ -26,4 +26,35 @@ public void enter() {
public void exit() {
}
public void setState(GameStates newState){
state.exit();
state.enter();
state = newState;
}
@Override
public void selectAnimationEnd(){
state.selectAnimationEnd();
}
public AnimationState getAnimation() {
return animationState;
}
public DetermineStartPlayerState getDetermineStartPlayer() {
return determineStartPlayerState;
}
public SpectatorState getSpectator() {
return spectatorState;
}
public TurnState getTurn() {
return turnState;
}
public WaitingState getWaiting() {
return waitingState;
}
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client;
public class Settings extends ClientState {
public class InterruptState extends ClientState {
public Settings(ClientState parent, ClientGameLogic logic) {
public InterruptState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -1,8 +1,8 @@
package pp.mdga.client;
public class Interrupt extends ClientState {
public class SettingsState extends ClientState {
public Interrupt(ClientState parent, ClientGameLogic logic) {
public SettingsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Statistics extends CeremonyStates {
public Statistics(ClientState parent, ClientGameLogic logic) {
public class PodiumState extends CeremonyStates {
public PodiumState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Podium extends CeremonyStates {
public Podium(ClientState parent, ClientGameLogic logic) {
public class StatisticsState extends CeremonyStates {
public StatisticsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -1,63 +0,0 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
import pp.mdga.game.Color;
import pp.mdga.message.client.*;
import pp.mdga.message.server.ServerStartGame;
public class Lobby extends DialogStates {
private final Dialogs parent;
public Lobby(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (Dialogs) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
@Override
public void selectTSK(Color color) {
logic.send(new SelectTSK(color));
}
@Override
public void deselectTSK(Color color) {
logic.send(new DeselectTSK(color));
}
@Override
public void selectReady() {
logic.send(new LobbyReady());
}
@Override
public void selectUnready(){
logic.send(new LobbyNotReady());
}
@Override
public void selectStart(){
logic.send(new StartGame());
}
@Override
public void received(ServerStartGame msg){
parent.startGame();
}
}

View File

@@ -0,0 +1,76 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
import pp.mdga.game.Color;
import pp.mdga.game.Player;
import pp.mdga.message.client.*;
import pp.mdga.message.server.LobbyPlayerJoinMessage;
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
import pp.mdga.message.server.ServerStartGameMessage;
public class LobbyState extends DialogStates {
private final DialogsState parent;
public LobbyState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}
@Override
public void selectTSK(Color color) {
logic.send(new SelectTSKMessage(color));
}
@Override
public void deselectTSK(Color color) {
logic.send(new DeselectTSKMessage(color));
}
@Override
public void selectReady() {
logic.send(new LobbyReadyMessage());
}
@Override
public void selectUnready(){
logic.send(new LobbyNotReadyMessage());
}
@Override
public void selectStart(){
logic.send(new StartGameMessage());
}
@Override
public void received(ServerStartGameMessage msg){
parent.startGame();
}
@Override
public void received(LobbyPlayerJoinMessage msg){
logic.getGame().getPlayers().put(msg.getId(), new Player(msg.getName()));
}
@Override
public void received(LobbyPlayerLeaveMessage msg){
logic.getGame().getPlayers().remove(msg.getId());
}
}

View File

@@ -2,15 +2,15 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
import pp.mdga.client.DialogsState;
public class NetworkDialog extends DialogStates {
public class NetworkDialogState extends DialogStates {
private final Dialogs parent;
private final DialogsState parent;
public NetworkDialog(ClientState parent, ClientGameLogic logic) {
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (Dialogs) parent;
this.parent = (DialogsState) parent;
}
private boolean checkIP(String IP){
@@ -49,7 +49,8 @@ public void enter() {
public void exit() {
}
public void selectBack() {
@Override
public void selectLeave() {
parent.setState(parent.getStartDialog());
}

View File

@@ -1,37 +0,0 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.Dialogs;
public class StartDialog extends DialogStates {
private final Dialogs parent;
public StartDialog(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (Dialogs) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
public void selectJoin() {
parent.setState(parent.getNetworkDialog());
}
public void selectHost() {
parent.setState(parent.getLobby());
}
public void selectLeave() {
parent.exit();
}
}

View File

@@ -0,0 +1,39 @@
package pp.mdga.client.dialogState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.DialogsState;
public class StartDialogState extends DialogStates {
private final DialogsState parent;
public StartDialogState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DialogsState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
public void selectJoin(String name) {
parent.getOwnPlayer().setName(name);
parent.setState(parent.getNetworkDialog());
}
public void selectHost(String name) {
parent.getOwnPlayer().setName(name);
parent.setState(parent.getLobby());
}
public void selectLeave() {
parent.exit();
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Animation extends GameStates {
public Animation(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,32 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.message.client.AnimationEndMessage;
public class AnimationState extends GameStates {
private final GameState parent;
public AnimationState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
parent.setState(parent.getWaiting());
}
}

View File

@@ -1,21 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class DetermineStartPlayer extends GameStates {
public DetermineStartPlayer(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,46 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
public class DetermineStartPlayerState extends GameStates {
private final GameState parent;
private DetermineStartPlayerStates state;
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
@Override
public void enter() {
state = rollRankingDiceState;
}
@Override
public void exit() {
state = null;
}
public void setState(DetermineStartPlayerStates state) {
this.state.exit();
state.enter();
this.state = state;
}
public RollRankingDiceState getRollRankingDice() {
return rollRankingDiceState;
}
public WaitRankingState getWaitRanking() {
return waitRankingState;
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Spectator extends GameStates {
public Spectator(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,26 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.message.server.CeremonyMessage;
public class SpectatorState extends GameStates {
public SpectatorState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony());
}
}

View File

@@ -1,21 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Turn extends GameStates {
public Turn(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,92 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.client.gameState.turnState.MovePieceState;
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.client.gameState.turnState.RollDiceState;
import pp.mdga.client.gameState.turnState.TurnStates;
import pp.mdga.message.server.CeremonyMessage;
import pp.mdga.message.server.EndOfTurnMessage;
import pp.mdga.message.server.NoTurnMessage;
import pp.mdga.message.server.SpectatorMessage;
public class TurnState extends GameStates {
private GameState parent;
private TurnStates state;
private final ChoosePieceState choosePieceState = new ChoosePieceState(this, logic);
private final MovePieceState movePieceState = new MovePieceState(this, logic);
private final PlayPowerCardState playPowerCardState = new PlayPowerCardState(this, logic);
private final PowerCardState powerCardState = new PowerCardState(this, logic);
private final RollDiceState rollDiceState = new RollDiceState(this, logic);
public TurnState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
@Override
public void enter() {
state = powerCardState;
}
@Override
public void exit() {
state = null;
}
public void setState(TurnStates state){
this.state.exit();
state.enter();
this.state = state;
}
@Override
public void received(NoTurnMessage msg){
parent.setState(parent.getWaiting());
}
@Override
public void received(EndOfTurnMessage msg){
parent.setState(parent.getWaiting());
}
@Override
public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony());
}
@Override
public void received(SpectatorMessage msg){
parent.setState(parent.getSpectator());
}
public ChoosePieceState getChoosePiece() {
return choosePieceState;
}
public MovePieceState getMovePiece() {
return movePieceState;
}
public PlayPowerCardState getPlayPowerCard() {
return playPowerCardState;
}
public PowerCardState getPowerCard() {
return powerCardState;
}
public RollDiceState getRollDice() {
return rollDiceState;
}
public GameState getParent(){
return parent;
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Waiting extends GameStates {
public Waiting(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,43 @@
package pp.mdga.client.gameState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.GameState;
import pp.mdga.message.server.CeremonyMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.EndOfTurnMessage;
public class WaitingState extends GameStates {
private final GameState parent;
public WaitingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (GameState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(CeremonyMessage msg){
logic.setState(logic.getCeremony());
}
@Override
public void received(DiceNowMessage msg){
parent.setState(parent.getTurn());
}
@Override
public void received(EndOfTurnMessage msg){
parent.setState(parent.getWaiting());
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class RollRankingDice extends DetermineStartPlayerStates {
public RollRankingDice(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,37 @@
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.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
public class RollRankingDiceState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectDice(){
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
parent.setState(parent.getWaitRanking());
}
}

View File

@@ -1,21 +0,0 @@
package pp.mdga.client.gameState.determineStartPlayerState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.GameStates;
public class WaitRanking extends GameStates {
public WaitRanking(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,37 @@
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.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
public class WaitRankingState extends DetermineStartPlayerStates {
private final DetermineStartPlayerState parent;
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (DetermineStartPlayerState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(RankingRollAgainMessage msg){
parent.setState(parent.getRollRankingDice());
}
@Override
public void received(RankingResponseMessage msg){
//TODO: implement
}
}

View File

@@ -0,0 +1,58 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.choosePieceState.*;
public class ChoosePieceState extends TurnStates {
private TurnState parent;
private ChoosePieceStates currentState;
private final NoPieceState noPieceState = new NoPieceState(this, logic);
private final SelectPieceState selectPieceState = new SelectPieceState(this, logic);
private final StartPieceState startPieceState = new StartPieceState(this, logic);
private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic);
public ChoosePieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (TurnState) parent;
}
@Override
public void enter() {
currentState = noPieceState;
}
@Override
public void exit() {
}
public void setState(ChoosePieceStates state){
currentState.exit();
currentState = state;
currentState.enter();
}
public NoPieceState getNoPiece(){
return noPieceState;
}
public SelectPieceState getSelectPiece(){
return selectPieceState;
}
public StartPieceState getStartPiece(){
return startPieceState;
}
public WaitingPieceState getWaitingPiece(){
return waitingPieceState;
}
public TurnState getParent(){
return parent;
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class MovePiece extends TurnStates {
public MovePiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -3,9 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class ChoosePiece extends TurnStates {
public ChoosePiece(ClientState parent, ClientGameLogic logic) {
public class MovePieceState extends TurnStates {
public MovePieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -0,0 +1,32 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.message.server.PlayCardMessage;
public class PlayPowerCardState extends TurnStates {
private final TurnState parent;
private PlayCardMessage playCardMessage;
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (TurnState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
playCardMessage = null;
}
public void setPlayCard(PlayCardMessage playCardMessage) {
this.playCardMessage = playCardMessage;
}
}

View File

@@ -1,21 +0,0 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class PowerCard extends TurnStates {
public PowerCard(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,57 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.TurnState;
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
public class PowerCardState extends TurnStates {
private final TurnState parent;
private PowerCardStates state;
private final ChoosePowerCardState choosePowerCardState = new ChoosePowerCardState(this, logic);
private final ShieldState shieldState = new ShieldState(this, logic);
private final SwapState swapState = new SwapState(this, logic);
public PowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (TurnState) parent;
}
@Override
public void enter() {
state = choosePowerCardState;
}
@Override
public void exit() {
state = null;
}
public void setState(PowerCardStates state) {
this.state.exit();
state.enter();
this.state = state;
}
public ChoosePowerCardState getChoosePowerCard() {
return choosePowerCardState;
}
public ShieldState getShield() {
return shieldState;
}
public SwapState getSwap() {
return swapState;
}
public TurnState getParent() {
return parent;
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class RollDice extends TurnStates {
public RollDice(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class PlayPowerCard extends TurnStates {
public PlayPowerCard(ClientState parent, ClientGameLogic logic) {
public class RollDiceState extends TurnStates {
public RollDiceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class NoPiece extends ChoosePieceStates {
public NoPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,51 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.message.server.*;
import pp.mdga.message.server.StartPieceMessage;
import java.util.ArrayList;
import java.util.stream.Collectors;
public class NoPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
public NoPieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (ChoosePieceState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void received(SelectPieceMessage msg) {
parent.setState(parent.getSelectPiece());
parent.getSelectPiece().setPossiblePieces(msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
}
@Override
public void received(WaitPieceMessage msg){
parent.setState(parent.getWaitingPiece());
}
@Override
public void received(StartPieceMessage msg){
parent.setState(parent.getStartPiece());
}
@Override
public void received(NoTurnMessage msg){
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class SelectPiece extends ChoosePieceStates {
public SelectPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,47 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
import java.util.ArrayList;
public class SelectPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
private ArrayList<Piece> possiblePieces;
public SelectPieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (ChoosePieceState) parent;
}
@Override
public void enter() {
possiblePieces = new ArrayList<>();
}
@Override
public void exit() {
}
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
this.possiblePieces = possiblePieces;
}
@Override
public void selectPiece(Piece piece){
if(possiblePieces.contains(piece)){
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
}
}
@Override
public void received(MoveMessage msg){
parent.getParent().setState(parent.getParent().getMovePiece());
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class StartPiece extends ChoosePieceStates {
public StartPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,42 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
public class StartPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
private Piece moveablePiece;
public StartPieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (ChoosePieceState) parent;
}
@Override
public void enter() {
}
@Override
public void exit() {
}
@Override
public void selectPiece(Piece piece){
if(moveablePiece.equals(piece)){
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
}
}
@Override
public void received(MoveMessage msg){
parent.getParent().setState(parent.getParent().getMovePiece());
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class WaitingPiece extends ChoosePieceStates {
public WaitingPiece(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,40 @@
package pp.mdga.client.gameState.turnState.choosePieceState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.ChoosePieceState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.MoveMessage;
public class WaitingPieceState extends ChoosePieceStates {
private final ChoosePieceState parent;
private Piece moveablePiece;
public WaitingPieceState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (ChoosePieceState) parent;
}
@Override
public void enter() {
moveablePiece = null;
}
@Override
public void exit() {
}
@Override
public void selectPiece(Piece piece){
if(moveablePiece.equals(piece)){
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
}
}
@Override
public void received(MoveMessage msg){
parent.getParent().setState(parent.getParent().getMovePiece());
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class ChoosePowerCard extends PowerCardStates {
public ChoosePowerCard(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,66 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.BonusCard;
import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PossibleCardMessage;
import pp.mdga.message.server.PossiblePieceMessage;
import java.util.ArrayList;
import java.util.stream.Collectors;
public class ChoosePowerCardState extends PowerCardStates {
private final PowerCardState parent;
private ArrayList<BonusCard> possibleCards;
public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (PowerCardState) parent;
}
@Override
public void enter() {
possibleCards = new ArrayList<>();
}
@Override
public void exit() {
possibleCards = null;
}
@Override
public void received(PossibleCardMessage msg){
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
}
@Override
public void selectCard(BonusCard card){
if(card != null){
logic.send(new SelectCardMessage(card));
} else {
logic.send(new NoPowerCardMessage());
}
}
@Override
public void received(DiceNowMessage msg){
parent.getParent().setState(parent.getParent().getRollDice());
}
@Override
public void received(PossiblePieceMessage msg){
if (msg.getEnemyPossiblePieces().isEmpty()){
parent.setState(parent.getShield());
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
} else {
parent.setState(parent.getSwap());
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
}
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Shield extends PowerCardStates {
public Shield(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,52 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;
import java.lang.System.Logger.Level;
import java.util.ArrayList;
public class ShieldState extends PowerCardStates {
private final PowerCardState parent;
private ArrayList<Piece> possiblePieces;
public ShieldState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (PowerCardState) parent;
}
@Override
public void enter() {
possiblePieces = new ArrayList<>();
}
@Override
public void exit() {
possiblePieces = null;
}
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
this.possiblePieces = possiblePieces;
}
public void selectPiece(Piece piece) {
if (possiblePieces.contains(piece)) {
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getIdentifier()));
} else {
LOGGER.log(Level.DEBUG, "Invalid piece selected");
}
}
@Override
public void received(PlayCardMessage msg) {
parent.getParent().setState(parent.getParent().getPlayPowerCard());
parent.getParent().getPlayPowerCard().setPlayCard(msg);
}
}

View File

@@ -1,20 +0,0 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class Swap extends PowerCardStates {
public Swap(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}
@Override
public void enter() {
}
@Override
public void exit() {
}
}

View File

@@ -0,0 +1,63 @@
package pp.mdga.client.gameState.turnState.powerCardState;
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gameState.turnState.PowerCardState;
import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.server.PlayCardMessage;
import java.util.ArrayList;
public class SwapState extends PowerCardStates {
private final PowerCardState parent;
private ArrayList<Piece> possibleOwnPieces;
private ArrayList<Piece> possibleEnemyPieces;
private Piece selectedOwnPiece;
private Piece selectedEnemyPiece;
public SwapState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
this.parent = (PowerCardState) parent;
}
@Override
public void enter() {
possibleOwnPieces = new ArrayList<>();
possibleEnemyPieces = new ArrayList<>();
}
@Override
public void exit() {
possibleOwnPieces = null;
possibleEnemyPieces = null;
}
public void setPossibleOwnPieces(ArrayList<Piece> possibleOwnPieces) {
this.possibleOwnPieces = possibleOwnPieces;
}
public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
this.possibleEnemyPieces = possibleEnemyPieces;
}
@Override
public void selectPiece(Piece piece){
if (possibleOwnPieces.contains(piece)){
selectedOwnPiece = piece;
} else if (possibleEnemyPieces.contains(piece)){
selectedEnemyPiece = piece;
}
if (selectedOwnPiece != null && selectedEnemyPiece != null){
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getIdentifier(), selectedEnemyPiece.getIdentifier()));
}
}
@Override
public void received(PlayCardMessage msg) {
parent.getParent().setState(parent.getParent().getPlayPowerCard());
parent.getParent().getPlayPowerCard().setPlayCard(msg);
}
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class MainSettings extends ClientState {
public MainSettings(ClientState parent, ClientGameLogic logic) {
public class AudioSettingsState extends SettingStates {
public AudioSettingsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class AudioSettings extends SettingStates {
public AudioSettings(ClientState parent, ClientGameLogic logic) {
public class MainSettingsState extends ClientState {
public MainSettingsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -3,8 +3,8 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
public class VideoSettings extends SettingStates {
public VideoSettings(ClientState parent, ClientGameLogic logic) {
public class VideoSettingsState extends SettingStates {
public VideoSettingsState(ClientState parent, ClientGameLogic logic) {
super(parent, logic);
}

View File

@@ -134,12 +134,22 @@ public int getNumberOfActivePlayers() {
return activePlayers;
}
/**
* This method will be used to return a piece based on the identifier.
*
* @return the piece specified by the identifier
*/
public Piece getPieceThroughIdentifier(String identifier){
String[] parts = identifier.split("-");
return board.getPlayerData().get(Color.valueOf(parts[0])).getPieces()[Integer.parseInt(parts[1])];
}
/**
* This method notifies the observers.
*/
public void notifyObservers() {
for (Observer observer : new ArrayList<>(observers)) {
observer.update();
//TODO: observer.update();
}
}

View File

@@ -1,5 +1,7 @@
package pp.mdga.game;
import java.util.UUID;
/**
* This class will be used to hold all Piece relevant data.
*/
@@ -8,6 +10,7 @@ public class Piece {
private PieceState state;
private final Color color;
private final int id;
private final UUID uuid = UUID.randomUUID();
/**
* This constructor is used to create a new Piece
@@ -93,4 +96,13 @@ public Color getColor() {
public String getIdentifier() {
return color.toString() + "-" + id;
}
/**
* This method is used to get the color of the piece
*
* @return the color of the piece
*/
public UUID getUuid() {
return uuid;
}
}

View File

@@ -6,11 +6,11 @@
* A message indicating an animation event is finished in the game.
*/
@Serializable
public class AnimationEnd extends ClientMessage {
public class AnimationEndMessage extends ClientMessage {
/**
* Constructs an AnimationEnd message.
*/
public AnimationEnd() {
public AnimationEndMessage() {
super();
}

View File

@@ -10,7 +10,7 @@ public interface ClientInterpreter {
* @param msg the AnimationEnd message to be processed
* @param from the connection ID from which the message was received
*/
void received(AnimationEnd msg, int from);
void received(AnimationEndMessage msg, int from);
/**
* Processes a received DeselectTSK message.
@@ -18,7 +18,7 @@ public interface ClientInterpreter {
* @param msg the DeselectTSK message to be processed
* @param from the connection ID from which the message was received
*/
void received(DeselectTSK msg, int from);
void received(DeselectTSKMessage msg, int from);
/**
* Processes a received ForceStartGame message.
@@ -26,7 +26,7 @@ public interface ClientInterpreter {
* @param msg the ForceStartGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(StartGame msg, int from);
void received(StartGameMessage msg, int from);
/**
* Processes a received JoinServer message.
@@ -34,7 +34,7 @@ public interface ClientInterpreter {
* @param msg the JoinServer message to be processed
* @param from the connection ID from which the message was received
*/
void received(JoinServer msg, int from);
void received(JoinServerMessage msg, int from);
/**
* Processes a received LeaveGame message.
@@ -42,7 +42,7 @@ public interface ClientInterpreter {
* @param msg the LeaveGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(LeaveGame msg, int from);
void received(LeaveGameMessage msg, int from);
/**
* Processes a received LobbyNotReady message.
@@ -50,7 +50,7 @@ public interface ClientInterpreter {
* @param msg the LobbyNotReady message to be processed
* @param from the connection ID from which the message was received
*/
void received(LobbyNotReady msg, int from);
void received(LobbyNotReadyMessage msg, int from);
/**
* Processes a received LobbyReady message.
@@ -58,7 +58,7 @@ public interface ClientInterpreter {
* @param msg the LobbyReady message to be processed
* @param from the connection ID from which the message was received
*/
void received(LobbyReady msg, int from);
void received(LobbyReadyMessage msg, int from);
/**
* Processes a received Disconnected message.
@@ -66,7 +66,7 @@ public interface ClientInterpreter {
* @param msg the Disconnected message to be processed
* @param from the connection ID from which the message was received
*/
void received(Disconnected msg, int from);
void received(DisconnectedMessage msg, int from);
/**
* Processes a received RequestBriefing message.
@@ -74,7 +74,7 @@ public interface ClientInterpreter {
* @param msg the RequestBriefing message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestBriefing msg, int from);
void received(RequestBriefingMessage msg, int from);
/**
* Processes a received RequestDie message.
@@ -82,7 +82,7 @@ public interface ClientInterpreter {
* @param msg the RequestDie message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestDie msg, int from);
void received(RequestDieMessage msg, int from);
/**
* Processes a received RequestMove message.
@@ -90,7 +90,7 @@ public interface ClientInterpreter {
* @param msg the RequestMove message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestMove msg, int from);
void received(RequestMoveMessage msg, int from);
/**
* Processes a received RequestPlayCard message.
@@ -98,7 +98,7 @@ public interface ClientInterpreter {
* @param msg the RequestPlayCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(RequestPlayCard msg, int from);
void received(RequestPlayCardMessage msg, int from);
/**
* Processes a received SelectCard message.
@@ -106,7 +106,7 @@ public interface ClientInterpreter {
* @param msg the SelectCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectCard msg, int from);
void received(SelectCardMessage msg, int from);
/**
* Processes a received SelectTSK message.
@@ -114,7 +114,7 @@ public interface ClientInterpreter {
* @param msg the SelectTSK message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectTSK msg, int from);
void received(SelectTSKMessage msg, int from);
/**
* Processes a received ForceContinueGame message.
@@ -122,7 +122,7 @@ public interface ClientInterpreter {
* @param msg the ForceContinueGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(ForceContinueGame msg, int from);
void received(ForceContinueGameMessage msg, int from);
/**
* Processes a received ClientStartGame message.
@@ -130,7 +130,7 @@ public interface ClientInterpreter {
* @param msg the ClientStartGame message to be processed
* @param from the connection ID from which the message was received
*/
void received(ClientStartGame msg, int from);
void received(ClientStartGameMessage msg, int from);
/**
* Processes a received NoPowerCard message.
@@ -138,7 +138,7 @@ public interface ClientInterpreter {
* @param msg the NoPowerCard message to be processed
* @param from the connection ID from which the message was received
*/
void received(NoPowerCard msg, int from);
void received(NoPowerCardMessage msg, int from);
/**
* Processes a received SelectedPieces message.
@@ -146,5 +146,5 @@ public interface ClientInterpreter {
* @param msg the SelectedPieces message to be processed
* @param from the connection ID from which the message was received
*/
void received(SelectedPieces msg, int from);
void received(SelectedPiecesMessage msg, int from);
}

View File

@@ -6,11 +6,11 @@
* A message sent by the host to start the game.
*/
@Serializable
public class ClientStartGame extends ClientMessage {
public class ClientStartGameMessage extends ClientMessage {
/**
* Constructs a new ClientStartGame instance.
*/
public ClientStartGame() {
public ClientStartGameMessage() {
super();
}

View File

@@ -7,7 +7,7 @@
* A message sent by a client to deselect a TSK.
*/
@Serializable
public class DeselectTSK extends ClientMessage {
public class DeselectTSKMessage extends ClientMessage {
/**
* The color associated with the TSK to be deselected.
*/
@@ -18,7 +18,7 @@ public class DeselectTSK extends ClientMessage {
*
* @param color the color associated with the TSK to be deselected
*/
public DeselectTSK(Color color) {
public DeselectTSKMessage(Color color) {
super();
this.color = color;
}
@@ -26,7 +26,7 @@ public DeselectTSK(Color color) {
/**
* Default constructor for serialization purposes.
*/
private DeselectTSK() {
private DeselectTSKMessage() {
color = null;
}

View File

@@ -6,8 +6,8 @@
*
*/
@Serializable
public class Disconnected extends ClientMessage {
public Disconnected() {
public class DisconnectedMessage extends ClientMessage {
public DisconnectedMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the host to force the continuation of the game, when the game was interrupted.
*/
@Serializable
public class ForceContinueGame extends ClientMessage {
public class ForceContinueGameMessage extends ClientMessage {
/**
* Constructs a new ForceContinueGame message.
*/
public ForceContinueGame() {
public ForceContinueGameMessage() {
super();
}

View File

@@ -6,14 +6,14 @@
* A message sent by a client when joining the server.
*/
@Serializable
public class JoinServer extends ClientMessage {
public class JoinServerMessage extends ClientMessage {
private final String name;
/**
* Constructs a new JoinServer instance.
*/
public JoinServer(String name) {
public JoinServerMessage(String name) {
super();
this.name = name;
}
@@ -21,7 +21,7 @@ public JoinServer(String name) {
/**
* Constructs a new JoinServer instance.
*/
public JoinServer() {
public JoinServerMessage() {
super();
name = null;
}

View File

@@ -6,11 +6,11 @@
* A message sent by a client to leave the game.
*/
@Serializable
public class LeaveGame extends ClientMessage {
public class LeaveGameMessage extends ClientMessage {
/**
* Constructs a new LeaveGame instance.
*/
public LeaveGame() {
public LeaveGameMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by a client to unready in the lobby.
*/
@Serializable
public class LobbyNotReady extends ClientMessage {
public class LobbyNotReadyMessage extends ClientMessage {
/**
* Constructs a new LobbyNotReady instance.
*/
public LobbyNotReady() {
public LobbyNotReadyMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the client to ready-up in the lobby.
*/
@Serializable
public class LobbyReady extends ClientMessage {
public class LobbyReadyMessage extends ClientMessage {
/**
* Constructs a new LobbyReady instance.
*/
public LobbyReady() {
public LobbyReadyMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by a client to indicate that the player is not using a power card.
*/
@Serializable
public class NoPowerCard extends ClientMessage {
public class NoPowerCardMessage extends ClientMessage {
/**
* Constructs a new NoPowerCard instance.
*/
public NoPowerCard() {
public NoPowerCardMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by a client to request a briefing from the server. (after a reconnect)
*/
@Serializable
public class RequestBriefing extends ClientMessage {
public class RequestBriefingMessage extends ClientMessage {
/**
* Constructs a new RequestBriefing instance.
*/
public RequestBriefing() {
public RequestBriefingMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by a client to request a die roll.
*/
@Serializable
public class RequestDie extends ClientMessage {
public class RequestDieMessage extends ClientMessage {
/**
* Constructs a new RequestDie instance.
*/
public RequestDie() {
public RequestDieMessage() {
super();
}

View File

@@ -6,7 +6,7 @@
* A message sent by a client to request a move for a piece.
*/
@Serializable
public class RequestMove extends ClientMessage {
public class RequestMoveMessage extends ClientMessage {
/**
* The identifier for the piece.
*/
@@ -17,14 +17,14 @@ public class RequestMove extends ClientMessage {
*
* @param pieceIdentifier the piece identifier
*/
public RequestMove(String pieceIdentifier) {
public RequestMoveMessage(String pieceIdentifier) {
this.pieceIdentifier = pieceIdentifier;
}
/**
* Default constructor for serialization purposes.
*/
private RequestMove() {
private RequestMoveMessage() {
pieceIdentifier = null;
}

View File

@@ -7,7 +7,7 @@
* A message sent by a client to request playing a bonus card.
*/
@Serializable
public class RequestPlayCard extends ClientMessage {
public class RequestPlayCardMessage extends ClientMessage {
/**
* The bonus card to be played.
*/
@@ -26,7 +26,7 @@ public class RequestPlayCard extends ClientMessage {
* @param card the bonus card to be played
* @param ownPieceIdentifier the identifier of the piece
*/
public RequestPlayCard(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) {
public RequestPlayCardMessage(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) {
this.ownPieceIdentifier = ownPieceIdentifier;
this.card = card;
this.enemyPieceIdentifier = enemyPieceIdentifier;
@@ -35,7 +35,7 @@ public RequestPlayCard(BonusCard card, String ownPieceIdentifier, String enemyPi
/**
* Default constructor for serialization purposes.
*/
private RequestPlayCard() {
private RequestPlayCardMessage() {
card = null;
ownPieceIdentifier = null;
enemyPieceIdentifier = null;
@@ -48,12 +48,12 @@ private RequestPlayCard() {
* @param enemyPieceIdentifier the identifier of the enemy piece
* @return a new RequestPlayCard instance
*/
public static RequestPlayCard requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){
return new RequestPlayCard(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
public static RequestPlayCardMessage requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){
return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
}
public static RequestPlayCard requestPlayShield(String ownPieceIdentifier){
return new RequestPlayCard(BonusCard.SHIELD, ownPieceIdentifier, null);
public static RequestPlayCardMessage requestPlayShield(String ownPieceIdentifier){
return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null);
}
/**

View File

@@ -7,7 +7,7 @@
* A message sent from the client to the server to select a bonus card.
*/
@Serializable
public class SelectCard extends ClientMessage {
public class SelectCardMessage extends ClientMessage {
/**
* The bonus card to be selected.
*/
@@ -18,14 +18,14 @@ public class SelectCard extends ClientMessage {
*
* @param card the bonus card to be selected
*/
public SelectCard(BonusCard card) {
public SelectCardMessage(BonusCard card) {
this.card = card;
}
/**
* Default constructor for serialization purposes.
*/
private SelectCard() {
private SelectCardMessage() {
card = null;
}

View File

@@ -7,7 +7,7 @@
* A message sent by a client to select a TSK.
*/
@Serializable
public class SelectTSK extends ClientMessage {
public class SelectTSKMessage extends ClientMessage {
/**
* The color associated with the TSK to be selected.
*/
@@ -18,14 +18,14 @@ public class SelectTSK extends ClientMessage {
*
* @param color the color associated with the TSK to be selected
*/
public SelectTSK(Color color) {
public SelectTSKMessage(Color color) {
this.color = color;
}
/**
* Default constructor for serialization purposes.
*/
private SelectTSK() {
private SelectTSKMessage() {
color = null;
}

View File

@@ -6,7 +6,7 @@
* A message sent by a client to indicate that a piece has been selected for a bonus cards.
*/
@Serializable
public class SelectedPieces extends ClientMessage {
public class SelectedPiecesMessage extends ClientMessage {
/**
* The piece identifier.
*/
@@ -17,14 +17,14 @@ public class SelectedPieces extends ClientMessage {
*
* @param pieceIdentifier the piece identifier
*/
public SelectedPieces(String pieceIdentifier) {
public SelectedPiecesMessage(String pieceIdentifier) {
this.pieceIdentifier = pieceIdentifier;
}
/**
* Default constructor for serialization purposes.
*/
private SelectedPieces() {
private SelectedPiecesMessage() {
pieceIdentifier = null;
}

View File

@@ -6,11 +6,11 @@
* A message sent by the host to force start the game when not everyone is ready or not everyone has selected a TSK.
*/
@Serializable
public class StartGame extends ClientMessage {
public class StartGameMessage extends ClientMessage {
private final boolean forceStartGame;
public StartGame(boolean forceStartGame){
public StartGameMessage(boolean forceStartGame){
super();
this.forceStartGame = forceStartGame;
}
@@ -18,7 +18,7 @@ public StartGame(boolean forceStartGame){
/**
* Constructs a new ForceStartGame message.
*/
public StartGame() {
public StartGameMessage() {
super();
forceStartGame = false;
}

View File

@@ -7,7 +7,7 @@
* A message sent by the server to inform the clients about the active player.
*/
@Serializable
public class ActivePlayer extends ServerMessage {
public class ActivePlayerMessage extends ServerMessage {
/**
* The color of the active player.
*/
@@ -18,7 +18,7 @@ public class ActivePlayer extends ServerMessage {
*
* @param color the color of the active player
*/
public ActivePlayer(Color color) {
public ActivePlayerMessage(Color color) {
super();
this.color = color;
}
@@ -26,7 +26,7 @@ public ActivePlayer(Color color) {
/**
* Default constructor for serialization purposes.
*/
private ActivePlayer() {
private ActivePlayerMessage() {
color = null;
}

View File

@@ -9,7 +9,7 @@
* A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board.
*/
@Serializable
public class AnyPiece extends ServerMessage {
public class AnyPieceMessage extends ServerMessage {
/**
* The list of pieces
*/
@@ -18,7 +18,7 @@ public class AnyPiece extends ServerMessage {
/**
* Constructor for AnyPiece
*/
public AnyPiece() {
public AnyPieceMessage() {
super();
piece = new ArrayList<>();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to the reconnected player to provide a briefing about the current game state.
*/
@Serializable
public class Briefing extends ServerMessage {
public class BriefingMessage extends ServerMessage {
/**
* Constructs a new Briefing instance.
*/
public Briefing() {
public BriefingMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to the active player to indicate that they can roll the dice again.
*/
@Serializable
public class DiceAgain extends ServerMessage {
public class DiceAgainMessage extends ServerMessage {
/**
* Constructs a new DiceAgain instance.
*/
public DiceAgain() {
public DiceAgainMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to the active player to enable the dice now button.
*/
@Serializable
public class DiceNow extends ServerMessage {
public class DiceNowMessage extends ServerMessage {
/**
* Constructs a new DiceNow instance.
*/
public DiceNow() {
public DiceNowMessage() {
super();
}

View File

@@ -8,7 +8,7 @@
* A message sent by the server to the client to inform about the dice roll.
*/
@Serializable
public class Die extends ServerMessage {
public class DieMessage extends ServerMessage {
/**
* The eye of the dice
*/
@@ -25,7 +25,7 @@ public class Die extends ServerMessage {
* @param diceEye the eye of the dice
* @param moveablePieces the pieces that can be moved
*/
public Die(int diceEye, List<String> moveablePieces) {
public DieMessage(int diceEye, List<String> moveablePieces) {
super();
this.diceEye = diceEye;
this.moveablePieces = moveablePieces;
@@ -34,7 +34,7 @@ public Die(int diceEye, List<String> moveablePieces) {
/**
* Default constructor for serialization purposes.
*/
private Die() {
private DieMessage() {
diceEye = 0;
moveablePieces = null;
}
@@ -45,8 +45,8 @@ private Die() {
* @param diceEye the eye of the dice
* @return a new Dice object
*/
public static Die inactivePlayer(int diceEye) {
return new Die(diceEye, null);
public static DieMessage inactivePlayer(int diceEye) {
return new DieMessage(diceEye, null);
}
/**
@@ -56,8 +56,8 @@ public static Die inactivePlayer(int diceEye) {
* @param moveablePieces the pieces that can be moved
* @return a new Dice object
*/
public static Die activePlayer(int diceEye, List<String> moveablePieces) {
return new Die(diceEye, moveablePieces);
public static DieMessage activePlayer(int diceEye, List<String> moveablePieces) {
return new DieMessage(diceEye, moveablePieces);
}
/**

View File

@@ -6,11 +6,11 @@
* A message sent by the server to indicate the end of the turn of the active player.
*/
@Serializable
public class EndOfTurn extends ServerMessage {
public class EndOfTurnMessage extends ServerMessage {
/**
* Constructs a new EndOfTurn instance.
*/
public EndOfTurn() {
public EndOfTurnMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to indicate that the client has been accepted into the lobby.
*/
@Serializable
public class LobbyAccept extends ServerMessage {
public class LobbyAcceptMessage extends ServerMessage {
/**
* Constructs a new LobbyAccept instance.
*/
public LobbyAccept() {
public LobbyAcceptMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to deny a client's request to join the lobby.
*/
@Serializable
public class LobbyDeny extends ServerMessage {
public class LobbyDenyMessage extends ServerMessage {
/**
* Constructs a new LobbyDeny instance.
*/
public LobbyDeny() {
public LobbyDenyMessage() {
super();
}

View File

@@ -6,7 +6,7 @@
* A message sent from the server to the client indicating that a player has joined the lobby.
*/
@Serializable
public class LobbyPlayerJoin extends ServerMessage {
public class LobbyPlayerJoinMessage extends ServerMessage {
/**
* The name of the player joining the lobby.
@@ -23,7 +23,7 @@ public class LobbyPlayerJoin extends ServerMessage {
*
* @param name the name of the player joining the lobby
*/
public LobbyPlayerJoin(int id, String name) {
public LobbyPlayerJoinMessage(int id, String name) {
super();
this.name = name;
this.id = id;
@@ -32,7 +32,7 @@ public LobbyPlayerJoin(int id, String name) {
/**
* Default constructor for serialization purposes.
*/
private LobbyPlayerJoin() {
private LobbyPlayerJoinMessage() {
name = null;
id = 0;
}

View File

@@ -7,7 +7,7 @@
* A message sent by the server to indicate that a player has left the lobby.
*/
@Serializable
public class LobbyPlayerLeave extends ServerMessage {
public class LobbyPlayerLeaveMessage extends ServerMessage {
/**
* The name of the player leaving the lobby.
*/
@@ -24,7 +24,7 @@ public class LobbyPlayerLeave extends ServerMessage {
* @param id the id of the player leaving the lobby
* @param color the color associated with the player leaving the lobby
*/
public LobbyPlayerLeave(int id, Color color) {
public LobbyPlayerLeaveMessage(int id, Color color) {
super();
this.id = id;
this.color = color;
@@ -33,7 +33,7 @@ public LobbyPlayerLeave(int id, Color color) {
/**
* Default constructor for serialization purposes.
*/
private LobbyPlayerLeave() {
private LobbyPlayerLeaveMessage() {
id = 0;
color = null;
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to the active player to indicate that he has no valid moves.
*/
@Serializable
public class NoTurn extends ServerMessage {
public class NoTurnMessage extends ServerMessage {
/**
* Constructs a new NoTurn instance.
*/
public NoTurn() {
public NoTurnMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to indicate that the game is paused.
*/
@Serializable
public class PauseGame extends ServerMessage {
public class PauseGameMessage extends ServerMessage {
/**
* Constructs a new PauseGame instance.
*/
public PauseGame() {
public PauseGameMessage() {
super();
}

View File

@@ -7,7 +7,7 @@
* A message sent by the server to the active player to play a card.
*/
@Serializable
public class PlayCard extends ServerMessage {
public class PlayCardMessage extends ServerMessage {
/**
* The card that should be played.
*/
@@ -26,7 +26,7 @@ public class PlayCard extends ServerMessage {
* @param card the card that should be played
* @param pieceIdentifier the identifier of the piece that should be moved
*/
public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) {
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) {
super();
this.card = card;
this.pieceIdentifier = pieceIdentifier;
@@ -36,7 +36,7 @@ public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEn
/**
* Default constructor for serialization purposes.
*/
private PlayCard() {
private PlayCardMessage() {
this.pieceIdentifierEnemy = null;
card = null;
pieceIdentifier = null;
@@ -49,17 +49,8 @@ private PlayCard() {
* @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected
* @return a new PlayCard message
*/
public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) {
return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy);
}
/**
* Creates a new PlayCard message for the given card and piece identifier.
*
* @return a new PlayCard message
*/
public static PlayCard turbo() {
return new PlayCard(BonusCard.TURBO, null, null);
public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) {
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy);
}
/**
@@ -68,8 +59,8 @@ public static PlayCard turbo() {
* @param pieceIdentifier the identifier of the piece of the player that should be affected
* @return a new PlayCard message
*/
public static PlayCard shield(String pieceIdentifier) {
return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null);
public static PlayCardMessage shield(String pieceIdentifier) {
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null);
}
/**

View File

@@ -10,7 +10,7 @@
* A message sent by the server to the client to indicate the possible cards that can be chosen.
*/
@Serializable
public class PossibleCard extends ServerMessage {
public class PossibleCardMessage extends ServerMessage {
/**
* The list of possible cards.
*/
@@ -19,7 +19,7 @@ public class PossibleCard extends ServerMessage {
/**
* Constructor for a PossibleCard instance.
*/
public PossibleCard() {
public PossibleCardMessage() {
super();
possibleCards = new ArrayList<>();
}

View File

@@ -9,7 +9,7 @@
* A message sent by the server to the active player to give all possible pieces to choose from.
*/
@Serializable
public class PossiblePiece extends ServerMessage {
public class PossiblePieceMessage extends ServerMessage {
/**
* The list of possible own pieces
*/
@@ -23,7 +23,7 @@ public class PossiblePiece extends ServerMessage {
/**
* Constructor for PossiblePiece
*/
public PossiblePiece() {
public PossiblePieceMessage() {
super();
possibleOwnPieces = new ArrayList<>();
possibleEnemyPieces = new ArrayList<>();
@@ -36,11 +36,11 @@ public PossiblePiece() {
* @param possibleEnemyPieces the list of possible enemy pieces
* @return the swapped possible pieces
*/
public static PossiblePiece swapPossiblePieces(ArrayList<String> possibleOwnPieces, ArrayList<String> possibleEnemyPieces) {
PossiblePiece possiblePiece = new PossiblePiece();
possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces);
possiblePiece.possibleEnemyPieces.addAll(possibleEnemyPieces);
return possiblePiece;
public static PossiblePieceMessage swapPossiblePieces(ArrayList<String> possibleOwnPieces, ArrayList<String> possibleEnemyPieces) {
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
return possiblePieceMessage;
}
/**
@@ -49,10 +49,10 @@ public static PossiblePiece swapPossiblePieces(ArrayList<String> possibleOwnPiec
* @param possibleOwnPieces the list of possible own pieces
* @return the possible pieces for the shield
*/
public static PossiblePiece shieldPossiblePieces(ArrayList<String> possibleOwnPieces){
PossiblePiece possiblePiece = new PossiblePiece();
possiblePiece.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePiece;
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<String> possibleOwnPieces){
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePieceMessage;
}
/**

View File

@@ -6,11 +6,11 @@
* A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer)
*/
@Serializable
public class RankingResponse extends ServerMessage {
public class RankingResponseMessage extends ServerMessage {
/**
* Constructs a new RankingResponse instance.
*/
public RankingResponse() {
public RankingResponseMessage() {
super();
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to the clients to indicate that the ranking shall be rolled again. (only in DetermineStartPlayer)
*/
@Serializable
public class RankingRollAgain extends ServerMessage {
public class RankingRollAgainMessage extends ServerMessage {
/**
* Constructs a new RankingRollAgain instance.
*/
public RankingRollAgain() {
public RankingRollAgainMessage() {
super();
}

View File

@@ -7,7 +7,7 @@
* A message sent by the server to a client that has reconnected to the game. (give the last saved model)
*/
@Serializable
public class ReconnectBriefing extends ServerMessage {
public class ReconnectBriefingMessage extends ServerMessage {
/**
* The game.
*/
@@ -16,7 +16,7 @@ public class ReconnectBriefing extends ServerMessage {
/**
* Constructs a new ReconnectBriefing message.
*/
public ReconnectBriefing(Game game) {
public ReconnectBriefingMessage(Game game) {
super();
this.game = game;
}
@@ -24,7 +24,7 @@ public ReconnectBriefing(Game game) {
/**
* Default constructor for serialization purposes.
*/
private ReconnectBriefing() {
private ReconnectBriefingMessage() {
this(null);
}

View File

@@ -6,11 +6,11 @@
* A message sent by the server to resume the game.
*/
@Serializable
public class ResumeGame extends ServerMessage {
public class ResumeGameMessage extends ServerMessage {
/**
* Constructs a new ResumeGame instance.
*/
public ResumeGame() {
public ResumeGameMessage() {
super();
}

View File

@@ -0,0 +1,56 @@
package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable;
import java.util.List;
@Serializable
public class SelectPieceMessage extends ServerMessage{
private final List<String> pieces;
/**
* Constructs a new SelectPiece instance.
*
* @param pieces the pieces to be selected
*/
public SelectPieceMessage(List<String> pieces){
this.pieces = pieces;
}
/**
* Default constructor for serialization purposes.
*/
public SelectPieceMessage(){
pieces = null;
}
/**
* Getter for the pieces
*
* @return the pieces
*/
public List<String> getPieces(){
return pieces;
}
/**
* Accepts a visitor to process this message.
*
* @param interpreter the visitor to process this message
*/
@Override
public void accept(ServerInterpreter interpreter) {
}
/**
* Returns a string representation of this message.
*
* @return a string representation of this message
*/
@Override
public String getInfoTextKey() {
return "";
}
}

View File

@@ -10,21 +10,21 @@ public interface ServerInterpreter {
*
* @param msg the ActivePlayer message received
*/
void received(ActivePlayer msg);
void received(ActivePlayerMessage msg);
/**
* Handles an AnyPiece message received from the server.
*
* @param msg the AnyPiece message received
*/
void received(AnyPiece msg);
void received(AnyPieceMessage msg);
/**
* Handles a Briefing message received from the server.
*
* @param msg the Briefing message received
*/
void received(Briefing msg);
void received(BriefingMessage msg);
/**
* Handles a Ceremony message received from the server.
@@ -38,56 +38,56 @@ public interface ServerInterpreter {
*
* @param msg the Dice message received
*/
void received(Die msg);
void received(DieMessage msg);
/**
* Handles a DiceAgain message received from the server.
*
* @param msg the DiceAgain message received
*/
void received(DiceAgain msg);
void received(DiceAgainMessage msg);
/**
* Handles a DiceNow message received from the server.
*
* @param msg the DiceNow message received
*/
void received(DiceNow msg);
void received(DiceNowMessage msg);
/**
* Handles an EndOfGame message received from the server.
*
* @param msg the EndOfGame message received
*/
void received(EndOfTurn msg);
void received(EndOfTurnMessage msg);
/**
* Handles a GameOver message received from the server.
*
* @param msg the GameOver message received
*/
void received(LobbyAccept msg);
void received(LobbyAcceptMessage msg);
/**
* Handles a LobbyDeny message received from the server.
*
* @param msg the LobbyDeny message received
*/
void received(LobbyDeny msg);
void received(LobbyDenyMessage msg);
/**
* Handles a LobbyPlayerJoin message received from the server.
*
* @param msg the LobbyPlayerJoin message received
*/
void received(LobbyPlayerJoin msg);
void received(LobbyPlayerJoinMessage msg);
/**
* Handles a LobbyPlayerLeave message received from the server.
*
* @param msg the LobbyPlayerLeave message received
*/
void received(LobbyPlayerLeave msg);
void received(LobbyPlayerLeaveMessage msg);
/**
* Handles a MoveMessage message received from the server.
@@ -101,103 +101,110 @@ public interface ServerInterpreter {
*
* @param msg the NoTurn message received
*/
void received(NoTurn msg);
void received(NoTurnMessage msg);
/**
* Handles a PauseGame message received from the server.
*
* @param msg the PauseGame message received
*/
void received(PauseGame msg);
void received(PauseGameMessage msg);
/**
* Handles a PlayCard message received from the server.
*
* @param msg the PlayCard message received
*/
void received(PlayCard msg);
void received(PlayCardMessage msg);
/**
* Handles a PossibleCard message received from the server.
*
* @param msg the PossibleCard message received
*/
void received(PossibleCard msg);
void received(PossibleCardMessage msg);
/**
* Handles a PossiblePiece message received from the server.
*
* @param msg the PossiblePiece message received
*/
void received(PossiblePiece msg);
void received(PossiblePieceMessage msg);
/**
* Handles a RankingResponce message received from the server.
*
* @param msg the RankingResponce message received
*/
void received(RankingResponse msg);
void received(RankingResponseMessage msg);
/**
* Handles a RankingRollAgain message received from the server.
*
* @param msg the RankingRollAgain message received
*/
void received(RankingRollAgain msg);
void received(RankingRollAgainMessage msg);
/**
* Handles a ReconnectBriefing message received from the server.
*
* @param msg the ReconnectBriefing message received
*/
void received(ReconnectBriefing msg);
void received(ReconnectBriefingMessage msg);
/**
* Handles a ResumeGame message received from the server.
*
* @param msg the ResumeGame message received
*/
void received(ResumeGame msg);
void received(ResumeGameMessage msg);
/**
* Handles a ServerStartGame message received from the server.
*
* @param msg the ServerStartGame message received
*/
void received(ServerStartGame msg);
void received(ServerStartGameMessage msg);
/**
* Handles a StartPiece message received from the server.
*
* @param msg the StartPiece message received
*/
void received(StartPiece msg);
void received(StartPieceMessage msg);
/**
* Handles a UpdateReady message received from the server.
*
* @param msg the UpdateReady message received
*/
void received(UpdateReady msg);
void received(UpdateReadyMessage msg);
/**
* Handles a UpdateTSK message received from the server.
*
* @param msg the UpdateTSK message received
*/
void received(UpdateTSK msg);
void received(UpdateTSKMessage msg);
/**
* Handles a WaitPiece message received from the server.
*
* @param msg the WaitPiece message received
*/
void received(WaitPiece msg);
void received(WaitPieceMessage msg);
/**
* Handles a Spectator message received from the server.
*
* @param msg the Spectator message received.
*/
void received(Spectator msg);
void received(SpectatorMessage msg);
/**
* Handles a SelectPiece message received from the server.
*
* @param msg the SelectPiece message received.
*/
void received(SelectPieceMessage msg);
}

View File

@@ -6,11 +6,11 @@
* A message indicating that the game shall start.
*/
@Serializable
public class ServerStartGame extends ServerMessage {
public class ServerStartGameMessage extends ServerMessage {
/**
* Constructs a new ServerStartGame instance.
*/
public ServerStartGame() {
public ServerStartGameMessage() {
super();
}

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