Merge commit
This commit is contained in:
@@ -11,6 +11,8 @@ public class AnimationState extends GameStates {
|
|||||||
|
|
||||||
private final GameState parent;
|
private final GameState parent;
|
||||||
|
|
||||||
|
private boolean spectator = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a client state of the specified game logic.
|
* Constructs a client state of the specified game logic.
|
||||||
*
|
*
|
||||||
@@ -34,7 +36,16 @@ public void enter() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
spectator = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the spectator.
|
||||||
|
*
|
||||||
|
* @param spectator the spectator
|
||||||
|
*/
|
||||||
|
public void setSpectator(boolean spectator) {
|
||||||
|
this.spectator = spectator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +54,10 @@ public void exit() {
|
|||||||
@Override
|
@Override
|
||||||
public void selectAnimationEnd() {
|
public void selectAnimationEnd() {
|
||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
parent.setState(parent.getWaiting());
|
if (spectator){
|
||||||
|
parent.setState(parent.getSpectator());
|
||||||
|
} else {
|
||||||
|
parent.setState(parent.getWaiting());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
|
import pp.mdga.game.Node;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.game.PieceState;
|
import pp.mdga.game.PieceState;
|
||||||
import pp.mdga.game.ShieldState;
|
import pp.mdga.game.ShieldState;
|
||||||
@@ -31,6 +32,7 @@ public SpectatorState(ClientState parent, ClientGameLogic logic) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
|
parent.getAnimation().setSpectator(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +44,9 @@ public void exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the Ceremony Message.
|
* Handles the reception of a CeremonyMessage.
|
||||||
|
*
|
||||||
|
* @param msg the ceremony message
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(CeremonyMessage msg) {
|
public void received(CeremonyMessage msg) {
|
||||||
@@ -50,34 +54,30 @@ public void received(CeremonyMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the Draw card message.
|
* Handles the reception of a DieMessage.
|
||||||
*
|
*
|
||||||
* @param msg the draw card message
|
* @param msg the die message
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
//stats
|
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().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()));
|
if (logic.getGame().getTurboFlag()) {
|
||||||
parent.setState(parent.getAnimation());
|
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
|
||||||
|
} else {
|
||||||
|
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//stats
|
||||||
|
if (msg.getDiceEye() == 6) {
|
||||||
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||||
|
logic.getGame().getGameStatistics().increaseDiced6();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the PlayCardMessage Message.
|
* Handles the reception of a PlayCardMessage.
|
||||||
|
*
|
||||||
|
* @param msg the play card message
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg) {
|
public void received(PlayCardMessage msg) {
|
||||||
@@ -89,28 +89,73 @@ public void received(PlayCardMessage msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the ActivePlayerMessage Message.
|
* 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()));
|
||||||
logic.getGame().setActiveColor(msg.getColor());
|
logic.getGame().setActiveColor(msg.getColor());
|
||||||
parent.setState(parent.getAnimation());
|
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()) {
|
||||||
|
logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
|
||||||
|
piece.setShield(ShieldState.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the MoveMessage Message.
|
* 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());
|
||||||
if (msg.isHomeMove()) {
|
if (msg.isHomeMove()) {
|
||||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
if (piece.getState().equals(PieceState.HOME)) {
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
int pieceHomeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
|
||||||
|
Node pieceNode = logic.getGame().getActivePlayer().getHomeNodes()[pieceHomeIndex];
|
||||||
|
|
||||||
|
//gets the oldNode
|
||||||
|
int homeIndex = logic.getGame().getActivePlayer().getHomeIndexOfPiece(piece);
|
||||||
|
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()) {
|
||||||
|
piece.setState(PieceState.HOMEFINISHED);
|
||||||
|
} else {
|
||||||
|
piece.setState(PieceState.HOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldNode.clearOccupant();
|
||||||
|
targetNode.setOccupant(piece);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||||
|
int oldNoteIdx = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||||
|
Node oldNode = logic.getGame().getBoard().getInfield()[oldNoteIdx];
|
||||||
|
|
||||||
|
//gets the targetNode
|
||||||
|
Node targetNode = logic.getGame().getActivePlayer().getHomeNodes()[msg.getTargetIndex()];
|
||||||
|
|
||||||
|
if (msg.getTargetIndex() == logic.getGame().getActivePlayer().getHighestHomeIdx()) {
|
||||||
|
piece.setState(PieceState.HOMEFINISHED);
|
||||||
|
} else {
|
||||||
|
piece.setState(PieceState.HOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldNode.clearOccupant();
|
||||||
|
targetNode.setOccupant(piece);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||||
|
|
||||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
||||||
if (occ != null) {
|
if (occ != null) {
|
||||||
//TODO: MoveThrowNotification
|
//TODO: MoveThrowNotification
|
||||||
@@ -122,7 +167,7 @@ public void received(MoveMessage msg) {
|
|||||||
//set occ to waiting
|
//set occ to waiting
|
||||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||||
}
|
}
|
||||||
if (msg.getPiece().getState().equals(PieceState.WAITING)) {
|
if (oldIndex == -1) {
|
||||||
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
|
logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
|
logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
|
||||||
piece.setState(PieceState.ACTIVE);
|
piece.setState(PieceState.ACTIVE);
|
||||||
@@ -133,7 +178,17 @@ public void received(MoveMessage msg) {
|
|||||||
}
|
}
|
||||||
//set new node
|
//set new node
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
|
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
|
||||||
|
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()) {
|
||||||
|
piece.setShield(ShieldState.ACTIVE);
|
||||||
|
logic.addNotification(new ShieldActiveNotification(piece.getUuid()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("send AnimationEndMessage");
|
||||||
logic.getGame().setTurboFlag(false);
|
logic.getGame().setTurboFlag(false);
|
||||||
parent.setState(parent.getAnimation());
|
parent.setState(parent.getAnimation());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,16 @@ public void received(EndOfTurnMessage msg) {
|
|||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the dice now message.
|
||||||
|
*
|
||||||
|
* @param msg the dice now message
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void received(DiceNowMessage msg) {
|
||||||
|
currentState.received(msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives the move message.
|
* Receives the move message.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user