added java docs
This commit is contained in:
@@ -4,6 +4,13 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
|
|
||||||
public abstract class CeremonyStates extends ClientState {
|
public abstract class CeremonyStates extends ClientState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
protected CeremonyStates(ClientState parent, ClientGameLogic logic) {
|
protected CeremonyStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,21 +8,36 @@ public class PodiumState extends CeremonyStates {
|
|||||||
|
|
||||||
private final CeremonyState parent;
|
private final CeremonyState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructs a new PodiumState.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public PodiumState(ClientState parent, ClientGameLogic logic) {
|
public PodiumState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (CeremonyState) parent;
|
this.parent = (CeremonyState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client enters the PodiumState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client exits the PodiumState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the next button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectNext() {
|
public void selectNext() {
|
||||||
parent.setState(parent.getStatisticsState());
|
parent.setState(parent.getStatisticsState());
|
||||||
|
|||||||
@@ -4,20 +4,36 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
|
|
||||||
public class StatisticsState extends CeremonyStates {
|
public class StatisticsState extends CeremonyStates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructs a new StatisticsState.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public StatisticsState(ClientState parent, ClientGameLogic logic) {
|
public StatisticsState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client enters the StatisticsState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client exits the StatisticsState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the next button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectNext() {
|
public void selectNext() {
|
||||||
logic.setState(logic.getDialogs());
|
logic.setState(logic.getDialogs());
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
public abstract class DialogStates extends ClientState {
|
public abstract class DialogStates extends ClientState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public DialogStates(ClientState parent, ClientGameLogic logic) {
|
public DialogStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,20 +19,35 @@ public class LobbyState extends DialogStates {
|
|||||||
|
|
||||||
private final DialogsState parent;
|
private final DialogsState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor of the LobbyState.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public LobbyState(ClientState parent, ClientGameLogic logic) {
|
public LobbyState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (DialogsState) parent;
|
this.parent = (DialogsState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client enters the LobbyState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName()));
|
logic.send(new JoinedLobbyMessage(logic.getOwnPlayerName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client exits the LobbyState.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the leave button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectLeave() {
|
public void selectLeave() {
|
||||||
parent.setState(parent.getStartDialog());
|
parent.setState(parent.getStartDialog());
|
||||||
@@ -40,26 +55,45 @@ public void selectLeave() {
|
|||||||
logic.send(new LeaveGameMessage());
|
logic.send(new LeaveGameMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the color of the player.
|
||||||
|
*
|
||||||
|
* @param color the color of the player
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectTSK(Color color) {
|
public void selectTSK(Color color) {
|
||||||
logic.send(new SelectTSKMessage(color));
|
logic.send(new SelectTSKMessage(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client deselects the color of the player.
|
||||||
|
*
|
||||||
|
* @param color the color of the player
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deselectTSK(Color color) {
|
public void deselectTSK(Color color) {
|
||||||
logic.send(new DeselectTSKMessage(color));
|
logic.send(new DeselectTSKMessage(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the ready button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectReady() {
|
public void selectReady() {
|
||||||
logic.send(new LobbyReadyMessage());
|
logic.send(new LobbyReadyMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the unready button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectUnready() {
|
public void selectUnready() {
|
||||||
logic.send(new LobbyNotReadyMessage());
|
logic.send(new LobbyNotReadyMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client selects the start button.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectStart() {
|
public void selectStart() {
|
||||||
if (logic.isHost() && logic.getGame().areAllReady()) {
|
if (logic.isHost() && logic.getGame().areAllReady()) {
|
||||||
@@ -70,6 +104,11 @@ public void selectStart() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client receives a message.
|
||||||
|
*
|
||||||
|
* @param msg the message which was received
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ServerStartGameMessage msg) {
|
public void received(ServerStartGameMessage msg) {
|
||||||
for (Player player : msg.getPlayers()) {
|
for (Player player : msg.getPlayers()) {
|
||||||
@@ -91,6 +130,11 @@ public void received(ServerStartGameMessage msg) {
|
|||||||
logic.setState(logic.getGameState());
|
logic.setState(logic.getGameState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client receives a message.
|
||||||
|
*
|
||||||
|
* @param msg the message which was received
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerJoinedMessage msg) {
|
public void received(LobbyPlayerJoinedMessage msg) {
|
||||||
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
|
if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
|
||||||
@@ -105,6 +149,11 @@ public void received(LobbyPlayerJoinedMessage msg) {
|
|||||||
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
logic.getGame().getPlayers().put(msg.getId(), msg.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client receives a message.
|
||||||
|
*
|
||||||
|
* @param msg the message which was received
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateTSKMessage msg) {
|
public void received(UpdateTSKMessage msg) {
|
||||||
if (msg.isTaken()) {
|
if (msg.isTaken()) {
|
||||||
@@ -116,15 +165,24 @@ public void received(UpdateTSKMessage msg) {
|
|||||||
logic.getGame().getPlayers().get(msg.getId()).setColor(msg.getColor());
|
logic.getGame().getPlayers().get(msg.getId()).setColor(msg.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client receives a message.
|
||||||
|
*
|
||||||
|
* @param msg the message which was received
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(LobbyPlayerLeaveMessage msg) {
|
public void received(LobbyPlayerLeaveMessage msg) {
|
||||||
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
|
||||||
logic.getGame().getPlayers().remove(msg.getId());
|
logic.getGame().getPlayers().remove(msg.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called whenever the client receives a message.
|
||||||
|
*
|
||||||
|
* @param msg the message which was received
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(UpdateReadyMessage msg) {
|
public void received(UpdateReadyMessage msg) {
|
||||||
//TODO server sendet kein update on UNready
|
|
||||||
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
|
||||||
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,35 @@ public class AnimationState extends GameStates {
|
|||||||
|
|
||||||
private final GameState parent;
|
private final GameState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public AnimationState(ClientState parent, ClientGameLogic logic) {
|
public AnimationState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the animation end.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
|
|||||||
@@ -18,41 +18,83 @@ public class DetermineStartPlayerState extends GameStates {
|
|||||||
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
||||||
private final Intro intro = new Intro(this, logic);
|
private final Intro intro = new Intro(this, logic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the roll ranking dice.
|
||||||
|
*
|
||||||
|
* @return the roll ranking dice
|
||||||
|
*/
|
||||||
public RollRankingDiceState getRollRankingDice() {
|
public RollRankingDiceState getRollRankingDice() {
|
||||||
return rollRankingDiceState;
|
return rollRankingDiceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the wait ranking.
|
||||||
|
*
|
||||||
|
* @return the wait ranking
|
||||||
|
*/
|
||||||
public WaitRankingState getWaitRanking() {
|
public WaitRankingState getWaitRanking() {
|
||||||
return waitRankingState;
|
return waitRankingState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state.
|
||||||
|
*
|
||||||
|
* @return the state
|
||||||
|
*/
|
||||||
public DetermineStartPlayerStates getState() {
|
public DetermineStartPlayerStates getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the intro.
|
||||||
|
*
|
||||||
|
* @return the intro
|
||||||
|
*/
|
||||||
public Intro getIntro() {
|
public Intro getIntro() {
|
||||||
return intro;
|
return intro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parent state.
|
||||||
|
*
|
||||||
|
* @return the parent state
|
||||||
|
*/
|
||||||
public GameState getParent() {
|
public GameState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
this.setState(this.rollRankingDiceState);
|
this.setState(this.rollRankingDiceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state.
|
||||||
|
*
|
||||||
|
* @param state the state
|
||||||
|
*/
|
||||||
public void setState(DetermineStartPlayerStates state) {
|
public void setState(DetermineStartPlayerStates state) {
|
||||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||||
if (this.state != null) {
|
if (this.state != null) {
|
||||||
@@ -62,36 +104,67 @@ public void setState(DetermineStartPlayerStates state) {
|
|||||||
this.state.enter();
|
this.state.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the dice.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectDice() {
|
public void selectDice() {
|
||||||
state.selectDice();
|
state.selectDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the animation end.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
state.selectAnimationEnd();
|
state.selectAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the die message.
|
||||||
|
*
|
||||||
|
* @param msg the die message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ceremony message.
|
||||||
|
*
|
||||||
|
* @param msg the ceremony message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ranking roll again message.
|
||||||
|
*
|
||||||
|
* @param msg the ranking roll again message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingRollAgainMessage msg) {
|
public void received(RankingRollAgainMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ranking response message.
|
||||||
|
*
|
||||||
|
* @param msg the ranking response message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingResponseMessage msg) {
|
public void received(RankingResponseMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ranking result message.
|
||||||
|
*
|
||||||
|
* @param msg the ranking result message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
|
|||||||
@@ -14,10 +14,21 @@ public abstract class GameStates extends ClientState {
|
|||||||
|
|
||||||
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public GameStates(ClientState parent, ClientGameLogic logic) {
|
public GameStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the power card.
|
||||||
|
*
|
||||||
|
* @param msg the play card message
|
||||||
|
*/
|
||||||
protected void handlePowerCard(PlayCardMessage msg) {
|
protected void handlePowerCard(PlayCardMessage msg) {
|
||||||
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
|
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
|
||||||
logic.getGame().setTurboFlag(true);
|
logic.getGame().setTurboFlag(true);
|
||||||
@@ -30,6 +41,11 @@ protected void handlePowerCard(PlayCardMessage msg) {
|
|||||||
logic.getGame().getDiscardPile().add(msg.getCard());
|
logic.getGame().getDiscardPile().add(msg.getCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the shield.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid
|
||||||
|
*/
|
||||||
private void handleShield(UUID uuid) {
|
private void handleShield(UUID uuid) {
|
||||||
Board board = logic.getGame().getBoard();
|
Board board = logic.getGame().getBoard();
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(uuid);
|
Piece piece = logic.getGame().getPieceThroughUUID(uuid);
|
||||||
@@ -44,6 +60,12 @@ private void handleShield(UUID uuid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps the pieces.
|
||||||
|
*
|
||||||
|
* @param messageOwn the own piece
|
||||||
|
* @param messageEnemy the enemy piece
|
||||||
|
*/
|
||||||
private void swapPieces(Piece messageOwn, Piece messageEnemy) {
|
private void swapPieces(Piece messageOwn, Piece messageEnemy) {
|
||||||
//swap Pieces in Model
|
//swap Pieces in Model
|
||||||
Board board = logic.getGame().getBoard();
|
Board board = logic.getGame().getBoard();
|
||||||
@@ -61,6 +83,12 @@ private void swapPieces(Piece messageOwn, Piece messageEnemy) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the shield after the swap.
|
||||||
|
*
|
||||||
|
* @param node the node
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
private void checkShieldAfterSwap(Node node, Piece piece) {
|
private void checkShieldAfterSwap(Node node, Piece piece) {
|
||||||
if (node.isStart()) {
|
if (node.isStart()) {
|
||||||
if (piece.isShielded()) {
|
if (piece.isShielded()) {
|
||||||
|
|||||||
@@ -15,25 +15,45 @@ public class SpectatorState extends GameStates {
|
|||||||
|
|
||||||
private final GameState parent;
|
private final GameState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public SpectatorState(ClientState parent, ClientGameLogic logic) {
|
public SpectatorState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the Ceremony Message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
logic.setState(logic.getCeremony());
|
logic.setState(logic.getCeremony());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the Draw card message.
|
||||||
|
*
|
||||||
|
* @param msg the draw card message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DrawCardMessage msg) {
|
public void received(DrawCardMessage msg) {
|
||||||
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
||||||
@@ -46,17 +66,19 @@ public void received(DrawCardMessage msg) {
|
|||||||
logic.getGame().getGameStatistics().increaseActivatedBonusNodes();
|
logic.getGame().getGameStatistics().increaseActivatedBonusNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the Die Message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
//logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
||||||
if (msg.getDiceEye() == 6) {
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
|
||||||
}
|
|
||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the PlayCardMessage Message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
||||||
@@ -66,6 +88,9 @@ public void received(PlayCardMessage msg) {
|
|||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ActivePlayerMessage Message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||||
@@ -73,6 +98,9 @@ public void received(ActivePlayerMessage msg) {
|
|||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the MoveMessage Message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
|
|||||||
@@ -3,11 +3,30 @@
|
|||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.client.gamestate.turnstate.*;
|
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||||
|
import pp.mdga.client.gamestate.turnstate.MovePieceState;
|
||||||
|
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
|
||||||
|
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||||
|
import pp.mdga.client.gamestate.turnstate.RollDiceState;
|
||||||
|
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.game.ShieldState;
|
import pp.mdga.game.ShieldState;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.CeremonyMessage;
|
||||||
|
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.message.server.EndOfTurnMessage;
|
||||||
|
import pp.mdga.message.server.MoveMessage;
|
||||||
|
import pp.mdga.message.server.NoTurnMessage;
|
||||||
|
import pp.mdga.message.server.PlayCardMessage;
|
||||||
|
import pp.mdga.message.server.PossibleCardsMessage;
|
||||||
|
import pp.mdga.message.server.PossiblePieceMessage;
|
||||||
|
import pp.mdga.message.server.SelectPieceMessage;
|
||||||
|
import pp.mdga.message.server.SpectatorMessage;
|
||||||
|
import pp.mdga.message.server.StartPieceMessage;
|
||||||
|
import pp.mdga.message.server.WaitPieceMessage;
|
||||||
import pp.mdga.notification.RemoveShieldNotification;
|
import pp.mdga.notification.RemoveShieldNotification;
|
||||||
|
|
||||||
public class TurnState extends GameStates {
|
public class TurnState extends GameStates {
|
||||||
@@ -22,11 +41,20 @@ public class TurnState extends GameStates {
|
|||||||
private final RollDiceState rollDiceState = new RollDiceState(this, logic);
|
private final RollDiceState rollDiceState = new RollDiceState(this, logic);
|
||||||
private boolean canChangeTurbo = false;
|
private boolean canChangeTurbo = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public TurnState(ClientState parent, ClientGameLogic logic) {
|
public TurnState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
logic = logic;
|
logic = logic;
|
||||||
@@ -40,11 +68,19 @@ public void enter() {
|
|||||||
this.setState(this.powerCardState);
|
this.setState(this.powerCardState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state.
|
||||||
|
*
|
||||||
|
* @param state the state
|
||||||
|
*/
|
||||||
public void setState(TurnStates state) {
|
public void setState(TurnStates state) {
|
||||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||||
if (this.state != null) {
|
if (this.state != null) {
|
||||||
@@ -54,133 +90,269 @@ public void setState(TurnStates state) {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the dice.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectDice() {
|
public void selectDice() {
|
||||||
state.selectDice();
|
state.selectDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
state.selectPiece(piece);
|
state.selectPiece(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the card.
|
||||||
|
*
|
||||||
|
* @param card the card
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectCard(BonusCard card) {
|
public void selectCard(BonusCard card) {
|
||||||
state.selectCard(card);
|
state.selectCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the animation end.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
state.selectAnimationEnd();
|
state.selectAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the select piece message.
|
||||||
|
*
|
||||||
|
* @param msg the select piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg) {
|
public void received(SelectPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the wait piece message.
|
||||||
|
*
|
||||||
|
* @param msg the wait piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(WaitPieceMessage msg) {
|
public void received(WaitPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the start piece message.
|
||||||
|
*
|
||||||
|
* @param msg the start piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(StartPieceMessage msg) {
|
public void received(StartPieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the NoTurnMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the NoTurnMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(NoTurnMessage msg) {
|
public void received(NoTurnMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the MoveMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the MoveMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the CeremonyMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the CeremonyMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the EndOfTurnMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the EndOfTurnMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the SpectatorMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the SpectatorMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SpectatorMessage msg) {
|
public void received(SpectatorMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the DiceAgainMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the DiceAgainMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceAgainMessage msg) {
|
public void received(DiceAgainMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the PossibleCardsMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the PossibleCardsMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardsMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the PlayCardMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the PlayCardMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the DiceNow message.
|
||||||
|
*
|
||||||
|
* @param msg the DiceNow message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the DieMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the DieMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the PossiblePieceMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the PossiblePieceMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossiblePieceMessage msg) {
|
public void received(PossiblePieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ChoosePieceStateMessage message.
|
||||||
|
*
|
||||||
|
* @param msg the ChoosePieceStateMessage message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ChoosePieceStateMessage msg) {
|
public void received(ChoosePieceStateMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ChoosePieceState.
|
||||||
|
*
|
||||||
|
* @return the ChoosePieceState
|
||||||
|
*/
|
||||||
public ChoosePieceState getChoosePiece() {
|
public ChoosePieceState getChoosePiece() {
|
||||||
return choosePieceState;
|
return choosePieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the MovePieceState.
|
||||||
|
*
|
||||||
|
* @return the MovePieceState
|
||||||
|
*/
|
||||||
public MovePieceState getMovePiece() {
|
public MovePieceState getMovePiece() {
|
||||||
return movePieceState;
|
return movePieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the PlayPowerCardState.
|
||||||
|
*
|
||||||
|
* @return the PlayPowerCardState
|
||||||
|
*/
|
||||||
public PlayPowerCardState getPlayPowerCard() {
|
public PlayPowerCardState getPlayPowerCard() {
|
||||||
return playPowerCardState;
|
return playPowerCardState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the PowerCardState.
|
||||||
|
*
|
||||||
|
* @return the PowerCardState
|
||||||
|
*/
|
||||||
public PowerCardState getPowerCard() {
|
public PowerCardState getPowerCard() {
|
||||||
return powerCardState;
|
return powerCardState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the RollDiceState.
|
||||||
|
*
|
||||||
|
* @return the RollDiceState
|
||||||
|
*/
|
||||||
public RollDiceState getRollDice() {
|
public RollDiceState getRollDice() {
|
||||||
return rollDiceState;
|
return rollDiceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parent GameState.
|
||||||
|
*
|
||||||
|
* @return the parent GameState
|
||||||
|
*/
|
||||||
public GameState getParent() {
|
public GameState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current TurnStates.
|
||||||
|
*
|
||||||
|
* @return the current TurnStates
|
||||||
|
*/
|
||||||
public TurnStates getState() {
|
public TurnStates getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if turbo can be changed.
|
||||||
|
*
|
||||||
|
* @return true if turbo can be changed, false otherwise
|
||||||
|
*/
|
||||||
public boolean isCanChangeTurbo() {
|
public boolean isCanChangeTurbo() {
|
||||||
return canChangeTurbo;
|
return canChangeTurbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the turbo change flag.
|
||||||
|
*
|
||||||
|
* @param canChangeTurbo the new value for the turbo change flag
|
||||||
|
*/
|
||||||
public void setCanChangeTurbo(boolean canChangeTurbo) {
|
public void setCanChangeTurbo(boolean canChangeTurbo) {
|
||||||
this.canChangeTurbo = canChangeTurbo;
|
this.canChangeTurbo = canChangeTurbo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,31 +10,56 @@
|
|||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the waiting state in the game.
|
||||||
|
*/
|
||||||
public class WaitingState extends GameStates {
|
public class WaitingState extends GameStates {
|
||||||
|
|
||||||
private final GameState parent;
|
private final GameState parent;
|
||||||
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new WaitingState.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the game logic
|
||||||
|
*/
|
||||||
public WaitingState(ClientState parent, ClientGameLogic logic) {
|
public WaitingState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when entering the waiting state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when exiting the waiting state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reception of a CeremonyMessage.
|
||||||
|
*
|
||||||
|
* @param msg the ceremony message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
logic.setState(logic.getCeremony());
|
logic.setState(logic.getCeremony());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reception of a DieMessage.
|
||||||
|
*
|
||||||
|
* @param msg the die message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
@@ -51,6 +76,11 @@ public void received(DieMessage msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reception of a PlayCardMessage.
|
||||||
|
*
|
||||||
|
* @param msg the play card message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
||||||
@@ -60,6 +90,11 @@ public void received(PlayCardMessage msg) {
|
|||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reception of an ActivePlayerMessage.
|
||||||
|
*
|
||||||
|
* @param msg the active player message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||||
@@ -76,6 +111,11 @@ public void received(ActivePlayerMessage msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reception of a MoveMessage.
|
||||||
|
*
|
||||||
|
* @param msg the move message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
import pp.mdga.client.gamestate.GameStates;
|
import pp.mdga.client.gamestate.GameStates;
|
||||||
|
|
||||||
public abstract class DetermineStartPlayerStates extends GameStates {
|
public abstract class DetermineStartPlayerStates extends GameStates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,23 +15,38 @@ public class RollRankingDiceState extends DetermineStartPlayerStates {
|
|||||||
private final DetermineStartPlayerState parent;
|
private final DetermineStartPlayerState parent;
|
||||||
private boolean isRolled = false;
|
private boolean isRolled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
|
public RollRankingDiceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
this.parent = (DetermineStartPlayerState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Entering RollRankingDiceState");
|
LOGGER.log(System.Logger.Level.INFO, "Entering RollRankingDiceState");
|
||||||
logic.addNotification(new DiceNowNotification());
|
logic.addNotification(new DiceNowNotification());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState");
|
LOGGER.log(System.Logger.Level.INFO, "Exiting RollRankingDiceState");
|
||||||
isRolled = false;
|
isRolled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the dice.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectDice() {
|
public void selectDice() {
|
||||||
if (!isRolled) {
|
if (!isRolled) {
|
||||||
@@ -40,6 +55,11 @@ public void selectDice() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a DieMessage.
|
||||||
|
*
|
||||||
|
* @param msg the DieMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
parent.setState(parent.getWaitRanking());
|
parent.setState(parent.getWaitRanking());
|
||||||
|
|||||||
@@ -20,11 +20,20 @@ public class WaitRankingState extends DetermineStartPlayerStates {
|
|||||||
private final DetermineStartPlayerState parent;
|
private final DetermineStartPlayerState parent;
|
||||||
private boolean canChange = false;
|
private boolean canChange = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
public WaitRankingState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
this.parent = (DetermineStartPlayerState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the state to the intro state.
|
||||||
|
*/
|
||||||
private void changeToIntro() {
|
private void changeToIntro() {
|
||||||
if (!canChange) {
|
if (!canChange) {
|
||||||
canChange = true;
|
canChange = true;
|
||||||
@@ -33,22 +42,38 @@ private void changeToIntro() {
|
|||||||
parent.setState(parent.getIntro());
|
parent.setState(parent.getIntro());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Entering WaitRankingState");
|
LOGGER.log(System.Logger.Level.INFO, "Entering WaitRankingState");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
canChange = false;
|
canChange = false;
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Exiting WaitRankingState");
|
LOGGER.log(System.Logger.Level.INFO, "Exiting WaitRankingState");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a DiceNowMessage.
|
||||||
|
*
|
||||||
|
* @param msg the DiceNowMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
parent.setState(parent.getRollRankingDice());
|
parent.setState(parent.getRollRankingDice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a RankingResponseMessage.
|
||||||
|
*
|
||||||
|
* @param msg the RankingResponseMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingResponseMessage msg) {
|
public void received(RankingResponseMessage msg) {
|
||||||
Map<Color, Integer> rankingResults = new HashMap<>();
|
Map<Color, Integer> rankingResults = new HashMap<>();
|
||||||
@@ -58,12 +83,20 @@ public void received(RankingResponseMessage msg) {
|
|||||||
logic.addNotification(new RankingResponceNotification(rankingResults));
|
logic.addNotification(new RankingResponceNotification(rankingResults));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the view has completed the animation.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
changeToIntro();
|
changeToIntro();
|
||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends an ActivePlayerMessage.
|
||||||
|
*
|
||||||
|
* @param msg the ActivePlayerMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ActivePlayerMessage msg) {
|
public void received(ActivePlayerMessage msg) {
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
logic.getGame().setActiveColor(msg.getColor());
|
||||||
|
|||||||
@@ -17,22 +17,39 @@ public class ChoosePieceState extends TurnStates {
|
|||||||
private final StartPieceState startPieceState = new StartPieceState(this, logic);
|
private final StartPieceState startPieceState = new StartPieceState(this, logic);
|
||||||
private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic);
|
private final WaitingPieceState waitingPieceState = new WaitingPieceState(this, logic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public ChoosePieceState(ClientState parent, ClientGameLogic logic) {
|
public ChoosePieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (TurnState) parent;
|
this.parent = (TurnState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
this.setState(this.noPieceState);
|
this.setState(this.noPieceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
currentState.exit();
|
currentState.exit();
|
||||||
currentState = null;
|
currentState = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state.
|
||||||
|
*
|
||||||
|
* @param state the state
|
||||||
|
*/
|
||||||
public void setState(ChoosePieceStates state) {
|
public void setState(ChoosePieceStates state) {
|
||||||
System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state);
|
System.out.println("CLIENT STATE old: " + this.currentState + " new: " + state);
|
||||||
if (currentState != null) {
|
if (currentState != null) {
|
||||||
@@ -42,56 +59,104 @@ public void setState(ChoosePieceStates state) {
|
|||||||
currentState = state;
|
currentState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
currentState.selectPiece(piece);
|
currentState.selectPiece(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the select piece message.
|
||||||
|
*
|
||||||
|
* @param msg the select piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg) {
|
public void received(SelectPieceMessage msg) {
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the wait piece message.
|
||||||
|
*
|
||||||
|
* @param msg the wait piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(WaitPieceMessage msg) {
|
public void received(WaitPieceMessage msg) {
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the start piece message.
|
||||||
|
*
|
||||||
|
* @param msg the start piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(StartPieceMessage msg) {
|
public void received(StartPieceMessage msg) {
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the end of turn message.
|
||||||
|
*
|
||||||
|
* @param msg the end of turn message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the move message.
|
||||||
|
*
|
||||||
|
* @param msg the move message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the no piece state.
|
||||||
|
*/
|
||||||
public NoPieceState getNoPiece() {
|
public NoPieceState getNoPiece() {
|
||||||
return noPieceState;
|
return noPieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the select piece state.
|
||||||
|
*/
|
||||||
public SelectPieceState getSelectPiece() {
|
public SelectPieceState getSelectPiece() {
|
||||||
return selectPieceState;
|
return selectPieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the start piece state.
|
||||||
|
*/
|
||||||
public StartPieceState getStartPiece() {
|
public StartPieceState getStartPiece() {
|
||||||
return startPieceState;
|
return startPieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the waiting piece state.
|
||||||
|
*/
|
||||||
public WaitingPieceState getWaitingPiece() {
|
public WaitingPieceState getWaitingPiece() {
|
||||||
return waitingPieceState;
|
return waitingPieceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current state.
|
||||||
|
*/
|
||||||
public ChoosePieceStates getState() {
|
public ChoosePieceStates getState() {
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parent state.
|
||||||
|
*/
|
||||||
public TurnState getParent() {
|
public TurnState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,46 +13,86 @@ public class MovePieceState extends TurnStates {
|
|||||||
|
|
||||||
private final TurnState parent;
|
private final TurnState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public MovePieceState(ClientState parent, ClientGameLogic logic) {
|
public MovePieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (TurnState) parent;
|
this.parent = (TurnState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the animation end.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the ceremony message.
|
||||||
|
*
|
||||||
|
* @param msg the ceremony message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
logic.setState(logic.getCeremony());
|
logic.setState(logic.getCeremony());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the end of turn message.
|
||||||
|
*
|
||||||
|
* @param msg the end of turn message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
parent.getParent().setState(parent.getParent().getWaiting());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the spectator message.
|
||||||
|
*
|
||||||
|
* @param msg the spectator message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SpectatorMessage msg) {
|
public void received(SpectatorMessage msg) {
|
||||||
parent.getParent().setState(parent.getParent().getSpectator());
|
parent.getParent().setState(parent.getParent().getSpectator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the dice now message.
|
||||||
|
*
|
||||||
|
* @param msg the dice now message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
parent.setState(parent.getRollDice());
|
parent.setState(parent.getRollDice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parent state.
|
||||||
|
*
|
||||||
|
* @return the parent state
|
||||||
|
*/
|
||||||
public TurnState getParent() {
|
public TurnState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,20 @@ public class PlayPowerCardState extends TurnStates {
|
|||||||
private PlayCardMessage playCardMessage;
|
private PlayCardMessage playCardMessage;
|
||||||
private int extraAnimationCounter = 0;
|
private int extraAnimationCounter = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param parent parent state
|
||||||
|
* @param logic game logic
|
||||||
|
*/
|
||||||
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (TurnState) parent;
|
this.parent = (TurnState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter the state
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
if (playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) {
|
if (playCardMessage.getCard().getCard().equals(BonusCard.SWAP)) {
|
||||||
@@ -31,15 +40,26 @@ public void enter() {
|
|||||||
handlePowerCard(playCardMessage);
|
handlePowerCard(playCardMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
playCardMessage = null;
|
playCardMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the power card
|
||||||
|
*
|
||||||
|
* @param playCardMessage the play card message
|
||||||
|
*/
|
||||||
public void setPlayCard(PlayCardMessage playCardMessage) {
|
public void setPlayCard(PlayCardMessage playCardMessage) {
|
||||||
this.playCardMessage = playCardMessage;
|
this.playCardMessage = playCardMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The view has finished its animation
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
if (extraAnimationCounter > 0) {
|
if (extraAnimationCounter > 0) {
|
||||||
|
|||||||
@@ -23,22 +23,38 @@ public class PowerCardState extends TurnStates {
|
|||||||
private final ShieldState shieldState = new ShieldState(this, logic);
|
private final ShieldState shieldState = new ShieldState(this, logic);
|
||||||
private final SwapState swapState = new SwapState(this, logic);
|
private final SwapState swapState = new SwapState(this, logic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public PowerCardState(ClientState parent, ClientGameLogic logic) {
|
public PowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (TurnState) parent;
|
this.parent = (TurnState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
this.setState(this.choosePowerCardState);
|
this.setState(this.choosePowerCardState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
public void exit() {
|
public void exit() {
|
||||||
state.exit();
|
state.exit();
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the state.
|
||||||
|
*
|
||||||
|
* @param state the state
|
||||||
|
*/
|
||||||
public void setState(PowerCardStates state) {
|
public void setState(PowerCardStates state) {
|
||||||
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
System.out.println("CLIENT STATE old: " + this.state + " new: " + state);
|
||||||
|
|
||||||
@@ -49,52 +65,97 @@ public void setState(PowerCardStates state) {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the possible cards message.
|
||||||
|
*
|
||||||
|
* @param msg the possible cards message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardsMessage msg) {
|
public void received(PossibleCardsMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the play card message.
|
||||||
|
*
|
||||||
|
* @param msg the play card message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the dice now message.
|
||||||
|
*
|
||||||
|
* @param msg the dice now message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the possible piece message.
|
||||||
|
*
|
||||||
|
* @param msg the possible piece message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossiblePieceMessage msg) {
|
public void received(PossiblePieceMessage msg) {
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the card.
|
||||||
|
*
|
||||||
|
* @param card the card
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectCard(BonusCard card) {
|
public void selectCard(BonusCard card) {
|
||||||
state.selectCard(card);
|
state.selectCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
state.selectPiece(piece);
|
state.selectPiece(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the choose power card state.
|
||||||
|
*/
|
||||||
public ChoosePowerCardState getChoosePowerCard() {
|
public ChoosePowerCardState getChoosePowerCard() {
|
||||||
return choosePowerCardState;
|
return choosePowerCardState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shield state.
|
||||||
|
*/
|
||||||
public ShieldState getShield() {
|
public ShieldState getShield() {
|
||||||
return shieldState;
|
return shieldState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the swap state.
|
||||||
|
*/
|
||||||
public SwapState getSwap() {
|
public SwapState getSwap() {
|
||||||
return swapState;
|
return swapState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parent state.
|
||||||
|
*/
|
||||||
public TurnState getParent() {
|
public TurnState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the state.
|
||||||
|
*/
|
||||||
public PowerCardStates getState() {
|
public PowerCardStates getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,27 +17,47 @@ public class RollDiceState extends TurnStates {
|
|||||||
private final TurnState parent;
|
private final TurnState parent;
|
||||||
private boolean isRolled = false;
|
private boolean isRolled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
public RollDiceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (TurnState) parent;
|
this.parent = (TurnState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
isRolled = false;
|
isRolled = false;
|
||||||
logic.addNotification(new DiceNowNotification());
|
logic.addNotification(new DiceNowNotification());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
logic.getGame().setDiceModifier(1);
|
logic.getGame().setDiceModifier(1);
|
||||||
isRolled = false;
|
isRolled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parent state.
|
||||||
|
*
|
||||||
|
* @return the parent state
|
||||||
|
*/
|
||||||
public TurnState getParent() {
|
public TurnState getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the dice.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectDice() {
|
public void selectDice() {
|
||||||
if (!isRolled) {
|
if (!isRolled) {
|
||||||
@@ -46,6 +66,11 @@ public void selectDice() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the die message.
|
||||||
|
*
|
||||||
|
* @param msg the die message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
@@ -58,21 +83,39 @@ public void received(DieMessage msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the animation end.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the choose piece state message.
|
||||||
|
*
|
||||||
|
* @param msg the choose piece state message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(ChoosePieceStateMessage msg) {
|
public void received(ChoosePieceStateMessage msg) {
|
||||||
parent.setState(parent.getChoosePiece());
|
parent.setState(parent.getChoosePiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the no turn message.
|
||||||
|
*
|
||||||
|
* @param msg the no turn message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(NoTurnMessage msg) {
|
public void received(NoTurnMessage msg) {
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
parent.getParent().setState(parent.getParent().getWaiting());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the dice now message.
|
||||||
|
*
|
||||||
|
* @param msg the dice now message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg) {
|
public void received(DiceNowMessage msg) {
|
||||||
isRolled = false;
|
isRolled = false;
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
import pp.mdga.client.gamestate.GameStates;
|
import pp.mdga.client.gamestate.GameStates;
|
||||||
|
|
||||||
public abstract class TurnStates extends GameStates {
|
public abstract class TurnStates extends GameStates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
public TurnStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||||
|
|
||||||
public abstract class ChoosePieceStates extends TurnStates {
|
public abstract class ChoosePieceStates extends TurnStates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,21 +23,36 @@ public class NoPieceState extends ChoosePieceStates {
|
|||||||
|
|
||||||
private final ChoosePieceState parent;
|
private final ChoosePieceState parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public NoPieceState(ClientState parent, ClientGameLogic logic) {
|
public NoPieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (ChoosePieceState) parent;
|
this.parent = (ChoosePieceState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Entering NoPieceState");
|
LOGGER.log(System.Logger.Level.INFO, "Entering NoPieceState");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg) {
|
public void received(SelectPieceMessage msg) {
|
||||||
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
|
||||||
@@ -48,6 +63,9 @@ public void received(SelectPieceMessage msg) {
|
|||||||
parent.setState(parent.getSelectPiece());
|
parent.setState(parent.getSelectPiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the dice.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(WaitPieceMessage msg) {
|
public void received(WaitPieceMessage msg) {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage");
|
LOGGER.log(System.Logger.Level.INFO, "Received WaitPieceMessage");
|
||||||
@@ -56,6 +74,11 @@ public void received(WaitPieceMessage msg) {
|
|||||||
parent.setState(parent.getWaitingPiece());
|
parent.setState(parent.getWaitingPiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a DiceNowMessage.
|
||||||
|
*
|
||||||
|
* @param msg the DiceNowMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(StartPieceMessage msg) {
|
public void received(StartPieceMessage msg) {
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||||
@@ -71,12 +94,22 @@ public void received(StartPieceMessage msg) {
|
|||||||
parent.setState(parent.getStartPiece());
|
parent.setState(parent.getStartPiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a DiceNowMessage.
|
||||||
|
*
|
||||||
|
* @param msg the DiceNowMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(EndOfTurnMessage msg) {
|
public void received(EndOfTurnMessage msg) {
|
||||||
logic.getGame().setTurboFlag(false);
|
logic.getGame().setTurboFlag(false);
|
||||||
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
|
parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a DiceNowMessage.
|
||||||
|
*
|
||||||
|
* @param msg the DiceNowMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(DiceNowMessage msg){
|
public void received(DiceNowMessage msg){
|
||||||
parent.getParent().setState(parent.getParent().getRollDice());
|
parent.getParent().setState(parent.getParent().getRollDice());
|
||||||
|
|||||||
@@ -18,25 +18,47 @@ public class SelectPieceState extends ChoosePieceStates {
|
|||||||
private ArrayList<Piece> possiblePieces;
|
private ArrayList<Piece> possiblePieces;
|
||||||
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public SelectPieceState(ClientState parent, ClientGameLogic logic) {
|
public SelectPieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (ChoosePieceState) parent;
|
this.parent = (ChoosePieceState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
possiblePieces = new ArrayList<>();
|
possiblePieces = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the possible pieces.
|
||||||
|
*
|
||||||
|
* @param possiblePieces the possible pieces
|
||||||
|
*/
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||||
this.possiblePieces = possiblePieces;
|
this.possiblePieces = possiblePieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
if (possiblePieces.contains(piece)) {
|
if (possiblePieces.contains(piece)) {
|
||||||
@@ -44,6 +66,11 @@ public void selectPiece(Piece piece) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a MoveMessage.
|
||||||
|
*
|
||||||
|
* @param msg the MoveMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
|
|||||||
@@ -17,26 +17,47 @@ public class StartPieceState extends ChoosePieceStates {
|
|||||||
private final ChoosePieceState parent;
|
private final ChoosePieceState parent;
|
||||||
private Piece moveablePiece;
|
private Piece moveablePiece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public StartPieceState(ClientState parent, ClientGameLogic logic) {
|
public StartPieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (ChoosePieceState) parent;
|
this.parent = (ChoosePieceState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
moveablePiece = null;
|
moveablePiece = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the moveable piece.
|
||||||
|
*
|
||||||
|
* @param moveablePiece the moveable piece
|
||||||
|
*/
|
||||||
public void setMoveablePiece(Piece moveablePiece) {
|
public void setMoveablePiece(Piece moveablePiece) {
|
||||||
this.moveablePiece = moveablePiece;
|
this.moveablePiece = moveablePiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
if (moveablePiece.equals(piece)) {
|
if (moveablePiece.equals(piece)) {
|
||||||
@@ -44,6 +65,11 @@ public void selectPiece(Piece piece) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the move message.
|
||||||
|
*
|
||||||
|
* @param msg the move message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
|
|||||||
@@ -17,25 +17,47 @@ public class WaitingPieceState extends ChoosePieceStates {
|
|||||||
private final ChoosePieceState parent;
|
private final ChoosePieceState parent;
|
||||||
private Piece moveablePiece;
|
private Piece moveablePiece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public WaitingPieceState(ClientState parent, ClientGameLogic logic) {
|
public WaitingPieceState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (ChoosePieceState) parent;
|
this.parent = (ChoosePieceState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
moveablePiece = null;
|
moveablePiece = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the moveable piece.
|
||||||
|
*
|
||||||
|
* @param piece the moveable piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
logic.send(new RequestMoveMessage(piece));
|
logic.send(new RequestMoveMessage(piece));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the move message.
|
||||||
|
*
|
||||||
|
* @param msg the move message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg) {
|
public void received(MoveMessage msg) {
|
||||||
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
import pp.mdga.client.gamestate.turnstate.TurnStates;
|
||||||
|
|
||||||
public abstract class PowerCardStates extends TurnStates {
|
public abstract class PowerCardStates extends TurnStates {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
public PowerCardStates(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,26 +18,48 @@ public class ShieldState extends PowerCardStates {
|
|||||||
|
|
||||||
private ArrayList<Piece> possiblePieces;
|
private ArrayList<Piece> possiblePieces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public ShieldState(ClientState parent, ClientGameLogic logic) {
|
public ShieldState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (PowerCardState) parent;
|
this.parent = (PowerCardState) parent;
|
||||||
possiblePieces = new ArrayList<>();
|
possiblePieces = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList()));
|
logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
possiblePieces = null;
|
possiblePieces = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the possible pieces.
|
||||||
|
*
|
||||||
|
* @param possiblePieces the possible pieces
|
||||||
|
*/
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||||
this.possiblePieces = possiblePieces;
|
this.possiblePieces = possiblePieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
if (possiblePieces.contains(piece)) {
|
if (possiblePieces.contains(piece)) {
|
||||||
// logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
|
// logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
|
||||||
@@ -49,7 +71,11 @@ public void selectPiece(Piece piece) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the server sends a PlayCardMessage.
|
||||||
|
*
|
||||||
|
* @param msg the PlayCardMessage
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ public class SwapState extends PowerCardStates {
|
|||||||
private Piece selectedOwnPiece;
|
private Piece selectedOwnPiece;
|
||||||
private Piece selectedEnemyPiece;
|
private Piece selectedEnemyPiece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a client state of the specified game logic.
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public SwapState(ClientState parent, ClientGameLogic logic) {
|
public SwapState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (PowerCardState) parent;
|
this.parent = (PowerCardState) parent;
|
||||||
@@ -31,6 +37,9 @@ public SwapState(ClientState parent, ClientGameLogic logic) {
|
|||||||
selectedEnemyPiece = null;
|
selectedEnemyPiece = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Entering SwapState");
|
LOGGER.log(System.Logger.Level.INFO, "Entering SwapState");
|
||||||
@@ -41,6 +50,9 @@ public void enter() {
|
|||||||
selectedEnemyPiece = null;
|
selectedEnemyPiece = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Exiting SwapState");
|
LOGGER.log(System.Logger.Level.INFO, "Exiting SwapState");
|
||||||
@@ -48,14 +60,29 @@ public void exit() {
|
|||||||
possibleEnemyPieces.clear();
|
possibleEnemyPieces.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the possible own pieces.
|
||||||
|
*
|
||||||
|
* @param possibleOwnPieces the possible own pieces
|
||||||
|
*/
|
||||||
public void setPossibleOwnPieces(ArrayList<Piece> possibleOwnPieces) {
|
public void setPossibleOwnPieces(ArrayList<Piece> possibleOwnPieces) {
|
||||||
this.possibleOwnPieces = possibleOwnPieces;
|
this.possibleOwnPieces = possibleOwnPieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the possible enemy pieces.
|
||||||
|
*
|
||||||
|
* @param possibleEnemyPieces the possible enemy pieces
|
||||||
|
*/
|
||||||
public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
|
public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
|
||||||
this.possibleEnemyPieces = possibleEnemyPieces;
|
this.possibleEnemyPieces = possibleEnemyPieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the piece.
|
||||||
|
*
|
||||||
|
* @param piece the piece
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPiece(Piece piece) {
|
public void selectPiece(Piece piece) {
|
||||||
if (possibleOwnPieces.contains(piece)) {
|
if (possibleOwnPieces.contains(piece)) {
|
||||||
@@ -74,6 +101,11 @@ public void selectPiece(Piece piece) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive a card
|
||||||
|
*
|
||||||
|
* @param msg card message
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user