adjusted all State containing 'received(PlayCardMessage msg)' to work with the new message
This commit is contained in:
@@ -12,25 +12,21 @@
|
||||
import pp.mdga.notification.SwapPieceNotification;
|
||||
import pp.mdga.notification.ThrowPieceNotification;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class GameStates extends ClientState {
|
||||
public GameStates(ClientState parent, ClientGameLogic logic) {
|
||||
super(parent, logic);
|
||||
}
|
||||
|
||||
protected void handlePowerCard(PlayCardMessage msg) {
|
||||
if (msg.getCard().equals(BonusCard.TURBO)) {
|
||||
if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
|
||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||
} else if (msg.getCard().equals(BonusCard.SHIELD)) {
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
} else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
|
||||
handleShield(msg.getPieces().get(0).getUuid());
|
||||
} else {
|
||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
|
||||
}
|
||||
} else {
|
||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
|
||||
Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
|
||||
Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
|
||||
int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
|
||||
logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
|
||||
@@ -47,4 +43,14 @@ protected void throwPiece(Piece piece) {
|
||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||
piece.setState(PieceState.WAITING);
|
||||
}
|
||||
|
||||
private void handleShield(UUID uuid) {
|
||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(uuid)) % 10 != 0) {
|
||||
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
|
||||
logic.addNotification(new ShieldSuppressedNotification(uuid));
|
||||
} else {
|
||||
logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.ACTIVE);
|
||||
logic.addNotification(new ShieldActiveNotification(uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public void received(DieMessage msg) {
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||
|
||||
@@ -51,7 +51,7 @@ public void received(DieMessage msg) {
|
||||
|
||||
@Override
|
||||
public void received(PlayCardMessage msg) {
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
||||
handlePowerCard(msg);
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
|
||||
logic.getGame().getGameStatistics().increaseCardsPlayed();
|
||||
|
||||
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
|
||||
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
|
||||
handlePowerCard(playCardMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ public void selectCard(BonusCard card){
|
||||
*/
|
||||
@Override
|
||||
public void received(PlayCardMessage msg){
|
||||
if(msg.getCard().getCard().equals(BonusCard.TURBO)){
|
||||
parent.getParent().getPlayPowerCard().setPlayCard(msg);
|
||||
parent.getParent().setState(parent.getParent().getPlayPowerCard());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user