Merge branch 'development' into 'dev/test'
merge development into test See merge request progproj/gruppen-ht24/Gruppe-01!22
This commit is contained in:
@@ -17,7 +17,7 @@ public class MdgaApp extends SimpleApplication {
|
||||
MdgaView view = null;
|
||||
private MdgaState state = MdgaState.MAIN;
|
||||
|
||||
private static float resolutionFactor = 1.8f;
|
||||
private static float resolutionFactor = 1.0f;
|
||||
|
||||
public static void main(String[] args) {
|
||||
AppSettings settings = new AppSettings(true);
|
||||
|
||||
@@ -89,13 +89,13 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof MovePieceNotification) {
|
||||
MovePieceNotification n = (MovePieceNotification)notification;
|
||||
//gameView.getBoardHandler().movePiece(n.get); //TODO
|
||||
} else if (notification instanceof MoveThrowPieceNotification) {
|
||||
MoveThrowPieceNotification n = (MoveThrowPieceNotification)notification;
|
||||
//TODO: } else if (notification instanceof MoveThrowPieceNotification) {
|
||||
//TODO: MoveThrowPieceNotification n = (MoveThrowPieceNotification)notification;
|
||||
//gameView.getBoardHandler().throwPiece(n.); //TODO
|
||||
} else if (notification instanceof NoShieldNotification) {
|
||||
NoShieldNotification n = (NoShieldNotification)notification;
|
||||
gameView.getBoardHandler().unshieldPiece(n.getPieceId());
|
||||
} else if (notification instanceof PieceInGameNotification) {
|
||||
//TODO:} else if (notification instanceof PieceInGameNotification) {
|
||||
// Handle PieceInGameNotification
|
||||
} else if (notification instanceof PlayCardNotification) {
|
||||
// Handle PlayCardNotification
|
||||
@@ -107,7 +107,7 @@ private void handleGame(Notification notification) {
|
||||
// Handle RollDiceNotification
|
||||
} else if (notification instanceof SelectableCardsNotification) {
|
||||
// Handle SelectableCardsNotification
|
||||
} else if (notification instanceof SelectablePiecesNotification) {
|
||||
//TODO: } else if (notification instanceof SelectablePiecesNotification) {
|
||||
// Handle SelectablePiecesNotification
|
||||
} else if (notification instanceof ShieldActiveNotification) {
|
||||
ShieldActiveNotification n = (ShieldActiveNotification)notification;
|
||||
|
||||
@@ -1,19 +1,56 @@
|
||||
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;
|
||||
|
||||
public class CeremonyState extends ClientState {
|
||||
|
||||
private CeremonyStates currentState;
|
||||
|
||||
private final PodiumState podiumState = new PodiumState(this, logic);
|
||||
private final StatisticsState statisticsState = new StatisticsState(this, logic);
|
||||
|
||||
public CeremonyState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
|
||||
private CeremonyNotification prepareNotification(){
|
||||
CeremonyNotification notification = new CeremonyNotification();
|
||||
|
||||
//TODO: creation of the notification
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
currentState = podiumState;
|
||||
logic.addNotification(prepareNotification());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
currentState.exit();
|
||||
}
|
||||
|
||||
public void setState(CeremonyStates state){
|
||||
this.currentState.exit();
|
||||
state.enter();
|
||||
currentState = state;
|
||||
}
|
||||
|
||||
public PodiumState getPodiumState(){
|
||||
return podiumState;
|
||||
}
|
||||
|
||||
public StatisticsState getStatisticsState(){
|
||||
return statisticsState;
|
||||
}
|
||||
|
||||
public CeremonyStates getState(){
|
||||
return currentState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Game;
|
||||
import pp.mdga.game.Piece;
|
||||
@@ -19,11 +20,13 @@ public class ClientGameLogic implements ServerInterpreter {
|
||||
private final ClientSender clientSender;
|
||||
private ClientState state;
|
||||
private final ArrayList<Notification> notifications = new ArrayList<>();
|
||||
private boolean isHost;
|
||||
|
||||
private final DialogsState dialogsState = new DialogsState(null, this);
|
||||
private final GameState gameState = new GameState(null, this);
|
||||
private final CeremonyState ceremonyState = new CeremonyState(null, this);
|
||||
private final InterruptState interruptState = new InterruptState(null, this);
|
||||
private final SettingsState settingsState = new SettingsState(null, this);
|
||||
|
||||
public ClientGameLogic(Game game, ClientSender clientSender) {
|
||||
this.game = game;
|
||||
@@ -59,6 +62,14 @@ public ClientState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public boolean isHost(){
|
||||
return isHost;
|
||||
}
|
||||
|
||||
public void setHost(boolean isHost){
|
||||
this.isHost = isHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
state.received(msg);
|
||||
@@ -201,16 +212,15 @@ public void received(SpectatorMessage msg) {
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg) {
|
||||
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public void selectPiece(UUID pieceId){
|
||||
state.selectPiece(getPiece(pieceId));
|
||||
}
|
||||
|
||||
//TODO: implement
|
||||
public void selectCard(UUID cardId){
|
||||
state.selectCard(null);
|
||||
public void selectCard(BonusCard card){
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
public void selectTsk(Color color){
|
||||
@@ -226,7 +236,7 @@ public void selectName(String name){
|
||||
}
|
||||
|
||||
public void selectReady(boolean ready){
|
||||
state.selectReady();
|
||||
state.selectReady(ready);
|
||||
}
|
||||
|
||||
public void selectHost(String name){
|
||||
@@ -237,8 +247,8 @@ public void selectLeave(){
|
||||
state.selectLeave();
|
||||
}
|
||||
|
||||
public void selectJoin(String name){
|
||||
state.selectJoin(name);
|
||||
public void selectJoin(String ip){
|
||||
state.selectJoin(ip);
|
||||
}
|
||||
|
||||
public void selectAnimationEnd(){
|
||||
@@ -255,6 +265,12 @@ public void setState(ClientState state){
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void enterInterrupt(){
|
||||
interruptState.enter();
|
||||
interruptState.setPreviousState(state);
|
||||
this.state = interruptState;
|
||||
}
|
||||
|
||||
public GameState getGameState(){
|
||||
return gameState;
|
||||
}
|
||||
@@ -271,8 +287,16 @@ public DialogsState getDialogs(){
|
||||
return dialogsState;
|
||||
}
|
||||
|
||||
public SettingsState getSettings(){
|
||||
return settingsState;
|
||||
}
|
||||
|
||||
public Notification getNotification(){
|
||||
return notifications.remove(0);
|
||||
}
|
||||
|
||||
public void addNotification(Notification notification){
|
||||
notifications.add(notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public void setName(String name) {
|
||||
LOGGER.log(Level.DEBUG, "Setting name not allowed.");
|
||||
}
|
||||
|
||||
public void selectReady() {
|
||||
public void selectReady(boolean ready) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting ready not allowed.");
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public void selectHost(String name) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting host not allowed.");
|
||||
}
|
||||
|
||||
public void selectJoin(String name) {
|
||||
public void selectJoin(String string) {
|
||||
LOGGER.log(Level.DEBUG, "Selecting join not allowed.");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
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.game.Player;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class DialogsState extends ClientState {
|
||||
|
||||
private DialogStates currentState;
|
||||
|
||||
private Player ownPlayer;
|
||||
private int ownPlayerID;
|
||||
private String ownPlayerName;
|
||||
|
||||
private final LobbyState lobbyState = new LobbyState(this, logic);
|
||||
private final NetworkDialogState networkDialogState = new NetworkDialogState(this, logic);
|
||||
@@ -31,6 +32,8 @@ public void exit(){
|
||||
@Override
|
||||
public void enter(){
|
||||
currentState = startDialogState;
|
||||
ownPlayerID = 0;
|
||||
ownPlayerName = null;
|
||||
}
|
||||
|
||||
public void setState(DialogStates newState){
|
||||
@@ -39,8 +42,16 @@ public void setState(DialogStates newState){
|
||||
currentState = newState;
|
||||
}
|
||||
|
||||
public Player getOwnPlayer() {
|
||||
return ownPlayer;
|
||||
public int getOwnPlayerId() {
|
||||
return ownPlayerID;
|
||||
}
|
||||
|
||||
public String getOwnPlayerName() {
|
||||
return ownPlayerName;
|
||||
}
|
||||
|
||||
public void setOwnPlayerName(String ownPlayerName) {
|
||||
this.ownPlayerName = ownPlayerName;
|
||||
}
|
||||
|
||||
public LobbyState getLobby() {
|
||||
@@ -60,6 +71,46 @@ public void startGame(){
|
||||
logic.setState(logic.getGameState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectLeave(){
|
||||
currentState.selectLeave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectTSK(Color color){
|
||||
currentState.selectTSK(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deselectTSK(Color color){
|
||||
currentState.deselectTSK(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectReady(boolean ready){
|
||||
currentState.selectReady(ready);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectUnready(){
|
||||
currentState.selectUnready();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
currentState.selectStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectJoin(String string){
|
||||
currentState.selectJoin(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectHost(String name){
|
||||
currentState.selectHost(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
currentState.received(msg);
|
||||
@@ -69,4 +120,23 @@ public void received(LobbyPlayerJoinMessage msg){
|
||||
public void received(LobbyPlayerLeaveMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateTSKMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateReadyMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
public DialogStates getState() {
|
||||
return currentState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.gameState.*;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.PauseGameMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||
import pp.mdga.notification.InterruptNotification;
|
||||
|
||||
public class GameState extends ClientState {
|
||||
|
||||
@@ -38,6 +43,36 @@ public void selectAnimationEnd(){
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PauseGameMessage msg){
|
||||
logic.enterInterrupt();
|
||||
logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingRollAgainMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public GameStates getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public AnimationState getAnimation() {
|
||||
return animationState;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,36 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.message.server.ResumeGameMessage;
|
||||
import pp.mdga.notification.ResumeNotification;
|
||||
|
||||
public class InterruptState extends ClientState {
|
||||
|
||||
private ClientState previousState;
|
||||
|
||||
public InterruptState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
previousState = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
previousState = null;
|
||||
}
|
||||
|
||||
public void setPreviousState(ClientState previousState) {
|
||||
this.previousState = previousState;
|
||||
}
|
||||
|
||||
public ClientState getPreviousState() {
|
||||
return previousState;
|
||||
}
|
||||
|
||||
public void received(ResumeGameMessage msg) {
|
||||
//TODO: logic.addNotification(new ResumeNotification());
|
||||
logic.setState(previousState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,45 @@
|
||||
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;
|
||||
|
||||
public class SettingsState extends ClientState {
|
||||
|
||||
private SettingStates currentState;
|
||||
|
||||
private final MainSettingsState mainSettingsState = new MainSettingsState(this, logic);
|
||||
private final AudioSettingsState audioSettingsState = new AudioSettingsState(this, logic);
|
||||
private final VideoSettingsState videoSettingsState = new VideoSettingsState(this, logic);
|
||||
|
||||
public SettingsState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
currentState = mainSettingsState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
currentState.exit();
|
||||
}
|
||||
|
||||
public SettingStates getState(){
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public MainSettingsState getMainSettingsState(){
|
||||
return mainSettingsState;
|
||||
}
|
||||
|
||||
public AudioSettingsState getAudioSettingsState(){
|
||||
return audioSettingsState;
|
||||
}
|
||||
|
||||
public VideoSettingsState getVideoSettingsState(){
|
||||
return videoSettingsState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package pp.mdga.client.ceremonyState;
|
||||
|
||||
import pp.mdga.client.CeremonyState;
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
|
||||
public class PodiumState extends CeremonyStates {
|
||||
|
||||
private final CeremonyState parent;
|
||||
|
||||
public PodiumState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (CeremonyState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -17,4 +22,8 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
public void selectNext(){
|
||||
parent.setState(parent.getStatisticsState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
import pp.mdga.message.server.LobbyPlayerJoinMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
import pp.mdga.message.server.UpdateTSKMessage;
|
||||
import pp.mdga.notification.TskSelectNotification;
|
||||
import pp.mdga.notification.TskUnselectNotification;
|
||||
|
||||
public class LobbyState extends DialogStates {
|
||||
|
||||
@@ -21,12 +25,10 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +47,7 @@ public void deselectTSK(Color color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectReady() {
|
||||
public void selectReady(boolean ready) {
|
||||
logic.send(new LobbyReadyMessage());
|
||||
}
|
||||
|
||||
@@ -56,7 +58,13 @@ public void selectUnready(){
|
||||
|
||||
@Override
|
||||
public void selectStart(){
|
||||
logic.send(new StartGameMessage());
|
||||
if(logic.isHost() && logic.getGame().allReady()){
|
||||
logic.send(new StartGameMessage(false));
|
||||
} else if(logic.isHost() && !logic.getGame().allReady()) {
|
||||
logic.send(new StartGameMessage(true));
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,8 +77,21 @@ public void received(LobbyPlayerJoinMessage msg){
|
||||
logic.getGame().getPlayers().put(msg.getId(), new Player(msg.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(UpdateTSKMessage msg){
|
||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||
logic.getGame().getPlayers().get(msg.getId()).setColor(msg.getColor());
|
||||
logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), parent.getOwnPlayerId()== msg.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,16 +23,21 @@ public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectJoin(String name) {
|
||||
parent.getOwnPlayer().setName(name);
|
||||
parent.setOwnPlayerName(name);
|
||||
parent.setState(parent.getNetworkDialog());
|
||||
logic.setHost(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectHost(String name) {
|
||||
parent.getOwnPlayer().setName(name);
|
||||
parent.setOwnPlayerName(name);
|
||||
parent.setState(parent.getLobby());
|
||||
logic.setHost(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectLeave() {
|
||||
parent.exit();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
|
||||
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
|
||||
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||
|
||||
public class DetermineStartPlayerState extends GameStates {
|
||||
|
||||
@@ -36,6 +39,26 @@ public void setState(DetermineStartPlayerStates state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice() {
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingRollAgainMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public RollRankingDiceState getRollRankingDice() {
|
||||
return rollRankingDiceState;
|
||||
}
|
||||
@@ -43,4 +66,12 @@ public RollRankingDiceState getRollRankingDice() {
|
||||
public WaitRankingState getWaitRanking() {
|
||||
return waitRankingState;
|
||||
}
|
||||
|
||||
public DetermineStartPlayerStates getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public GameState getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,8 @@ public RollDiceState getRollDice() {
|
||||
public GameState getParent(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
public TurnStates getState(){
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
public class WaitingState extends GameStates {
|
||||
|
||||
@@ -16,6 +19,30 @@ public WaitingState(ClientState parent, ClientGameLogic logic) {
|
||||
this.parent = (GameState) parent;
|
||||
}
|
||||
|
||||
private CeremonyNotification createCeremonyNotification(){
|
||||
CeremonyNotification notification = new CeremonyNotification();
|
||||
for (var player : logic.getGame().getPlayers().entrySet()){
|
||||
notification.getColors().add(player.getValue().getColor());
|
||||
notification.getNames().add(player.getValue().getName());
|
||||
notification.getSixes().add(player.getValue().getPlayerStatistic().getDiced6());
|
||||
notification.getBonusNodes().add(player.getValue().getPlayerStatistic().getActivatedBonusNodes());
|
||||
notification.getPiecesLost().add(player.getValue().getPlayerStatistic().getPiecesBeingThrown());
|
||||
notification.getPiecesThrown().add(player.getValue().getPlayerStatistic().getPiecesThrown());
|
||||
notification.getNodesMoved().add(player.getValue().getPlayerStatistic().getTraveledNodes());
|
||||
notification.getBonusCardsPlayed().add(player.getValue().getPlayerStatistic().getCardsPlayed());
|
||||
}
|
||||
|
||||
notification.getNames().add("GAME OVERALL");
|
||||
notification.getNodesMoved().add(logic.getGame().getGameStatistics().getTraveledNodes());
|
||||
notification.getSixes().add(logic.getGame().getGameStatistics().getDiced6());
|
||||
notification.getPiecesThrown().add(logic.getGame().getGameStatistics().getPiecesThrown());
|
||||
notification.getPiecesLost().add(logic.getGame().getGameStatistics().getPiecesBeingThrown());
|
||||
notification.getBonusNodes().add(logic.getGame().getGameStatistics().getActivatedBonusNodes());
|
||||
notification.getBonusCardsPlayed().add(logic.getGame().getGameStatistics().getCardsPlayed());
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
@@ -28,16 +55,67 @@ public void exit() {
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
logic.addNotification(createCeremonyNotification());
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
logic.addNotification(new DiceNowNotification());
|
||||
parent.setState(parent.getTurn());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
parent.setState(parent.getWaiting());
|
||||
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()));
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
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().getPieceThroughIdentifier(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
|
||||
} else {
|
||||
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
|
||||
}
|
||||
} else {
|
||||
Piece ownPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifierEnemy());
|
||||
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
||||
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
||||
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||
} else if (msg.isHomeMove()){
|
||||
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
|
||||
} else {
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||
logic.addNotification(new ThrowPieceNotification(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant().getUuid()));
|
||||
}
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.notification.DiceNowNotification;
|
||||
|
||||
public class RollRankingDiceState extends DetermineStartPlayerStates {
|
||||
|
||||
@@ -17,7 +18,7 @@ public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
logic.addNotification(new DiceNowNotification());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||
import pp.mdga.notification.ActivePlayerNotification;
|
||||
|
||||
public class WaitRankingState extends DetermineStartPlayerStates {
|
||||
|
||||
@@ -32,6 +33,8 @@ public void received(RankingRollAgainMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
//TODO: implement
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
currentState.exit();
|
||||
currentState= null;
|
||||
}
|
||||
|
||||
public void setState(ChoosePieceStates state){
|
||||
@@ -52,6 +53,10 @@ public WaitingPieceState getWaitingPiece(){
|
||||
return waitingPieceState;
|
||||
}
|
||||
|
||||
public ChoosePieceStates getState(){
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public TurnState getParent(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class MovePieceState extends TurnStates {
|
||||
|
||||
private final TurnState parent;
|
||||
|
||||
public MovePieceState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (TurnState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -17,4 +23,28 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getSpectator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
parent.setState(parent.getRollDice());
|
||||
}
|
||||
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
|
||||
public class PlayPowerCardState extends TurnStates {
|
||||
|
||||
@@ -18,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
logic.addNotification(new PlayCardNotification(null , playCardMessage.getCard())); //TODO: get color
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,4 +31,10 @@ public void exit() {
|
||||
public void setPlayCard(PlayCardMessage playCardMessage) {
|
||||
this.playCardMessage = playCardMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
parent.setState(parent.getRollDice());
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public void enter() {
|
||||
state = choosePowerCardState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
state.exit();
|
||||
state = null;
|
||||
}
|
||||
|
||||
@@ -54,4 +54,8 @@ public SwapState getSwap() {
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public PowerCardStates getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.NoTurnMessage;
|
||||
|
||||
public class RollDiceState extends TurnStates {
|
||||
|
||||
private final TurnState parent;
|
||||
|
||||
public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (TurnState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -15,6 +22,20 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
logic.getGame().setDiceModifier(1);
|
||||
}
|
||||
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void received(DieMessage msg){
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
parent.setState(parent.getChoosePiece());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public void selectPiece(Piece piece) {
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public void selectPiece(Piece piece){
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
|
||||
public class MainSettingsState extends ClientState {
|
||||
public class MainSettingsState extends SettingStates {
|
||||
public MainSettingsState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
public class Board {
|
||||
private Map<Color, PlayerData> playerData;
|
||||
private Node[] infield;
|
||||
private final Node[] infield;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new board
|
||||
|
||||
@@ -14,11 +14,6 @@ public class DieMessage extends ServerMessage {
|
||||
*/
|
||||
private final int diceEye;
|
||||
|
||||
/**
|
||||
* The pieces that can be moved
|
||||
*/
|
||||
private final List<String> moveablePieces;
|
||||
|
||||
/**
|
||||
* Constructor for Dice
|
||||
*
|
||||
@@ -28,7 +23,6 @@ public class DieMessage extends ServerMessage {
|
||||
public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
super();
|
||||
this.diceEye = diceEye;
|
||||
this.moveablePieces = moveablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +30,6 @@ public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
*/
|
||||
private DieMessage() {
|
||||
diceEye = 0;
|
||||
moveablePieces = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,15 +62,6 @@ public int getDiceEye() {
|
||||
return diceEye;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the pieces that can be moved
|
||||
*
|
||||
* @return the pieces that can be moved
|
||||
*/
|
||||
public List<String> getMoveablePieces() {
|
||||
return moveablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -12,14 +12,26 @@ public class MoveMessage extends ServerMessage {
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
|
||||
/**
|
||||
* The index of the target node;
|
||||
*/
|
||||
private final int targetIndex;
|
||||
|
||||
/**
|
||||
* True if the pieces move into the home.
|
||||
*/
|
||||
private final boolean isHomeMove;
|
||||
|
||||
/**
|
||||
* Constructs a new MoveMessage instance.
|
||||
*
|
||||
* @param identifier the identifier of the piece that should be moved
|
||||
*/
|
||||
public MoveMessage(String identifier) {
|
||||
public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
|
||||
super();
|
||||
this.pieceIdentifier = identifier;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +39,8 @@ public MoveMessage(String identifier) {
|
||||
*/
|
||||
private MoveMessage() {
|
||||
pieceIdentifier = null;
|
||||
targetIndex = 0;
|
||||
isHomeMove = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +52,24 @@ public String getIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the target Node.
|
||||
*
|
||||
* @return the target index
|
||||
*/
|
||||
public int getTargetIndex(){
|
||||
return targetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean based on if it is a home move or not.
|
||||
*
|
||||
* @return the boolean isHomeMove.
|
||||
*/
|
||||
public boolean isHomeMove(){
|
||||
return isHomeMove;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class PauseGameMessage extends ServerMessage {
|
||||
|
||||
/**
|
||||
* the id of the player who has disconnected
|
||||
*/
|
||||
private int playerId;
|
||||
|
||||
/**
|
||||
* Constructs a new PauseGame instance.
|
||||
*/
|
||||
@@ -14,6 +20,23 @@ public PauseGameMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new PauseGame instance.
|
||||
*/
|
||||
public PauseGameMessage(int playerId) {
|
||||
super();
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player id of the disconnected player
|
||||
*
|
||||
* @return the id of the disconnected player as an int
|
||||
*/
|
||||
public int getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -20,17 +20,20 @@ public class PlayCardMessage extends ServerMessage {
|
||||
|
||||
private final String pieceIdentifierEnemy;
|
||||
|
||||
private final int diceModifier;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayCard message.
|
||||
*
|
||||
* @param card the card that should be played
|
||||
* @param pieceIdentifier the identifier of the piece that should be moved
|
||||
*/
|
||||
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy, int diceModifier) {
|
||||
super();
|
||||
this.card = card;
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.pieceIdentifierEnemy = pieceIdentifierEnemy;
|
||||
this.diceModifier = diceModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,7 @@ private PlayCardMessage() {
|
||||
this.pieceIdentifierEnemy = null;
|
||||
card = null;
|
||||
pieceIdentifier = null;
|
||||
diceModifier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +54,7 @@ private PlayCardMessage() {
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy);
|
||||
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +64,17 @@ public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifie
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage shield(String pieceIdentifier) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null);
|
||||
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new PlayCardMessage for a turbo card
|
||||
*
|
||||
* @param diceModifier the new modifier of the dice
|
||||
* @return newly constructed message
|
||||
*/
|
||||
public static PlayCardMessage turbo(int diceModifier){
|
||||
return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +104,16 @@ public String getPieceIdentifierEnemy() {
|
||||
return pieceIdentifierEnemy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this method returns the dice modifier
|
||||
*
|
||||
* @return the dice modifier as int
|
||||
*/
|
||||
public int getDiceModifier(){
|
||||
return diceModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -7,11 +7,32 @@
|
||||
*/
|
||||
@Serializable
|
||||
public class RankingResponseMessage extends ServerMessage {
|
||||
|
||||
private final int startingPlayerId;
|
||||
|
||||
/**
|
||||
* Constructs a new RankingResponse instance.
|
||||
*/
|
||||
public RankingResponseMessage(int startingPlayerId) {
|
||||
super();
|
||||
this.startingPlayerId = startingPlayerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new RankingResponse instance.
|
||||
*/
|
||||
public RankingResponseMessage() {
|
||||
super();
|
||||
this.startingPlayerId = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the starting Player.
|
||||
*
|
||||
* @return the id of the starting player as an int
|
||||
*/
|
||||
public int getStartingPlayerId() {
|
||||
return startingPlayerId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,14 +8,20 @@
|
||||
public class SelectPieceMessage extends ServerMessage{
|
||||
|
||||
private final List<String> pieces;
|
||||
private final List<Boolean> isHomeMove;
|
||||
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 targetIndex the List of indexes of target nodes of the pieces
|
||||
*/
|
||||
public SelectPieceMessage(List<String> pieces){
|
||||
public SelectPieceMessage(List<String> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
this.pieces = pieces;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,6 +29,8 @@ public SelectPieceMessage(List<String> pieces){
|
||||
*/
|
||||
public SelectPieceMessage(){
|
||||
pieces = null;
|
||||
isHomeMove = null;
|
||||
targetIndex = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,14 +12,21 @@ public class StartPieceMessage extends ServerMessage {
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
|
||||
/**
|
||||
* The target index of the move;
|
||||
*/
|
||||
private final int targetIndex;
|
||||
|
||||
/**
|
||||
* Constructs a new StartPiece instance with the specified piece identifier.
|
||||
*
|
||||
* @param pieceIdentifier the identifier for the piece
|
||||
* @param targetIndex the index of the targetNode
|
||||
*/
|
||||
public StartPieceMessage(String pieceIdentifier) {
|
||||
public StartPieceMessage(String pieceIdentifier, int targetIndex) {
|
||||
super();
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +35,7 @@ public StartPieceMessage(String pieceIdentifier) {
|
||||
private StartPieceMessage() {
|
||||
super();
|
||||
this.pieceIdentifier = "";
|
||||
this.targetIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +47,15 @@ public String getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the target node
|
||||
*
|
||||
* @return the index of the target node as int.
|
||||
*/
|
||||
public int getTargetIndex(){
|
||||
return targetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@ public class UpdateTSKMessage extends ServerMessage {
|
||||
private final Color color;
|
||||
|
||||
/**
|
||||
* Constructs a new UpdateTSK instance with the specified name and color.
|
||||
* Constructs a new UpdateTSK instance with the specified id and color.
|
||||
*
|
||||
* @param id the name associated with the update
|
||||
* @param color the color associated with the update
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -8,12 +10,14 @@
|
||||
public class AcquireCardNotification extends Notification{
|
||||
|
||||
private UUID cardId;
|
||||
private BonusCard bonusCard;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param cardId The id of the card that was acquired.
|
||||
*/
|
||||
public AcquireCardNotification(UUID cardId) {
|
||||
public AcquireCardNotification(BonusCard bonusCard, UUID cardId) {
|
||||
this.bonusCard = bonusCard;
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
@@ -24,4 +28,8 @@ public AcquireCardNotification(UUID cardId) {
|
||||
public UUID getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
public BonusCard getBonusCard() {
|
||||
return bonusCard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ActivePlayerNotification extends Notification {
|
||||
*/
|
||||
private Color color;
|
||||
|
||||
ActivePlayerNotification(Color color) {
|
||||
public ActivePlayerNotification(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,156 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Class CeremonyNotification
|
||||
* Represents a notification for a ceremony in the game.
|
||||
*
|
||||
* Index mapping:
|
||||
* index = 0 ==> winner
|
||||
* index = 1 ==> 2nd
|
||||
* index = 2 ==> third place
|
||||
* index = 3 ==> loser
|
||||
* index = 4 ==> total
|
||||
*/
|
||||
public class CeremonyNotification extends Notification{
|
||||
public class CeremonyNotification extends Notification {
|
||||
private ArrayList<Color> colors;
|
||||
private ArrayList<String> names;
|
||||
private ArrayList<Integer> piecesThrown;
|
||||
private ArrayList<Integer> piecesLost;
|
||||
private ArrayList<Integer> bonusCardsPlayed;
|
||||
private ArrayList<Integer> sixes;
|
||||
private ArrayList<Integer> nodesMoved;
|
||||
private ArrayList<Integer> bonusNodes;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Initializes all lists.
|
||||
*/
|
||||
CeremonyNotification() {
|
||||
public CeremonyNotification() {
|
||||
this.colors = new ArrayList<>();
|
||||
this.names = new ArrayList<>();
|
||||
this.piecesThrown = new ArrayList<>();
|
||||
this.piecesLost = new ArrayList<>();
|
||||
this.bonusCardsPlayed = new ArrayList<>();
|
||||
this.sixes = new ArrayList<>();
|
||||
this.nodesMoved = new ArrayList<>();
|
||||
this.bonusNodes = new ArrayList<>();
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
/**
|
||||
* @return the list of colors
|
||||
*/
|
||||
public ArrayList<Color> getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors the list of colors to set
|
||||
*/
|
||||
public void setColors(ArrayList<Color> colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of player names
|
||||
*/
|
||||
public ArrayList<String> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param names the list of player names to set
|
||||
*/
|
||||
public void setNames(ArrayList<String> names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of pieces thrown
|
||||
*/
|
||||
public ArrayList<Integer> getPiecesThrown() {
|
||||
return piecesThrown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param piecesThrown the list of pieces thrown to set
|
||||
*/
|
||||
public void setPiecesThrown(ArrayList<Integer> piecesThrown) {
|
||||
this.piecesThrown = piecesThrown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of pieces lost
|
||||
*/
|
||||
public ArrayList<Integer> getPiecesLost() {
|
||||
return piecesLost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param piecesLost the list of pieces lost to set
|
||||
*/
|
||||
public void setPiecesLost(ArrayList<Integer> piecesLost) {
|
||||
this.piecesLost = piecesLost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of bonus cards played
|
||||
*/
|
||||
public ArrayList<Integer> getBonusCardsPlayed() {
|
||||
return bonusCardsPlayed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bonusCardsPlayed the list of bonus cards played to set
|
||||
*/
|
||||
public void setBonusCardsPlayed(ArrayList<Integer> bonusCardsPlayed) {
|
||||
this.bonusCardsPlayed = bonusCardsPlayed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of sixes rolled
|
||||
*/
|
||||
public ArrayList<Integer> getSixes() {
|
||||
return sixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sixes the list of sixes rolled to set
|
||||
*/
|
||||
public void setSixes(ArrayList<Integer> sixes) {
|
||||
this.sixes = sixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of nodes moved
|
||||
*/
|
||||
public ArrayList<Integer> getNodesMoved() {
|
||||
return nodesMoved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodesMoved the list of nodes moved to set
|
||||
*/
|
||||
public void setNodesMoved(ArrayList<Integer> nodesMoved) {
|
||||
this.nodesMoved = nodesMoved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of bonus nodes
|
||||
*/
|
||||
public ArrayList<Integer> getBonusNodes() {
|
||||
return bonusNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bonusNodes the list of bonus nodes to set
|
||||
*/
|
||||
public void setBonusNodes(ArrayList<Integer> bonusNodes) {
|
||||
this.bonusNodes = bonusNodes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ public class DiceNowNotification extends Notification {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
DiceNowNotification() {
|
||||
public DiceNowNotification() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class DicingNotification extends Notification{
|
||||
* Constructor.
|
||||
* @param color The color of the player that diced.
|
||||
*/
|
||||
DicingNotification(Color color) {
|
||||
public DicingNotification(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DrawCardNotification extends Notification {
|
||||
* @param color the color of the player who drew the card
|
||||
* @param card the card that was drawn
|
||||
*/
|
||||
DrawCardNotification(Color color, BonusCard card) {
|
||||
public DrawCardNotification(Color color, BonusCard card) {
|
||||
this.color = color;
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ public class GameNotification extends Notification{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
GameNotification() {
|
||||
public GameNotification() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class HomeMoveNotification extends Notification {
|
||||
* @param pieceId the piece id
|
||||
* @param homeIndex the home index
|
||||
*/
|
||||
HomeMoveNotification(UUID pieceId, int homeIndex) {
|
||||
public HomeMoveNotification(UUID pieceId, int homeIndex) {
|
||||
this.pieceId = pieceId;
|
||||
this.homeIndex = homeIndex;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ public class InterruptNotification extends Notification {
|
||||
private Color color;
|
||||
|
||||
/**
|
||||
* @param color the color of the player who drew the card
|
||||
* @param color the color of the player who disconnected
|
||||
*/
|
||||
InterruptNotification(Color color) {
|
||||
public InterruptNotification(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color of the player who drew the card
|
||||
* @return the color of the player who disconnected
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
|
||||
@@ -7,6 +7,6 @@ public class LobbyDialogNotification extends Notification{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
LobbyDialogNotification() {
|
||||
public LobbyDialogNotification() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,76 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a piece has been moved.
|
||||
*/
|
||||
public class MovePieceNotification extends Notification {
|
||||
|
||||
private Color color;
|
||||
private int nodeIndex;
|
||||
/**
|
||||
* The unique identifier of the piece being moved.
|
||||
*/
|
||||
private final UUID piece;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param color the color of the piece that has been moved.
|
||||
* @param nodeIndex the index of the node the piece has been moved to.
|
||||
* The index of the node from which the piece started moving.
|
||||
* Ignored if {@code moveStart} is {@code true}.
|
||||
*/
|
||||
MovePieceNotification(Color color, int nodeIndex) {
|
||||
this.color = color;
|
||||
this.nodeIndex = nodeIndex;
|
||||
private final int startIndex;
|
||||
|
||||
/**
|
||||
* The index of the node to which the piece is moving.
|
||||
* If {@code moveStart} is {@code true}, this index represents the start node.
|
||||
*/
|
||||
private final int moveIndex;
|
||||
|
||||
/**
|
||||
* Flag indicating that the piece ({@code uuid}) is moving from waiting area to the startNode.
|
||||
*/
|
||||
private final boolean moveStart;
|
||||
|
||||
/**
|
||||
* Constructs a notification for a piece start movement.
|
||||
*
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param moveIndex the destination node index
|
||||
* @param moveStart whether to ignore {@code startIndex} and use {@code moveIndex} as the start node
|
||||
*/
|
||||
public MovePieceNotification(UUID piece, int moveIndex, boolean moveStart) {
|
||||
this.piece = piece;
|
||||
this.startIndex = 0;
|
||||
this.moveIndex = moveIndex;
|
||||
this.moveStart = moveStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color of the piece that has been moved.
|
||||
* @return the color of the piece that has been moved.
|
||||
* Constructs a notification for a piece infield move with {@code moveStart} set to {@code false}.
|
||||
*
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param startIndex the starting node index
|
||||
* @param moveIndex the destination node index
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
public MovePieceNotification(UUID piece, int startIndex, int moveIndex) {
|
||||
this.piece = piece;
|
||||
this.startIndex = startIndex;
|
||||
this.moveIndex = moveIndex;
|
||||
this.moveStart = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of the node the piece has been moved to.
|
||||
* @return the index of the node the piece has been moved to.
|
||||
*/
|
||||
public int getNodeIndex() {
|
||||
return nodeIndex;
|
||||
public int getMoveIndex() {
|
||||
return moveIndex;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public UUID getPiece() {
|
||||
return piece;
|
||||
}
|
||||
|
||||
public boolean isMoveStart() {
|
||||
return moveStart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MoveThrowPieceNotification extends Notification{
|
||||
|
||||
private UUID pieceId1;
|
||||
private UUID pieceId2;
|
||||
private int nodeIndex;
|
||||
private Color colorPiece2;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new MoveThrowPieceNotification
|
||||
*
|
||||
* @param pieceId1 the pieceId1
|
||||
* @param pieceId2 the pieceId2
|
||||
* @param nodeIndex the nodeIndex
|
||||
* @param colorPiece2 the color
|
||||
*/
|
||||
public MoveThrowPieceNotification(UUID pieceId1, UUID pieceId2, int nodeIndex, Color colorPiece2) {
|
||||
this.pieceId1 = pieceId1;
|
||||
this.pieceId2 = pieceId2;
|
||||
this.nodeIndex = nodeIndex;
|
||||
this.colorPiece2 = colorPiece2;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the pieceId1
|
||||
*
|
||||
* @return the pieceId1
|
||||
*/
|
||||
public UUID getPieceId1() {
|
||||
return pieceId1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the pieceId2
|
||||
*
|
||||
* @return the pieceId2
|
||||
*/
|
||||
public UUID getPieceId2() {
|
||||
return pieceId2;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the nodeIndex
|
||||
*
|
||||
* @return the nodeIndex
|
||||
*/
|
||||
public int getNodeIndex() {
|
||||
return nodeIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the color
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
public Color getColor() {
|
||||
return colorPiece2;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
public abstract class Notification {
|
||||
|
||||
public void accept(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a piece is in the game
|
||||
*/
|
||||
public class PieceInGameNotification extends Notification{
|
||||
private Color color;
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param color the color of the piece
|
||||
* @param id the id of the piece
|
||||
*/
|
||||
PieceInGameNotification(Color color, UUID id) {
|
||||
this.color = color;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color of the piece
|
||||
*/
|
||||
public Color getColor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the piece
|
||||
*/
|
||||
public UUID getId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class PlayCardNotification extends Notification {
|
||||
* @param color the color of the player that played the card.
|
||||
* @param card the card that was played.
|
||||
*/
|
||||
PlayCardNotification(Color color, BonusCard card) {
|
||||
public PlayCardNotification(Color color, BonusCard card) {
|
||||
this.color = color;
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a player is in the game.
|
||||
*/
|
||||
@@ -9,15 +12,17 @@ public class PlayerInGameNotification extends Notification {
|
||||
|
||||
private Color color;
|
||||
private String name;
|
||||
private List<UUID> piecesList;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param color the color of the player that is in the game.
|
||||
* @param name the name of the player that is in the game.
|
||||
*/
|
||||
PlayerInGameNotification(Color color, String name) {
|
||||
public PlayerInGameNotification(Color color, List<UUID> piecesList, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
this.piecesList = piecesList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,4 +40,8 @@ public Color getColor() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<UUID> getPiecesList() {
|
||||
return piecesList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ResumeNotification extends Notification {
|
||||
* Constructor.
|
||||
* @param color the color of the player that is in the game.
|
||||
*/
|
||||
ResumeNotification(Color color) {
|
||||
public ResumeNotification(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class RollDiceNotification extends Notification{
|
||||
* @param eyes the number of eyes that were rolled.
|
||||
* @param moveNumber the number of the move that was made.
|
||||
*/
|
||||
RollDiceNotification(Color color, int eyes, int moveNumber) {
|
||||
public RollDiceNotification(Color color, int eyes, int moveNumber) {
|
||||
this.color = color;
|
||||
this.eyes = eyes;
|
||||
this.moveNumber = moveNumber;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class SelectableCardsNotification extends Notification {
|
||||
* Constructor.
|
||||
* @param cards The list of cards that the player can choose from.
|
||||
*/
|
||||
SelectableCardsNotification(List<BonusCard> cards) {
|
||||
public SelectableCardsNotification(List<BonusCard> cards) {
|
||||
this.cards = cards;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification for selecting pieces and their possible moves.
|
||||
*/
|
||||
public class SelectableMoveNotification extends Notification{
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the pieces that can be moved based on the dice roll.
|
||||
*/
|
||||
private final List<UUID> pieces;
|
||||
|
||||
/**
|
||||
* List of integers representing the target nodes the pieces can move to.
|
||||
*/
|
||||
private final List<Integer> moveIndexe;
|
||||
|
||||
/**
|
||||
* List of booleans indicating whether the corresponding target nodes are in the home area.
|
||||
* {@code true} if the target node is in the home area, {@code false} if in the infield.
|
||||
*/
|
||||
private final List<Boolean> homeMoves;
|
||||
|
||||
/**
|
||||
* Constructs a notification for selectable piece moves.
|
||||
*
|
||||
* @param pieces the list of pieces that can be moved
|
||||
* @param moveIndexe the list of target nodes for the moves
|
||||
* @param homeMoves the list indicating if the target nodes are in the home area
|
||||
*/
|
||||
public SelectableMoveNotification(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
|
||||
this.pieces = pieces;
|
||||
this.moveIndexe = moveIndexe;
|
||||
this.homeMoves = homeMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of pieces that can be moved.
|
||||
*
|
||||
* @return a list of UUIDs representing the movable pieces
|
||||
*/
|
||||
public List<UUID> getPieces() {
|
||||
return pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of target nodes for the moves.
|
||||
*
|
||||
* @return a list of integers representing the target nodes
|
||||
*/
|
||||
public List<Integer> getMoveIndexe() {
|
||||
return moveIndexe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list indicating whether the target nodes are in the home area.
|
||||
*
|
||||
* @return a list of booleans, {@code true} if the target node is in the home area, {@code false} otherwise
|
||||
*/
|
||||
public List<Boolean> getHomeMoves() {
|
||||
return homeMoves;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification to inform the client about the selectable pieces.
|
||||
*/
|
||||
public class SelectablePiecesNotification extends Notification{
|
||||
|
||||
private List<UUID> selectablePieces;
|
||||
|
||||
/**
|
||||
* @param selectablePieces
|
||||
*/
|
||||
SelectablePiecesNotification(List<UUID> selectablePieces){
|
||||
this.selectablePieces = selectablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List<UUID>
|
||||
*/
|
||||
public List<UUID> getSelectablePieces(){
|
||||
return selectablePieces;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification for selecting pieces for swapcard.
|
||||
*/
|
||||
public class SelectableSwapNotification extends Notification{
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the player's own pieces available for selection.
|
||||
*/
|
||||
private final List<UUID> ownPieces;
|
||||
|
||||
/**
|
||||
* List of UUIDs representing the opponent's pieces available for selection.
|
||||
*/
|
||||
private final List<UUID> enemyPieces;
|
||||
|
||||
/**
|
||||
* Constructs a notification for selecting pieces for swapcard.
|
||||
*
|
||||
* @param ownPieces the list of the player's own pieces
|
||||
* @param enemyPieces the list of the opponent's pieces
|
||||
*/
|
||||
public SelectableSwapNotification(List<UUID> ownPieces, List<UUID> enemyPieces) {
|
||||
this.ownPieces = ownPieces;
|
||||
this.enemyPieces = enemyPieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the player's own pieces available for selection.
|
||||
*
|
||||
* @return a list of UUIDs representing the player's own pieces
|
||||
*/
|
||||
public List<UUID> getOwnPieces() {
|
||||
return ownPieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of the opponent's pieces available for selection.
|
||||
*
|
||||
* @return a list of UUIDs representing the opponent's pieces
|
||||
*/
|
||||
public List<UUID> getEnemyPieces() {
|
||||
return enemyPieces;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ public class StartDialogNotification extends Notification{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
StartDialogNotification() {
|
||||
public StartDialogNotification() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SwapPieceNotification extends Notification {
|
||||
* @param firstPiece the UUID of the first piece that has been swapped.
|
||||
* @param secondPiece the UUID of the second piece that has been swapped.
|
||||
*/
|
||||
SwapPieceNotification(UUID firstPiece, UUID secondPiece) {
|
||||
public SwapPieceNotification(UUID firstPiece, UUID secondPiece) {
|
||||
assert(!firstPiece.equals(secondPiece));
|
||||
this.firstPiece = firstPiece;
|
||||
this.secondPiece = secondPiece;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ThrowPieceNotification extends Notification{
|
||||
|
||||
private UUID pieceId;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new ThrowPieceNotification
|
||||
*/
|
||||
public ThrowPieceNotification(UUID pieceId) {
|
||||
this.pieceId = pieceId;
|
||||
}
|
||||
|
||||
public UUID getPieceId() {
|
||||
return pieceId;
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,19 @@
|
||||
*/
|
||||
public class TskSelectNotification extends Notification{
|
||||
|
||||
private Color color;
|
||||
private String name;
|
||||
private boolean self;
|
||||
private final Color color;
|
||||
private final String name;
|
||||
private final boolean isSelf;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param color the color of the player that is in the game.
|
||||
* @param name the name of the player that is in the game.
|
||||
* @param self true if it was the local player selecting the tsk, false otherwise
|
||||
*/
|
||||
TskSelectNotification(Color color, String name, boolean self) {
|
||||
public TskSelectNotification(Color color, String name, boolean isSelf) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
this.self = self;
|
||||
this.isSelf = isSelf;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,10 +39,11 @@ public String getName() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if it was the local player selecting this tsk.
|
||||
* @return ture if it was the local player selecting the tsk.
|
||||
* returns a boolean based of if the select notification affects the own user
|
||||
*
|
||||
* @return boolean isSelf
|
||||
*/
|
||||
public boolean isSelf() {
|
||||
return self;
|
||||
return isSelf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class TskUnselectNotification extends Notification{
|
||||
* Constructor
|
||||
* @param color
|
||||
*/
|
||||
TskUnselectNotification(Color color){
|
||||
public TskUnselectNotification(Color color){
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user