removed unused imports and reformatted the code for code style
This commit is contained in:
@@ -15,7 +15,7 @@ public class CeremonyState extends ClientState {
|
||||
* Creates a new CeremonyState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public CeremonyState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -42,8 +42,8 @@ public void exit() {
|
||||
*
|
||||
* @param state the state to be set
|
||||
*/
|
||||
public void setState(CeremonyStates state){
|
||||
if(this.currentState != null){
|
||||
public void setState(CeremonyStates state) {
|
||||
if (this.currentState != null) {
|
||||
this.currentState.exit();
|
||||
}
|
||||
state.enter();
|
||||
@@ -55,7 +55,7 @@ public void setState(CeremonyStates state){
|
||||
*
|
||||
* @return the PodiumState
|
||||
*/
|
||||
public PodiumState getPodiumState(){
|
||||
public PodiumState getPodiumState() {
|
||||
return podiumState;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public PodiumState getPodiumState(){
|
||||
*
|
||||
* @return the StatisticsState
|
||||
*/
|
||||
public StatisticsState getStatisticsState(){
|
||||
public StatisticsState getStatisticsState() {
|
||||
return statisticsState;
|
||||
}
|
||||
|
||||
@@ -73,16 +73,15 @@ public StatisticsState getStatisticsState(){
|
||||
*
|
||||
* @return the current State
|
||||
*/
|
||||
public CeremonyStates getState(){
|
||||
public CeremonyStates getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to parse the selectNext from the clientGameLogic
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void selectNext(){
|
||||
public void selectNext() {
|
||||
currentState.selectNext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.CeremonyNotification;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
@@ -15,7 +14,7 @@ public abstract class ClientState implements Observer, ServerInterpreter {
|
||||
|
||||
protected ClientGameLogic logic;
|
||||
|
||||
protected ClientState(ClientState parent, ClientGameLogic logic){
|
||||
protected ClientState(ClientState parent, ClientGameLogic logic) {
|
||||
this.parent = parent;
|
||||
this.logic = logic;
|
||||
}
|
||||
@@ -24,14 +23,14 @@ protected ClientState(ClientState parent, ClientGameLogic logic){
|
||||
|
||||
public abstract void exit();
|
||||
|
||||
public ClientState getParent(){
|
||||
public ClientState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void update() {/* do nothing */}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ public void received(ChoosePieceStateMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DrawCardMessage msg){
|
||||
public void received(DrawCardMessage msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
||||
}
|
||||
|
||||
@@ -161,7 +160,9 @@ public void received(ServerStartGameMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ShutdownMessage msg) {LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());}
|
||||
public void received(ShutdownMessage msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg) {
|
||||
@@ -195,7 +196,7 @@ public void received(WaitPieceMessage msg) {
|
||||
|
||||
@Override
|
||||
public void received(IncorrectRequestMessage msg) {
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
||||
LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
|
||||
}
|
||||
|
||||
public void selectPiece(Piece piece) {
|
||||
@@ -238,23 +239,23 @@ public void deselectTSK(Color color) {
|
||||
LOGGER.log(Level.DEBUG, "Deselecting TSK not allowed.");
|
||||
}
|
||||
|
||||
public void selectUnready(){
|
||||
public void selectUnready() {
|
||||
LOGGER.log(Level.DEBUG, "Selecting unready not allowed.");
|
||||
}
|
||||
|
||||
public void selectStart(){
|
||||
public void selectStart() {
|
||||
LOGGER.log(Level.DEBUG, "Starting not allowed");
|
||||
}
|
||||
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
LOGGER.log(Level.DEBUG, "Animation end not allowed");
|
||||
}
|
||||
|
||||
public void selectNext(){
|
||||
public void selectNext() {
|
||||
LOGGER.log(Level.DEBUG, "Next not allowed");
|
||||
}
|
||||
|
||||
public void selectResume(){
|
||||
public void selectResume() {
|
||||
LOGGER.log(Level.DEBUG, "Resume not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DialogsState extends ClientState {
|
||||
* Creates a new DialogsState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public DialogsState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -29,7 +29,7 @@ public DialogsState(ClientState parent, ClientGameLogic logic) {
|
||||
* exits this state
|
||||
*/
|
||||
@Override
|
||||
public void exit(){
|
||||
public void exit() {
|
||||
currentState.exit();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public void exit(){
|
||||
* Enters the new state machine
|
||||
*/
|
||||
@Override
|
||||
public void enter(){
|
||||
public void enter() {
|
||||
setState(startDialogState);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public void enter(){
|
||||
*
|
||||
* @param newState the state to be set
|
||||
*/
|
||||
public void setState(DialogStates newState){
|
||||
if(currentState != null){
|
||||
public void setState(DialogStates newState) {
|
||||
if (currentState != null) {
|
||||
currentState.exit();
|
||||
}
|
||||
newState.enter();
|
||||
@@ -85,7 +85,7 @@ public StartDialogState getStartDialog() {
|
||||
* This method is used to call the selectLeave method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectLeave(){
|
||||
public void selectLeave() {
|
||||
currentState.selectLeave();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public void selectLeave(){
|
||||
* @param name the name to be set
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name){
|
||||
public void setName(String name) {
|
||||
currentState.setName(name);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public void setName(String name){
|
||||
* @param color the color to be set
|
||||
*/
|
||||
@Override
|
||||
public void selectTSK(Color color){
|
||||
public void selectTSK(Color color) {
|
||||
currentState.selectTSK(color);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public void selectTSK(Color color){
|
||||
* @param color the color to be deselected
|
||||
*/
|
||||
@Override
|
||||
public void deselectTSK(Color color){
|
||||
public void deselectTSK(Color color) {
|
||||
currentState.deselectTSK(color);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public void deselectTSK(Color color){
|
||||
* This method is used to call the selectReady method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectReady(){
|
||||
public void selectReady() {
|
||||
currentState.selectReady();
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public void selectReady(){
|
||||
* This method is used to call the selectUnready method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectUnready(){
|
||||
public void selectUnready() {
|
||||
currentState.selectUnready();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public void selectUnready(){
|
||||
* This method is used to call the selectStart method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectStart(){
|
||||
public void selectStart() {
|
||||
currentState.selectStart();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public void selectStart(){
|
||||
* @param string the string to be set
|
||||
*/
|
||||
@Override
|
||||
public void selectJoin(String string){
|
||||
public void selectJoin(String string) {
|
||||
currentState.selectJoin(string);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public void selectJoin(String string){
|
||||
* @param name the name to be set
|
||||
*/
|
||||
@Override
|
||||
public void selectHost(String name){
|
||||
public void selectHost(String name) {
|
||||
currentState.selectHost(name);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public void selectHost(String name){
|
||||
* @param msg the LobbyPlayerJoin message received
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyPlayerJoinedMessage msg){
|
||||
public void received(LobbyPlayerJoinedMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public void received(LobbyPlayerJoinedMessage msg){
|
||||
* @param msg the LobbyPlayerLeave message received
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyPlayerLeaveMessage msg){
|
||||
public void received(LobbyPlayerLeaveMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public void received(LobbyPlayerLeaveMessage msg){
|
||||
* @param msg the UpdateTSKMessage message received
|
||||
*/
|
||||
@Override
|
||||
public void received(UpdateTSKMessage msg){
|
||||
public void received(UpdateTSKMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public void received(UpdateTSKMessage msg){
|
||||
* @param msg the UpdateReady message received
|
||||
*/
|
||||
@Override
|
||||
public void received(UpdateReadyMessage msg){
|
||||
public void received(UpdateReadyMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public void received(UpdateReadyMessage msg){
|
||||
* @param msg the ServerStartGame message received
|
||||
*/
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg){
|
||||
public void received(ServerStartGameMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public void received(ServerStartGameMessage msg){
|
||||
* @param msg the LobbyAccept message received
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyAcceptMessage msg){
|
||||
public void received(LobbyAcceptMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ public void received(LobbyAcceptMessage msg){
|
||||
* @param msg the LobbyDeny message received
|
||||
*/
|
||||
@Override
|
||||
public void received(LobbyDenyMessage msg){
|
||||
public void received(LobbyDenyMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,9 @@
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.card.HiddenCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.game.card.TurboCard;
|
||||
import pp.mdga.message.client.LeaveGameMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.AcquireCardNotification;
|
||||
import pp.mdga.notification.CeremonyNotification;
|
||||
import pp.mdga.notification.DrawCardNotification;
|
||||
import pp.mdga.notification.InterruptNotification;
|
||||
import pp.mdga.notification.StartDialogNotification;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
public class GameState extends ClientState {
|
||||
|
||||
@@ -32,7 +25,7 @@ public class GameState extends ClientState {
|
||||
* Constructor for GameState
|
||||
*
|
||||
* @param parent the parent of this state
|
||||
* @param logic the ClientGameLogic
|
||||
* @param logic the ClientGameLogic
|
||||
*/
|
||||
public GameState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -59,8 +52,8 @@ public void exit() {
|
||||
*
|
||||
* @param newState the state to be set
|
||||
*/
|
||||
public void setState(GameStates newState){
|
||||
if(this.state != null){
|
||||
public void setState(GameStates newState) {
|
||||
if (this.state != null) {
|
||||
this.state.exit();
|
||||
}
|
||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + newState);
|
||||
@@ -72,7 +65,7 @@ public void setState(GameStates newState){
|
||||
* This method is used to call the selectAnimationEnd method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@@ -80,7 +73,7 @@ public void selectAnimationEnd(){
|
||||
* This method is used to call the selectDice method of the current state
|
||||
*/
|
||||
@Override
|
||||
public void selectDice(){
|
||||
public void selectDice() {
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@@ -90,7 +83,7 @@ public void selectDice(){
|
||||
* @param piece the piece to be selected
|
||||
*/
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
public void selectPiece(Piece piece) {
|
||||
state.selectPiece(piece);
|
||||
}
|
||||
|
||||
@@ -100,7 +93,7 @@ public void selectPiece(Piece piece){
|
||||
* @param card the card to be selected
|
||||
*/
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
public void selectCard(BonusCard card) {
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@@ -110,13 +103,13 @@ public void selectCard(BonusCard card){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(PauseGameMessage msg){
|
||||
public void received(PauseGameMessage msg) {
|
||||
logic.enterInterrupt();
|
||||
logic.addNotification(new InterruptNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectLeave(){
|
||||
public void selectLeave() {
|
||||
logic.send(new LeaveGameMessage());
|
||||
logic.addNotification(new StartDialogNotification());
|
||||
logic.setState(logic.getDialogs());
|
||||
@@ -128,7 +121,7 @@ public void selectLeave(){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
public void received(DieMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -138,7 +131,7 @@ public void received(DieMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(RankingRollAgainMessage msg){
|
||||
public void received(RankingRollAgainMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -148,7 +141,7 @@ public void received(RankingRollAgainMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
public void received(RankingResponseMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -158,7 +151,7 @@ public void received(RankingResponseMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
public void received(SelectPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -168,7 +161,7 @@ public void received(SelectPieceMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
public void received(WaitPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -178,7 +171,7 @@ public void received(WaitPieceMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
public void received(StartPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -188,7 +181,7 @@ public void received(StartPieceMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
public void received(NoTurnMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -198,7 +191,7 @@ public void received(NoTurnMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -208,7 +201,7 @@ public void received(MoveMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
public void received(CeremonyMessage msg) {
|
||||
CeremonyNotification notification = new CeremonyNotification();
|
||||
notification.setColors(msg.getColors());
|
||||
notification.setNames(msg.getNames());
|
||||
@@ -228,7 +221,7 @@ public void received(CeremonyMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
public void received(EndOfTurnMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -238,7 +231,7 @@ public void received(EndOfTurnMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
public void received(SpectatorMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -248,7 +241,7 @@ public void received(SpectatorMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
public void received(DiceAgainMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -258,7 +251,7 @@ public void received(DiceAgainMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(PossibleCardsMessage msg){
|
||||
public void received(PossibleCardsMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -268,7 +261,7 @@ public void received(PossibleCardsMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
public void received(PlayCardMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -278,7 +271,7 @@ public void received(PlayCardMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -288,27 +281,26 @@ public void received(DiceNowMessage msg){
|
||||
* @param msg the message to be received
|
||||
*/
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
public void received(PossiblePieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ChoosePieceStateMessage msg){
|
||||
public void received(ChoosePieceStateMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DrawCardMessage msg){
|
||||
public void received(DrawCardMessage msg) {
|
||||
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
||||
if (msg.getCard() instanceof HiddenCard) {
|
||||
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logic.addNotification(new AcquireCardNotification(msg.getCard().getCard()));
|
||||
}
|
||||
|
||||
@@ -319,7 +311,7 @@ public void received(DrawCardMessage msg){
|
||||
*
|
||||
* @return the current state
|
||||
*/
|
||||
public GameStates getState(){
|
||||
public GameStates getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import pp.mdga.message.client.ForceContinueGameMessage;
|
||||
import pp.mdga.message.server.ResumeGameMessage;
|
||||
import pp.mdga.notification.ResumeNotification;
|
||||
|
||||
public class InterruptState extends ClientState {
|
||||
|
||||
@@ -12,7 +11,7 @@ public class InterruptState extends ClientState {
|
||||
* Creates a new InterruptState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public InterruptState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -56,8 +55,8 @@ public ClientState getPreviousState() {
|
||||
* The host resumes the game
|
||||
*/
|
||||
@Override
|
||||
public void selectResume(){
|
||||
if(logic.isHost()){
|
||||
public void selectResume() {
|
||||
if (logic.isHost()) {
|
||||
logic.send(new ForceContinueGameMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SettingsState extends ClientState {
|
||||
* Creates a new SettingsState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public SettingsState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -45,28 +45,28 @@ public void exit() {
|
||||
/**
|
||||
* Changes the current state
|
||||
*/
|
||||
public SettingStates getState(){
|
||||
public SettingStates getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main settings state
|
||||
*/
|
||||
public MainSettingsState getMainSettingsState(){
|
||||
public MainSettingsState getMainSettingsState() {
|
||||
return mainSettingsState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the audio settings state
|
||||
*/
|
||||
public AudioSettingsState getAudioSettingsState(){
|
||||
public AudioSettingsState getAudioSettingsState() {
|
||||
return audioSettingsState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the video settings state
|
||||
*/
|
||||
public VideoSettingsState getVideoSettingsState(){
|
||||
public VideoSettingsState getVideoSettingsState() {
|
||||
return videoSettingsState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNext(){
|
||||
public void selectNext() {
|
||||
parent.setState(parent.getStatisticsState());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectNext(){
|
||||
public void selectNext() {
|
||||
logic.setState(logic.getDialogs());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
public abstract class DialogStates extends ClientState {
|
||||
|
||||
public DialogStates(ClientState parent, ClientGameLogic logic){
|
||||
public DialogStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public void selectStart() {
|
||||
|
||||
@Override
|
||||
public void received(ServerStartGameMessage msg) {
|
||||
for (Player player: msg.getPlayers()) {
|
||||
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
||||
for (Player player : msg.getPlayers()) {
|
||||
for (Map.Entry<Integer, Player> entry : this.logic.getGame().getPlayers().entrySet()) {
|
||||
if (entry.getValue().getColor() == player.getColor()) {
|
||||
this.logic.getGame().getPlayers().put(entry.getKey(), player);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ public class NetworkDialogState extends DialogStates {
|
||||
|
||||
/**
|
||||
* Constructor for the NetworkDialogState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the logic
|
||||
* @param logic the logic
|
||||
*/
|
||||
public NetworkDialogState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
|
||||
@@ -10,8 +10,9 @@ public class StartDialogState extends DialogStates {
|
||||
|
||||
/**
|
||||
* Constructor for the StartDialogState
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the logic
|
||||
* @param logic the logic
|
||||
*/
|
||||
public StartDialogState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
|
||||
@@ -26,7 +26,7 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
logic.send(new AnimationEndMessage());
|
||||
parent.setState(parent.getWaiting());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
|
||||
public class DetermineStartPlayerState extends GameStates {
|
||||
@@ -32,11 +31,11 @@ public WaitRankingState getWaitRanking() {
|
||||
return waitRankingState;
|
||||
}
|
||||
|
||||
public DetermineStartPlayerStates getState(){
|
||||
public DetermineStartPlayerStates getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Intro getIntro(){
|
||||
public Intro getIntro() {
|
||||
return intro;
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ public void exit() {
|
||||
|
||||
public void setState(DetermineStartPlayerStates state) {
|
||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||
if(this.state != null){
|
||||
if (this.state != null) {
|
||||
this.state.exit();
|
||||
}
|
||||
this.state = state;
|
||||
@@ -69,32 +68,32 @@ public void selectDice() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
public void received(DieMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingRollAgainMessage msg){
|
||||
public void received(RankingRollAgainMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
public void received(RankingResponseMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,12 @@
|
||||
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.game.Board;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Node;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
||||
import pp.mdga.notification.SwapPieceNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class GameStates extends ClientState {
|
||||
@@ -40,7 +33,7 @@ protected void handlePowerCard(PlayCardMessage msg) {
|
||||
private void handleShield(UUID uuid) {
|
||||
Board board = logic.getGame().getBoard();
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(uuid);
|
||||
Node node = board.getInfield()[board.getInfieldIndexOfPiece(piece)];
|
||||
Node node = board.getInfield()[board.getInfieldIndexOfPiece(piece)];
|
||||
if (node.isStart()) {
|
||||
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldActiveNotification(uuid));
|
||||
@@ -68,13 +61,13 @@ private void swapPieces(Piece messageOwn, Piece messageEnemy) {
|
||||
|
||||
}
|
||||
|
||||
private void checkShieldAfterSwap(Node node, Piece piece){
|
||||
if (node.isStart()){
|
||||
if (piece.isShielded()){
|
||||
private void checkShieldAfterSwap(Node node, Piece piece) {
|
||||
if (node.isStart()) {
|
||||
if (piece.isShielded()) {
|
||||
piece.setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
|
||||
}
|
||||
} else if (piece.isSuppressed()){
|
||||
} else if (piece.isSuppressed()) {
|
||||
piece.setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public void received(CeremonyMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DrawCardMessage msg){
|
||||
public void received(DrawCardMessage msg) {
|
||||
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
||||
if (msg.getCard() instanceof HiddenCard) {
|
||||
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
|
||||
@@ -87,14 +87,14 @@ public void received(MoveMessage msg) {
|
||||
if (occ != null) {
|
||||
//TODO: MoveThrowNotification
|
||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||
if (occ.isSuppressed()){
|
||||
if (occ.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
|
||||
occ.setShield(ShieldState.NONE);
|
||||
}
|
||||
//set occ to waiting
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
}
|
||||
if(msg.getPiece().getState().equals(PieceState.WAITING)){
|
||||
if (msg.getPiece().getState().equals(PieceState.WAITING)) {
|
||||
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
|
||||
piece.setState(PieceState.ACTIVE);
|
||||
|
||||
@@ -3,23 +3,12 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.MovePieceState;
|
||||
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.client.gamestate.turnstate.RollDiceState;
|
||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||
import pp.mdga.client.gamestate.turnstate.*;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.game.card.HiddenCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.game.card.TurboCard;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.RemoveShieldNotification;
|
||||
import pp.mdga.notification.AcquireCardNotification;
|
||||
import pp.mdga.notification.DrawCardNotification;
|
||||
|
||||
public class TurnState extends GameStates {
|
||||
|
||||
@@ -42,7 +31,7 @@ public TurnState(ClientState parent, ClientGameLogic logic) {
|
||||
public void enter() {
|
||||
logic = logic;
|
||||
for (Piece piece : logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPieces()) {
|
||||
if (piece.isShielded() || piece.isSuppressed()){
|
||||
if (piece.isShielded() || piece.isSuppressed()) {
|
||||
piece.setShield(ShieldState.NONE);
|
||||
logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
|
||||
}
|
||||
@@ -56,9 +45,9 @@ public void exit() {
|
||||
state = null;
|
||||
}
|
||||
|
||||
public void setState(TurnStates state){
|
||||
public void setState(TurnStates state) {
|
||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||
if(this.state != null){
|
||||
if (this.state != null) {
|
||||
this.state.exit();
|
||||
}
|
||||
state.enter();
|
||||
@@ -66,97 +55,97 @@ public void setState(TurnStates state){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
public void selectDice() {
|
||||
state.selectDice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
public void selectPiece(Piece piece) {
|
||||
state.selectPiece(piece);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
public void selectCard(BonusCard card) {
|
||||
state.selectCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
state.selectAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
public void received(SelectPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
public void received(WaitPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
public void received(StartPieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
public void received(NoTurnMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
public void received(CeremonyMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
public void received(EndOfTurnMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
public void received(SpectatorMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
public void received(DiceAgainMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCardsMessage msg){
|
||||
public void received(PossibleCardsMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
public void received(PlayCardMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
public void received(DieMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
public void received(PossiblePieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ChoosePieceStateMessage msg){
|
||||
public void received(ChoosePieceStateMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@@ -180,11 +169,11 @@ public RollDiceState getRollDice() {
|
||||
return rollDiceState;
|
||||
}
|
||||
|
||||
public GameState getParent(){
|
||||
public GameState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public TurnStates getState(){
|
||||
public TurnStates getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,9 @@ public void received(CeremonyMessage msg) {
|
||||
@Override
|
||||
public void received(DieMessage msg) {
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
if(logic.getGame().getTurboFlag()){
|
||||
if (logic.getGame().getTurboFlag()) {
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye()));
|
||||
}
|
||||
|
||||
@@ -65,11 +64,11 @@ public void received(PlayCardMessage msg) {
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||
logic.getGame().setActiveColor(msg.getColor());
|
||||
if(msg.getColor() == logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getColor()) {
|
||||
if (msg.getColor() == logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getColor()) {
|
||||
parent.setState(parent.getTurn());
|
||||
} else {
|
||||
for (Piece piece : logic.getGame().getActivePlayer().getPieces()){
|
||||
if (piece.isShielded() || piece.isSuppressed()){
|
||||
for (Piece piece : logic.getGame().getActivePlayer().getPieces()) {
|
||||
if (piece.isShielded() || piece.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
|
||||
piece.setShield(ShieldState.NONE);
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public void received(ActivePlayerMessage msg) {
|
||||
public void received(MoveMessage msg) {
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||
if (msg.isHomeMove()) {
|
||||
if(piece.getState().equals(PieceState.HOME)){
|
||||
if (piece.getState().equals(PieceState.HOME)) {
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
|
||||
Node pieceNode = logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex];
|
||||
@@ -91,18 +90,16 @@ public void received(MoveMessage msg) {
|
||||
Node oldNode = logic.getGame().getActivePlayer().getHomeNodes()[homeIndex];
|
||||
//gets the targetNode
|
||||
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()];
|
||||
if (msg.getTargetIndex() ==logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
|
||||
oldNode.clearOccupant();
|
||||
targetNode.setOccupant(piece);
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
|
||||
@@ -110,31 +107,29 @@ public void received(MoveMessage msg) {
|
||||
//gets the targetNode
|
||||
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()];
|
||||
|
||||
if (msg.getTargetIndex() ==logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
|
||||
oldNode.clearOccupant();
|
||||
targetNode.setOccupant(piece);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
||||
if (occ != null) {
|
||||
//TODO: MoveThrowNotification
|
||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||
if (occ.isSuppressed()){
|
||||
if (occ.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
|
||||
occ.setShield(ShieldState.NONE);
|
||||
}
|
||||
//set occ to waiting
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
}
|
||||
if(oldIndex == -1){
|
||||
if (oldIndex == -1) {
|
||||
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
|
||||
piece.setState(PieceState.ACTIVE);
|
||||
@@ -145,12 +140,12 @@ public void received(MoveMessage msg) {
|
||||
}
|
||||
//set new node
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isStart()){
|
||||
if (piece.isShielded()){
|
||||
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isStart()) {
|
||||
if (piece.isShielded()) {
|
||||
piece.setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
|
||||
}
|
||||
} else if (piece.isSuppressed()){
|
||||
} else if (piece.isSuppressed()) {
|
||||
piece.setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Intro extends DetermineStartPlayerStates{
|
||||
public class Intro extends DetermineStartPlayerStates {
|
||||
|
||||
private final DetermineStartPlayerState parent;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Intro extends DetermineStartPlayerStates{
|
||||
* Constructor for Intro
|
||||
*
|
||||
* @param parent the parent state
|
||||
* @param logic the client game logic
|
||||
* @param logic the client game logic
|
||||
*/
|
||||
public Intro(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -35,7 +35,7 @@ public Intro(ClientState parent, ClientGameLogic logic) {
|
||||
*
|
||||
* @return the parent state
|
||||
*/
|
||||
public DetermineStartPlayerState getParent(){
|
||||
public DetermineStartPlayerState getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ public DetermineStartPlayerState getParent(){
|
||||
*/
|
||||
@Override
|
||||
public void enter() {
|
||||
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
|
||||
for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
|
||||
logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
|
||||
logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
|
||||
entry.getValue().getWaitingArea()[0] = null;
|
||||
animationCounter++;
|
||||
for (PowerCard card : entry.getValue().getHandCards()){
|
||||
if(entry.getKey() == logic.getOwnPlayerId()){
|
||||
for (PowerCard card : entry.getValue().getHandCards()) {
|
||||
if (entry.getKey() == logic.getOwnPlayerId()) {
|
||||
logic.addNotification(new AcquireCardNotification(card.getCard()));
|
||||
} else {
|
||||
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), card.getCard()));
|
||||
@@ -71,13 +71,13 @@ public void exit() {
|
||||
* This method is used when the view has completed the animation.
|
||||
*/
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
animationCounter--;
|
||||
if(animationCounter != 0){
|
||||
if (animationCounter != 0) {
|
||||
return;
|
||||
}
|
||||
logic.send(new AnimationEndMessage());
|
||||
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
||||
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()) {
|
||||
parent.getParent().setState(parent.getParent().getTurn());
|
||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,7 @@ public class RollRankingDiceState extends DetermineStartPlayerStates {
|
||||
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
||||
|
||||
private final DetermineStartPlayerState parent;
|
||||
private boolean isRolled =false;
|
||||
private boolean isRolled = false;
|
||||
|
||||
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -29,20 +29,20 @@ public void enter() {
|
||||
@Override
|
||||
public void exit() {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState");
|
||||
isRolled=false;
|
||||
isRolled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
if(!isRolled){
|
||||
public void selectDice() {
|
||||
if (!isRolled) {
|
||||
isRolled = true;
|
||||
logic.send(new RequestDieMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
public void received(DieMessage msg) {
|
||||
parent.setState(parent.getWaitRanking());
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.ActivePlayerNotification;
|
||||
import pp.mdga.message.server.ActivePlayerMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.notification.RankingResponceNotification;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -24,8 +25,8 @@ public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
||||
this.parent = (DetermineStartPlayerState) parent;
|
||||
}
|
||||
|
||||
private void changeToIntro(){
|
||||
if(!canChange){
|
||||
private void changeToIntro() {
|
||||
if (!canChange) {
|
||||
canChange = true;
|
||||
return;
|
||||
}
|
||||
@@ -44,12 +45,12 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
parent.setState(parent.getRollRankingDice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RankingResponseMessage msg){
|
||||
public void received(RankingResponseMessage msg) {
|
||||
Map<Color, Integer> rankingResults = new HashMap<>();
|
||||
for (var entry : msg.getRankingResults().entrySet()) {
|
||||
rankingResults.put(logic.getGame().getPlayerById(entry.getKey()).getColor(), entry.getValue());
|
||||
@@ -58,13 +59,13 @@ public void received(RankingResponseMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
changeToIntro();
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ActivePlayerMessage msg){
|
||||
public void received(ActivePlayerMessage msg) {
|
||||
logic.getGame().setActiveColor(msg.getColor());
|
||||
changeToIntro();
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ public void enter() {
|
||||
@Override
|
||||
public void exit() {
|
||||
currentState.exit();
|
||||
currentState= null;
|
||||
currentState = null;
|
||||
}
|
||||
|
||||
public void setState(ChoosePieceStates state){
|
||||
public void setState(ChoosePieceStates state) {
|
||||
System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state);
|
||||
if(currentState != null){
|
||||
if (currentState != null) {
|
||||
currentState.exit();
|
||||
}
|
||||
state.enter();
|
||||
@@ -43,56 +43,56 @@ public void setState(ChoosePieceStates state){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
public void selectPiece(Piece piece) {
|
||||
currentState.selectPiece(piece);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SelectPieceMessage msg){
|
||||
public void received(SelectPieceMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
public void received(WaitPieceMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
public void received(StartPieceMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
public void received(EndOfTurnMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
currentState.received(msg);
|
||||
}
|
||||
|
||||
public NoPieceState getNoPiece(){
|
||||
public NoPieceState getNoPiece() {
|
||||
return noPieceState;
|
||||
}
|
||||
|
||||
public SelectPieceState getSelectPiece(){
|
||||
public SelectPieceState getSelectPiece() {
|
||||
return selectPieceState;
|
||||
}
|
||||
|
||||
public StartPieceState getStartPiece(){
|
||||
public StartPieceState getStartPiece() {
|
||||
return startPieceState;
|
||||
}
|
||||
|
||||
public WaitingPieceState getWaitingPiece(){
|
||||
public WaitingPieceState getWaitingPiece() {
|
||||
return waitingPieceState;
|
||||
}
|
||||
|
||||
public ChoosePieceStates getState(){
|
||||
public ChoosePieceStates getState() {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public TurnState getParent(){
|
||||
public TurnState getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.message.server.SpectatorMessage;
|
||||
|
||||
public class MovePieceState extends TurnStates {
|
||||
|
||||
@@ -26,27 +29,27 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(CeremonyMessage msg){
|
||||
public void received(CeremonyMessage msg) {
|
||||
logic.setState(logic.getCeremony());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
public void received(EndOfTurnMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(SpectatorMessage msg){
|
||||
public void received(SpectatorMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getSpectator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
parent.setState(parent.getRollDice());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.TurnState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.PlayCardNotification;
|
||||
@@ -24,7 +22,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
if(playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) {
|
||||
if (playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) {
|
||||
extraAnimationCounter++;
|
||||
}
|
||||
|
||||
@@ -43,8 +41,8 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
if(extraAnimationCounter > 0) {
|
||||
public void selectAnimationEnd() {
|
||||
if (extraAnimationCounter > 0) {
|
||||
extraAnimationCounter--;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public void exit() {
|
||||
public void setState(PowerCardStates state) {
|
||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||
|
||||
if(this.state != null){
|
||||
if (this.state != null) {
|
||||
this.state.exit();
|
||||
}
|
||||
state.enter();
|
||||
@@ -50,22 +50,22 @@ public void setState(PowerCardStates state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossibleCardsMessage msg){
|
||||
public void received(PossibleCardsMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
public void received(PlayCardMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(PossiblePieceMessage msg){
|
||||
public void received(PossiblePieceMessage msg) {
|
||||
state.received(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,43 +39,42 @@ public TurnState getParent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectDice(){
|
||||
if (!isRolled){
|
||||
public void selectDice() {
|
||||
if (!isRolled) {
|
||||
isRolled = true;
|
||||
logic.send(new RequestDieMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DieMessage msg){
|
||||
public void received(DieMessage msg) {
|
||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||
|
||||
if(logic.getGame().getTurboFlag()){
|
||||
if (logic.getGame().getTurboFlag()) {
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAnimationEnd(){
|
||||
public void selectAnimationEnd() {
|
||||
logic.send(new AnimationEndMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(ChoosePieceStateMessage msg){
|
||||
public void received(ChoosePieceStateMessage msg) {
|
||||
parent.setState(parent.getChoosePiece());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoTurnMessage msg){
|
||||
public void received(NoTurnMessage msg) {
|
||||
parent.getParent().setState(parent.getParent().getWaiting());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
public void received(DiceNowMessage msg) {
|
||||
isRolled = false;
|
||||
logic.addNotification(new DiceNowNotification());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.GameStates;
|
||||
|
||||
public abstract class TurnStates extends GameStates {
|
||||
public abstract class TurnStates extends GameStates {
|
||||
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.message.server.SelectPieceMessage;
|
||||
import pp.mdga.message.server.StartPieceMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.message.server.WaitPieceMessage;
|
||||
import pp.mdga.notification.SelectableMoveNotification;
|
||||
import pp.mdga.notification.WaitMoveNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -47,7 +47,7 @@ public void received(SelectPieceMessage msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(WaitPieceMessage msg){
|
||||
public void received(WaitPieceMessage msg) {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage");
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceID());
|
||||
logic.addNotification(new SelectableMoveNotification(new ArrayList<>(List.of(msg.getPieceID())), new ArrayList<>(List.of(logic.getGame().getPlayerByColor(piece.getColor()).getStartNodeIndex())), new ArrayList<>(List.of(false))));
|
||||
@@ -55,7 +55,7 @@ public void received(WaitPieceMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(StartPieceMessage msg){
|
||||
public void received(StartPieceMessage msg) {
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
List<UUID> listPiece = new ArrayList<>();
|
||||
List<Integer> listIndex = new ArrayList<>();
|
||||
@@ -70,7 +70,7 @@ public void received(StartPieceMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(EndOfTurnMessage msg){
|
||||
public void received(EndOfTurnMessage msg) {
|
||||
logic.getGame().setTurboFlag(false);
|
||||
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
|
||||
}
|
||||
|
||||
@@ -4,17 +4,11 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.notification.HomeMoveNotification;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.RemoveShieldNotification;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -63,29 +57,25 @@ public void received(MoveMessage msg) {
|
||||
System.out.println("Client: SelectState: activePiece in Home: infieldIndex" + infieldIndex);
|
||||
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
logic.getGame().getBoard().getInfield()[infieldIndex].clearOccupant();
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.out.println("Client: SelectPieceState: receivedMoveMessage:reached else");
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
System.out.println("Client: electPieceState: homeindex" + logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece));
|
||||
int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
|
||||
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex].clearOccupant();
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
||||
@@ -93,7 +83,7 @@ public void received(MoveMessage msg) {
|
||||
if (occ != null) {
|
||||
//TODO: MoveThrowNotification
|
||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||
if (occ.isSuppressed()){
|
||||
if (occ.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
|
||||
occ.setShield(ShieldState.NONE);
|
||||
}
|
||||
@@ -111,8 +101,7 @@ public void received(MoveMessage msg) {
|
||||
piece.setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
|
||||
}
|
||||
}
|
||||
else if (piece.isSuppressed()) {
|
||||
} else if (piece.isSuppressed()) {
|
||||
piece.setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
|
||||
}
|
||||
|
||||
@@ -7,15 +7,8 @@
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.RemoveShieldNotification;
|
||||
import pp.mdga.notification.ShieldActiveNotification;
|
||||
import pp.mdga.notification.ShieldSuppressedNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
public class StartPieceState extends ChoosePieceStates {
|
||||
|
||||
@@ -45,14 +38,14 @@ public void setMoveablePiece(Piece moveablePiece) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if(moveablePiece.equals(piece)){
|
||||
public void selectPiece(Piece piece) {
|
||||
if (moveablePiece.equals(piece)) {
|
||||
logic.send(new RequestMoveMessage(piece));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
int targetIndex = msg.getTargetIndex();
|
||||
@@ -62,21 +55,21 @@ public void received(MoveMessage msg){
|
||||
|
||||
//get Occupant
|
||||
Piece occ = targetNode.getOccupant();
|
||||
if (occ != null){
|
||||
if (occ != null) {
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
if (occ.isSuppressed()){
|
||||
if (occ.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
|
||||
occ.setShield(ShieldState.NONE);
|
||||
}
|
||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||
}
|
||||
|
||||
if (targetNode.isStart()){
|
||||
if (piece.isShielded()){
|
||||
if (targetNode.isStart()) {
|
||||
if (piece.isShielded()) {
|
||||
piece.setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(piece.getUuid()));
|
||||
}
|
||||
} else if (piece.isSuppressed()){
|
||||
} else if (piece.isSuppressed()) {
|
||||
piece.setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
|
||||
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
|
||||
|
||||
@@ -7,15 +7,11 @@
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.notification.MovePieceNotification;
|
||||
import pp.mdga.notification.RemoveShieldNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WaitingPieceState extends ChoosePieceStates {
|
||||
|
||||
private final ChoosePieceState parent;
|
||||
@@ -36,17 +32,17 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
public void selectPiece(Piece piece) {
|
||||
logic.send(new RequestMoveMessage(piece));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(MoveMessage msg){
|
||||
public void received(MoveMessage msg) {
|
||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
||||
if (occ != null){
|
||||
if (occ != null) {
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
if (occ.isSuppressed()){
|
||||
if (occ.isSuppressed()) {
|
||||
logic.addNotification(new RemoveShieldNotification(occ.getUuid()));
|
||||
occ.setShield(ShieldState.NONE);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.card.*;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
import pp.mdga.message.client.NoPowerCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
@@ -14,7 +13,6 @@
|
||||
import pp.mdga.message.server.PossibleCardsMessage;
|
||||
import pp.mdga.message.server.PossiblePieceMessage;
|
||||
import pp.mdga.notification.SelectableCardsNotification;
|
||||
import pp.mdga.notification.SelectableShieldNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -29,8 +27,9 @@ public class ChoosePowerCardState extends PowerCardStates {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param parent parent state
|
||||
* @param logic game logic
|
||||
* @param logic game logic
|
||||
*/
|
||||
public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
@@ -54,11 +53,12 @@ public void exit() {
|
||||
|
||||
/**
|
||||
* Set the possible cards
|
||||
*
|
||||
* @param msg possible cards message
|
||||
*/
|
||||
@Override
|
||||
public void received(PossibleCardsMessage msg){
|
||||
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
|
||||
public void received(PossibleCardsMessage msg) {
|
||||
possibleCards = (ArrayList<PowerCard>) msg.getPossibleCards();
|
||||
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
|
||||
for (PowerCard card : possibleCards) {
|
||||
if (!possibleBonusCards.contains(card.getCard())) {
|
||||
@@ -70,15 +70,16 @@ public void received(PossibleCardsMessage msg){
|
||||
|
||||
/**
|
||||
* Select a card
|
||||
*
|
||||
* @param card card to select
|
||||
*/
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
public void selectCard(BonusCard card) {
|
||||
Player player = logic.getGame().getPlayers().get(logic.getOwnPlayerId());
|
||||
ArrayList<PowerCard> handCards = player.getHandCards();
|
||||
if(card != null){
|
||||
if (card != null) {
|
||||
PowerCard select = player.getPowerCardByType(card);
|
||||
if(select == null){
|
||||
if (select == null) {
|
||||
select = select;
|
||||
}
|
||||
logic.send(new SelectCardMessage(select));
|
||||
@@ -89,11 +90,12 @@ public void selectCard(BonusCard card){
|
||||
|
||||
/**
|
||||
* Receive a card
|
||||
*
|
||||
* @param msg card message
|
||||
*/
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
if(msg.getCard().getCard().equals(BonusCard.TURBO)){
|
||||
public void received(PlayCardMessage msg) {
|
||||
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
logic.getGame().setTurboFlag(true);
|
||||
@@ -103,20 +105,22 @@ public void received(PlayCardMessage msg){
|
||||
|
||||
/**
|
||||
* Receive a die now message
|
||||
*
|
||||
* @param msg dice now message
|
||||
*/
|
||||
@Override
|
||||
public void received(DiceNowMessage msg){
|
||||
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()){
|
||||
public void received(PossiblePieceMessage msg) {
|
||||
if (msg.getEnemyPossiblePieces().isEmpty()) {
|
||||
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
|
||||
parent.setState(parent.getShield());
|
||||
} else {
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.SelectableShieldNotification;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShieldState extends PowerCardStates {
|
||||
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestPlayCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
import pp.mdga.notification.SelectableSwapNotification;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SwapState extends PowerCardStates {
|
||||
|
||||
@@ -59,17 +57,17 @@ public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectPiece(Piece piece){
|
||||
if (possibleOwnPieces.contains(piece)){
|
||||
public void selectPiece(Piece piece) {
|
||||
if (possibleOwnPieces.contains(piece)) {
|
||||
selectedOwnPiece = piece;
|
||||
} else if (possibleEnemyPieces.contains(piece)){
|
||||
} else if (possibleEnemyPieces.contains(piece)) {
|
||||
selectedEnemyPiece = piece;
|
||||
}
|
||||
if (selectedOwnPiece != null && selectedEnemyPiece != null){
|
||||
if (selectedOwnPiece != null && selectedEnemyPiece != null) {
|
||||
ArrayList<Piece> temp = new ArrayList<>();
|
||||
temp.add(selectedOwnPiece);
|
||||
temp.add(selectedEnemyPiece);
|
||||
System.out.println("Client : Swap: temp: "+temp.get(0)+temp.get(1));
|
||||
System.out.println("Client : Swap: temp: " + temp.get(0) + temp.get(1));
|
||||
logic.send(new SelectedPiecesMessage(temp));
|
||||
selectedEnemyPiece = null;
|
||||
selectedOwnPiece = null;
|
||||
|
||||
@@ -79,7 +79,7 @@ private StartNode createStartNode(int i) {
|
||||
*/
|
||||
public int getInfieldIndexOfPiece(Piece piece) {
|
||||
for (int i = 0; i < infield.length; i++) {
|
||||
if(infield[i].isOccupied()) {
|
||||
if (infield[i].isOccupied()) {
|
||||
if (infield[i].getOccupant().equals(piece)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public static Color getColorByIndex(int index) {
|
||||
public Color next(Game game) {
|
||||
ArrayList<Color> colorsInGame = new ArrayList<>();
|
||||
|
||||
for(Player p : game.getPlayers().values()) {
|
||||
if(p.isFinished()) {
|
||||
for (Player p : game.getPlayers().values()) {
|
||||
if (p.isFinished()) {
|
||||
continue;
|
||||
}
|
||||
colorsInGame.add(p.getColor());
|
||||
|
||||
@@ -109,7 +109,7 @@ private void initializeDrawPile() {
|
||||
*/
|
||||
public PowerCard draw() {
|
||||
if (!this.drawPile.isEmpty()) {
|
||||
if (drawPile.size() == 1){
|
||||
if (drawPile.size() == 1) {
|
||||
Collections.shuffle(this.discardPile);
|
||||
this.drawPile.addAll(this.discardPile);
|
||||
discardPile.clear();
|
||||
@@ -221,7 +221,7 @@ public Player getPlayerByColor(Color color) {
|
||||
*
|
||||
* @return the active player
|
||||
*/
|
||||
public Player getActivePlayer(){
|
||||
public Player getActivePlayer() {
|
||||
return getPlayerByColor(activeColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public void setOccupant(Piece occupant) {
|
||||
this.occupant = occupant;
|
||||
}
|
||||
|
||||
public boolean isBonus(){
|
||||
public boolean isBonus() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ public boolean isFinished() {
|
||||
*/
|
||||
public PowerCard getPowerCardByType(BonusCard bonusCard) {
|
||||
for (PowerCard card : this.handCards) {
|
||||
if(card.getCard().equals(bonusCard)) {
|
||||
if (card.getCard().equals(bonusCard)) {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
@@ -155,9 +155,9 @@ public PowerCard getPowerCardByType(BonusCard bonusCard) {
|
||||
// throw new RuntimeException("bonusCard is not in handCards");
|
||||
}
|
||||
|
||||
public Piece getWaitingPiece(){
|
||||
public Piece getWaitingPiece() {
|
||||
for (Piece piece : this.waitingArea) {
|
||||
if (piece != null){
|
||||
if (piece != null) {
|
||||
return piece;
|
||||
}
|
||||
}
|
||||
@@ -170,9 +170,9 @@ public Piece getWaitingPiece(){
|
||||
*
|
||||
* @return the boolean if the waiting area contains a piece
|
||||
*/
|
||||
public boolean hasPieceInWaitingArea(){
|
||||
public boolean hasPieceInWaitingArea() {
|
||||
for (Piece piece : this.waitingArea) {
|
||||
if (piece != null){
|
||||
if (piece != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -211,10 +211,10 @@ public boolean isHomeFinished(Piece piece) {
|
||||
*
|
||||
* @return the index
|
||||
*/
|
||||
public int getHighestHomeIdx(){
|
||||
for (int i =3; i>=0;i--){
|
||||
if(!homeNodes[i].isOccupied()) {
|
||||
System.out.println("Player: highestHomeIndex:"+i);
|
||||
public int getHighestHomeIdx() {
|
||||
for (int i = 3; i >= 0; i--) {
|
||||
if (!homeNodes[i].isOccupied()) {
|
||||
System.out.println("Player: highestHomeIndex:" + i);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ShieldCard extends PowerCard {
|
||||
public ShieldCard() {
|
||||
this.card = BonusCard.SHIELD;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to call the visit method of the given visitor parameter and pass a PowerCard object.
|
||||
*
|
||||
|
||||
@@ -33,7 +33,7 @@ public JoinedLobbyMessage() {
|
||||
*
|
||||
* @return the name of the player that is joining the server
|
||||
*/
|
||||
public String getName(){
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public class CeremonyMessage extends ServerMessage {
|
||||
private ArrayList<Integer> sixes;
|
||||
private ArrayList<Integer> nodesMoved;
|
||||
private ArrayList<Integer> bonusNodes;
|
||||
|
||||
/**
|
||||
* Constructs a new Ceremony instance.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@ public class ChoosePieceStateMessage extends ServerMessage {
|
||||
public ChoosePieceStateMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a visitor to process this message.
|
||||
*
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the client to inform about the dice roll.
|
||||
*/
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
|
||||
@Serializable
|
||||
public class DrawCardMessage extends ServerMessage{
|
||||
public class DrawCardMessage extends ServerMessage {
|
||||
|
||||
private final PowerCard card;
|
||||
|
||||
public DrawCardMessage(PowerCard card){
|
||||
public DrawCardMessage(PowerCard card) {
|
||||
super();
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
private DrawCardMessage(){
|
||||
private DrawCardMessage() {
|
||||
super();
|
||||
card = null;
|
||||
}
|
||||
@@ -28,12 +28,12 @@ public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
public PowerCard getCard(){
|
||||
public PowerCard getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DrawCardMessage{" + "PowerCard=" + card +'}';
|
||||
return "DrawCardMessage{" + "PowerCard=" + card + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public IncorrectRequestMessage() {
|
||||
*
|
||||
* @return the id of the error message
|
||||
*/
|
||||
public int getId(){
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package pp.mdga.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
/**
|
||||
* A message sent by the server to indicate that a player has left the lobby.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Piece;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the client to move a piece on the board.
|
||||
*/
|
||||
@@ -28,8 +26,8 @@ public class MoveMessage extends ServerMessage {
|
||||
/**
|
||||
* Constructs a new MoveMessage instance.
|
||||
*
|
||||
* @param piece the identifier of the piece that should be moved
|
||||
* @param isHomeMove boolean flag declaring home move or not
|
||||
* @param piece the identifier of the piece that should be moved
|
||||
* @param isHomeMove boolean flag declaring home move or not
|
||||
* @param targetIndex the targetIndex
|
||||
*/
|
||||
public MoveMessage(Piece piece, boolean isHomeMove, int targetIndex) {
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Piece;
|
||||
|
||||
import java.io.PipedOutputStream;
|
||||
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.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package pp.mdga.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.Piece;
|
||||
|
||||
import java.util.List;
|
||||
import pp.mdga.game.Piece;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to select a piece to move.
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that is sent when a card is acquired.
|
||||
*/
|
||||
public class AcquireCardNotification extends Notification{
|
||||
public class AcquireCardNotification extends Notification {
|
||||
|
||||
private BonusCard bonusCard;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
public class FinishNotification extends Notification{
|
||||
public class FinishNotification extends Notification {
|
||||
private Color colorFinished;
|
||||
|
||||
public FinishNotification(Color colorFinished){
|
||||
public FinishNotification(Color colorFinished) {
|
||||
this.colorFinished = colorFinished;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* GameNotification class
|
||||
*/
|
||||
public class GameNotification extends Notification{
|
||||
public class GameNotification extends Notification {
|
||||
|
||||
private final Color ownColor;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Notification that is to give information to the player.
|
||||
*/
|
||||
public class InfoNotification extends Notification{
|
||||
public class InfoNotification extends Notification {
|
||||
|
||||
private final String message;
|
||||
|
||||
@@ -28,5 +28,7 @@ public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean isError() { return isError; }
|
||||
public boolean isError() {
|
||||
return isError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
public class LobbyReadyNotification extends Notification{
|
||||
public class LobbyReadyNotification extends Notification {
|
||||
|
||||
/**
|
||||
* The color of the player.
|
||||
|
||||
@@ -31,9 +31,9 @@ public class MovePieceNotification extends Notification {
|
||||
/**
|
||||
* Constructs a notification for a piece start movement.
|
||||
*
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param moveIndex the destination node index
|
||||
* @param moveStart whether to ignore {@code startIndex} and use {@code moveIndex} as the start node
|
||||
* @param piece the unique identifier of the piece
|
||||
* @param moveIndex the destination node index
|
||||
* @param moveStart whether to ignore {@code startIndex} and use {@code moveIndex} as the start node
|
||||
*/
|
||||
public MovePieceNotification(UUID piece, int moveIndex, boolean moveStart) {
|
||||
this.piece = piece;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.server.ServerMessage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RankingResponceNotification extends Notification {
|
||||
private final Map<Color, Integer> rankingResults;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* Notification that a die has been rolled.
|
||||
*/
|
||||
public class RollDiceNotification extends Notification{
|
||||
public class RollDiceNotification extends Notification {
|
||||
|
||||
private Color color;
|
||||
private int eyes;
|
||||
@@ -14,10 +14,12 @@ public class RollDiceNotification extends Notification{
|
||||
private boolean isRanking;
|
||||
|
||||
//normal
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param color the color of the player that rolled the die.
|
||||
* @param eyes the number of eyes that were rolled.
|
||||
* @param eyes the number of eyes that were rolled.
|
||||
*/
|
||||
public RollDiceNotification(Color color, int eyes) {
|
||||
this.color = color;
|
||||
@@ -47,6 +49,7 @@ public RollDiceNotification(Color color, int eyes, int multiplier) {
|
||||
|
||||
/**
|
||||
* Get the color of the player that rolled the die.
|
||||
*
|
||||
* @return the color of the player that rolled the die.
|
||||
*/
|
||||
public Color getColor() {
|
||||
@@ -55,6 +58,7 @@ public Color getColor() {
|
||||
|
||||
/**
|
||||
* Get the number of eyes that were rolled.
|
||||
*
|
||||
* @return the number of eyes that were rolled.
|
||||
*/
|
||||
public int getEyes() {
|
||||
@@ -69,5 +73,7 @@ public boolean isTurbo() {
|
||||
return turbo;
|
||||
}
|
||||
|
||||
public boolean isRanking() { return isRanking; }
|
||||
public boolean isRanking() {
|
||||
return isRanking;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,7 @@ public class SelectableCardsNotification extends Notification {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param cards The list of cards that the player can choose from.
|
||||
*/
|
||||
public SelectableCardsNotification(List<BonusCard> cards) {
|
||||
@@ -22,6 +24,7 @@ public SelectableCardsNotification(List<BonusCard> cards) {
|
||||
|
||||
/**
|
||||
* Get the list of cards that the player can choose from.
|
||||
*
|
||||
* @return The list of cards that the player can choose from.
|
||||
*/
|
||||
public List<BonusCard> getCards() {
|
||||
|
||||
@@ -26,9 +26,9 @@ public class SelectableMoveNotification extends Notification {
|
||||
/**
|
||||
* Constructs a notification for selectable piece moves.
|
||||
*
|
||||
* @param pieces the list of pieces that can be moved
|
||||
* @param pieces the list of pieces that can be moved
|
||||
* @param moveIndices the list of target nodes for the moves
|
||||
* @param homeMoves the list indicating if the target nodes are in the home area
|
||||
* @param homeMoves the list indicating if the target nodes are in the home area
|
||||
*/
|
||||
public SelectableMoveNotification(List<UUID> pieces, List<Integer> moveIndices, List<Boolean> homeMoves) {
|
||||
this.pieces = pieces;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SelectableShieldNotification extends Notification{
|
||||
public class SelectableShieldNotification extends Notification {
|
||||
private List<UUID> pieces;
|
||||
|
||||
public SelectableShieldNotification(List<UUID> pieces){
|
||||
public SelectableShieldNotification(List<UUID> pieces) {
|
||||
this.pieces = pieces;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pp.mdga.notification;
|
||||
|
||||
public class TurboActiveNotification extends Notification{
|
||||
public class TurboActiveNotification extends Notification {
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ServerGameLogic implements ClientInterpreter {
|
||||
public class ServerGameLogic implements ClientInterpreter {
|
||||
/**
|
||||
* Constants.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.notification.CeremonyNotification;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
|
||||
/**
|
||||
@@ -28,9 +27,9 @@ public CeremonyState(ServerGameLogic logic) {
|
||||
*
|
||||
* @return the created CeremonyNotification
|
||||
*/
|
||||
private CeremonyMessage createCeremonyMessage(){
|
||||
private CeremonyMessage createCeremonyMessage() {
|
||||
CeremonyMessage message = new CeremonyMessage();
|
||||
for (var player : logic.getGame().getPlayerRanking().entrySet()){
|
||||
for (var player : logic.getGame().getPlayerRanking().entrySet()) {
|
||||
message.getColors().add(player.getValue().getColor());
|
||||
message.getNames().add(player.getValue().getName());
|
||||
message.getSixes().add(player.getValue().getPlayerStatistic().getDiced6());
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.message.server.PauseGameMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
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;
|
||||
|
||||
@@ -86,15 +86,15 @@ public void received(LeaveGameMessage msg, int from) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoPowerCardMessage msg, int from){
|
||||
public void received(NoPowerCardMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
public void received(SelectCardMessage msg, int from){
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
currentState.received(msg, from);
|
||||
}
|
||||
|
||||
public void received(RequestMoveMessage msg, int from){
|
||||
public void received(RequestMoveMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.game.card.TurboCard;
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
@@ -98,8 +94,7 @@ public void received(SelectTSKMessage msg, int from) {
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, Color.NONE, false));
|
||||
this.logic.getGame().getPlayerById(from).setColor(msg.getColor());
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, msg.getColor(), true));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(0));
|
||||
}
|
||||
}
|
||||
@@ -132,8 +127,7 @@ public void received(LobbyReadyMessage msg, int from) {
|
||||
if (color != Color.NONE) {
|
||||
this.logic.getGame().getPlayerById(from).setColor(color);
|
||||
this.logic.getServerSender().broadcast(new UpdateTSKMessage(from, color, true));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(1));
|
||||
}
|
||||
}
|
||||
@@ -171,8 +165,7 @@ public void received(StartGameMessage msg, int from) {
|
||||
} else {
|
||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(6));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ public ServerState(ServerGameLogic logic) {
|
||||
* @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) {}
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a DeselectTSKMessage message.
|
||||
@@ -50,7 +51,8 @@ public void received(AnimationEndMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(DeselectTSKMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a StartGame message.
|
||||
@@ -59,7 +61,8 @@ public void received(DeselectTSKMessage msg, int from) {}
|
||||
* @param msg as the message which was sent by the player as a StartGame object.
|
||||
* @param from as the client id of the player as an Integer.
|
||||
*/
|
||||
public void received(StartGameMessage msg, int from) {}
|
||||
public void received(StartGameMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a JoinedLobbyMessage message.
|
||||
@@ -68,7 +71,8 @@ public void received(StartGameMessage msg, int from) {}
|
||||
* @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(JoinedLobbyMessage msg, int from) {}
|
||||
public void received(JoinedLobbyMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received an LeaveGameMessage message.
|
||||
@@ -94,7 +98,8 @@ public void received(LeaveGameMessage msg, int from) {
|
||||
* @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) {}
|
||||
public void received(LobbyReadyMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a LobbyNotReadyMessage message.
|
||||
@@ -103,7 +108,8 @@ public void received(LobbyReadyMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(LobbyNotReadyMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a DisconnectedMessage message.
|
||||
@@ -112,7 +118,8 @@ public void received(LobbyNotReadyMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(DisconnectedMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestBriefingMessage message.
|
||||
@@ -121,7 +128,8 @@ public void received(DisconnectedMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(RequestBriefingMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestDieMessage message.
|
||||
@@ -130,7 +138,8 @@ public void received(RequestBriefingMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(RequestDieMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestMoveMessage message.
|
||||
@@ -139,7 +148,8 @@ public void received(RequestDieMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(RequestMoveMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a RequestPlayCardMessage message.
|
||||
@@ -148,7 +158,8 @@ public void received(RequestMoveMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(RequestPlayCardMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectCardMessage message.
|
||||
@@ -157,7 +168,8 @@ public void received(RequestPlayCardMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectTSKMessage message.
|
||||
@@ -166,7 +178,8 @@ public void received(SelectCardMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(SelectTSKMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a ForceContinueGameMessage message.
|
||||
@@ -175,7 +188,8 @@ public void received(SelectTSKMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(ForceContinueGameMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a ClientStartGameMessage message.
|
||||
@@ -184,7 +198,8 @@ public void received(ForceContinueGameMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(ClientStartGameMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a NoPowerCardMessage message.
|
||||
@@ -193,7 +208,8 @@ public void received(ClientStartGameMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(NoPowerCardMessage msg, int from) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called whenever the server received a SelectedPiecesMessage message.
|
||||
@@ -202,5 +218,6 @@ public void received(NoPowerCardMessage msg, int from) {}
|
||||
* @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) {}
|
||||
public void received(SelectedPiecesMessage msg, int from) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,12 @@
|
||||
import pp.mdga.message.server.ActivePlayerMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.message.server.RankingResponseMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.*;
|
||||
|
||||
public class DetermineStartPlayerState extends GameAutomatonState {
|
||||
/**
|
||||
@@ -32,7 +25,7 @@ public class DetermineStartPlayerState extends GameAutomatonState {
|
||||
private final Map<Integer, Integer> diceResults = new HashMap<>();
|
||||
private final Map<Integer, Integer> finalDiceResults = new HashMap<>();
|
||||
private final List<Integer> playersHaveToRoll = new ArrayList<>();
|
||||
private final Set<Integer> messageReceived = new HashSet<>();;
|
||||
private final Set<Integer> messageReceived = new HashSet<>();
|
||||
private int playerToStart;
|
||||
|
||||
/**
|
||||
@@ -77,8 +70,7 @@ public void received(RequestDieMessage msg, int from) {
|
||||
if (maximumRoll == entry.getValue()) {
|
||||
this.playersHaveToRoll.add(entry.getKey());
|
||||
LOGGER.log(Level.INFO, "Players have to roll(RD same as maximum): {0}", this.playersHaveToRoll.size());
|
||||
}
|
||||
else if (maximumRoll < entry.getValue()) {
|
||||
} else if (maximumRoll < entry.getValue()) {
|
||||
maximumRoll = entry.getValue();
|
||||
this.playersHaveToRoll.clear();
|
||||
this.playersHaveToRoll.add(entry.getKey());
|
||||
@@ -109,8 +101,7 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
}
|
||||
finalDiceResults.putAll(this.diceResults);
|
||||
diceResults.clear();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
finalDiceResults.putAll(this.diceResults);
|
||||
LOGGER.log(Level.INFO, "Players have to roll: %s".formatted(this.logic.getGame().getPlayerById(this.playersHaveToRoll.get(0))));
|
||||
Color color = this.logic.getGame().getPlayerById(this.playersHaveToRoll.get(0)).getColor();
|
||||
|
||||
@@ -6,12 +6,7 @@
|
||||
import pp.mdga.message.client.*;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.GameState;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
import pp.mdga.server.automaton.game.turn.MovePieceState;
|
||||
import pp.mdga.server.automaton.game.turn.PlayPowerCardState;
|
||||
import pp.mdga.server.automaton.game.turn.PowerCardState;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
import pp.mdga.server.automaton.game.turn.TurnAutomatonState;
|
||||
import pp.mdga.server.automaton.game.turn.*;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
@@ -118,7 +113,7 @@ public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
public void received(SelectCardMessage msg, int from){
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
currentState.received(msg, from);
|
||||
}
|
||||
|
||||
@@ -195,7 +190,7 @@ public void setCurrentState(TurnAutomatonState state) {
|
||||
if (this.currentState != null) {
|
||||
this.currentState.exit();
|
||||
}
|
||||
System.out.println("Server: the server entered:"+state);
|
||||
System.out.println("Server: the server entered:" + state);
|
||||
this.currentState = state;
|
||||
this.currentState.enter();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.ActivePlayerMessage;
|
||||
import pp.mdga.message.server.CeremonyMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.EndOfTurnMessage;
|
||||
import pp.mdga.message.server.SpectatorMessage;
|
||||
@@ -43,20 +42,20 @@ private void setActivePlayer(Color activePlayer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from){
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
finishedAnimations.add(logic.getGame().getPlayerById(from));
|
||||
if (finishedAnimations.size() == logic.getGame().getPlayers().size()) {
|
||||
if (logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).isFinished()){
|
||||
if (logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).isFinished()) {
|
||||
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getActivePlayer());
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new SpectatorMessage());
|
||||
setActivePlayer(logic.getGame().getActiveColor());
|
||||
if (logic.getGame().getPlayerRanking().size() == logic.getGame().getPlayers().size() - 1){
|
||||
if (logic.getGame().getPlayerRanking().size() == logic.getGame().getPlayers().size() - 1) {
|
||||
logic.getGame().getPlayerRanking().put(logic.getGame().getPlayerRanking().size(), logic.getGame().getActivePlayer());
|
||||
logic.setCurrentState(logic.getCeremonyState());
|
||||
return;
|
||||
}
|
||||
this.turnAutomaton.getGameAutomaton().setCurrentState(this.turnAutomaton.getGameAutomaton().getTurnState());
|
||||
} else if (logic.getGame().getDiceEyes() == 6){
|
||||
} else if (logic.getGame().getDiceEyes() == 6) {
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(logic.getGame().getActiveColor()), new DiceNowMessage());
|
||||
this.turnAutomaton.setCurrentState(this.turnAutomaton.getRollDiceState());
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.AnimationState;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -10,11 +10,7 @@
|
||||
import pp.mdga.message.server.PossibleCardsMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.TurnState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.ChoosePowerCardState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.PowerCardAutomatonState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.ShieldCardState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.SwapCardState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.TurboCardState;
|
||||
import pp.mdga.server.automaton.game.turn.powercard.*;
|
||||
import pp.mdga.visitor.ServerCardVisitor;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -41,7 +37,7 @@ public class PowerCardState extends TurnAutomatonState {
|
||||
private ServerCardVisitor visitor;
|
||||
private PowerCard selectedCard;
|
||||
private final Set<Piece> selectedPieces = new HashSet<>();
|
||||
private final Set<BonusCard> chekedCards = new HashSet<>();
|
||||
private final Set<BonusCard> chekedCards = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Constructs a server state of the specified game logic.
|
||||
@@ -74,8 +70,7 @@ public void enter() {
|
||||
if (this.visitor.getCards().isEmpty()) {
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
|
||||
this.turnAutomaton.setCurrentState(this.turnAutomaton.getRollDiceState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PossibleCardsMessage(this.visitor.getCards()));
|
||||
}
|
||||
}
|
||||
@@ -86,7 +81,7 @@ public void exit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(NoPowerCardMessage msg, int form){
|
||||
public void received(NoPowerCardMessage msg, int form) {
|
||||
currentState.received(msg, form);
|
||||
}
|
||||
|
||||
@@ -100,7 +95,7 @@ public void addSelectedPiece(Piece piece) {
|
||||
this.selectedPieces.add(piece);
|
||||
}
|
||||
|
||||
public void received(SelectCardMessage msg, int from){
|
||||
public void received(SelectCardMessage msg, int from) {
|
||||
currentState.received(msg, from);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
|
||||
@Override
|
||||
public void enter() {
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
|
||||
if (resetModifier){
|
||||
if (resetModifier) {
|
||||
logic.getGame().setDiceModifier(1);
|
||||
}
|
||||
this.setCurrentState(this.firstRollState);
|
||||
@@ -65,7 +65,7 @@ public void received(RequestDieMessage msg, int from) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(AnimationEndMessage msg, int from){
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
this.currentState.received(msg, from);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.ServerState;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
@@ -43,8 +42,7 @@ protected boolean canMove(Piece piece) {
|
||||
if (canPieceMoveInHome(piece, steps)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (canPieceMoveInHome(piece, steps)) {
|
||||
return true;
|
||||
}
|
||||
@@ -55,8 +53,8 @@ else if (40 > targetIdx && (!piece.getState().equals(PieceState.HOME) || !piece.
|
||||
//checks if the target-node is not occupied by an own color
|
||||
if (!tartgetNode.isOccupied(activeColor)) {
|
||||
//checks if the targetNode is not occupied or the occupant ha no shield
|
||||
if(tartgetNode.isOccupied()) {
|
||||
if(tartgetNode.getOccupant().getShield().equals(ShieldState.ACTIVE)) {
|
||||
if (tartgetNode.isOccupied()) {
|
||||
if (tartgetNode.getOccupant().getShield().equals(ShieldState.ACTIVE)) {
|
||||
System.out.println("Server: targetNode.getOccupant().getShield().equals(ShieldState.ACTIVE" + tartgetNode.getOccupant().getShield().equals(ShieldState.ACTIVE));
|
||||
return false;
|
||||
}
|
||||
@@ -88,8 +86,7 @@ protected boolean canPieceMoveInHome(Piece piece, int steps) {
|
||||
//tests if the steps are less than the possible movement
|
||||
if ((3 - homeIdx) >= steps - 1) {
|
||||
return !jumpOver(steps, homeIdx, false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -107,8 +104,7 @@ else if (piece.getState() == PieceState.ACTIVE) {
|
||||
if (restMovement >= 4) return false;
|
||||
return !jumpOver(restMovement, 0, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -126,7 +122,7 @@ private boolean jumpOver(int stepsInHome, int homeIdx, boolean outside) {
|
||||
//tests if the piece comes from the outside in the home
|
||||
if (outside) {
|
||||
System.out.println("Server: jumpOver: for the homeIndex: " + homeIdx + " ,stepsInHome: " + stepsInHome + " , outside: " + outside + " annd the targetIndex: " + stepsInHome);
|
||||
if(stepsInHome>3) return true;
|
||||
if (stepsInHome > 3) return true;
|
||||
if (logic.getGame().getActivePlayer().getHomeNodes()[stepsInHome].isOccupied()) return true;
|
||||
for (int i = 0; i <= stepsInHome; i++) {
|
||||
if (logic.getGame().getActivePlayer().getHomeNodes()[i].isOccupied()) return true;
|
||||
@@ -136,7 +132,7 @@ private boolean jumpOver(int stepsInHome, int homeIdx, boolean outside) {
|
||||
else {
|
||||
int targetIndex = stepsInHome + homeIdx;
|
||||
System.out.println("Server: jumpOver: for the homeIndex: " + homeIdx + " ,stepsInHome: " + stepsInHome + " , outside: " + outside + " and the targetIndex: " + targetIndex);
|
||||
if(targetIndex>3) return true;
|
||||
if (targetIndex > 3) return true;
|
||||
if (logic.getGame().getActivePlayer().getHomeNodes()[targetIndex].isOccupied()) return true;
|
||||
for (int i = 1 + homeIdx; i <= targetIndex; i++) {
|
||||
if (logic.getGame().getActivePlayer().getHomeNodes()[i].isOccupied()) return true;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.Resources;
|
||||
import pp.mdga.game.*;
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
|
||||
@@ -36,24 +36,19 @@ private void initialize() {
|
||||
}
|
||||
}
|
||||
this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
|
||||
}
|
||||
else if (activePlayer.hasPieceInWaitingArea()) {
|
||||
} else if (activePlayer.hasPieceInWaitingArea()) {
|
||||
if (!logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].isOccupied(activePlayer.getColor())) {
|
||||
if (logic.getGame().getDiceEyes() == 6) {
|
||||
this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getWaitingPieceState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkSelectPiece(activePlayer);
|
||||
}
|
||||
}
|
||||
else if (canMove(logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].getOccupant())) {
|
||||
} else if (canMove(logic.getGame().getBoard().getInfield()[activePlayer.getStartNodeIndex()].getOccupant())) {
|
||||
this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getStartPieceState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkSelectPiece(activePlayer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkSelectPiece(activePlayer);
|
||||
}
|
||||
}
|
||||
@@ -68,8 +63,7 @@ private void checkSelectPiece(Player activePlayer) {
|
||||
moveablePieces.removeIf(piece -> !canMove(piece));
|
||||
if (moveablePieces.isEmpty()) {
|
||||
this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getNoTurnState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.choosePieceAutomaton.getSelectPieceState().setMoveablePieces(moveablePieces);
|
||||
this.choosePieceAutomaton.setCurrentState(this.choosePieceAutomaton.getSelectPieceState());
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ public void enter() {
|
||||
int target = getHomeTargetIdx(piece, steps);
|
||||
targetIndex.add(target);
|
||||
isHomeMove.add(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int target = getInfieldTarget(piece, steps);
|
||||
targetIndex.add(target);
|
||||
isHomeMove.add(false);
|
||||
@@ -78,15 +77,13 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[targetHomeIdx];
|
||||
if (targetHomeIdx == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
|
||||
oldNode.clearOccupant();
|
||||
targetNode.setOccupant(piece);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
|
||||
|
||||
@@ -96,8 +93,7 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
|
||||
if (targetHomeIdx == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||
piece.setState(PieceState.HOMEFINISHED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
piece.setState(PieceState.HOME);
|
||||
}
|
||||
|
||||
@@ -105,8 +101,7 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
targetNode.setOccupant(piece);
|
||||
}
|
||||
LOGGER.log(System.Logger.Level.INFO, "Server : SelectPieceState: PieceState:" + piece.getState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Server : SelectPieceState: PieceState:" + piece.getState());
|
||||
int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
|
||||
@@ -147,8 +142,7 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
PowerCard cardToDraw = logic.getGame().draw();
|
||||
p.addHandCard(cardToDraw);
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(cardToDraw));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ public void received(RequestMoveMessage msg, int from) {
|
||||
PowerCard cardToDraw = logic.getGame().draw();
|
||||
p.addHandCard(cardToDraw);
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(cardToDraw));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
import pp.mdga.message.server.WaitPieceMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
|
||||
import pp.mdga.server.automaton.game.turn.rolldice.FirstRollState;
|
||||
|
||||
public class WaitingPieceState extends ChoosePieceAutomatonState {
|
||||
/**
|
||||
@@ -38,7 +36,7 @@ public void enter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(RequestMoveMessage msg, int from){
|
||||
public void received(RequestMoveMessage msg, int from) {
|
||||
if (msg.getPiece().equals(this.piece)) {
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeWaitingPiece(this.piece);
|
||||
piece.setState(PieceState.ACTIVE);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package pp.mdga.server.automaton.game.turn.powercard;
|
||||
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.card.HiddenCard;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.game.card.TurboCard;
|
||||
import pp.mdga.game.card.*;
|
||||
import pp.mdga.message.client.NoPowerCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
|
||||
@@ -14,7 +14,7 @@ public abstract class PowerCardAutomatonState extends ServerState {
|
||||
* Constructs a server state of the specified game logic.
|
||||
*
|
||||
* @param powerCardAutomaton as the automaton of the turn state as a PowerCardState object.
|
||||
* @param logic the game logic
|
||||
* @param logic the game logic
|
||||
*/
|
||||
public PowerCardAutomatonState(PowerCardState powerCardAutomaton, ServerGameLogic logic) {
|
||||
super(logic);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package pp.mdga.server.automaton.game.turn.powercard;
|
||||
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.ShieldState;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||
import pp.mdga.message.server.IncorrectRequestMessage;
|
||||
import pp.mdga.message.server.PlayCardMessage;
|
||||
@@ -62,8 +60,7 @@ public void received(SelectedPiecesMessage msg, int from) {
|
||||
this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
|
||||
this.logic.getGame().getDiscardPile().add(this.powerCardAutomaton.getSelectedCard());
|
||||
this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logic.getServerSender().send(from, new IncorrectRequestMessage(3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package pp.mdga.server.automaton.game.turn.powercard;
|
||||
|
||||
import pp.mdga.game.Board;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.game.Node;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
@@ -12,7 +11,6 @@
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.PowerCardState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SwapCardState extends PowerCardAutomatonState {
|
||||
@@ -58,12 +56,12 @@ public void received(SelectedPiecesMessage msg, int from) {
|
||||
if (msg.getPieces().size() == 2) {
|
||||
Piece selOwn = msg.getPieces().get(0);
|
||||
Piece selEnemy = msg.getPieces().get(1);
|
||||
System.out.println("Server: Swapcard: ownPiece: "+selOwn+ " enemyPiece: "+selEnemy);
|
||||
System.out.println("Server: Swapcard: ownPiece: " + selOwn + " enemyPiece: " + selEnemy);
|
||||
List<Piece> ownPieces = this.powerCardAutomaton.getVisitor().getSwapOwnPieces();
|
||||
List<Piece> enemyPieces = this.powerCardAutomaton.getVisitor().getSwapOtherPieces();
|
||||
|
||||
//if selOwn and selEnemy is in wrong order
|
||||
if(ownPieces.contains(selEnemy) && enemyPieces.contains(selOwn)){
|
||||
if (ownPieces.contains(selEnemy) && enemyPieces.contains(selOwn)) {
|
||||
Piece temp = selEnemy;
|
||||
selEnemy = selOwn;
|
||||
selOwn = temp;
|
||||
@@ -73,7 +71,8 @@ public void received(SelectedPiecesMessage msg, int from) {
|
||||
this.powerCardAutomaton.addSelectedPiece(selOwn);
|
||||
this.powerCardAutomaton.addSelectedPiece(selEnemy);
|
||||
|
||||
if(!(powerCardAutomaton.getSelectedCard() instanceof SwapCard)) throw new RuntimeException("getSelectedCard is not swapCard");
|
||||
if (!(powerCardAutomaton.getSelectedCard() instanceof SwapCard))
|
||||
throw new RuntimeException("getSelectedCard is not swapCard");
|
||||
|
||||
swapPieces(selOwn, selEnemy);
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.ChoosePieceStateMessage;
|
||||
import pp.mdga.message.server.DiceAgainMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
import pp.mdga.server.automaton.game.turn.RollDiceState;
|
||||
@@ -75,7 +73,7 @@ public void received(RequestDieMessage msg, int from) {
|
||||
public void received(AnimationEndMessage msg, int from) {
|
||||
if (from != this.logic.getGame().getActivePlayerId()) {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Received AnimationEndMessage from wrong player.");
|
||||
} else if (!isDied){
|
||||
} else if (!isDied) {
|
||||
LOGGER.log(System.Logger.Level.INFO, "Received AnimationEndMessage without the active player rolling a die.");
|
||||
} else if (!moveablePieces.isEmpty()) {
|
||||
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import pp.mdga.message.client.AnimationEndMessage;
|
||||
import pp.mdga.message.client.RequestDieMessage;
|
||||
import pp.mdga.message.server.ChoosePieceStateMessage;
|
||||
import pp.mdga.message.server.DiceAgainMessage;
|
||||
import pp.mdga.message.server.DiceNowMessage;
|
||||
import pp.mdga.message.server.DieMessage;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.card.HiddenCard;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
import pp.mdga.game.card.ShieldCard;
|
||||
import pp.mdga.game.card.SwapCard;
|
||||
import pp.mdga.game.card.TurboCard;
|
||||
import pp.mdga.game.card.*;
|
||||
import pp.mdga.server.ServerGameLogic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
Reference in New Issue
Block a user