Merge branch 'development' into 'dev/test'
merge development into test See merge request progproj/gruppen-ht24/Gruppe-01!26
This commit was merged in pull request #26.
This commit is contained in:
@@ -125,7 +125,7 @@ public void received(LobbyDenyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg) {
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -267,6 +267,10 @@ public void selectStart(){
|
||||
state.selectStart();
|
||||
}
|
||||
|
||||
public void selectResume(){
|
||||
state.selectResume();
|
||||
}
|
||||
|
||||
public void setState(ClientState state){
|
||||
this.state.exit();
|
||||
state.enter();
|
||||
|
||||
@@ -86,7 +86,7 @@ public void received(LobbyDenyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg) {
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg);
|
||||
}
|
||||
|
||||
@@ -236,6 +236,10 @@ 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()){
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
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.*;
|
||||
|
||||
public class DialogsState extends ClientState {
|
||||
@@ -112,7 +111,7 @@ public void selectHost(String name){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
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.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.InterruptNotification;
|
||||
|
||||
public class GameState extends ClientState {
|
||||
@@ -48,6 +47,16 @@ 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();
|
||||
@@ -69,6 +78,71 @@ 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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
import pp.mdga.message.client.ForceContinueGameMessage;
|
||||
import pp.mdga.message.server.ResumeGameMessage;
|
||||
import pp.mdga.notification.ResumeNotification;
|
||||
|
||||
@@ -29,6 +30,13 @@ 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);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
|
||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
@@ -25,6 +25,7 @@ public LobbyState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
logic.send(new JoinedLobbyMessage(parent.getOwnPlayerName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,8 +74,8 @@ public void received(ServerStartGameMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinMessage msg){
|
||||
logic.getGame().getPlayers().put(msg.getId(), new Player(msg.getName()));
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
@@ -20,16 +21,16 @@ 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()));
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
} else {
|
||||
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
}
|
||||
} else {
|
||||
Piece ownPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifierEnemy());
|
||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(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);
|
||||
@@ -45,5 +46,6 @@ protected void throwPiece(Piece piece){
|
||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||
piece.setState(PieceState.WAITING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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().getPieceThroughUUID(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() {
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
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.game.*;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
@@ -69,11 +66,18 @@ public void received(ActivePlayerMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(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);
|
||||
for(int i = msg.getTargetIndex() + 1; i < 4; i++){
|
||||
if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
|
||||
pieceToMove.setState(PieceState.HOME);
|
||||
break;
|
||||
}
|
||||
pieceToMove.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
} else {
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
|
||||
throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -37,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;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,9 @@
|
||||
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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public void exit() {
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg) {
|
||||
parent.setState(parent.getSelectPiece());
|
||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(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()));
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public void received(WaitPieceMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
//TODO: logic.addNotification(null);
|
||||
parent.setState(parent.getStartPiece());
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ public void setPossiblePieces(ArrayList<Piece> possiblePieces){
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(possiblePieces.contains(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece piece = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
if(msg.isHomeMove()){
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
|
||||
@@ -31,7 +31,7 @@ public void exit() {
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(moveablePiece.equals(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
|
||||
@@ -29,12 +30,14 @@ public void exit() {
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(moveablePiece.equals(piece)){
|
||||
logic.send(new SelectedPiecesMessage(piece.getIdentifier()));
|
||||
logic.send(new SelectedPiecesMessage(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
|
||||
pieceToMove.setState(PieceState.ACTIVE);
|
||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,32 +15,55 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* State where the player can choose a power card
|
||||
*/
|
||||
public class ChoosePowerCardState extends PowerCardStates {
|
||||
|
||||
private final PowerCardState parent;
|
||||
private ArrayList<BonusCard> possibleCards;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param parent parent state
|
||||
* @param logic game logic
|
||||
*/
|
||||
public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
this.parent = (PowerCardState) parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter the state
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
possibleCards = new ArrayList<>();
|
||||
//TODO: logic.send(new RequestPossibleCardsMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the state
|
||||
*/
|
||||
@Override
|
||||
public void exit() {
|
||||
possibleCards = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the possible cards
|
||||
* @param msg possible cards message
|
||||
*/
|
||||
@Override
|
||||
public void received(PossibleCardMessage msg){
|
||||
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
|
||||
logic.addNotification(new SelectableCardsNotification(possibleCards));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a card
|
||||
* @param card card to select
|
||||
*/
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
if(card != null){
|
||||
@@ -50,6 +73,10 @@ public void selectCard(BonusCard card){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive a card
|
||||
* @param msg card message
|
||||
*/
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
||||
@@ -59,19 +86,27 @@ public void received(PlayCardMessage msg){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive a die now message
|
||||
* @param msg dice now message
|
||||
*/
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
parent.getParent().setState(parent.getParent().getRollDice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive a possible piece message and decide if the player can swap or shield
|
||||
* @param msg possible piece message
|
||||
*/
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
if (msg.getEnemyPossiblePieces().isEmpty()){
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughIdentifier(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getShield());
|
||||
} else {
|
||||
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.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getSwap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||
|
||||
public void selectPiece(Piece piece) {
|
||||
if (possiblePieces.contains(piece)) {
|
||||
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getIdentifier()));
|
||||
logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
|
||||
} else {
|
||||
LOGGER.log(Level.DEBUG, "Invalid piece selected");
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public void selectPiece(Piece piece){
|
||||
selectedEnemyPiece = piece;
|
||||
}
|
||||
if (selectedOwnPiece != null && selectedEnemyPiece != null){
|
||||
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getIdentifier(), selectedEnemyPiece.getIdentifier()));
|
||||
logic.send(RequestPlayCardMessage.requestPlaySwap(selectedOwnPiece.getUuid(), selectedEnemyPiece.getUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,12 @@ public void setPieceOnBoard(int index, Piece piece) {
|
||||
infield[index].setOccupant(piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the index of a specific piece on the board
|
||||
*
|
||||
* @param piece the piece to be searched for
|
||||
* @return the index of the piece
|
||||
*/
|
||||
public int getInfieldIndexOfPiece(Piece piece) {
|
||||
for (int i = 0; i < infield.length; i++) {
|
||||
if (infield[i].getOccupant() == piece) {
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Enum representing the different types of bonus cards.
|
||||
*/
|
||||
public enum BonusCard {
|
||||
/**
|
||||
* The hidden bonus card.
|
||||
*/
|
||||
HIDDEN,
|
||||
/**
|
||||
* The shield bonus card.
|
||||
*/
|
||||
SHIELD,
|
||||
/**
|
||||
* The turbo bonus card.
|
||||
*/
|
||||
TURBO,
|
||||
/**
|
||||
* The swap bonus card.
|
||||
*/
|
||||
SWAP
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* This class represents a BonusNode
|
||||
*/
|
||||
public class BonusNode extends Node {
|
||||
|
||||
public BonusNode() {}
|
||||
|
||||
/**
|
||||
* This method is used to set a new Occupant
|
||||
*
|
||||
* @param occupant the new occupant of the node
|
||||
*/
|
||||
@Override
|
||||
public void setOccupant(Piece occupant) {
|
||||
if (occupant.isSuppressed()){
|
||||
occupant.setShield(ShieldState.NONE);
|
||||
}
|
||||
//Draw Card Event
|
||||
this.occupant = occupant;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,58 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* This enumeration will be used to show the four different TSK which can be picked from a player.
|
||||
* In Addition, the NONE color will be used to show a none color.
|
||||
*/
|
||||
public enum Color {
|
||||
/**
|
||||
* Represents the air force color.
|
||||
*/
|
||||
AIRFORCE,
|
||||
/**
|
||||
* Represents the cyber color.
|
||||
*/
|
||||
CYBER,
|
||||
/**
|
||||
* Represents the navy color.
|
||||
*/
|
||||
NAVY,
|
||||
ARMY;
|
||||
/**
|
||||
* Represents the army color.
|
||||
*/
|
||||
ARMY,
|
||||
/**
|
||||
* Represents the none color.
|
||||
*/
|
||||
NONE;
|
||||
|
||||
/**
|
||||
* This method will be used to return a Color enumeration depending on the given index parameter.
|
||||
*
|
||||
* @param index as the index of the color inside the values as an Integer.
|
||||
* @return a Color enumeration.
|
||||
*/
|
||||
public static Color getColorByIndex(int index) {
|
||||
if (index < 0 || index >= values().length) {
|
||||
throw new IllegalArgumentException("");
|
||||
}
|
||||
|
||||
return values()[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to calculate the next color inside the sequence.
|
||||
*
|
||||
* @return color as a Color Enumeration.
|
||||
*/
|
||||
public Color next() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
Color[] colors = values();
|
||||
int nextIndex = (this.ordinal() + 1) % colors.length;
|
||||
|
||||
if (colors[nextIndex] == NONE) {
|
||||
nextIndex = (nextIndex + 1) % colors.length;
|
||||
}
|
||||
|
||||
return colors[nextIndex];
|
||||
}
|
||||
}
|
||||
|
||||
133
Projekte/mdga/model/src/main/java/pp/mdga/game/Die.java
Normal file
133
Projekte/mdga/model/src/main/java/pp/mdga/game/Die.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
/**
|
||||
* This class represents a simple die with the possibilities to shuffle and return the roll result.
|
||||
* An important fact, the sum of ZERO_EYE, NORMAL_EYE and DOUBLE_EYE have to be 1.0;
|
||||
*/
|
||||
public class Die {
|
||||
/**
|
||||
* The maximum number of eyes on the die.
|
||||
*/
|
||||
public static final int MAXIMUM_EYES = 6;
|
||||
|
||||
/**
|
||||
* The probability of rolling a zero eye.
|
||||
*/
|
||||
public static final double ZERO_EYE = 0.2;
|
||||
|
||||
/**
|
||||
* The probability of rolling a normal eye.
|
||||
*/
|
||||
public static final double NORMAL_EYE = 0.2;
|
||||
|
||||
/**
|
||||
* The probability of rolling a double eye.
|
||||
*/
|
||||
public static final double DOUBLE_EYE = 0.6;
|
||||
|
||||
/**
|
||||
* The modifier applied to the die roll.
|
||||
*/
|
||||
private int dieModifier = 1;
|
||||
|
||||
/**
|
||||
* The random number generator used for die rolls.
|
||||
*/
|
||||
private final RandomGenerator random;
|
||||
|
||||
/**
|
||||
* The result of the last die roll.
|
||||
*/
|
||||
private int lastNumberOfDice;
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new Die object with a random seed.
|
||||
*/
|
||||
public Die() {
|
||||
this.random = RandomGeneratorFactory.of("Random").create();
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used to create a new Die object with a given seed.
|
||||
*
|
||||
* @param seed the seed for the random number generator
|
||||
*/
|
||||
public Die(long seed) {
|
||||
this.random = RandomGeneratorFactory.of("Random").create(seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return a random number generated by the random attribute of Die class.
|
||||
*
|
||||
* @return lastNumberOfDice as an Integer.
|
||||
*/
|
||||
public int shuffle() {
|
||||
this.lastNumberOfDice = this.random.nextInt(MAXIMUM_EYES) + 1;
|
||||
|
||||
return this.lastNumberOfDice;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return the given roll parameter.
|
||||
* It will be used for test cases.
|
||||
*
|
||||
* @param roll as the roll result which will be returned as an Integer.
|
||||
* @return lastNumberOfDice as an Integer.
|
||||
*/
|
||||
public int shuffle(int roll) {
|
||||
this.lastNumberOfDice = roll;
|
||||
|
||||
return this.lastNumberOfDice;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to modify the value of dieModifier attribute of Die class.
|
||||
*/
|
||||
public void modify() {
|
||||
float randomFloat = this.random.nextFloat();
|
||||
if (randomFloat < ZERO_EYE) {
|
||||
this.dieModifier = 0;
|
||||
} else if (ZERO_EYE <= randomFloat && randomFloat < ZERO_EYE + NORMAL_EYE) {
|
||||
this.dieModifier = 1;
|
||||
} else if (ZERO_EYE + NORMAL_EYE <= randomFloat && randomFloat < ZERO_EYE + NORMAL_EYE + DOUBLE_EYE) {
|
||||
this.dieModifier = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to reset all values of the Die class to its origins.
|
||||
*/
|
||||
public void reset() {
|
||||
this.dieModifier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return dieModifier attribute of Die class.
|
||||
*
|
||||
* @return dieModifier as an Integer.
|
||||
*/
|
||||
public int getDieModifier() {
|
||||
return this.dieModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used return lastNumberOfDice attribute of Die class.
|
||||
*
|
||||
* @return lastNumberOfDice as an Integer.
|
||||
*/
|
||||
public int getLastNumberOfDice() {
|
||||
return this.lastNumberOfDice;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to set dieModifier attribute of Die class to the given dieModifier parameter.
|
||||
*
|
||||
* @param dieModifier as the new value of dieModifier as an Integer.
|
||||
*/
|
||||
public void setDieModifier(int dieModifier) {
|
||||
this.dieModifier = dieModifier;
|
||||
}
|
||||
}
|
||||
@@ -9,25 +9,43 @@
|
||||
*/
|
||||
public class Game {
|
||||
/**
|
||||
* Constants.
|
||||
* The number of turbo cards available in the game.
|
||||
*/
|
||||
public static final int AMOUNT_OF_TURBO_CARDS = 16;
|
||||
public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
* The number of shield and swap cards available in the game.
|
||||
*/
|
||||
public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
|
||||
|
||||
// The modifier applied to the dice roll.
|
||||
private int diceModifier = 1;
|
||||
|
||||
// The number of eyes shown on the dice.
|
||||
private int diceEyes;
|
||||
|
||||
// A map of player IDs to Player objects.
|
||||
private Map<Integer, Player> players = new HashMap<>();
|
||||
|
||||
// The statistics of the game.
|
||||
private Statistic gameStatistics;
|
||||
|
||||
// The pile of bonus cards available for drawing.
|
||||
private List<BonusCard> drawPile;
|
||||
|
||||
// The pile of bonus cards that have been discarded.
|
||||
private List<BonusCard> discardPile = new ArrayList<>();
|
||||
|
||||
// The game board.
|
||||
private Board board;
|
||||
|
||||
// The die used in the game.
|
||||
private Die die;
|
||||
|
||||
// The color of the active player.
|
||||
private Color activeColor;
|
||||
private final ArrayList<Observer> observers = new ArrayList<>();
|
||||
private boolean allRanked = false;
|
||||
private boolean movablePieces = false;
|
||||
|
||||
// A flag indicating whether all players are ready.
|
||||
private boolean allReady = false;
|
||||
|
||||
/**
|
||||
@@ -66,27 +84,10 @@ public void removePlayer(int id) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds an observer to the game.
|
||||
* This method updates the active state of a player.
|
||||
*
|
||||
* @param observer the observer to be added
|
||||
*/
|
||||
public void addObserver(Observer observer) {
|
||||
observers.add(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes an observer from the game.
|
||||
*
|
||||
* @param observer the observer to be removed
|
||||
*/
|
||||
public void removeObserver(Observer observer) {
|
||||
observers.remove(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @param active
|
||||
* @param id the id of the player
|
||||
* @param active the new active state
|
||||
*/
|
||||
public void updatePlayerActiveState(int id, boolean active) {
|
||||
this.players.get(id).setActive(active);
|
||||
@@ -135,22 +136,19 @@ public int getNumberOfActivePlayers() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return a piece based on the identifier.
|
||||
* This method will be used to return a piece based on the UUID.
|
||||
*
|
||||
* @return the piece specified by the identifier
|
||||
* @return the piece specified by the UUID
|
||||
*/
|
||||
public Piece getPieceThroughIdentifier(String identifier){
|
||||
String[] parts = identifier.split("-");
|
||||
return board.getPlayerData().get(Color.valueOf(parts[0])).getPieces()[Integer.parseInt(parts[1])];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method notifies the observers.
|
||||
*/
|
||||
public void notifyObservers() {
|
||||
for (Observer observer : new ArrayList<>(observers)) {
|
||||
//TODO: observer.update();
|
||||
public Piece getPieceThroughUUID(UUID pieceId) {
|
||||
for (var playerData : board.getPlayerData().values()) {
|
||||
for (var piece : playerData.getPieces()) {
|
||||
if (piece.getUuid().equals(pieceId)) {
|
||||
return piece;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,6 +214,15 @@ public Board getBoard() {
|
||||
return board;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return die attribute of Game class.
|
||||
*
|
||||
* @return die as a Die object.
|
||||
*/
|
||||
public Die getDie() {
|
||||
return this.die;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the active color.
|
||||
*
|
||||
@@ -225,15 +232,6 @@ public Color getActiveColor() {
|
||||
return activeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether the game is interrupted.
|
||||
*
|
||||
* @return true if the game is interrupted, false otherwise
|
||||
*/
|
||||
public Boolean getMovablePieces() {
|
||||
return movablePieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the dice modifier.
|
||||
*
|
||||
@@ -306,35 +304,6 @@ public void setActiveColor(Color activeColor) {
|
||||
this.activeColor = activeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the game interruption state.
|
||||
*
|
||||
* @param movablePieces the new game interruption state
|
||||
*/
|
||||
public void setMovablePieces(Boolean movablePieces) {
|
||||
this.movablePieces = movablePieces;
|
||||
if (Boolean.FALSE.equals(movablePieces)) notifyObservers();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether all players have ranked.
|
||||
*
|
||||
* @return true if all players have ranked, false otherwise
|
||||
*/
|
||||
public Boolean allRanked() {
|
||||
return allRanked;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets whether all players have ranked.
|
||||
*
|
||||
* @param allRanked the new all ranked state
|
||||
*/
|
||||
public void setAllRanked(Boolean allRanked) {
|
||||
this.allRanked = allRanked;
|
||||
if (Boolean.TRUE.equals(allRanked)) notifyObservers();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the all ready state.
|
||||
*
|
||||
@@ -351,6 +320,5 @@ public Boolean allReady() {
|
||||
*/
|
||||
public void setAllReady(Boolean allReady) {
|
||||
this.allReady = allReady;
|
||||
if (Boolean.TRUE.equals(allReady)) notifyObservers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Represents a home node.
|
||||
*/
|
||||
public class HomeNode extends Node {
|
||||
|
||||
public HomeNode() {}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
public class Node {
|
||||
protected Piece occupant;
|
||||
|
||||
public Node() {}
|
||||
|
||||
/**
|
||||
* This method is used to get an occupant of the Node.
|
||||
*
|
||||
@@ -23,7 +21,7 @@ public Piece getOccupant() {
|
||||
* @param occupant the new occupant of the node
|
||||
*/
|
||||
public void setOccupant(Piece occupant) {
|
||||
if (occupant.isSuppressed()){
|
||||
if (occupant.isSuppressed()) {
|
||||
occupant.setShield(ShieldState.NONE);
|
||||
}
|
||||
this.occupant = occupant;
|
||||
|
||||
@@ -6,10 +6,24 @@
|
||||
* This class will be used to hold all Piece relevant data.
|
||||
*/
|
||||
public class Piece {
|
||||
/**
|
||||
* The shield state of the piece.
|
||||
*/
|
||||
private ShieldState shield;
|
||||
|
||||
/**
|
||||
* The current state of the piece.
|
||||
*/
|
||||
private PieceState state;
|
||||
|
||||
/**
|
||||
* The color of the piece.
|
||||
*/
|
||||
private final Color color;
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* The unique identifier of the piece.
|
||||
*/
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
/**
|
||||
@@ -22,7 +36,6 @@ public Piece(Color color, PieceState state, int id) {
|
||||
this.color = color;
|
||||
this.state = state;
|
||||
shield = ShieldState.NONE;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,15 +101,6 @@ public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
*
|
||||
* @return the color of the piece
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return color.toString() + "-" + id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get the color of the piece
|
||||
*
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Represents the state of a piece.
|
||||
*/
|
||||
public enum PieceState {
|
||||
/**
|
||||
* The piece is active.
|
||||
*/
|
||||
ACTIVE,
|
||||
/**
|
||||
* The piece is waiting.
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* The piece is in the home.
|
||||
*/
|
||||
HOME,
|
||||
/**
|
||||
* The piece is finished.
|
||||
*/
|
||||
HOMEFINISHED
|
||||
}
|
||||
|
||||
@@ -6,11 +6,34 @@
|
||||
* This class will be used to handle general PlayerData
|
||||
*/
|
||||
public class Player {
|
||||
/**
|
||||
* The name of the player.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The statistics of the player.
|
||||
*/
|
||||
private Statistic playerStatistic;
|
||||
|
||||
/**
|
||||
* The hand cards of the player.
|
||||
*/
|
||||
private ArrayList<BonusCard> handCards;
|
||||
private Color color;
|
||||
|
||||
/**
|
||||
* The color of the player.
|
||||
*/
|
||||
private Color color = Color.NONE;
|
||||
|
||||
/**
|
||||
* Indicates if the player is ready.
|
||||
*/
|
||||
private boolean isReady;
|
||||
|
||||
/**
|
||||
* Indicates if the player is active.
|
||||
*/
|
||||
private boolean active = true;
|
||||
|
||||
/**
|
||||
@@ -72,7 +95,7 @@ public ArrayList<BonusCard> getHandCards() {
|
||||
*
|
||||
* @param card the card to be added to the players hand
|
||||
*/
|
||||
public void addHandCards(BonusCard card) {
|
||||
public void addHandCard(BonusCard card) {
|
||||
handCards.add(card);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,24 @@
|
||||
* This class is used to represent PlayerData related to the board
|
||||
*/
|
||||
public class PlayerData {
|
||||
/**
|
||||
* An array of HomeNode objects representing the home nodes of the player.
|
||||
*/
|
||||
private HomeNode[] homeNodes;
|
||||
|
||||
/**
|
||||
* The index of the start node for the player.
|
||||
*/
|
||||
private int startNodeIndex;
|
||||
|
||||
/**
|
||||
* An array of Piece objects representing the waiting area of the player.
|
||||
*/
|
||||
private Piece[] waitingArea;
|
||||
|
||||
/**
|
||||
* An array of Piece objects representing all the pieces of the player.
|
||||
*/
|
||||
private Piece[] pieces;
|
||||
|
||||
/**
|
||||
@@ -75,7 +90,7 @@ public Piece[] getPieces() {
|
||||
* @param piece the piece to be added to the waiting area
|
||||
*/
|
||||
public void addWaitingPiece(Piece piece) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (waitingArea[i] == null) {
|
||||
waitingArea[i] = piece;
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Represents the state of a piece's shield.
|
||||
*/
|
||||
public enum ShieldState {
|
||||
/**
|
||||
* The shield is not active.
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* The shield is active.
|
||||
*/
|
||||
ACTIVE,
|
||||
/**
|
||||
* The shield is suppressed, when the piece is on a start node.
|
||||
*/
|
||||
SUPPRESSED
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Represents a start node.
|
||||
*/
|
||||
public class StartNode extends Node {
|
||||
|
||||
public StartNode(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the node.
|
||||
*/
|
||||
private Color color;
|
||||
|
||||
/**
|
||||
* This method is used to set a new Occupant
|
||||
* Creates a new start node with the given color.
|
||||
*
|
||||
* @param occupant the new occupant of the node
|
||||
* @param color the color of the node
|
||||
*/
|
||||
@Override
|
||||
public void setOccupant(Piece occupant) {
|
||||
if (occupant.isShielded()){
|
||||
occupant.setShield(ShieldState.SUPPRESSED);
|
||||
}
|
||||
this.occupant = occupant;
|
||||
public StartNode(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,13 +4,39 @@
|
||||
* This class will be used to store Statistics during the Game;
|
||||
*/
|
||||
public class Statistic {
|
||||
/**
|
||||
* The number of cards played.
|
||||
*/
|
||||
private int cardsPlayed;
|
||||
|
||||
/**
|
||||
* The number of pieces thrown. (enemy)
|
||||
*/
|
||||
private int piecesThrown;
|
||||
|
||||
/**
|
||||
* The number of pieces being thrown. (own pieces)
|
||||
*/
|
||||
private int piecesBeingThrown;
|
||||
|
||||
/**
|
||||
* The number of times a 6 was diced.
|
||||
*/
|
||||
private int diced6;
|
||||
|
||||
/**
|
||||
* The number of nodes traveled.
|
||||
*/
|
||||
private int traveledNodes;
|
||||
|
||||
/**
|
||||
* The number of bonus nodes activated.
|
||||
*/
|
||||
private int activatedBonusNodes;
|
||||
|
||||
/**
|
||||
* Constructs a new Statistic object with all values initialized to 0.
|
||||
*/
|
||||
public Statistic() {
|
||||
cardsPlayed = 0;
|
||||
piecesThrown = 0;
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface ClientInterpreter {
|
||||
* @param msg the JoinServer message to be processed
|
||||
* @param from the connection ID from which the message was received
|
||||
*/
|
||||
void received(JoinServerMessage msg, int from);
|
||||
void received(JoinedLobbyMessage msg, int from);
|
||||
|
||||
/**
|
||||
* Processes a received LeaveGame message.
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
* A message sent by a client when joining the server.
|
||||
*/
|
||||
@Serializable
|
||||
public class JoinServerMessage extends ClientMessage {
|
||||
public class JoinedLobbyMessage extends ClientMessage {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new JoinServer instance.
|
||||
*/
|
||||
public JoinServerMessage(String name) {
|
||||
public JoinedLobbyMessage(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
@@ -21,11 +21,20 @@ public JoinServerMessage(String name) {
|
||||
/**
|
||||
* Constructs a new JoinServer instance.
|
||||
*/
|
||||
public JoinServerMessage() {
|
||||
public JoinedLobbyMessage() {
|
||||
super();
|
||||
name = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the player that is joining the server.
|
||||
*
|
||||
* @return the name of the player that is joining the server
|
||||
*/
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to request a move for a piece.
|
||||
*/
|
||||
@@ -10,14 +12,14 @@ public class RequestMoveMessage extends ClientMessage {
|
||||
/**
|
||||
* The identifier for the piece.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructor for RequestMove
|
||||
*
|
||||
* @param pieceIdentifier the piece identifier
|
||||
*/
|
||||
public RequestMoveMessage(String pieceIdentifier) {
|
||||
public RequestMoveMessage(UUID pieceIdentifier) {
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ private RequestMoveMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to request playing a bonus card.
|
||||
*/
|
||||
@@ -16,9 +18,9 @@ public class RequestPlayCardMessage extends ClientMessage {
|
||||
/**
|
||||
* The identifier of the piece.
|
||||
*/
|
||||
private final String ownPieceIdentifier;
|
||||
private final UUID ownPieceIdentifier;
|
||||
|
||||
private final String enemyPieceIdentifier;
|
||||
private final UUID enemyPieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructs a new RequestPlayCard instance.
|
||||
@@ -26,7 +28,7 @@ public class RequestPlayCardMessage extends ClientMessage {
|
||||
* @param card the bonus card to be played
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
*/
|
||||
public RequestPlayCardMessage(BonusCard card, String ownPieceIdentifier, String enemyPieceIdentifier) {
|
||||
public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enemyPieceIdentifier) {
|
||||
this.ownPieceIdentifier = ownPieceIdentifier;
|
||||
this.card = card;
|
||||
this.enemyPieceIdentifier = enemyPieceIdentifier;
|
||||
@@ -48,11 +50,17 @@ private RequestPlayCardMessage() {
|
||||
* @param enemyPieceIdentifier the identifier of the enemy piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlaySwap(String ownPieceIdentifier, String enemyPieceIdentifier){
|
||||
public static RequestPlayCardMessage requestPlaySwap(UUID ownPieceIdentifier, UUID enemyPieceIdentifier){
|
||||
return new RequestPlayCardMessage(BonusCard.SWAP, ownPieceIdentifier, enemyPieceIdentifier);
|
||||
}
|
||||
|
||||
public static RequestPlayCardMessage requestPlayShield(String ownPieceIdentifier){
|
||||
/**
|
||||
* Creates a new RequestPlayCard instance for a shield bonus card.
|
||||
*
|
||||
* @param ownPieceIdentifier the identifier of the piece
|
||||
* @return a new RequestPlayCard instance
|
||||
*/
|
||||
public static RequestPlayCardMessage requestPlayShield(UUID ownPieceIdentifier){
|
||||
return new RequestPlayCardMessage(BonusCard.SHIELD, ownPieceIdentifier, null);
|
||||
}
|
||||
|
||||
@@ -70,7 +78,7 @@ public BonusCard getCard() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getOwnPieceIdentifier() {
|
||||
public UUID getOwnPieceIdentifier() {
|
||||
return ownPieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -79,7 +87,7 @@ public String getOwnPieceIdentifier() {
|
||||
*
|
||||
* @return the enemy piece identifier
|
||||
*/
|
||||
public String getEnemyPieceIdentifier() {
|
||||
public UUID getEnemyPieceIdentifier() {
|
||||
return enemyPieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by a client to indicate that a piece has been selected for a bonus cards.
|
||||
*/
|
||||
@@ -10,14 +12,14 @@ public class SelectedPiecesMessage extends ClientMessage {
|
||||
/**
|
||||
* The piece identifier.
|
||||
*/
|
||||
private String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* Constructor for SelectedPieces
|
||||
*
|
||||
* @param pieceIdentifier the piece identifier
|
||||
*/
|
||||
public SelectedPiecesMessage(String pieceIdentifier) {
|
||||
public SelectedPiecesMessage(UUID pieceIdentifier) {
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ private SelectedPiecesMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@ public StartGameMessage() {
|
||||
forceStartGame = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the game should be force started.
|
||||
*
|
||||
* @return whether the game should be force started
|
||||
*/
|
||||
public boolean isForceStartGame() {
|
||||
return forceStartGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this message.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player containing a list of pieces that the player can move any piece of the list on the board.
|
||||
@@ -13,7 +14,7 @@ public class AnyPieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The list of pieces
|
||||
*/
|
||||
private final ArrayList<String> piece;
|
||||
private final ArrayList<UUID> piece;
|
||||
|
||||
/**
|
||||
* Constructor for AnyPiece
|
||||
@@ -28,7 +29,7 @@ public AnyPieceMessage() {
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addPiece(String piece) {
|
||||
public void addPiece(UUID piece) {
|
||||
this.piece.add(piece);
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public void addPiece(String piece) {
|
||||
*
|
||||
* @return the list of pieces
|
||||
*/
|
||||
public List<String> getPiece() {
|
||||
public List<UUID> getPiece() {
|
||||
return piece;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,8 @@ public class DieMessage extends ServerMessage {
|
||||
* 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;
|
||||
}
|
||||
@@ -28,31 +27,10 @@ public DieMessage(int diceEye, List<String> moveablePieces) {
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private DieMessage() {
|
||||
public DieMessage() {
|
||||
diceEye = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the eye of the dice
|
||||
*
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package pp.mdga.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Player;
|
||||
|
||||
/**
|
||||
* A message sent from the server to the client indicating that a player has joined the lobby.
|
||||
*/
|
||||
@Serializable
|
||||
public class LobbyPlayerJoinMessage extends ServerMessage {
|
||||
public class LobbyPlayerJoinedMessage extends ServerMessage {
|
||||
|
||||
/**
|
||||
* The name of the player joining the lobby.
|
||||
* The player joining the lobby.
|
||||
*/
|
||||
private final String name;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The ID of the new Player
|
||||
@@ -21,29 +22,30 @@ public class LobbyPlayerJoinMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new LobbyPlayerJoin instance with the specified player name.
|
||||
*
|
||||
* @param name the name of the player joining the lobby
|
||||
* @param player the player joining the lobby
|
||||
* @param id the id of the player
|
||||
*/
|
||||
public LobbyPlayerJoinMessage(int id, String name) {
|
||||
public LobbyPlayerJoinedMessage(int id, Player player) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.player = player;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LobbyPlayerJoinMessage() {
|
||||
name = null;
|
||||
private LobbyPlayerJoinedMessage() {
|
||||
player = null;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the player joining the lobby.
|
||||
* Returns the player joining the lobby.
|
||||
*
|
||||
* @return the name of the player joining the lobby
|
||||
* @return the player joining the lobby
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,21 +13,14 @@ public class LobbyPlayerLeaveMessage extends ServerMessage {
|
||||
*/
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* The color associated with the player leaving the lobby.
|
||||
*/
|
||||
private final Color color;
|
||||
|
||||
/**
|
||||
* Constructs a new LobbyPlayerLeave instance with the specified player name and color.
|
||||
*
|
||||
* @param id the id of the player leaving the lobby
|
||||
* @param color the color associated with the player leaving the lobby
|
||||
* @param id the id of the player leaving the lobby.
|
||||
*/
|
||||
public LobbyPlayerLeaveMessage(int id, Color color) {
|
||||
public LobbyPlayerLeaveMessage(int id) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +28,6 @@ public LobbyPlayerLeaveMessage(int id, Color color) {
|
||||
*/
|
||||
private LobbyPlayerLeaveMessage() {
|
||||
id = 0;
|
||||
color = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,15 +39,6 @@ public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color associated with the player leaving the lobby.
|
||||
*
|
||||
* @return the color associated with the player leaving the lobby
|
||||
*/
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the client to move a piece on the board.
|
||||
*/
|
||||
@@ -10,7 +12,7 @@ public class MoveMessage extends ServerMessage {
|
||||
/**
|
||||
* The identifier of the piece that should be moved.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID pieceUUID;
|
||||
|
||||
/**
|
||||
* The index of the target node;
|
||||
@@ -27,9 +29,9 @@ public class MoveMessage extends ServerMessage {
|
||||
*
|
||||
* @param identifier the identifier of the piece that should be moved
|
||||
*/
|
||||
public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
|
||||
public MoveMessage(UUID identifier, boolean isHomeMove, int targetIndex) {
|
||||
super();
|
||||
this.pieceIdentifier = identifier;
|
||||
this.pieceUUID = identifier;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
}
|
||||
@@ -38,7 +40,7 @@ public MoveMessage(String identifier, boolean isHomeMove, int targetIndex) {
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private MoveMessage() {
|
||||
pieceIdentifier = null;
|
||||
pieceUUID = null;
|
||||
targetIndex = 0;
|
||||
isHomeMove = false;
|
||||
}
|
||||
@@ -48,8 +50,8 @@ private MoveMessage() {
|
||||
*
|
||||
* @return the identifier of the piece that should be moved
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return pieceIdentifier;
|
||||
public UUID getIdentifier() {
|
||||
return pieceUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to play a card.
|
||||
*/
|
||||
@@ -16,9 +18,9 @@ public class PlayCardMessage extends ServerMessage {
|
||||
/**
|
||||
* The identifier of the piece that should be moved.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID ownPieceID;
|
||||
|
||||
private final String pieceIdentifierEnemy;
|
||||
private final UUID enemyPieceID;
|
||||
|
||||
private final int diceModifier;
|
||||
|
||||
@@ -26,13 +28,15 @@ public class PlayCardMessage extends ServerMessage {
|
||||
* Constructs a new PlayCard message.
|
||||
*
|
||||
* @param card the card that should be played
|
||||
* @param pieceIdentifier the identifier of the piece that should be moved
|
||||
* @param ownPieceID the identifier of the piece that should be moved
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be moved
|
||||
* @param diceModifier the new modifier of the dice
|
||||
*/
|
||||
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy, int diceModifier) {
|
||||
public PlayCardMessage(BonusCard card, UUID ownPieceID, UUID enemyPieceID, int diceModifier) {
|
||||
super();
|
||||
this.card = card;
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.pieceIdentifierEnemy = pieceIdentifierEnemy;
|
||||
this.ownPieceID = ownPieceID;
|
||||
this.enemyPieceID = enemyPieceID;
|
||||
this.diceModifier = diceModifier;
|
||||
}
|
||||
|
||||
@@ -40,31 +44,31 @@ public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdent
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayCardMessage() {
|
||||
this.pieceIdentifierEnemy = null;
|
||||
ownPieceID = null;
|
||||
card = null;
|
||||
pieceIdentifier = null;
|
||||
enemyPieceID = null;
|
||||
diceModifier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new PlayCard message for the given card and piece identifier.
|
||||
*
|
||||
* @param pieceIdentifier the identifier of the piece of the player that should be affected
|
||||
* @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be affected
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy, 1);
|
||||
public static PlayCardMessage swap(UUID ownPieceID, UUID enemyPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, ownPieceID, enemyPieceID, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new PlayCard message for the given card and piece identifier.
|
||||
*
|
||||
* @param pieceIdentifier the identifier of the piece of the player that should be affected
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @return a new PlayCard message
|
||||
*/
|
||||
public static PlayCardMessage shield(String pieceIdentifier) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null, 1);
|
||||
public static PlayCardMessage shield(UUID ownPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, ownPieceID, null, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,8 +95,8 @@ public BonusCard getCard() {
|
||||
*
|
||||
* @return the identifier of the piece that should be moved
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
public UUID getPieceIdentifier() {
|
||||
return ownPieceID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +104,8 @@ public String getPieceIdentifier() {
|
||||
*
|
||||
* @return the identifier of the enemy piece that should be moved
|
||||
*/
|
||||
public String getPieceIdentifierEnemy() {
|
||||
return pieceIdentifierEnemy;
|
||||
public UUID getPieceIdentifierEnemy() {
|
||||
return enemyPieceID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to give all possible pieces to choose from.
|
||||
@@ -13,12 +14,12 @@ public class PossiblePieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The list of possible own pieces
|
||||
*/
|
||||
private final List<String> possibleOwnPieces;
|
||||
private final List<UUID> possibleOwnPieces;
|
||||
|
||||
/**
|
||||
* The list of possible enemy pieces
|
||||
*/
|
||||
private final List<String> possibleEnemyPieces;
|
||||
private final List<UUID> possibleEnemyPieces;
|
||||
|
||||
/**
|
||||
* Constructor for PossiblePiece
|
||||
@@ -36,7 +37,7 @@ public PossiblePieceMessage() {
|
||||
* @param possibleEnemyPieces the list of possible enemy pieces
|
||||
* @return the swapped possible pieces
|
||||
*/
|
||||
public static PossiblePieceMessage swapPossiblePieces(ArrayList<String> possibleOwnPieces, ArrayList<String> possibleEnemyPieces) {
|
||||
public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOwnPieces, ArrayList<UUID> possibleEnemyPieces) {
|
||||
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
|
||||
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
|
||||
possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
|
||||
@@ -49,7 +50,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<String> possible
|
||||
* @param possibleOwnPieces the list of possible own pieces
|
||||
* @return the possible pieces for the shield
|
||||
*/
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<String> possibleOwnPieces){
|
||||
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces){
|
||||
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
|
||||
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
|
||||
return possiblePieceMessage;
|
||||
@@ -60,7 +61,7 @@ public static PossiblePieceMessage shieldPossiblePieces(ArrayList<String> possib
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addOwnPossiblePiece(String piece) {
|
||||
public void addOwnPossiblePiece(UUID piece) {
|
||||
this.possibleOwnPieces.add(piece);
|
||||
}
|
||||
|
||||
@@ -69,21 +70,21 @@ public void addOwnPossiblePiece(String piece) {
|
||||
*
|
||||
* @param piece the piece to add
|
||||
*/
|
||||
public void addEnemyPossiblePiece(String piece) {
|
||||
public void addEnemyPossiblePiece(UUID piece) {
|
||||
this.possibleEnemyPieces.add(piece);
|
||||
}
|
||||
|
||||
/** Getter for the list of possible pieces
|
||||
* @return the list of possible pieces
|
||||
*/
|
||||
public List<String> getOwnPossiblePieces() {
|
||||
public List<UUID> getOwnPossiblePieces() {
|
||||
return possibleOwnPieces;
|
||||
}
|
||||
|
||||
/** Getter for the list of possible enemy pieces
|
||||
* @return the list of possible enemy pieces
|
||||
*/
|
||||
public List<String> getEnemyPossiblePieces() {
|
||||
public List<UUID> getEnemyPossiblePieces() {
|
||||
return possibleEnemyPieces;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Serializable
|
||||
public class SelectPieceMessage extends ServerMessage{
|
||||
|
||||
private final List<String> pieces;
|
||||
private final List<UUID> pieces;
|
||||
private final List<Boolean> isHomeMove;
|
||||
private final List<Integer> targetIndex;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class SelectPieceMessage extends ServerMessage{
|
||||
* @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, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
public SelectPieceMessage(List<UUID> pieces, List<Boolean> isHomeMove, List<Integer> targetIndex){
|
||||
this.pieces = pieces;
|
||||
this.isHomeMove = isHomeMove;
|
||||
this.targetIndex = targetIndex;
|
||||
@@ -38,7 +39,7 @@ public SelectPieceMessage(){
|
||||
*
|
||||
* @return the pieces
|
||||
*/
|
||||
public List<String> getPieces(){
|
||||
public List<UUID> getPieces(){
|
||||
return pieces;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public interface ServerInterpreter {
|
||||
*
|
||||
* @param msg the LobbyPlayerJoin message received
|
||||
*/
|
||||
void received(LobbyPlayerJoinMessage msg);
|
||||
void received(LobbyPlayerJoinedMessage msg);
|
||||
|
||||
/**
|
||||
* Handles a LobbyPlayerLeave message received from the server.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player that he has to move a start piece.
|
||||
*/
|
||||
@@ -10,7 +12,7 @@ public class StartPieceMessage extends ServerMessage {
|
||||
/**
|
||||
* The identifier for the piece.
|
||||
*/
|
||||
private final String pieceIdentifier;
|
||||
private final UUID pieceIdentifier;
|
||||
|
||||
/**
|
||||
* The target index of the move;
|
||||
@@ -23,7 +25,7 @@ public class StartPieceMessage extends ServerMessage {
|
||||
* @param pieceIdentifier the identifier for the piece
|
||||
* @param targetIndex the index of the targetNode
|
||||
*/
|
||||
public StartPieceMessage(String pieceIdentifier, int targetIndex) {
|
||||
public StartPieceMessage(UUID pieceIdentifier, int targetIndex) {
|
||||
super();
|
||||
this.pieceIdentifier = pieceIdentifier;
|
||||
this.targetIndex = targetIndex;
|
||||
@@ -34,7 +36,7 @@ public StartPieceMessage(String pieceIdentifier, int targetIndex) {
|
||||
*/
|
||||
private StartPieceMessage() {
|
||||
super();
|
||||
this.pieceIdentifier = "";
|
||||
this.pieceIdentifier = null;
|
||||
this.targetIndex = 0;
|
||||
}
|
||||
|
||||
@@ -43,7 +45,7 @@ private StartPieceMessage() {
|
||||
*
|
||||
* @return the piece identifier
|
||||
*/
|
||||
public String getPieceIdentifier() {
|
||||
public UUID getPieceIdentifier() {
|
||||
return pieceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
public class DetermineStartPlayerState extends GameState {
|
||||
public DetermineStartPlayerState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class FirstRollStateState extends RollDiceState {
|
||||
public FirstRollStateState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class MovePieceState extends TurnState {
|
||||
public MovePieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class NoPieceState extends ChoosePieceState {
|
||||
public NoPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class NoTurnState extends ChoosePieceState {
|
||||
public NoTurnState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class PowerCardState extends TurnState {
|
||||
public PowerCardState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class RollDiceState extends TurnState {
|
||||
public RollDiceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class SecondRollState extends RollDiceState {
|
||||
public SecondRollState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class SelectPieceState extends ChoosePieceState {
|
||||
public SelectPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public void received(StartGameMessage msg, int from) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(JoinServerMessage msg, int from) {
|
||||
public void received(JoinedLobbyMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,4 +21,11 @@ public interface ServerSender {
|
||||
* @param message as the message which will be sent to all players as a ServerMessage.
|
||||
*/
|
||||
void broadcast(ServerMessage message);
|
||||
|
||||
/**
|
||||
* This method will be used to disconnect the client depending on the given id parameter.
|
||||
*
|
||||
* @param id as the connection id of the client as an Integer.
|
||||
*/
|
||||
void disconnectClient(int id);
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class StartPieceState extends ChoosePieceState {
|
||||
public StartPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class ThirdRollState extends RollDiceState {
|
||||
public ThirdRollState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
public class TurnState extends GameState {
|
||||
public TurnState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package pp.mdga.server;
|
||||
|
||||
public class WaitingPieceState extends ChoosePieceState {
|
||||
public WaitingPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,11 @@
|
||||
*
|
||||
*/
|
||||
public class CeremonyState extends ServerState {
|
||||
/**
|
||||
* Create LobbyState constants.
|
||||
*/
|
||||
private static final System.Logger LOGGER = System.getLogger(CeremonyState.class.getName());
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -20,7 +25,7 @@ public CeremonyState(ServerGameLogic logic) {
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
// ToDo: Close server.
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered CeremonyState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
package pp.mdga.server.automaton;
|
||||
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.client.DisconnectedMessage;
|
||||
import pp.mdga.message.client.LeaveGameMessage;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.PauseGameMessage;
|
||||
import pp.mdga.server.automaton.game.AnimationState;
|
||||
import pp.mdga.server.automaton.game.DetermineStartPlayerState;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.GameAutomatonState;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class represents the game state of this application.
|
||||
* In Addition, it will be used as a state machine for the game process.
|
||||
*/
|
||||
public class GameState extends ServerState {
|
||||
/**
|
||||
* Create LobbyState constants.
|
||||
*/
|
||||
private static final System.Logger LOGGER = System.getLogger(GameState.class.getName());
|
||||
|
||||
/**
|
||||
* Create GameState states.
|
||||
*/
|
||||
private GameAutomatonState currentState;
|
||||
private final GameAutomatonState determineStartPlayerState;
|
||||
private final GameAutomatonState animationState;
|
||||
private final GameAutomatonState turnState;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -16,6 +36,10 @@ public class GameState extends ServerState {
|
||||
*/
|
||||
public GameState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
this.determineStartPlayerState = new DetermineStartPlayerState(this, logic);
|
||||
this.animationState = new AnimationState(this, logic);
|
||||
this.turnState = new TurnState(this, logic);
|
||||
this.setCurrentState(this.determineStartPlayerState);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +47,7 @@ public GameState(ServerGameLogic logic) {
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered GameState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +59,8 @@ public void exit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a DisconnectedMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a Disconnected object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
@@ -46,6 +72,8 @@ public void received(DisconnectedMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an LeaveGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LeaveGame object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
@@ -57,4 +85,78 @@ public void received(LeaveGameMessage msg, int from) {
|
||||
this.logic.setCurrentState(this.logic.getCeremonyState());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestDieMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a RequestDieMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestDieMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return currentState attribute of GameState class.
|
||||
*
|
||||
* @return currentState as a GameAutomatonState object.
|
||||
*/
|
||||
public GameAutomatonState getCurrentState() {
|
||||
return this.currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return determineStartPlayerState attribute of GameState class.
|
||||
*
|
||||
* @return determineStartPlayerState as a GameAutomatonState object.
|
||||
*/
|
||||
public GameAutomatonState getDetermineStartPlayerState() {
|
||||
return this.determineStartPlayerState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return animationState attribute of GameState class.
|
||||
*
|
||||
* @return animationState as a GameAutomatonState object.
|
||||
*/
|
||||
public GameAutomatonState getAnimationState() {
|
||||
return this.animationState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return turnState attribute of GameState class.
|
||||
*
|
||||
* @return turnState as a GameAutomatonState object.
|
||||
*/
|
||||
public GameAutomatonState getTurnState() {
|
||||
return this.turnState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to set currentState attribute of GameState class to the given state parameter.
|
||||
* In Addition, the currentState will be exited, changed and entered.
|
||||
*
|
||||
* @param state as the new currentState attribute as a GameAutomatonState object.
|
||||
*/
|
||||
public void setCurrentState(GameAutomatonState state) {
|
||||
if (this.currentState != null) {
|
||||
this.currentState.exit();
|
||||
}
|
||||
this.currentState = state;
|
||||
this.currentState.enter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
*
|
||||
*/
|
||||
public class InterruptState extends ServerState {
|
||||
/**
|
||||
* Create LobbyState constants.
|
||||
*/
|
||||
private static final System.Logger LOGGER = System.getLogger(InterruptState.class.getName());
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*/
|
||||
@@ -28,7 +33,7 @@ public InterruptState(ServerGameLogic logic) {
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
// Create timer and connect signal.
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered InterruptState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +44,13 @@ public void exit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a ForceContinueGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a ForceContinueGameMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(ForceContinueGameMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new ResumeGameMessage());
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
package pp.mdga.server.automaton;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.ServerStartGameMessage;
|
||||
import pp.mdga.message.server.UpdateReadyMessage;
|
||||
import pp.mdga.message.server.UpdateTSKMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class represents the lobby state of the server.
|
||||
* It will handle all join and disconnect messages, as well the selection of the color of the player.
|
||||
*/
|
||||
public class LobbyState extends ServerState {
|
||||
/**
|
||||
* Create LobbyState constants.
|
||||
*/
|
||||
private static final System.Logger LOGGER = System.getLogger(ServerState.class.getName());
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
@@ -24,7 +32,7 @@ public LobbyState(ServerGameLogic logic) {
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered LobbyState state.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,53 +44,111 @@ public void exit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a JoinedLobbyMessage message.
|
||||
* It will also get the client id of the player who send this messag
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a JoinedLobbyMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(JoinedLobbyMessage msg, int from) {
|
||||
Player player = new Player(msg.getName());
|
||||
player.setColor(Color.getColorByIndex(this.logic.getGame().getPlayers().size()));
|
||||
this.logic.getGame().addPlayer(from, player);
|
||||
this.logic.getServerSender().broadcast(new LobbyPlayerJoinedMessage(from, player));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectTSKMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectTSK object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectTSKMessage msg, int from) {
|
||||
for (Map.Entry<Integer, Player> entry : this.logic.getGame().getPlayers().entrySet()) {
|
||||
if (entry.getValue().getColor() == msg.getColor()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.logic.getGame().getPlayerById(from).setColor(msg.getColor());
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, msg.getColor()));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a DeselectTSKMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a DeselectTSK object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(DeselectTSKMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, msg.getColor()));
|
||||
this.logic.getGame().getPlayerById(from).setColor(Color.NONE);
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, Color.NONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a LobbyReadyMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LobbyReady object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyReadyMessage msg, int from) {
|
||||
this.logic.getGame().getPlayerById(from).setReady(true);
|
||||
this.logic.getServerSender().broadcast(new UpdateReadyMessage(from, true));
|
||||
for (Map.Entry<Integer, Player> entry : this.logic.getGame().getPlayers().entrySet()) {
|
||||
if (!entry.getValue().isActive()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.logic.getGame().setAllReady(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a LobbyNotReadyMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LobbyNotReady object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyNotReadyMessage msg, int from) {
|
||||
this.logic.getGame().getPlayerById(from).setReady(false);
|
||||
this.logic.getGame().setAllReady(false);
|
||||
this.logic.getServerSender().broadcast(new UpdateReadyMessage(from, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an LeaveGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LeaveGameMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(LeaveGameMessage msg, int from) {
|
||||
this.logic.getGame().removePlayer(from);
|
||||
this.logic.getServerSender().broadcast(new LobbyPlayerLeaveMessage(from));
|
||||
this.logic.getServerSender().disconnectClient(from);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a StartGame message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a ForceStartGame object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(StartGameMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new ServerStartGameMessage());
|
||||
this.logic.setCurrentState(this.logic.getGameState());
|
||||
if (msg.isForceStartGame() || this.logic.getGame().allReady()) {
|
||||
this.logic.getServerSender().broadcast(new ServerStartGameMessage());
|
||||
this.logic.setCurrentState(this.logic.getGameState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,19 +33,19 @@ public ServerState(ServerGameLogic logic) {
|
||||
public abstract void exit();
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an AnimationEnd message.
|
||||
* This method will be called whenever the server received an AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEnd object.
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(AnimationEndMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an DeselectTSK message.
|
||||
* This method will be called whenever the server received a DeselectTSKMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a DeselectTSK object.
|
||||
* @param msg as the message which was sent by the player as a DeselectTSKMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(DeselectTSKMessage msg, int from) {}
|
||||
@@ -60,136 +60,136 @@ public void received(DeselectTSKMessage msg, int from) {}
|
||||
public void received(StartGameMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a JoinServer message.
|
||||
* This method will be called whenever the server received a JoinedLobbyMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a JoinServer object.
|
||||
* @param msg as the message which was sent by the player as a JoinedLobbyMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(JoinServerMessage msg, int from) {}
|
||||
public void received(JoinedLobbyMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an LeaveGame message.
|
||||
* This method will be called whenever the server received an LeaveGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LeaveGame object.
|
||||
* @param msg as the message which was sent by the player as a LeaveGameMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(LeaveGameMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a LobbyReady message.
|
||||
* This method will be called whenever the server received a LobbyReadyMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LobbyReady object.
|
||||
* @param msg as the message which was sent by the player as a LobbyReadyMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(LobbyReadyMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a LobbyNotReady message.
|
||||
* This method will be called whenever the server received a LobbyNotReadyMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a LobbyNotReady object.
|
||||
* @param msg as the message which was sent by the player as a LobbyNotReadyMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(LobbyNotReadyMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a Disconnected message.
|
||||
* This method will be called whenever the server received a DisconnectedMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a Disconnected object.
|
||||
* @param msg as the message which was sent by the player as a DisconnectedMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(DisconnectedMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a Briefing message.
|
||||
* This method will be called whenever the server received a RequestBriefingMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a Briefing object.
|
||||
* @param msg as the message which was sent by the player as a RequestBriefingMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(RequestBriefingMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a Die message.
|
||||
* This method will be called whenever the server received a RequestDieMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a Die object.
|
||||
* @param msg as the message which was sent by the player as a RequestDieMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(RequestDieMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestMove message.
|
||||
* This method will be called whenever the server received a RequestMoveMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a RequestMove object.
|
||||
* @param msg as the message which was sent by the player as a RequestMoveMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(RequestMoveMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a PlayCard message.
|
||||
* This method will be called whenever the server received a RequestPlayCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a PlayCard object.
|
||||
* @param msg as the message which was sent by the player as a RequestPlayCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(RequestPlayCardMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectCard message.
|
||||
* This method will be called whenever the server received a SelectCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectCard object.
|
||||
* @param msg as the message which was sent by the player as a SelectCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(SelectCardMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectTSK message.
|
||||
* This method will be called whenever the server received a SelectTSKMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectTSK object.
|
||||
* @param msg as the message which was sent by the player as a SelectTSKMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(SelectTSKMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a ForceContinueGame message.
|
||||
* This method will be called whenever the server received a ForceContinueGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a ForceContinueGame object.
|
||||
* @param msg as the message which was sent by the player as a ForceContinueGameMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(ForceContinueGameMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a ClientStartGame message.
|
||||
* This method will be called whenever the server received a ClientStartGameMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a ClientStartGame object.
|
||||
* @param msg as the message which was sent by the player as a ClientStartGameMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(ClientStartGameMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a NoPowerCard message.
|
||||
* This method will be called whenever the server received a NoPowerCardMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a NoPowerCard object.
|
||||
* @param msg as the message which was sent by the player as a NoPowerCardMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(NoPowerCardMessage msg, int from) {}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectedPieces message.
|
||||
* This method will be called whenever the server received a SelectedPiecesMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a SelectedPieces object.
|
||||
* @param msg as the message which was sent by the player as a SelectedPiecesMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(SelectedPiecesMessage msg, int from) {}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package pp.mdga.server.automaton.game;
|
||||
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
/**
|
||||
* This class represents the animation state of the game state.
|
||||
*
|
||||
*/
|
||||
public class AnimationState extends GameAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param gameAutomaton as the automaton of the game state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public AnimationState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(gameAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an AnimationEndMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.logic.getServerSender().send(from, new DiceNowMessage());
|
||||
this.gameAutomaton.setCurrentState(this.gameAutomaton.getTurnState());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package pp.mdga.server.automaton.game;
|
||||
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DetermineStartPlayerState extends GameAutomatonState {
|
||||
/**
|
||||
* Create DetermineStartPlayerState attributes.
|
||||
*/
|
||||
private Map<Player, Integer> diceResults = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param gameAutomaton as the automaton of the game state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public DetermineStartPlayerState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(gameAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestDieMessage message.
|
||||
* It will also get the client id of the player who send this message.
|
||||
*
|
||||
* @param msg as the message which was sent by the player as a RequestDieMessage object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
@Override
|
||||
public void received(RequestDieMessage msg, int from) {
|
||||
int roll = this.logic.getGame().getDie().shuffle();
|
||||
this.diceResults.put(this.logic.getGame().getPlayerById(from), roll);
|
||||
if (this.diceResults.size() == this.logic.getGame().getPlayers().size()) {
|
||||
Map<Integer, Long> frequencyMap = diceResults.values().stream()
|
||||
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
Map.Entry<Integer, Long> result = frequencyMap.entrySet().stream()
|
||||
.max(Map.Entry.comparingByKey())
|
||||
.orElseThrow(() -> new IllegalStateException("Die Map ist leer"));
|
||||
}
|
||||
this.logic.getServerSender().send(from, new DieMessage(roll));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return diceResults attribute of DetermineStartPlayerState class.
|
||||
*
|
||||
* @return diceResults as a Map combing Player objects and Integers.
|
||||
*/
|
||||
public Map<Player, Integer> getDiceResults() {
|
||||
return this.diceResults;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package pp.mdga.server.automaton.game;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
import pp.mdga.server.automaton.ServerState;
|
||||
|
||||
/**
|
||||
* This abstract class represents the game automaton state of the game state automaton.
|
||||
*/
|
||||
public abstract class GameAutomatonState extends ServerState {
|
||||
/**
|
||||
* Create GameAutomatonState attributes.
|
||||
*/
|
||||
protected final GameState gameAutomaton;
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param gameAutomaton as the automaton of the game state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public GameAutomatonState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
this.gameAutomaton = gameAutomaton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package pp.mdga.server.automaton.game;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
public class TurnState extends GameAutomatonState {
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param gameAutomaton as the automaton of the game state as a GameState object.
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
|
||||
super(gameAutomaton, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package pp.mdga.server;
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class ChoosePieceState extends TurnState {
|
||||
public ChoosePieceState(ServerGameLogic logic) {
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class MovePieceState extends TurnState {
|
||||
public MovePieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class PowerCardState extends TurnState {
|
||||
public PowerCardState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
public class RollDiceState extends TurnState {
|
||||
public RollDiceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public class NoPieceState extends ChoosePieceState {
|
||||
public NoPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public class NoTurnState extends ChoosePieceState {
|
||||
public NoTurnState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public class SelectPieceState extends ChoosePieceState {
|
||||
public SelectPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public class StartPieceState extends ChoosePieceState {
|
||||
public StartPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
public class WaitingPieceState extends ChoosePieceState {
|
||||
public WaitingPieceState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.rolldice;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
|
||||
public class FirstRollStateState extends RollDiceState {
|
||||
public FirstRollStateState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.rolldice;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
|
||||
public class SecondRollState extends RollDiceState {
|
||||
public SecondRollState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package pp.mdga.server.automaton.game.turn.rolldice;
|
||||
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
|
||||
public class ThirdRollState extends RollDiceState {
|
||||
public ThirdRollState(ServerGameLogic logic) {
|
||||
super(logic);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user