This commit is contained in:
Benjamin Feyer
2024-12-09 16:11:32 +01:00
7 changed files with 36 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ public class GameView extends MdgaView {
private GuiHandler guiHandler; private GuiHandler guiHandler;
private ButtonLeft leaveButton; private ButtonLeft leaveButton;
private ButtonRight confirmButton; public ButtonRight confirmButton;
private ButtonRight noPowerButton; private ButtonRight noPowerButton;
@@ -28,6 +28,9 @@ public class GameView extends MdgaView {
private FilterPostProcessor fpp; private FilterPostProcessor fpp;
public boolean needConfirm = false;
public boolean needNoPower = false;
private Node guiHandlerNode = new Node(); private Node guiHandlerNode = new Node();
public GameView(MdgaApp app) { public GameView(MdgaApp app) {
@@ -116,19 +119,26 @@ public Color getOwnColor() {
public void needConfirm() { public void needConfirm() {
noPowerButton.hide(); noPowerButton.hide();
confirmButton.show(); confirmButton.show();
needConfirm = true;
} }
public void noConfirm() { public void noConfirm() {
confirmButton.hide(); confirmButton.hide();
needConfirm = false;
} }
public void showNoPower() { public void showNoPower() {
confirmButton.hide(); confirmButton.hide();
noPowerButton.show(); noPowerButton.show();
needNoPower = true;
} }
public void hideNoPower() { public void hideNoPower() {
noPowerButton.hide(); noPowerButton.hide();
needNoPower = false;
} }
public void enterInterrupt(Color color) { public void enterInterrupt(Color color) {

View File

@@ -59,7 +59,6 @@ public void enter() {
public void leave() { public void leave() {
onLeave(); onLeave();
settingsButton.hide(); settingsButton.hide();
while (settingsDepth > 0) { while (settingsDepth > 0) {
@@ -197,7 +196,13 @@ public void pressForward() {
} }
if (this instanceof GameView gameView) { if (this instanceof GameView gameView) {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); if(gameView.needConfirm) {
app.getModelSynchronize().confirm();
} else if(gameView.needNoPower) {
app.getModelSynchronize().confirm();
} else {
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
}
} }
if (this instanceof CeremonyView ceremonyView) { if (this instanceof CeremonyView ceremonyView) {

View File

@@ -4,6 +4,8 @@
import pp.mdga.client.ClientState; import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState; import pp.mdga.client.gamestate.TurnState;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.card.ShieldCard;
import pp.mdga.game.card.SwapCard;
import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.PlayCardNotification; import pp.mdga.notification.PlayCardNotification;
@@ -13,7 +15,7 @@ public class PlayPowerCardState extends TurnStates {
private final TurnState parent; private final TurnState parent;
private PlayCardMessage playCardMessage; private PlayCardMessage playCardMessage;
private int animationCounter = 0; private int extraAnimationCounter = 0;
public PlayPowerCardState(ClientState parent, ClientGameLogic logic) { public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
super(parent, logic); super(parent, logic);
@@ -22,11 +24,12 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
animationCounter++; if(playCardMessage.getCard() instanceof SwapCard) {
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard())); extraAnimationCounter++;
if(!playCardMessage.getCard().getCard().equals(BonusCard.TURBO)){
animationCounter++;
} }
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
handlePowerCard(playCardMessage); handlePowerCard(playCardMessage);
} }
@@ -41,10 +44,12 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override @Override
public void selectAnimationEnd(){ public void selectAnimationEnd(){
animationCounter--; if(extraAnimationCounter > 0) {
if(animationCounter == 0){ extraAnimationCounter--;
logic.send(new AnimationEndMessage()); return;
parent.setState(parent.getRollDice());
} }
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
} }
} }

View File

@@ -38,7 +38,6 @@ public void exit() {
@Override @Override
public void received(SelectPieceMessage msg) { public void received(SelectPieceMessage msg) {
//TODO
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));
parent.getSelectPiece().setPossiblePieces(pieces); parent.getSelectPiece().setPossiblePieces(pieces);
ArrayList<UUID> listPiece = pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)); ArrayList<UUID> listPiece = pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new));

View File

@@ -112,7 +112,6 @@ public void received(PossiblePieceMessage msg){
if (msg.getEnemyPossiblePieces().isEmpty()){ if (msg.getEnemyPossiblePieces().isEmpty()){
parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new))); parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
parent.setState(parent.getShield()); parent.setState(parent.getShield());
logic.addNotification(new SelectableShieldNotification(msg.getOwnPossiblePieces().stream().map(Piece::getUuid).toList()));
} else { } else {
System.out.println("Should enter Swap State"); System.out.println("Should enter Swap State");
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new))); parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));

View File

@@ -7,6 +7,7 @@
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.SelectableShieldNotification;
import java.lang.System.Logger.Level; import java.lang.System.Logger.Level;
import java.util.ArrayList; import java.util.ArrayList;
@@ -27,8 +28,7 @@ public ShieldState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
logic.addNotification(null); logic.addNotification(new SelectableShieldNotification(possiblePieces.stream().map(Piece::getUuid).toList()));
//TODO: selectable piece notification
} }
@Override @Override

View File

@@ -94,8 +94,8 @@ public Game() {
* This method initializes the draw pile with the predefined number of bonus cards. * This method initializes the draw pile with the predefined number of bonus cards.
*/ */
private void initializeDrawPile() { private void initializeDrawPile() {
// this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS); this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
// this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS); this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS); this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile); Collections.shuffle(this.drawPile);
} }