Development #35
@@ -144,7 +144,6 @@ private void initializeSerializables() {
|
||||
Serializer.registerClass(Piece.class);
|
||||
Serializer.registerClass(BonusNode.class);
|
||||
Serializer.registerClass(StartNode.class);
|
||||
Serializer.registerClass(PlayerData.class);
|
||||
Serializer.registerClass(HomeNode.class);
|
||||
|
||||
Serializer.registerClass(Color.class, new EnumSerializer());
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.ceremonyState.CeremonyStates;
|
||||
import pp.mdga.client.ceremonyState.PodiumState;
|
||||
import pp.mdga.client.ceremonyState.StatisticsState;
|
||||
import pp.mdga.notification.CeremonyNotification;
|
||||
import pp.mdga.client.ceremonystate.CeremonyStates;
|
||||
import pp.mdga.client.ceremonystate.PodiumState;
|
||||
import pp.mdga.client.ceremonystate.StatisticsState;
|
||||
|
||||
public class CeremonyState extends ClientState {
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
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 pp.mdga.notification.InfoNotification;
|
||||
import pp.mdga.notification.Notification;
|
||||
import pp.mdga.notification.StartDialogNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -52,20 +52,21 @@ public ClientGameLogic(ClientSender clientSender) {
|
||||
*
|
||||
* @param msg the message to be sent
|
||||
*/
|
||||
public void send(ClientMessage msg){
|
||||
public void send(ClientMessage msg) {
|
||||
LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
|
||||
clientSender.send(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get a piece by its id
|
||||
*
|
||||
* @param pieceId the UUID of the piece
|
||||
* @return the piece
|
||||
*/
|
||||
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)){
|
||||
private Piece getPiece(UUID pieceId) {
|
||||
for (var player : this.game.getPlayers().values()) {
|
||||
for (Piece piece : player.getPieces()) {
|
||||
if (piece.getUuid().equals(pieceId)) {
|
||||
return piece;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +79,7 @@ private Piece getPiece(UUID pieceId){
|
||||
*
|
||||
* @return the clientSender
|
||||
*/
|
||||
public ClientSender getClientSender(){
|
||||
public ClientSender getClientSender() {
|
||||
return clientSender;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ public void setOwnPlayerId(int ownPlayerId) {
|
||||
*
|
||||
* @return the game
|
||||
*/
|
||||
public Game getGame(){
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ public Game getGame(){
|
||||
*
|
||||
* @return the current State
|
||||
*/
|
||||
public ClientState getState(){
|
||||
public ClientState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ public ClientState getState(){
|
||||
*
|
||||
* @return if the client is a host
|
||||
*/
|
||||
public boolean isHost(){
|
||||
public boolean isHost() {
|
||||
return isHost;
|
||||
}
|
||||
|
||||
@@ -150,8 +151,8 @@ public boolean isHost(){
|
||||
*
|
||||
* @return the calculated moves as int
|
||||
*/
|
||||
public int getCalculatedMoves(){
|
||||
return game.getDiceEyes() * game.getDiceModifier();
|
||||
public int getCalculatedMoves() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +160,7 @@ public int getCalculatedMoves(){
|
||||
*
|
||||
* @param isHost the boolean value
|
||||
*/
|
||||
public void setHost(boolean isHost){
|
||||
public void setHost(boolean isHost) {
|
||||
this.isHost = isHost;
|
||||
}
|
||||
|
||||
@@ -480,14 +481,14 @@ public void received(SelectPieceMessage msg) {
|
||||
*
|
||||
* @param pieceId the pieceID
|
||||
*/
|
||||
public void selectPiece(UUID pieceId){
|
||||
public void selectPiece(UUID pieceId) {
|
||||
state.selectPiece(getPiece(pieceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method call the method selectNExt of the state
|
||||
*/
|
||||
public void selectNext(){
|
||||
public void selectNext() {
|
||||
state.selectNext();
|
||||
}
|
||||
|
||||
@@ -496,7 +497,7 @@ public void selectNext(){
|
||||
*
|
||||
* @param card the BonusCard to selected
|
||||
*/
|
||||
public void selectCard(BonusCard card){
|
||||
public void selectCard(BonusCard card) {
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@@ -505,7 +506,7 @@ public void selectCard(BonusCard card){
|
||||
*
|
||||
* @param color the Color to be selected
|
||||
*/
|
||||
public void selectTsk(Color color){
|
||||
public void selectTsk(Color color) {
|
||||
state.selectTSK(color);
|
||||
}
|
||||
|
||||
@@ -514,14 +515,14 @@ public void selectTsk(Color color){
|
||||
*
|
||||
* @param color the color to be deselcted
|
||||
*/
|
||||
public void deselectTSK(Color color){
|
||||
public void deselectTSK(Color color) {
|
||||
state.deselectTSK(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the selectDice method of the state
|
||||
*/
|
||||
public void selectDice(){
|
||||
public void selectDice() {
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@@ -530,7 +531,7 @@ public void selectDice(){
|
||||
*
|
||||
* @param name the name to be set
|
||||
*/
|
||||
public void selectName(String name){
|
||||
public void selectName(String name) {
|
||||
state.setName(name);
|
||||
}
|
||||
|
||||
@@ -539,8 +540,8 @@ public void selectName(String name){
|
||||
*
|
||||
* @param ready the value if this method should ready or unready
|
||||
*/
|
||||
public void selectReady(boolean ready){
|
||||
if(ready){
|
||||
public void selectReady(boolean ready) {
|
||||
if (ready) {
|
||||
state.selectReady();
|
||||
} else {
|
||||
state.selectUnready();
|
||||
@@ -552,14 +553,14 @@ public void selectReady(boolean ready){
|
||||
*
|
||||
* @param name the name of the player hosting
|
||||
*/
|
||||
public void selectHost(String name){
|
||||
public void selectHost(String name) {
|
||||
state.selectHost(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the selectLeave method of the state
|
||||
*/
|
||||
public void selectLeave(){
|
||||
public void selectLeave() {
|
||||
state.selectLeave();
|
||||
}
|
||||
|
||||
@@ -568,28 +569,28 @@ public void selectLeave(){
|
||||
*
|
||||
* @param ip the ip to cennect to
|
||||
*/
|
||||
public void selectJoin(String ip){
|
||||
public void selectJoin(String ip) {
|
||||
state.selectJoin(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the selectAnimationEnd method of the state
|
||||
*/
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the selectStart method of the state
|
||||
*/
|
||||
public void selectStart(){
|
||||
public void selectStart() {
|
||||
state.selectStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the selectResume method of the state
|
||||
*/
|
||||
public void selectResume(){
|
||||
public void selectResume() {
|
||||
state.selectResume();
|
||||
}
|
||||
|
||||
@@ -598,7 +599,7 @@ public void selectResume(){
|
||||
*
|
||||
* @param state the new state
|
||||
*/
|
||||
public void setState(ClientState state){
|
||||
public void setState(ClientState state) {
|
||||
this.state.exit();
|
||||
state.enter();
|
||||
this.state = state;
|
||||
@@ -607,7 +608,7 @@ public void setState(ClientState state){
|
||||
/**
|
||||
* This method is used to enter the interrupt state and save the previous state
|
||||
*/
|
||||
public void enterInterrupt(){
|
||||
public void enterInterrupt() {
|
||||
interruptState.enter();
|
||||
interruptState.setPreviousState(state);
|
||||
this.state = interruptState;
|
||||
@@ -618,7 +619,7 @@ public void enterInterrupt(){
|
||||
*
|
||||
* @return the GameState
|
||||
*/
|
||||
public GameState getGameState(){
|
||||
public GameState getGameState() {
|
||||
return gameState;
|
||||
}
|
||||
|
||||
@@ -627,7 +628,7 @@ public GameState getGameState(){
|
||||
*
|
||||
* @return the CeremonyState
|
||||
*/
|
||||
public CeremonyState getCeremony(){
|
||||
public CeremonyState getCeremony() {
|
||||
return ceremonyState;
|
||||
}
|
||||
|
||||
@@ -636,7 +637,7 @@ public CeremonyState getCeremony(){
|
||||
*
|
||||
* @return the InterruptState
|
||||
*/
|
||||
public InterruptState getInterrupt(){
|
||||
public InterruptState getInterrupt() {
|
||||
return interruptState;
|
||||
}
|
||||
|
||||
@@ -645,7 +646,7 @@ public InterruptState getInterrupt(){
|
||||
*
|
||||
* @return the DialogsState
|
||||
*/
|
||||
public DialogsState getDialogs(){
|
||||
public DialogsState getDialogs() {
|
||||
return dialogsState;
|
||||
}
|
||||
|
||||
@@ -654,7 +655,7 @@ public DialogsState getDialogs(){
|
||||
*
|
||||
* @return the SettingsState
|
||||
*/
|
||||
public SettingsState getSettings(){
|
||||
public SettingsState getSettings() {
|
||||
return settingsState;
|
||||
}
|
||||
|
||||
@@ -663,8 +664,8 @@ public SettingsState getSettings(){
|
||||
*
|
||||
* @return the next notification
|
||||
*/
|
||||
public Notification getNotification(){
|
||||
if(!notifications.isEmpty()){
|
||||
public Notification getNotification() {
|
||||
if (!notifications.isEmpty()) {
|
||||
return notifications.remove(0);
|
||||
} else {
|
||||
return null;
|
||||
@@ -676,7 +677,7 @@ public Notification getNotification(){
|
||||
*
|
||||
* @param notification the notification to be added
|
||||
*/
|
||||
public void addNotification(Notification notification){
|
||||
public void addNotification(Notification notification) {
|
||||
notifications.add(notification);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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.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.Color;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.gameState.*;
|
||||
import pp.mdga.client.gamestate.*;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.LeaveGameMessage;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.settingsState.AudioSettingsState;
|
||||
import pp.mdga.client.settingsState.MainSettingsState;
|
||||
import pp.mdga.client.settingsState.SettingStates;
|
||||
import pp.mdga.client.settingsState.VideoSettingsState;
|
||||
import pp.mdga.client.settingsstate.AudioSettingsState;
|
||||
import pp.mdga.client.settingsstate.MainSettingsState;
|
||||
import pp.mdga.client.settingsstate.SettingStates;
|
||||
import pp.mdga.client.settingsstate.VideoSettingsState;
|
||||
|
||||
public class SettingsState extends ClientState {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.ceremonyState;
|
||||
package pp.mdga.client.ceremonystate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.ceremonyState;
|
||||
package pp.mdga.client.ceremonystate;
|
||||
|
||||
import pp.mdga.client.CeremonyState;
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.ceremonyState;
|
||||
package pp.mdga.client.ceremonystate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.dialogState;
|
||||
package pp.mdga.client.dialogstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.dialogState;
|
||||
package pp.mdga.client.dialogstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -6,16 +6,14 @@
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.PlayerData;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
import pp.mdga.message.server.UpdateTSKMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LobbyState extends DialogStates {
|
||||
|
||||
@@ -58,41 +56,46 @@ public void selectReady() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectUnready(){
|
||||
public void selectUnready() {
|
||||
logic.send(new LobbyNotReadyMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
if(logic.isHost() && logic.getGame().areAllReady()){
|
||||
logic.send(new StartGameMessage(false));
|
||||
} else if(logic.isHost() && !logic.getGame().areAllReady()) {
|
||||
logic.send(new StartGameMessage(true));
|
||||
public void selectStart() {
|
||||
if (logic.isHost() && logic.getGame().areAllReady()) {
|
||||
logic.send(new StartGameMessage());
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg){
|
||||
public void received(ServerStartGameMessage msg) {
|
||||
for (Player player: msg.getPlayers()) {
|
||||
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
||||
if (entry.getValue().getColor() == player.getColor()) {
|
||||
this.logic.getGame().getPlayers().put(entry.getKey(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
logic.getGame().setBoard(msg.getBoard());
|
||||
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
|
||||
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
|
||||
for (var player : logic.getGame().getPlayers().values()) {
|
||||
List<UUID> pieces = new ArrayList<>();
|
||||
for (Piece piece : logic.getGame().getBoard().getPlayerData().get(entry.getValue().getColor()).getPieces()) {
|
||||
for (Piece piece : player.getPieces()) {
|
||||
pieces.add(piece.getUuid());
|
||||
}
|
||||
logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName()));
|
||||
logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
|
||||
}
|
||||
logic.setState(logic.getGameState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
if(msg.getPlayer().getName().equals(logic.getOwnPlayerName())){
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
|
||||
logic.setOwnPlayerId(msg.getId());
|
||||
}
|
||||
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()){
|
||||
if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
|
||||
logic.setHost(true);
|
||||
}
|
||||
|
||||
@@ -101,9 +104,9 @@ public void received(LobbyPlayerJoinedMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateTSKMessage msg){
|
||||
if(msg.isTaken()) {
|
||||
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId()== msg.getId()));
|
||||
public void received(UpdateTSKMessage msg) {
|
||||
if (msg.isTaken()) {
|
||||
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
|
||||
} else {
|
||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||
}
|
||||
@@ -112,13 +115,13 @@ public void received(UpdateTSKMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerLeaveMessage msg){
|
||||
public void received(LobbyPlayerLeaveMessage msg) {
|
||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||
logic.getGame().getPlayers().remove(msg.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateReadyMessage msg){
|
||||
public void received(UpdateReadyMessage msg) {
|
||||
//TODO server sendet kein update on UNready
|
||||
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
||||
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.dialogState;
|
||||
package pp.mdga.client.dialogstate;
|
||||
|
||||
import pp.mdga.Resources;
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.dialogState;
|
||||
package pp.mdga.client.dialogstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.gameState;
|
||||
package pp.mdga.client.gamestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,11 +1,14 @@
|
||||
package pp.mdga.client.gameState;
|
||||
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;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.ActivePlayerMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||
@@ -17,12 +20,33 @@ public class DetermineStartPlayerState extends GameStates {
|
||||
|
||||
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
||||
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
||||
private final Intro intro = new Intro(this, logic);
|
||||
|
||||
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (GameState) parent;
|
||||
}
|
||||
|
||||
public RollRankingDiceState getRollRankingDice() {
|
||||
return rollRankingDiceState;
|
||||
}
|
||||
|
||||
public WaitRankingState getWaitRanking() {
|
||||
return waitRankingState;
|
||||
}
|
||||
|
||||
public DetermineStartPlayerStates getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public Intro getIntro(){
|
||||
return intro;
|
||||
}
|
||||
|
||||
public GameState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
this.setState(this.rollRankingDiceState);
|
||||
@@ -46,6 +70,11 @@ public void selectDice() {
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
state.received(msg);
|
||||
@@ -61,19 +90,8 @@ public void received(RankingResponseMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public RollRankingDiceState getRollRankingDice() {
|
||||
return rollRankingDiceState;
|
||||
}
|
||||
|
||||
public WaitRankingState getWaitRanking() {
|
||||
return waitRankingState;
|
||||
}
|
||||
|
||||
public DetermineStartPlayerStates getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public GameState getParent() {
|
||||
return parent;
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.gameState;
|
||||
package pp.mdga.client.gamestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -17,10 +17,10 @@ public GameStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
protected void handlePowerCard(PlayCardMessage msg){
|
||||
if (msg.getCard().equals(BonusCard.TURBO)){
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else if (msg.getCard().equals(BonusCard.SHIELD)){
|
||||
protected void handlePowerCard(PlayCardMessage msg) {
|
||||
if (msg.getCard().equals(BonusCard.TURBO)) {
|
||||
//logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else if (msg.getCard().equals(BonusCard.SHIELD)) {
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
@@ -36,12 +36,12 @@ protected void handlePowerCard(PlayCardMessage msg){
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
||||
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
|
||||
}
|
||||
logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard()));
|
||||
logic.getGame().getDiscardPile().add(msg.getCard());
|
||||
}
|
||||
|
||||
protected void throwPiece(Piece piece){
|
||||
protected void throwPiece(Piece piece) {
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
|
||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||
@@ -1,11 +1,14 @@
|
||||
package pp.mdga.client.gameState;
|
||||
package pp.mdga.client.gamestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
import pp.mdga.notification.ActivePlayerNotification;
|
||||
import pp.mdga.notification.HomeMoveNotification;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
|
||||
public class SpectatorState extends GameStates {
|
||||
|
||||
@@ -27,15 +30,15 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
public void received(CeremonyMessage msg) {
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
public void received(DieMessage msg) {
|
||||
//logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
||||
if(msg.getDiceEye() == 6){
|
||||
if (msg.getDiceEye() == 6) {
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||
logic.getGame().getGameStatistics().increaseDiced6();
|
||||
}
|
||||
@@ -43,7 +46,7 @@ public void received(DieMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
public void received(PlayCardMessage msg) {
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
@@ -52,26 +55,26 @@ public void received(PlayCardMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||
logic.getGame().setActiveColor(msg.getColor());
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if (msg.isHomeMove()){
|
||||
if (msg.isHomeMove()) {
|
||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||
} else {
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
||||
}
|
||||
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
||||
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
} else {
|
||||
@@ -1,14 +1,14 @@
|
||||
package pp.mdga.client.gameState;
|
||||
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.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.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
@@ -1,9 +1,10 @@
|
||||
package pp.mdga.client.gameState;
|
||||
package pp.mdga.client.gamestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
@@ -27,21 +28,21 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
public void received(CeremonyMessage msg) {
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
logic.addNotification(new DiceNowNotification());
|
||||
parent.setState(parent.getTurn());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
public void received(DieMessage msg) {
|
||||
// logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
||||
if(msg.getDiceEye() == 6){
|
||||
if (msg.getDiceEye() == 6) {
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||
logic.getGame().getGameStatistics().increaseDiced6();
|
||||
}
|
||||
@@ -49,7 +50,7 @@ public void received(DieMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
public void received(PlayCardMessage msg) {
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
@@ -58,21 +59,21 @@ public void received(PlayCardMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||
logic.getGame().setActiveColor(msg.getColor());
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if (msg.isHomeMove()){
|
||||
if (msg.isHomeMove()) {
|
||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
|
||||
logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
|
||||
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
|
||||
logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
|
||||
for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
|
||||
if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
|
||||
pieceToMove.setState(PieceState.HOME);
|
||||
break;
|
||||
}
|
||||
@@ -84,7 +85,7 @@ public void received(MoveMessage msg){
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
|
||||
logic.getGame().getGameStatistics().increasePiecesThrown();
|
||||
}
|
||||
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
||||
if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
} else {
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.GameStates;
|
||||
import pp.mdga.client.gamestate.GameStates;
|
||||
|
||||
public abstract class DetermineStartPlayerStates extends GameStates {
|
||||
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
||||
@@ -0,0 +1,80 @@
|
||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Intro extends DetermineStartPlayerStates{
|
||||
|
||||
private final DetermineStartPlayerState parent;
|
||||
|
||||
private int animationCounter = 0;
|
||||
|
||||
/**
|
||||
* Constructor for Intro
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the client game logic
|
||||
*/
|
||||
public Intro(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (DetermineStartPlayerState) parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the parent state;
|
||||
*
|
||||
* @return the parent state
|
||||
*/
|
||||
public DetermineStartPlayerState getParent(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to enter this state and play all necessary intro animations.
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
|
||||
//logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
|
||||
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
|
||||
animationCounter++;
|
||||
if(entry.getKey() == logic.getOwnPlayerId()){
|
||||
//logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0)));
|
||||
} else {
|
||||
//logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method i s used to exit this state.
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
animationCounter = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used when the view has completed the animation.
|
||||
*/
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
animationCounter--;
|
||||
if(animationCounter != 0){
|
||||
return;
|
||||
}
|
||||
logic.send(new AnimationEndMessage());
|
||||
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
||||
parent.getParent().setState(parent.getParent().getTurn());
|
||||
} else {
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.notification.DiceNowNotification;
|
||||
@@ -28,13 +28,12 @@ public void exit() {
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
System.out.println("selectDice");
|
||||
logic.send(new RequestDieMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
|
||||
parent.setState(parent.getWaitRanking());
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package pp.mdga.client.gameState.determineStartPlayerState;
|
||||
package pp.mdga.client.gamestate.determinestartplayerstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.ActivePlayerMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||
import pp.mdga.notification.ActivePlayerNotification;
|
||||
@@ -10,6 +12,7 @@
|
||||
public class WaitRankingState extends DetermineStartPlayerStates {
|
||||
|
||||
private final DetermineStartPlayerState parent;
|
||||
private boolean canTransition = false;
|
||||
|
||||
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -18,7 +21,6 @@ public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,8 +35,27 @@ public void received(RankingRollAgainMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
|
||||
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
logic.send(new AnimationEndMessage());
|
||||
changeToIntro();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||
logic.getGame().setActiveColor(msg.getColor());
|
||||
changeToIntro();
|
||||
}
|
||||
|
||||
private void changeToIntro(){
|
||||
if (!canTransition){
|
||||
canTransition = true;
|
||||
return;
|
||||
}
|
||||
parent.setState(parent.getIntro());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.client.gameState.turnState.choosePieceState.*;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
@@ -1,12 +1,12 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.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;
|
||||
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;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.NoTurnMessage;
|
||||
|
||||
@@ -22,7 +22,7 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
logic.getGame().setDiceModifier(1);
|
||||
//logic.getGame().setDiceModifier(1);
|
||||
}
|
||||
|
||||
public TurnState getParent() {
|
||||
@@ -30,7 +30,7 @@ public TurnState getParent() {
|
||||
}
|
||||
|
||||
public void received(DieMessage msg){
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
// logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
parent.setState(parent.getChoosePiece());
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState;
|
||||
package pp.mdga.client.gamestate.turnstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.GameStates;
|
||||
import pp.mdga.client.gamestate.GameStates;
|
||||
|
||||
public abstract class TurnStates extends GameStates {
|
||||
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||
|
||||
public abstract class ChoosePieceStates extends TurnStates {
|
||||
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
||||
@@ -1,12 +1,11 @@
|
||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.message.server.StartPieceMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.SelectableMoveNotification;
|
||||
import pp.mdga.notification.WaitMoveNotification;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
@@ -31,24 +31,24 @@ public void exit() {
|
||||
|
||||
}
|
||||
|
||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces){
|
||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||
this.possiblePieces = possiblePieces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(possiblePieces.contains(piece)){
|
||||
public void selectPiece(Piece piece) {
|
||||
if (possiblePieces.contains(piece)) {
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if(msg.isHomeMove()){
|
||||
if (msg.isHomeMove()) {
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||
} else {
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.choosePieceState;
|
||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.message.client.NoPowerCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
@@ -39,7 +39,7 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
@Override
|
||||
public void enter() {
|
||||
possibleCards = new ArrayList<>();
|
||||
//TODO: logic.send(new RequestPossibleCardsMessage());
|
||||
System.out.println("ChoosePowerCardState");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public void selectCard(BonusCard card){
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
//logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||
|
||||
public abstract class PowerCardStates extends TurnStates {
|
||||
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.client.gameState.turnState.powerCardState;
|
||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.settingsState;
|
||||
package pp.mdga.client.settingsstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.settingsState;
|
||||
package pp.mdga.client.settingsstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.settingsState;
|
||||
package pp.mdga.client.settingsstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.client.settingsState;
|
||||
package pp.mdga.client.settingsstate;
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
@@ -2,31 +2,38 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class will be used to hold all Board relevant data.
|
||||
*/
|
||||
@Serializable
|
||||
public class Board {
|
||||
private Map<Color, PlayerData> playerData = new HashMap<>();
|
||||
/**
|
||||
* The size of the board.
|
||||
*/
|
||||
public static final int BOARD_SIZE = 40;
|
||||
|
||||
/**
|
||||
* Create Board attributes.
|
||||
*/
|
||||
private final Node[] infield;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new board
|
||||
*/
|
||||
public Board() {
|
||||
infield = new Node[40];
|
||||
for (int i = 0; i < 40; i++) {
|
||||
if (i % 10 == 0) {
|
||||
infield[i] = new StartNode(
|
||||
i == 0 ? Color.AIRFORCE :
|
||||
i == 10 ? Color.CYBER :
|
||||
i == 20 ? Color.NAVY :
|
||||
Color.ARMY
|
||||
);
|
||||
} else if (i == 4 || i == 14 || i == 24 || i == 34) {
|
||||
infield = new Node[BOARD_SIZE];
|
||||
initializeBoard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the board by setting up the nodes.
|
||||
* Start nodes, bonus nodes, and regular nodes are created based on their positions.
|
||||
*/
|
||||
private void initializeBoard() {
|
||||
for (int i = 0; i < BOARD_SIZE; i++) {
|
||||
if (isStartNode(i)) {
|
||||
infield[i] = createStartNode(i);
|
||||
} else if (isBonusNode(i)) {
|
||||
infield[i] = new BonusNode();
|
||||
} else {
|
||||
infield[i] = new Node(null);
|
||||
@@ -35,23 +42,48 @@ public Board() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to add the given color and playerData parameters to the playerData attribute of
|
||||
* Board class.
|
||||
* Checks if the given index is a start node.
|
||||
*
|
||||
* @param color as the color of the player as a Color enumeration.
|
||||
* @param playerData as the playerData of the player as a PlayerData object.
|
||||
* @param i the index to check
|
||||
* @return true if the index is a start node, false otherwise
|
||||
*/
|
||||
public void addPlayerData(Color color, PlayerData playerData) {
|
||||
this.playerData.put(color, playerData);
|
||||
private boolean isStartNode(int i) {
|
||||
return i % 10 == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the playerData
|
||||
* Checks if the given index is a bonus node.
|
||||
*
|
||||
* @return the playerData
|
||||
* @param i the index to check
|
||||
* @return true if the index is a bonus node, false otherwise
|
||||
*/
|
||||
public Map<Color, PlayerData> getPlayerData() {
|
||||
return playerData;
|
||||
private boolean isBonusNode(int i) {
|
||||
return i % 10 == 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a start node with the appropriate color based on the index.
|
||||
*
|
||||
* @param i the index of the start node
|
||||
* @return a new StartNode with the corresponding color
|
||||
*/
|
||||
private StartNode createStartNode(int i) {
|
||||
return new StartNode(Color.getColor(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the index of a specific piece on the board
|
||||
*
|
||||
* @param piece the piece to be searched for
|
||||
* @return the index of the piece
|
||||
*/
|
||||
public int getInfieldIndexOfPiece(Piece piece) {
|
||||
for (int i = 0; i < infield.length; i++) {
|
||||
if (infield[i].getOccupant() == piece) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,18 +105,8 @@ public void setPieceOnBoard(int index, Piece piece) {
|
||||
infield[index].setOccupant(piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the index of a specific piece on the board
|
||||
*
|
||||
* @param piece the piece to be searched for
|
||||
* @return the index of the piece
|
||||
*/
|
||||
public int getInfieldIndexOfPiece(Piece piece) {
|
||||
for (int i = 0; i < infield.length; i++) {
|
||||
if (infield[i].getOccupant() == piece) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Default Board";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class BonusNode extends Node {
|
||||
BonusNode(){
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
BonusNode() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* This enumeration will be used to show the four different TSK which can be picked from a player.
|
||||
* In Addition, the NONE color will be used to show a none color.
|
||||
* This enumeration represents the four different TSK colors that a player can choose.
|
||||
* Additionally, the NONE color indicates the absence of a color.
|
||||
*/
|
||||
@Serializable
|
||||
public enum Color {
|
||||
@@ -58,4 +58,19 @@ public Color next() {
|
||||
|
||||
return colors[nextIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return the color of the given index.
|
||||
*
|
||||
* @param i as the index of the color as an Integer.
|
||||
* @return a Color enumeration.
|
||||
*/
|
||||
public static Color getColor(int i) {
|
||||
for (Color color : Color.values()) {
|
||||
if (color.ordinal() == i) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The Game class represents the game state of the Ludo game.
|
||||
* The Game class represents the game state of the game.
|
||||
* It contains all the information needed to play the game.
|
||||
* The game state is updated by the game logic.
|
||||
*/
|
||||
@@ -14,38 +14,53 @@ public class Game {
|
||||
public static final int AMOUNT_OF_TURBO_CARDS = 16;
|
||||
|
||||
/**
|
||||
* The number of shield and swap cards available in the game.
|
||||
* The number of shield cards available in the game.
|
||||
*/
|
||||
public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
|
||||
public static final int AMOUNT_OF_SHIELD_CARDS = 12;
|
||||
|
||||
// The modifier applied to the dice roll.
|
||||
private int diceModifier = 1;
|
||||
/**
|
||||
* The number of swap cards available in the game.
|
||||
*/
|
||||
public static final int AMOUNT_OF_SWAP_CARDS = 12;
|
||||
|
||||
// The number of eyes shown on the dice.
|
||||
private int diceEyes;
|
||||
|
||||
// A map of player IDs to Player objects.
|
||||
/**
|
||||
* A map of player IDs to Player objects.
|
||||
*/
|
||||
private Map<Integer, Player> players = new HashMap<>();
|
||||
|
||||
// The statistics of the game.
|
||||
/**
|
||||
* The statistics of the game.
|
||||
*/
|
||||
private Statistic gameStatistics;
|
||||
|
||||
// The pile of bonus cards available for drawing.
|
||||
private List<BonusCard> drawPile;
|
||||
/**
|
||||
* The pile of bonus cards available for drawing.
|
||||
*/
|
||||
private List<BonusCard> drawPile = new ArrayList<>();
|
||||
|
||||
// The pile of bonus cards that have been discarded.
|
||||
/**
|
||||
* The pile of bonus cards that have been discarded.
|
||||
*/
|
||||
private List<BonusCard> discardPile = new ArrayList<>();
|
||||
|
||||
// The game board.
|
||||
/**
|
||||
* The game board.
|
||||
*/
|
||||
private Board board;
|
||||
|
||||
// The die used in the game.
|
||||
/**
|
||||
* The die used in the game.
|
||||
*/
|
||||
private Die die;
|
||||
|
||||
// The host of this game
|
||||
/**
|
||||
* The host of this game
|
||||
*/
|
||||
private int host = -1;
|
||||
|
||||
// The color of the active player.
|
||||
/**
|
||||
* The color of the active player.
|
||||
*/
|
||||
private Color activeColor;
|
||||
|
||||
/**
|
||||
@@ -53,18 +68,30 @@ public class Game {
|
||||
*/
|
||||
public Game() {
|
||||
gameStatistics = new Statistic();
|
||||
drawPile = new ArrayList<>();
|
||||
for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) {
|
||||
drawPile.add(BonusCard.TURBO);
|
||||
}
|
||||
for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) {
|
||||
drawPile.add(BonusCard.SWAP);
|
||||
drawPile.add(BonusCard.SHIELD);
|
||||
}
|
||||
initializeDrawPile();
|
||||
board = new Board();
|
||||
die = new Die();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes the draw pile with the predefined number of bonus cards.
|
||||
*/
|
||||
private void initializeDrawPile() {
|
||||
addBonusCards(BonusCard.TURBO, AMOUNT_OF_TURBO_CARDS);
|
||||
addBonusCards(BonusCard.SWAP, AMOUNT_OF_SWAP_CARDS);
|
||||
addBonusCards(BonusCard.SHIELD, AMOUNT_OF_SHIELD_CARDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a number of bonus cards to the draw pile.
|
||||
*
|
||||
* @param card the card to add
|
||||
* @param count the number of cards to add
|
||||
*/
|
||||
private void addBonusCards(BonusCard card, int count) {
|
||||
drawPile.addAll(Collections.nCopies(count, card));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a player to the game.
|
||||
*
|
||||
@@ -99,7 +126,7 @@ public void updatePlayerActiveState(int id, boolean active) {
|
||||
* If yes it will return true, otherwise false.
|
||||
*
|
||||
* @param color as the color which should be checked if taken as a Color enumeration.
|
||||
* @return true or false.
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean isColorTaken(Color color) {
|
||||
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
|
||||
@@ -152,6 +179,15 @@ public Player getPlayerByColor(Color color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return all connected players as a list.
|
||||
*
|
||||
* @return players as a List of Player objects.
|
||||
*/
|
||||
public List<Player> getPlayersAsList() {
|
||||
return new ArrayList<>(this.players.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return the id of the active player depending on the activeColor attribute of Game
|
||||
* class.
|
||||
@@ -166,7 +202,7 @@ public int getActivePlayerId() {
|
||||
* This method will be used to return the id of the Player defined by the given color parameter.
|
||||
*
|
||||
* @param color as the color of the player as a Color enumeration.
|
||||
* @return the id of the player as an Integer.
|
||||
* @return the id of the player as an Integer.
|
||||
*/
|
||||
public int getPlayerIdByColor(Color color) {
|
||||
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
|
||||
@@ -216,8 +252,8 @@ public boolean areAllReady() {
|
||||
* @return the piece specified by the UUID
|
||||
*/
|
||||
public Piece getPieceThroughUUID(UUID pieceId) {
|
||||
for (var playerData : board.getPlayerData().values()) {
|
||||
for (var piece : playerData.getPieces()) {
|
||||
for (var player : this.getPlayers().values()) {
|
||||
for (var piece : player.getPieces()) {
|
||||
if (piece.getUuid().equals(pieceId)) {
|
||||
return piece;
|
||||
}
|
||||
@@ -235,24 +271,6 @@ public boolean isHost() {
|
||||
return this.host != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the dice modifier.
|
||||
*
|
||||
* @return the dice modifier
|
||||
*/
|
||||
public int getDiceModifier() {
|
||||
return diceModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the dice eyes.
|
||||
*
|
||||
* @return the dice eyes
|
||||
*/
|
||||
public int getDiceEyes() {
|
||||
return diceEyes;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the players.
|
||||
*
|
||||
@@ -325,24 +343,6 @@ public int getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the dice modifier.
|
||||
*
|
||||
* @param diceModifier the new dice modifier
|
||||
*/
|
||||
public void setDiceModifier(int diceModifier) {
|
||||
this.diceModifier = diceModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the dice eyes.
|
||||
*
|
||||
* @param diceEyes the new dice eyes
|
||||
*/
|
||||
public void setDiceEyes(int diceEyes) {
|
||||
this.diceEyes = diceEyes;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the players.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class HomeNode extends Node {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public HomeNode() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,33 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* This class will be used the represent a Node on which the pieces can travel along
|
||||
* Represents a node on the board.
|
||||
*/
|
||||
@Serializable
|
||||
public class Node {
|
||||
/**
|
||||
* The occupant of the node.
|
||||
*/
|
||||
protected Piece occupant;
|
||||
|
||||
public Node(Piece piece){
|
||||
/**
|
||||
* This constructor is used to create a new node object with a given occupant.
|
||||
*
|
||||
* @param piece as the occupant of the node.
|
||||
*/
|
||||
public Node(Piece piece) {
|
||||
occupant = piece;
|
||||
}
|
||||
|
||||
private Node(){
|
||||
/**
|
||||
* This constructor is used to create a new node object with a default occupant.
|
||||
*/
|
||||
private Node() {
|
||||
occupant = new Piece(Color.AIRFORCE, PieceState.WAITING);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get an occupant of the Node.
|
||||
* This method is used to get an occupant of the node.
|
||||
*
|
||||
* @return the current occupant of the node
|
||||
*/
|
||||
@@ -27,7 +38,7 @@ public Piece getOccupant() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to set a new Occupant
|
||||
* This method is used to set a new occupant
|
||||
*
|
||||
* @param occupant the new occupant of the node
|
||||
*/
|
||||
@@ -58,9 +69,9 @@ public boolean isOccupied() {
|
||||
* This method will be used to check if the node is occupied by a piece of the given color.
|
||||
*
|
||||
* @param color as the color of the piece as a Color object.
|
||||
* @return true or false.
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean isOccupied(Color color) {
|
||||
return this.occupant != null && this.occupant.getColor() == color;
|
||||
return isOccupied() && this.occupant.getColor() == color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,72 +51,72 @@ private Piece() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Sets the shield state of the piece.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @param shield the new shield state
|
||||
*/
|
||||
public void setShield(ShieldState shield) {
|
||||
this.shield = shield;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Gets the shield state of the piece.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return the shield state
|
||||
*/
|
||||
public ShieldState getShield() {
|
||||
return shield;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Sets the state of the piece.
|
||||
*
|
||||
* @param state the state of the piece
|
||||
* @param state the new state
|
||||
*/
|
||||
public void setState(PieceState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Gets the state of the piece.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return the state
|
||||
*/
|
||||
public PieceState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Checks if the piece is shielded.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return true if the piece is shielded, false otherwise
|
||||
*/
|
||||
public boolean isShielded() {
|
||||
return shield == ShieldState.ACTIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Checks if the shield of a piece is suppressed.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return true if the shield is suppressed, false otherwise
|
||||
*/
|
||||
public boolean isSuppressed() {
|
||||
return shield == ShieldState.SUPPRESSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Gets the color of the piece.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return the color
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
* Gets the unique identifier of the piece.
|
||||
*
|
||||
* @return the color of the piece
|
||||
* @return the UUID
|
||||
*/
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
|
||||
@@ -22,5 +22,5 @@ public enum PieceState {
|
||||
/**
|
||||
* The piece is finished.
|
||||
*/
|
||||
HOMEFINISHED;
|
||||
HOMEFINISHED
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class will be used to handle general PlayerData
|
||||
* This class represents a player in the game.
|
||||
*/
|
||||
@Serializable
|
||||
public class Player {
|
||||
@@ -44,10 +44,29 @@ public class Player {
|
||||
* Node and piece attributes
|
||||
*/
|
||||
private int startNodeIndex = -1;
|
||||
|
||||
/**
|
||||
* The home nodes of the player.
|
||||
*/
|
||||
private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES];
|
||||
|
||||
/**
|
||||
* The waiting area of the player.
|
||||
*/
|
||||
private Piece[] waitingArea = new Piece[Resources.MAX_PIECES];
|
||||
|
||||
/**
|
||||
* The pieces of the player.
|
||||
*/
|
||||
private Piece[] pieces = new Piece[Resources.MAX_PIECES];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Player() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor constructs a new Player object
|
||||
*
|
||||
@@ -57,13 +76,6 @@ public Player(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Player() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to initialize all nodes and pieces of the Player class.
|
||||
*/
|
||||
@@ -73,6 +85,7 @@ public void initialize() {
|
||||
this.pieces[index] = new Piece(this.color, PieceState.WAITING);
|
||||
this.waitingArea[index] = this.pieces[index];
|
||||
}
|
||||
startNodeIndex = color.ordinal() * 10;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,21 +94,16 @@ public void initialize() {
|
||||
* @param card the card to be added to the players hand
|
||||
*/
|
||||
public void addHandCard(BonusCard card) {
|
||||
handCards.add(card);
|
||||
this.handCards.add(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a BonusCard to be removed from the players hand.
|
||||
* This method will be used to remove the given card parameter from the handCards attribute of Player card.
|
||||
*
|
||||
* @param card the cards type to be removed
|
||||
* @return the removed card or null if there is none of that card type
|
||||
* @param card as the card which should be removed from the handCards attribute as a PowerCard object.
|
||||
*/
|
||||
public BonusCard removeHandCard(BonusCard card) {
|
||||
BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
|
||||
if (cardToRemove != null) {
|
||||
handCards.remove(cardToRemove);
|
||||
}
|
||||
return cardToRemove;
|
||||
public void removeHandCard(BonusCard card) {
|
||||
this.handCards.remove(card);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +128,12 @@ public void addWaitingPiece(Piece piece) {
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
for (int i = 0; i < Resources.MAX_PIECES; i++) {
|
||||
if (this.pieces[i].getState() != PieceState.HOMEFINISHED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,4 +261,24 @@ public void setReady(boolean ready) {
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets a piece at the given index in the home area
|
||||
*
|
||||
* @param index the index of the node
|
||||
* @param piece the piece to be set at the given index
|
||||
*/
|
||||
public void setPieceInHome(int index, Piece piece) {
|
||||
this.homeNodes[index].setOccupant(piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* The string representation of the player
|
||||
*
|
||||
* @return the string representation of the player
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Player: " + name + " Color: " + color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.Resources;
|
||||
|
||||
/**
|
||||
* This class is used to represent PlayerData related to the board
|
||||
*/
|
||||
@Serializable
|
||||
public class PlayerData {
|
||||
/**
|
||||
* An array of HomeNode objects representing the home nodes of the player.
|
||||
*/
|
||||
private HomeNode[] homeNodes;
|
||||
|
||||
/**
|
||||
* The index of the start node for the player.
|
||||
*/
|
||||
private int startNodeIndex;
|
||||
|
||||
/**
|
||||
* An array of Piece objects representing the waiting area of the player.
|
||||
*/
|
||||
private Piece[] waitingArea;
|
||||
|
||||
/**
|
||||
* An array of Piece objects representing all the pieces of the player.
|
||||
*/
|
||||
private Piece[] pieces;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new PlayerData object
|
||||
*
|
||||
* @param color the color of the player
|
||||
*/
|
||||
public PlayerData(Color color) {
|
||||
homeNodes = new HomeNode[Resources.MAX_PIECES];
|
||||
pieces = new Piece[Resources.MAX_PIECES];
|
||||
waitingArea = new Piece[Resources.MAX_PIECES];
|
||||
for (int i = 0; i < Resources.MAX_PIECES; i++) {
|
||||
homeNodes[i] = new HomeNode();
|
||||
pieces[i] = new Piece(color, PieceState.WAITING);
|
||||
waitingArea[i] = pieces[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
private PlayerData() {
|
||||
homeNodes = new HomeNode[Resources.MAX_PIECES];
|
||||
waitingArea = new Piece[Resources.MAX_PIECES];
|
||||
pieces = new Piece[Resources.MAX_PIECES];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to check if the player is finished.
|
||||
* ToDo: Currently return always false. Implement logic!
|
||||
*
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an Array of HomeNodes
|
||||
*
|
||||
* @return the array of HomeNodes
|
||||
*/
|
||||
public Node[] getHomeNodes() {
|
||||
return homeNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the index of the StartNode
|
||||
*
|
||||
* @return the index of the StartNode
|
||||
*/
|
||||
public int getStartNodeIndex() {
|
||||
return startNodeIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the index of the startNode.
|
||||
*
|
||||
* @param startNodeIndex the integer index of the startNode
|
||||
*/
|
||||
public void setStartNodeIndex(int startNodeIndex) {
|
||||
this.startNodeIndex = startNodeIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an array pieces representing the waiting area.
|
||||
*
|
||||
* @return the waiting area
|
||||
*/
|
||||
public Piece[] getWaitingArea() {
|
||||
return waitingArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an array of pieces with all the players pieces
|
||||
*
|
||||
* @return the array of pieces
|
||||
*/
|
||||
public Piece[] getPieces() {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a piece to the waiting area
|
||||
*
|
||||
* @param piece the piece to be added to the waiting area
|
||||
*/
|
||||
public void addWaitingPiece(Piece piece) {
|
||||
for (int i = 0; i < Resources.MAX_PIECES; i++) {
|
||||
if (waitingArea[i] == null) {
|
||||
waitingArea[i] = piece;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes a piece from the waiting area
|
||||
*
|
||||
* @return the piece that was removed from the waiting area
|
||||
*/
|
||||
public Piece removePieceFromWaitingArea() {
|
||||
for (int i = 0; i < Resources.MAX_PIECES; i++) {
|
||||
if (waitingArea[i] != null) {
|
||||
Piece piece = waitingArea[i];
|
||||
waitingArea[i] = null;
|
||||
return piece;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets a piece at the given index in the home area
|
||||
*
|
||||
* @param index the index of the node
|
||||
* @param piece the piece to be set at the given index
|
||||
*/
|
||||
public void setPieceInHome(int index, Piece piece) {
|
||||
homeNodes[index].setOccupant(piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return if the given piece parameter is inside the homNodes attribute of PlayerData
|
||||
* class.
|
||||
* If yes it will return true, otherwise false.
|
||||
*
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean homeIncludes(Piece piece) {
|
||||
for (Node node : this.homeNodes) {
|
||||
if (node.getOccupant() == piece) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return the index of the given piece parameter in the homeNodes attribute of
|
||||
* PlayerData class.
|
||||
*
|
||||
* @return index as an Integer.
|
||||
*/
|
||||
public int getIndexInHome(Piece piece) {
|
||||
for (int i = 0; i < Resources.MAX_PIECES; i++) {
|
||||
if (homeNodes[i].getOccupant() == piece) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be usd to check if the waitingArea attribute of PlayerData class is empty.
|
||||
* If yes it will return false, otherwise true.
|
||||
*
|
||||
* @return true or false.
|
||||
*/
|
||||
public boolean hasPieceInWaitingArea() {
|
||||
for (Piece piece : waitingArea) {
|
||||
if (piece != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,5 @@ public enum ShieldState {
|
||||
/**
|
||||
* The shield is suppressed, when the piece is on a start node.
|
||||
*/
|
||||
SUPPRESSED;
|
||||
SUPPRESSED
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public StartNode(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for serialization.
|
||||
*/
|
||||
private StartNode() {
|
||||
super(null);
|
||||
color = Color.NONE;
|
||||
|
||||
@@ -68,7 +68,7 @@ public void setCardsPlayed(int cardsPlayed) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the count of enemyPieces Thrown during the game.
|
||||
* This method returns the count of enemyPieces thrown during the game.
|
||||
*
|
||||
* @return the count of enemyPieces thrown
|
||||
*/
|
||||
@@ -77,7 +77,7 @@ public int getPiecesThrown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the new count of enemyPieces Thrown
|
||||
* This method sets the new count of enemyPieces thrown
|
||||
*
|
||||
* @param piecesThrown the new count of pieces thrown.
|
||||
*/
|
||||
@@ -165,28 +165,28 @@ public void increaseCardsPlayed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
* This method increases the value of piecesThrown by 1.
|
||||
*/
|
||||
public void increasePiecesThrown() {
|
||||
piecesThrown++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
* This method increases the value of piecesBeingThrown by 1.
|
||||
*/
|
||||
public void increasePiecesBeingThrown() {
|
||||
piecesBeingThrown++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
* This method increases the value of diced6 by 1.
|
||||
*/
|
||||
public void increaseDiced6() {
|
||||
diced6++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
* This method increases the value of traveledNodes by 1.
|
||||
*/
|
||||
public void increaseTraveledNodes() {
|
||||
traveledNodes++;
|
||||
@@ -202,7 +202,7 @@ public void increaseTraveledNodes(int nodes) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
* This method increases the value of activatedBonusNodes by 1.
|
||||
*/
|
||||
public void increaseActivatedBonusNodes() {
|
||||
activatedBonusNodes++;
|
||||
|
||||
@@ -14,16 +14,6 @@ public AnimationEndMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnimationEnd{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor for processing this message.
|
||||
*
|
||||
|
||||
@@ -21,17 +21,17 @@ public interface ClientInterpreter {
|
||||
void received(DeselectTSKMessage msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received ForceStartGame message.
|
||||
* Processes a received StartGame message.
|
||||
*
|
||||
* @param msg the ForceStartGame message to be processed
|
||||
* @param msg the StartGame message to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(StartGameMessage msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received JoinServer message.
|
||||
* Processes a received JoinedLobby message.
|
||||
*
|
||||
* @param msg the JoinServer message to be processed
|
||||
* @param msg the JoinedLobby message to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(JoinedLobbyMessage msg, int from);
|
||||
|
||||
@@ -21,4 +21,8 @@ protected ClientMessage() {
|
||||
* @param from the connection ID of the sender
|
||||
*/
|
||||
public abstract void accept(ClientInterpreter interpreter, int from);
|
||||
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,22 +8,12 @@
|
||||
@Serializable
|
||||
public class ClientStartGameMessage extends ClientMessage {
|
||||
/**
|
||||
* Constructs a new ClientStartGame instance.
|
||||
* Constructor.
|
||||
*/
|
||||
public ClientStartGameMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientStartGame{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -3,24 +3,17 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* A message sent by a client to indicate that it has disconnected.
|
||||
*/
|
||||
@Serializable
|
||||
public class DisconnectedMessage extends ClientMessage {
|
||||
/**
|
||||
* Constructs a new Disconnected message.
|
||||
*/
|
||||
public DisconnectedMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientStartGame{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public ForceContinueGameMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForceContinueGame{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class JoinedLobbyMessage extends ClientMessage {
|
||||
|
||||
/**
|
||||
* The name of the player that is joining the server.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
@@ -42,7 +44,7 @@ public String getName(){
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JoinServer{}";
|
||||
return "JoinServer {" + "name=" + name + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,16 +14,6 @@ public LeaveGameMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LeaveGame{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public LobbyNotReadyMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LobbyNotReady{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public LobbyReadyMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LobbyReady{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public NoPowerCardMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NoPowerCard{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public RequestBriefingMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RequestBriefing{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,6 @@ public RequestDieMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RequestDie{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -20,12 +20,15 @@ public class RequestPlayCardMessage extends ClientMessage {
|
||||
*/
|
||||
private final UUID ownPieceIdentifier;
|
||||
|
||||
/**
|
||||
* The identifier of the enemy piece.
|
||||
*/
|
||||
private final UUID enemyPieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructs a new RequestPlayCard instance.
|
||||
*
|
||||
* @param card the bonus card to be played
|
||||
* @param card the bonus card to be played
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
*/
|
||||
public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
|
||||
@@ -46,11 +49,11 @@ private RequestPlayCardMessage() {
|
||||
/**
|
||||
* Creates a new RequestPlayCard instance for a given bonus card.
|
||||
*
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
* @param enemyPieceIdentifier the identifier of the enemy piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier){
|
||||
public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
|
||||
return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
|
||||
}
|
||||
|
||||
@@ -60,7 +63,7 @@ public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UU
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier){
|
||||
public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier) {
|
||||
return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null);
|
||||
}
|
||||
|
||||
@@ -98,7 +101,8 @@ public UUID getEnemyPieceIdentifier() {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RequestPlayCard={card=" + card.toString() + '}';
|
||||
assert card != null;
|
||||
return "RequestPlayCard={card=" + card + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,11 @@ private SelectTSKMessage() {
|
||||
color = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color associated with the TSK to be selected.
|
||||
*
|
||||
* @return the color associated with the TSK to be selected
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -7,39 +7,11 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class StartGameMessage extends ClientMessage {
|
||||
|
||||
private final boolean forceStartGame;
|
||||
|
||||
public StartGameMessage(boolean forceStartGame){
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public StartGameMessage() {
|
||||
super();
|
||||
this.forceStartGame = forceStartGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ForceStartGame message.
|
||||
*/
|
||||
private StartGameMessage() {
|
||||
super();
|
||||
forceStartGame = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the game should be force started.
|
||||
*
|
||||
* @return whether the game should be force started
|
||||
*/
|
||||
public boolean isForceStartGame() {
|
||||
return forceStartGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForceStartGame{}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,14 +58,4 @@ public void accept(ServerInterpreter interpreter) {
|
||||
public String toString() {
|
||||
return "ActivePlayer{color=" + color + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the informational text associated with this message.
|
||||
*
|
||||
* @return the key for the informational text
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +61,4 @@ public void accept(ServerInterpreter interpreter) {
|
||||
public String toString() {
|
||||
return "AnyPiece{piece=" + piece + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public BriefingMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public CeremonyMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public DiceAgainMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public DiceNowMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DieMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructor for Dice
|
||||
*
|
||||
* @param diceEye the eye of the dice
|
||||
* @param diceEye the eye of the dice
|
||||
*/
|
||||
public DieMessage(int diceEye) {
|
||||
super();
|
||||
@@ -57,16 +57,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "DieMessage{" + "diceEye=" + diceEye + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public EndOfTurnMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class IncorrectRequestMessage extends ServerMessage {
|
||||
* @param id as the id of the error message as an Integer.
|
||||
*/
|
||||
public IncorrectRequestMessage(int id) {
|
||||
super();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -22,6 +23,7 @@ public IncorrectRequestMessage(int id) {
|
||||
* Constructor.
|
||||
*/
|
||||
public IncorrectRequestMessage() {
|
||||
super();
|
||||
this.id = 0;
|
||||
}
|
||||
|
||||
@@ -35,17 +37,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bundle key of the informational text to be shown at the client.
|
||||
* This key is used to retrieve the appropriate localized text for display.
|
||||
*
|
||||
* @return the bundle key of the informational text
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return necessary class information in a more readable format.
|
||||
*
|
||||
|
||||
@@ -39,7 +39,6 @@ public int getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
@@ -51,22 +50,12 @@ public void accept(ServerInterpreter interpreter) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
* This method will be used to return necessary class information in a more readable format.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
* @return information as a String.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Lobby Accept";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "LobbyAcceptMessage with host: %d".formatted(this.host);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public LobbyDenyMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LobbyDeny";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public LobbyPlayerJoinedMessage(int id, Player player, boolean host) {
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LobbyPlayerJoinedMessage() {
|
||||
super();
|
||||
player = null;
|
||||
id = 0;
|
||||
host = false;
|
||||
@@ -61,7 +62,7 @@ public Player getPlayer() {
|
||||
*
|
||||
* @return the id of the player
|
||||
*/
|
||||
public int getId(){
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -79,23 +80,8 @@ public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "LobbyPlayerJoinedMessage{" + "player=" + player + ", id=" + id + ", host=" + host + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class LobbyPlayerLeaveMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new LobbyPlayerLeave instance with the specified player name and color.
|
||||
*
|
||||
* @param id the id of the player leaving the lobby.
|
||||
* @param id the id of the player leaving the lobby.
|
||||
*/
|
||||
public LobbyPlayerLeaveMessage(int id) {
|
||||
super();
|
||||
@@ -27,6 +27,7 @@ public LobbyPlayerLeaveMessage(int id) {
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LobbyPlayerLeaveMessage() {
|
||||
super();
|
||||
id = 0;
|
||||
}
|
||||
|
||||
@@ -56,16 +57,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "LobbyPlayerLeaveMessage{" + "id=" + id + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private MoveMessage() {
|
||||
super();
|
||||
pieceUUID = null;
|
||||
targetIndex = 0;
|
||||
isHomeMove = false;
|
||||
@@ -59,7 +60,7 @@ public UUID getIdentifier() {
|
||||
*
|
||||
* @return the target index
|
||||
*/
|
||||
public int getTargetIndex(){
|
||||
public int getTargetIndex() {
|
||||
return targetIndex;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ public int getTargetIndex(){
|
||||
*
|
||||
* @return the boolean isHomeMove.
|
||||
*/
|
||||
public boolean isHomeMove(){
|
||||
public boolean isHomeMove() {
|
||||
return isHomeMove;
|
||||
}
|
||||
|
||||
@@ -89,16 +90,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "MoveMessage{" + "pieceUUID=" + pieceUUID + ", targetIndex=" + targetIndex + ", isHomeMove=" + isHomeMove + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public NoTurnMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class PauseGameMessage extends ServerMessage {
|
||||
|
||||
/**
|
||||
* the id of the player who has disconnected
|
||||
*/
|
||||
@@ -54,16 +53,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "PauseGameMessage{" + "playerId=" + playerId + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,21 @@ public class PlayCardMessage extends ServerMessage {
|
||||
*/
|
||||
private final UUID ownPieceID;
|
||||
|
||||
/**
|
||||
* The identifier of the enemy piece that should be moved.
|
||||
*/
|
||||
private final UUID enemyPieceID;
|
||||
|
||||
/**
|
||||
* The modifier of the dice.
|
||||
*/
|
||||
private final int diceModifier;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayCard message.
|
||||
*
|
||||
* @param card the card that should be played
|
||||
* @param ownPieceID the identifier of the piece that should be moved
|
||||
* @param card the card that should be played
|
||||
* @param ownPieceID the identifier of the piece that should be moved
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be moved
|
||||
* @param diceModifier the new modifier of the dice
|
||||
*/
|
||||
@@ -53,7 +59,7 @@ private PlayCardMessage() {
|
||||
/**
|
||||
* Creates a new PlayCard message for the given card and piece identifier.
|
||||
*
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be affected
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
@@ -77,7 +83,7 @@ public static PlayCardMessage shield(UUID ownPieceID) {
|
||||
* @param diceModifier the new modifier of the dice
|
||||
* @return newly constructed message
|
||||
*/
|
||||
public static PlayCardMessage turbo(int diceModifier){
|
||||
public static PlayCardMessage turbo(int diceModifier) {
|
||||
return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier);
|
||||
}
|
||||
|
||||
@@ -114,7 +120,7 @@ public UUID getPieceIdentifierEnemy() {
|
||||
*
|
||||
* @return the dice modifier as int
|
||||
*/
|
||||
public int getDiceModifier(){
|
||||
public int getDiceModifier() {
|
||||
return diceModifier;
|
||||
}
|
||||
|
||||
@@ -135,16 +141,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "PlayCardMessage{" + "card=" + card + ", ownPieceID=" + ownPieceID + ", enemyPieceID=" + enemyPieceID + ", diceModifier=" + diceModifier + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,16 +59,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "PossibleCardMessage{" + "possibleCards=" + possibleCards + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public PossiblePieceMessage() {
|
||||
/**
|
||||
* Swap the possible pieces
|
||||
*
|
||||
* @param possibleOwnPieces the list of possible own pieces
|
||||
* @param possibleOwnPieces the list of possible own pieces
|
||||
* @param possibleEnemyPieces the list of possible enemy pieces
|
||||
* @return the swapped possible pieces
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOw
|
||||
* @param possibleOwnPieces the list of possible own pieces
|
||||
* @return the possible pieces for the shield
|
||||
*/
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces){
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces) {
|
||||
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
|
||||
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
|
||||
return possiblePieceMessage;
|
||||
@@ -74,14 +74,18 @@ public void addEnemyPossiblePiece(UUID piece) {
|
||||
this.possibleEnemyPieces.add(piece);
|
||||
}
|
||||
|
||||
/** Getter for the list of possible pieces
|
||||
/**
|
||||
* Getter for the list of possible pieces
|
||||
*
|
||||
* @return the list of possible pieces
|
||||
*/
|
||||
public List<UUID> getOwnPossiblePieces() {
|
||||
return possibleOwnPieces;
|
||||
}
|
||||
|
||||
/** Getter for the list of possible enemy pieces
|
||||
/**
|
||||
* Getter for the list of possible enemy pieces
|
||||
*
|
||||
* @return the list of possible enemy pieces
|
||||
*/
|
||||
public List<UUID> getEnemyPossiblePieces() {
|
||||
@@ -105,16 +109,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "PossiblePieceMessage{" + "possibleOwnPieces=" + possibleOwnPieces + ", possibleEnemyPieces=" + possibleEnemyPieces + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,16 +52,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "RankingResponseMessage{" + "startingPlayerId=" + startingPlayerId + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public RankingRollAgainMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,16 +54,6 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
return "ReconnectBriefingMessage{" + "game=" + game + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,4 @@ public ResumeGameMessage() {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,35 @@
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to select a piece to move.
|
||||
*/
|
||||
@Serializable
|
||||
public class SelectPieceMessage extends ServerMessage{
|
||||
|
||||
public class SelectPieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The list of pieces
|
||||
*/
|
||||
private final List<UUID> pieces;
|
||||
|
||||
/**
|
||||
* The list of booleans of isHomeMove of the pieces
|
||||
*/
|
||||
private final List<Boolean> isHomeMove;
|
||||
|
||||
/**
|
||||
* The list of indexes of target nodes of the pieces
|
||||
*/
|
||||
private final List<Integer> targetIndex;
|
||||
|
||||
/**
|
||||
* Constructs a new SelectPiece instance.
|
||||
*
|
||||
* @param pieces the pieces to be selected
|
||||
* @param isHomeMove the List of booleans of isHomeMove of the pieces
|
||||
* @param pieces the pieces to be selected
|
||||
* @param isHomeMove the List of booleans of isHomeMove of the pieces
|
||||
* @param targetIndex the List of indexes of target nodes of the pieces
|
||||
*/
|
||||
public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex) {
|
||||
super();
|
||||
this.pieces = pieces;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
@@ -28,7 +42,8 @@ public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Inte
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
public SelectPieceMessage(){
|
||||
public SelectPieceMessage() {
|
||||
super();
|
||||
pieces = null;
|
||||
isHomeMove = null;
|
||||
targetIndex = null;
|
||||
@@ -39,7 +54,7 @@ public SelectPieceMessage(){
|
||||
*
|
||||
* @return the pieces
|
||||
*/
|
||||
public List<UUID> getPieces(){
|
||||
public List<UUID> getPieces() {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
@@ -48,7 +63,7 @@ public List<UUID> getPieces(){
|
||||
*
|
||||
* @return List of boolean values
|
||||
*/
|
||||
public List<Boolean> getIsHomeMove(){
|
||||
public List<Boolean> getIsHomeMove() {
|
||||
return isHomeMove;
|
||||
}
|
||||
|
||||
@@ -57,7 +72,7 @@ public List<Boolean> getIsHomeMove(){
|
||||
*
|
||||
* @return List of integers
|
||||
*/
|
||||
public List<Integer> getTargetIndex(){
|
||||
public List<Integer> getTargetIndex() {
|
||||
return targetIndex;
|
||||
}
|
||||
|
||||
@@ -77,7 +92,7 @@ public void accept(ServerInterpreter interpreter) {
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
public String toString() {
|
||||
return "SelectPieceMessage{" + "pieces=" + pieces + ", isHomeMove=" + isHomeMove + ", targetIndex=" + targetIndex + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface ServerInterpreter {
|
||||
/**
|
||||
* Handles a Die message received from the server.
|
||||
*
|
||||
* @param msg the Dice message received
|
||||
* @param msg the Die message received
|
||||
*/
|
||||
void received(DieMessage msg);
|
||||
|
||||
@@ -55,16 +55,16 @@ public interface ServerInterpreter {
|
||||
void received(DiceNowMessage msg);
|
||||
|
||||
/**
|
||||
* Handles an EndOfGame message received from the server.
|
||||
* Handles an EndOfTurn message received from the server.
|
||||
*
|
||||
* @param msg the EndOfGame message received
|
||||
* @param msg the EndOfTurn message received
|
||||
*/
|
||||
void received(EndOfTurnMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a GameOver message received from the server.
|
||||
* Handles a LobbyAccept message received from the server.
|
||||
*
|
||||
* @param msg the GameOver message received
|
||||
* @param msg the LobbyAccept message received
|
||||
*/
|
||||
void received(LobbyAcceptMessage msg);
|
||||
|
||||
@@ -132,9 +132,9 @@ public interface ServerInterpreter {
|
||||
void received(PossiblePieceMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a RankingResponce message received from the server.
|
||||
* Handles a RankingResponse message received from the server.
|
||||
*
|
||||
* @param msg the RankingResponce message received
|
||||
* @param msg the RankingResponse message received
|
||||
*/
|
||||
void received(RankingResponseMessage msg);
|
||||
|
||||
@@ -209,9 +209,9 @@ public interface ServerInterpreter {
|
||||
void received(SelectPieceMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a SelectTSK message received from the server.
|
||||
* Handles a Shutdown message received from the server.
|
||||
*
|
||||
* @param msg the SelectTSK message received.
|
||||
* @param msg the Shutdown message received.
|
||||
*/
|
||||
void received(ShutdownMessage msg);
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ protected ServerMessage() {
|
||||
public abstract void accept(ServerInterpreter interpreter);
|
||||
|
||||
/**
|
||||
* Gets the bundle key of the informational text to be shown at the client.
|
||||
* This key is used to retrieve the appropriate localized text for display.
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
* @return the bundle key of the informational text
|
||||
* @return a string representation of this message
|
||||
*/
|
||||
public abstract String getInfoTextKey();
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Board;
|
||||
import pp.mdga.game.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A message indicating that the game shall start.
|
||||
@@ -9,28 +13,45 @@
|
||||
@Serializable
|
||||
public class ServerStartGameMessage extends ServerMessage {
|
||||
/**
|
||||
* Create ServerStartGameMessage attributes.
|
||||
* The list of players.
|
||||
*/
|
||||
private final List<Player> players;
|
||||
|
||||
/**
|
||||
* The board of the game.
|
||||
*/
|
||||
private final Board board;
|
||||
|
||||
/**
|
||||
* Constructs a new ServerStartGame instance.
|
||||
* Constructor.
|
||||
*/
|
||||
public ServerStartGameMessage() {
|
||||
super();
|
||||
this.players = new ArrayList<>();
|
||||
this.board = new Board();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param board as the board of the game as a Board object.
|
||||
* @param players as the connected players as a List of Player objects.
|
||||
* @param board as the board of the game as a Board object.
|
||||
*/
|
||||
public ServerStartGameMessage(Board board) {
|
||||
public ServerStartGameMessage(List<Player> players, Board board) {
|
||||
super();
|
||||
this.players = players;
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return players attribute of ServerStartGameMessage class.
|
||||
*
|
||||
* @return players as a List of Player objects.
|
||||
*/
|
||||
public List<Player> getPlayers() {
|
||||
return this.players;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return board attribute of ServerStartGameMessage class.
|
||||
*
|
||||
@@ -57,16 +78,7 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
return "ServerStartGameMessage{" + "players=" + players + ", board=" + board + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for the info text of this message.
|
||||
*
|
||||
* @return the key for the info text of this message
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class ShutdownMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new Shutdown message.
|
||||
*/
|
||||
public ShutdownMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
@@ -16,15 +23,4 @@ public class ShutdownMessage extends ServerMessage {
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bundle key of the informational text to be shown at the client.
|
||||
* This key is used to retrieve the appropriate localized text for display.
|
||||
*
|
||||
* @return the bundle key of the informational text
|
||||
*/
|
||||
@Override
|
||||
public String getInfoTextKey() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user