Merge development
This commit is contained in:
@@ -58,7 +58,7 @@ private void handleLobby(Notification notification) {
|
||||
LobbyView lobbyView = (LobbyView) app.getView();
|
||||
|
||||
if (notification instanceof TskSelectNotification n) {
|
||||
//lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||
lobbyView.setTaken(n.getColor(), true, false, n.getName());
|
||||
} else if (notification instanceof TskUnselectNotification n) {
|
||||
lobbyView.setTaken(n.getColor(), false, false, null);
|
||||
@@ -81,7 +81,7 @@ private void handleGame(Notification notification) {
|
||||
} else if (notification instanceof ActivePlayerNotification n) {
|
||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
||||
/*app.enter(MdgaState.CEREMONY);
|
||||
app.enter(MdgaState.CEREMONY);
|
||||
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||
int size = ceremonyNotification.getNames().size();
|
||||
|
||||
@@ -106,7 +106,7 @@ private void handleGame(Notification notification) {
|
||||
|
||||
ceremonyView.addCeremonyParticipant(color, i, name);
|
||||
ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
||||
}*/
|
||||
}
|
||||
} else if (notification instanceof DiceNowNotification) {
|
||||
guiHandler.showDice();
|
||||
} else if (notification instanceof DicingNotification n) {
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
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);
|
||||
@@ -9,11 +18,30 @@ public CeremonyState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
currentState = podiumState;
|
||||
logic.addNotification(createCeremonyNotification());
|
||||
}
|
||||
|
||||
@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,18 @@ public ClientState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public boolean isHost(){
|
||||
return isHost;
|
||||
}
|
||||
|
||||
public int getCalculatedMoves(){
|
||||
return game.getDiceEyes() * game.getDiceModifier();
|
||||
}
|
||||
|
||||
public void setHost(boolean isHost){
|
||||
this.isHost = isHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
state.received(msg);
|
||||
@@ -201,16 +216,19 @@ 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 selectNext(){
|
||||
state.selectNext();
|
||||
}
|
||||
|
||||
public void selectCard(BonusCard card){
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
public void selectTsk(Color color){
|
||||
@@ -226,7 +244,7 @@ public void selectName(String name){
|
||||
}
|
||||
|
||||
public void selectReady(boolean ready){
|
||||
state.selectReady();
|
||||
state.selectReady(ready);
|
||||
}
|
||||
|
||||
public void selectHost(String name){
|
||||
@@ -237,8 +255,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(){
|
||||
@@ -249,12 +267,22 @@ public void selectStart(){
|
||||
state.selectStart();
|
||||
}
|
||||
|
||||
public void selectResume(){
|
||||
state.selectResume();
|
||||
}
|
||||
|
||||
public void setState(ClientState state){
|
||||
this.state.exit();
|
||||
state.enter();
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void enterInterrupt(){
|
||||
interruptState.enter();
|
||||
interruptState.setPreviousState(state);
|
||||
this.state = interruptState;
|
||||
}
|
||||
|
||||
public GameState getGameState(){
|
||||
return gameState;
|
||||
}
|
||||
@@ -271,8 +299,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.CeremonyNotification;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
@@ -199,7 +200,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 +208,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.");
|
||||
}
|
||||
|
||||
@@ -230,4 +231,36 @@ public void selectStart(){
|
||||
public void selectAnimationEnd(){
|
||||
LOGGER.log(Level.DEBUG, "Animation end not allowed");
|
||||
}
|
||||
|
||||
public void selectNext(){
|
||||
LOGGER.log(Level.DEBUG, "Next not allowed");
|
||||
}
|
||||
|
||||
public void selectResume(){
|
||||
LOGGER.log(Level.DEBUG, "Resume not allowed");
|
||||
}
|
||||
|
||||
protected 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,10 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.client.gameState.*;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.InterruptNotification;
|
||||
|
||||
public class GameState extends ClientState {
|
||||
|
||||
@@ -38,6 +42,111 @@ public void selectAnimationEnd(){
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
state.selectPiece(piece);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public GameStates getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public AnimationState getAnimation() {
|
||||
return animationState;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,44 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.message.client.ForceContinueGameMessage;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectResume(){
|
||||
if(logic.isHost()){
|
||||
logic.send(new ForceContinueGameMessage());
|
||||
}
|
||||
}
|
||||
|
||||
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,9 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNext(){
|
||||
parent.setState(parent.getStatisticsState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,9 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNext(){
|
||||
logic.setState(logic.getDialogs());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,48 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
||||
import pp.mdga.notification.SwapPieceNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
|
||||
public abstract class GameStates extends ClientState {
|
||||
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)){
|
||||
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);
|
||||
}
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard());
|
||||
logic.getGame().getDiscardPile().add(msg.getCard());
|
||||
}
|
||||
|
||||
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.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,18 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
public class SpectatorState extends GameStates {
|
||||
|
||||
private final GameState parent;
|
||||
|
||||
public SpectatorState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (GameState) parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,4 +30,55 @@ public void exit() {
|
||||
public void received(CeremonyMessage msg){
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||
logic.getGame().getGameStatistics().increaseDiced6();
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||
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 (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);
|
||||
} 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)){
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
} else {
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
}
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
import pp.mdga.client.gameState.turnState.PowerCardState;
|
||||
import pp.mdga.client.gameState.turnState.RollDiceState;
|
||||
import pp.mdga.client.gameState.turnState.TurnStates;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.message.server.NoTurnMessage;
|
||||
import pp.mdga.message.server.SpectatorMessage;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class TurnState extends GameStates {
|
||||
|
||||
@@ -47,23 +46,83 @@ public void setState(TurnStates state){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
parent.setState(parent.getWaiting());
|
||||
public void selectPiece(Piece piece){
|
||||
state.selectPiece(piece);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
parent.setState(parent.getWaiting());
|
||||
public void selectCard(BonusCard card){
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
logic.setState(logic.getCeremony());
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
parent.setState(parent.getSpectator());
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
public ChoosePieceState getChoosePiece() {
|
||||
@@ -89,4 +148,8 @@ public RollDiceState getRollDice() {
|
||||
public GameState getParent(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
public TurnStates getState(){
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
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 {
|
||||
|
||||
@@ -31,26 +36,58 @@ public void received(CeremonyMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
logic.addNotification(new DiceNowNotification());
|
||||
parent.setState(parent.getTurn());
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||
logic.getGame().getGameStatistics().increaseDiced6();
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||
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 (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);
|
||||
} 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)){
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
} else {
|
||||
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.client.gameState.turnState.choosePieceState.*;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class ChoosePieceState extends TurnStates {
|
||||
|
||||
@@ -27,7 +29,8 @@ public void enter() {
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
currentState.exit();
|
||||
currentState= null;
|
||||
}
|
||||
|
||||
public void setState(ChoosePieceStates state){
|
||||
@@ -36,6 +39,36 @@ public void setState(ChoosePieceStates state){
|
||||
currentState.enter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
currentState.selectPiece(piece);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
public NoPieceState getNoPiece(){
|
||||
return noPieceState;
|
||||
}
|
||||
@@ -52,6 +85,10 @@ public WaitingPieceState getWaitingPiece(){
|
||||
return waitingPieceState;
|
||||
}
|
||||
|
||||
public ChoosePieceStates getState(){
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public TurnState getParent(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
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.*;
|
||||
|
||||
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 +24,33 @@ public void enter() {
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
|
||||
@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,15 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.TurnState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
||||
import pp.mdga.notification.SwapPieceNotification;
|
||||
|
||||
public class PlayPowerCardState extends TurnStates {
|
||||
|
||||
@@ -18,7 +26,8 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
|
||||
handlePowerCard(playCardMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,4 +38,10 @@ public void exit() {
|
||||
public void setPlayCard(PlayCardMessage playCardMessage) {
|
||||
this.playCardMessage = playCardMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
parent.setState(parent.getRollDice());
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
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;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.message.server.PossibleCardMessage;
|
||||
import pp.mdga.message.server.PossiblePieceMessage;
|
||||
|
||||
public class PowerCardState extends TurnStates {
|
||||
|
||||
@@ -28,8 +34,8 @@ public void enter() {
|
||||
state = choosePowerCardState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
state.exit();
|
||||
state = null;
|
||||
}
|
||||
|
||||
@@ -39,6 +45,36 @@ public void setState(PowerCardStates state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(BonusCard card) {
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece) {
|
||||
state.selectPiece(piece);
|
||||
}
|
||||
|
||||
public ChoosePowerCardState getChoosePowerCard() {
|
||||
return choosePowerCardState;
|
||||
}
|
||||
@@ -54,4 +90,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.message.server.StartPieceMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.SelectableMoveNotification;
|
||||
import pp.mdga.notification.WaitMoveNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -31,16 +35,21 @@ public void exit() {
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg) {
|
||||
parent.setState(parent.getSelectPiece());
|
||||
parent.getSelectPiece().setPossiblePieces(msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new));
|
||||
parent.getSelectPiece().setPossiblePieces(pieces);
|
||||
logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
logic.addNotification(new WaitMoveNotification(msg.getPieceID()));
|
||||
parent.setState(parent.getWaitingPiece());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
//TODO: logic.addNotification(null);
|
||||
parent.setState(parent.getStartPiece());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.notification.HomeMoveNotification;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -42,6 +44,19 @@ public void selectPiece(Piece piece){
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
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);
|
||||
} 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();
|
||||
}
|
||||
logic.addNotification(new MovePieceNotification(piece.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
|
||||
}
|
||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
import pp.mdga.message.client.NoPowerCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.message.server.PossibleCardMessage;
|
||||
import pp.mdga.message.server.PossiblePieceMessage;
|
||||
import pp.mdga.notification.SelectableCardsNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -36,6 +38,7 @@ public void exit() {
|
||||
@Override
|
||||
public void received(PossibleCardMessage msg){
|
||||
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
|
||||
logic.addNotification(new SelectableCardsNotification(possibleCards));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +50,15 @@ public void selectCard(BonusCard card){
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getRollDice());
|
||||
@@ -55,12 +67,12 @@ public void received(DiceNowMessage msg){
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
if (msg.getEnemyPossiblePieces().isEmpty()){
|
||||
parent.setState(parent.getShield());
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getShield());
|
||||
} else {
|
||||
parent.setState(parent.getSwap());
|
||||
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getSwap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@ public class ShieldState extends PowerCardStates {
|
||||
public ShieldState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (PowerCardState) parent;
|
||||
possiblePieces = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
possiblePieces = new ArrayList<>();
|
||||
logic.addNotification(null);
|
||||
//TODO: selectable piece notification
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +48,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.SelectableSwapNotification;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SwapState extends PowerCardStates {
|
||||
@@ -21,12 +23,15 @@ public class SwapState extends PowerCardStates {
|
||||
public SwapState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (PowerCardState) parent;
|
||||
possibleOwnPieces = new ArrayList<>();
|
||||
possibleEnemyPieces = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
possibleOwnPieces = new ArrayList<>();
|
||||
possibleEnemyPieces = new ArrayList<>();
|
||||
ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
|
||||
ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
|
||||
logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,7 +62,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);
|
||||
}
|
||||
|
||||
@@ -163,6 +163,15 @@ public void increaseTraveledNodes() {
|
||||
traveledNodes++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of traveledNodes by the given amount.
|
||||
*
|
||||
* @param nodes the amount of nodes to increase the traveledNodes by.
|
||||
*/
|
||||
public void increaseTraveledNodes(int nodes) {
|
||||
traveledNodes += nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method increases the value of cardsPlayed by 1.
|
||||
*/
|
||||
|
||||
@@ -14,50 +14,21 @@ public class DieMessage extends ServerMessage {
|
||||
*/
|
||||
private final int diceEye;
|
||||
|
||||
/**
|
||||
* The pieces that can be moved
|
||||
*/
|
||||
private final List<String> moveablePieces;
|
||||
|
||||
/**
|
||||
* Constructor for Dice
|
||||
*
|
||||
* @param diceEye the eye of the dice
|
||||
* @param moveablePieces the pieces that can be moved
|
||||
*/
|
||||
public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
public DieMessage(int diceEye) {
|
||||
super();
|
||||
this.diceEye = diceEye;
|
||||
this.moveablePieces = moveablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private DieMessage() {
|
||||
public DieMessage() {
|
||||
diceEye = 0;
|
||||
moveablePieces = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for inactivePlayer
|
||||
*
|
||||
* @param diceEye the eye of the dice
|
||||
* @return a new Dice object
|
||||
*/
|
||||
public static DieMessage inactivePlayer(int diceEye) {
|
||||
return new DieMessage(diceEye, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for activePlayer
|
||||
*
|
||||
* @param diceEye the eye of the dice
|
||||
* @param moveablePieces the pieces that can be moved
|
||||
* @return a new Dice object
|
||||
*/
|
||||
public static DieMessage activePlayer(int diceEye, List<String> moveablePieces) {
|
||||
return new DieMessage(diceEye, moveablePieces);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,15 +40,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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,24 @@ public List<String> getPieces(){
|
||||
return pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if a move is a home move for an index
|
||||
*
|
||||
* @return List of boolean values
|
||||
*/
|
||||
public List<Boolean> getIsHomeMove(){
|
||||
return isHomeMove;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the target index of the pieces
|
||||
*
|
||||
* @return List of integers
|
||||
*/
|
||||
public List<Integer> 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
|
||||
|
||||
@@ -2,16 +2,39 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to choose a piece from the waiting area.
|
||||
*/
|
||||
@Serializable
|
||||
public class WaitPieceMessage extends ServerMessage {
|
||||
|
||||
private final UUID pieceID;
|
||||
|
||||
/**
|
||||
* Constructs a new WaitPiece instance.
|
||||
*/
|
||||
public WaitPieceMessage(UUID pieceID) {
|
||||
super();
|
||||
this.pieceID = pieceID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new WaitPiece instance.
|
||||
*/
|
||||
public WaitPieceMessage() {
|
||||
super();
|
||||
this.pieceID = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the pieceID
|
||||
*
|
||||
* @return the pieceID
|
||||
*/
|
||||
public UUID getPieceID() {
|
||||
return pieceID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ public class ThrowPieceNotification extends Notification{
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new ThrowPieceNotification
|
||||
*
|
||||
* @param pieceId1 the pieceId1
|
||||
* @param pieceId2 the pieceId2
|
||||
* @param nodeIndex the nodeIndex
|
||||
* @param colorPiece2 the color
|
||||
*/
|
||||
public ThrowPieceNotification(UUID pieceId) {
|
||||
this.pieceId = 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
|
||||
*/
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user