merge development into test #22

Merged
j23f0712 merged 8 commits from development into dev/test 2024-12-01 00:34:41 +01:00
4 changed files with 93 additions and 9 deletions
Showing only changes of commit 5ff56ed9d8 - Show all commits

View File

@@ -17,7 +17,7 @@ public class MdgaApp extends SimpleApplication {
MdgaView view = null; MdgaView view = null;
private MdgaState state = MdgaState.MAIN; private MdgaState state = MdgaState.MAIN;
private static float resolutionFactor = 1.8f; private static float resolutionFactor = 1.0f;
public static void main(String[] args) { public static void main(String[] args) {
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);

View File

@@ -3,7 +3,12 @@
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.game.BonusCard;
import pp.mdga.game.Piece;
import pp.mdga.game.Player;
import pp.mdga.game.ShieldState;
import pp.mdga.message.server.*; import pp.mdga.message.server.*;
import pp.mdga.notification.*;
public class WaitingState extends GameStates { public class WaitingState extends GameStates {
@@ -14,6 +19,30 @@ public WaitingState(ClientState parent, ClientGameLogic logic) {
this.parent = (GameState) parent; this.parent = (GameState) parent;
} }
private CeremonyNotification createCeremonyNotification(){
CeremonyNotification notification = new CeremonyNotification();
for (var player : logic.getGame().getPlayers().entrySet()){
notification.getColors().add(player.getValue().getColor());
notification.getNames().add(player.getValue().getName());
notification.getSixes().add(player.getValue().getPlayerStatistic().getDiced6());
notification.getBonusNodes().add(player.getValue().getPlayerStatistic().getActivatedBonusNodes());
notification.getPiecesLost().add(player.getValue().getPlayerStatistic().getPiecesBeingThrown());
notification.getPiecesThrown().add(player.getValue().getPlayerStatistic().getPiecesThrown());
notification.getNodesMoved().add(player.getValue().getPlayerStatistic().getTraveledNodes());
notification.getBonusCardsPlayed().add(player.getValue().getPlayerStatistic().getCardsPlayed());
}
notification.getNames().add("GAME OVERALL");
notification.getNodesMoved().add(logic.getGame().getGameStatistics().getTraveledNodes());
notification.getSixes().add(logic.getGame().getGameStatistics().getDiced6());
notification.getPiecesThrown().add(logic.getGame().getGameStatistics().getPiecesThrown());
notification.getPiecesLost().add(logic.getGame().getGameStatistics().getPiecesBeingThrown());
notification.getBonusNodes().add(logic.getGame().getGameStatistics().getActivatedBonusNodes());
notification.getBonusCardsPlayed().add(logic.getGame().getGameStatistics().getCardsPlayed());
return notification;
}
@Override @Override
public void enter() { public void enter() {
@@ -26,31 +55,67 @@ public void exit() {
@Override @Override
public void received(CeremonyMessage msg){ public void received(CeremonyMessage msg){
logic.addNotification(createCeremonyNotification());
logic.setState(logic.getCeremony()); logic.setState(logic.getCeremony());
} }
@Override @Override
public void received(DiceNowMessage msg){ public void received(DiceNowMessage msg){
logic.addNotification(new DiceNowNotification());
parent.setState(parent.getTurn()); parent.setState(parent.getTurn());
} }
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(PlayCardMessage msg){ public void received(PlayCardMessage msg){
logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
if (msg.getCard().equals(BonusCard.TURBO)){
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().equals(BonusCard.SHIELD)){
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier())) % 10 != 0) {
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
} else {
logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier()).getUuid()));
}
} else {
Piece ownPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifier());
Piece enemyPiece = logic.getGame().getPieceThroughIdentifier(msg.getPieceIdentifierEnemy());
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);
logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
}
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(ActivePlayerMessage msg){ public void received(ActivePlayerMessage msg){
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
logic.getGame().setActiveColor(msg.getColor());
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
@Override @Override
public void received(MoveMessage msg){ public void received(MoveMessage msg){
Piece pieceToMove = logic.getGame().getPieceThroughIdentifier(msg.getIdentifier());
if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
} else if (msg.isHomeMove()){
logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
} else {
if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
logic.addNotification(new ThrowPieceNotification(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant().getUuid()));
}
logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
}
parent.setState(parent.getAnimation()); parent.setState(parent.getAnimation());
} }
} }

View File

@@ -20,17 +20,20 @@ public class PlayCardMessage extends ServerMessage {
private final String pieceIdentifierEnemy; private final String pieceIdentifierEnemy;
private final int diceModifier;
/** /**
* Constructs a new PlayCard message. * Constructs a new PlayCard message.
* *
* @param card the card that should be played * @param card the card that should be played
* @param pieceIdentifier the identifier of the piece that should be moved * @param pieceIdentifier the identifier of the piece that should be moved
*/ */
public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) { public PlayCardMessage(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy, int diceModifier) {
super(); super();
this.card = card; this.card = card;
this.pieceIdentifier = pieceIdentifier; this.pieceIdentifier = pieceIdentifier;
this.pieceIdentifierEnemy = pieceIdentifierEnemy; this.pieceIdentifierEnemy = pieceIdentifierEnemy;
this.diceModifier = diceModifier;
} }
/** /**
@@ -40,6 +43,7 @@ private PlayCardMessage() {
this.pieceIdentifierEnemy = null; this.pieceIdentifierEnemy = null;
card = null; card = null;
pieceIdentifier = null; pieceIdentifier = null;
diceModifier = 1;
} }
/** /**
@@ -50,7 +54,7 @@ private PlayCardMessage() {
* @return a new PlayCard message * @return a new PlayCard message
*/ */
public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) { public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifierEnemy) {
return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy); return new PlayCardMessage(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy, 1);
} }
/** /**
@@ -60,7 +64,17 @@ public static PlayCardMessage swap(String pieceIdentifier, String pieceIdentifie
* @return a new PlayCard message * @return a new PlayCard message
*/ */
public static PlayCardMessage shield(String pieceIdentifier) { public static PlayCardMessage shield(String pieceIdentifier) {
return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null); return new PlayCardMessage(BonusCard.SHIELD, pieceIdentifier, null, 1);
}
/**
* creates a new PlayCardMessage for a turbo card
*
* @param diceModifier the new modifier of the dice
* @return newly constructed message
*/
public static PlayCardMessage turbo(int diceModifier){
return new PlayCardMessage(BonusCard.TURBO, null, null, diceModifier);
} }
/** /**
@@ -90,6 +104,16 @@ public String getPieceIdentifierEnemy() {
return pieceIdentifierEnemy; return pieceIdentifierEnemy;
} }
/**
* this method returns the dice modifier
*
* @return the dice modifier as int
*/
public int getDiceModifier(){
return diceModifier;
}
/** /**
* Accepts a visitor to process this message. * Accepts a visitor to process this message.
* *

View File

@@ -10,11 +10,6 @@ public class ThrowPieceNotification extends Notification{
/** /**
* This constructor is used to create a new ThrowPieceNotification * This constructor is used to create a new ThrowPieceNotification
*
* @param pieceId1 the pieceId1
* @param pieceId2 the pieceId2
* @param nodeIndex the nodeIndex
* @param colorPiece2 the color
*/ */
public ThrowPieceNotification(UUID pieceId) { public ThrowPieceNotification(UUID pieceId) {
this.pieceId = pieceId; this.pieceId = pieceId;