12 Commits

Author SHA1 Message Date
Hanno Fleischer
5a9f7a8118 added AnimationEndMessages to 'RollDiceState', 'MovePieceState' and 'PlayPowerCardState' 2024-12-06 18:45:14 +01:00
Hanno Fleischer
2e1fe3c050 fixed a missing method call ind TurnState and removed debug sout statements ind 'RollDiceMessage' 2024-12-06 15:19:04 +01:00
Hanno Fleischer
308b592b65 Merge branch 'development' into 'dev/model'
Development merge

See merge request progproj/gruppen-ht24/Gruppe-01!36
2024-12-06 09:55:19 +00:00
Felix Koppe
c4e7fb1d41 Fix logic in modelSyncronizer 2024-12-06 10:54:02 +01:00
Felix Koppe
aacc0440b3 Update .gitignore 2024-12-06 10:33:13 +01:00
Hanno Fleischer
43c0e3bcc7 Merge branch 'development' into 'dev/model'
Development

See merge request progproj/gruppen-ht24/Gruppe-01!35
2024-12-06 09:09:29 +00:00
Felix Koppe
95635f5fb7 Fix ownColor in gameView 2024-12-06 09:59:28 +01:00
Daniel Grigencha
4904b32ea3 Updated 'ChoosePieceState' class.
Updated the 'ChoosePieceState' class by adding the 'RequestMoveMessage' handling to it.
2024-12-06 08:58:51 +01:00
Daniel Grigencha
b00219c4fb Updated 'PlayPowerCardState' class.
Updated the 'PlayPowerCardState' class by adding the 'AnimationEndMessage' handling to it.
2024-12-06 08:58:01 +01:00
Daniel Grigencha
12cf5f3e71 Updated 'PowerCardState' class.
Updated the 'PowerCardState' class by adding the 'SelectedPiecesMessage' handling to it.
2024-12-06 08:57:08 +01:00
Daniel Grigencha
77b0207214 Updated 'TurnState' class.
Updated the 'TurnState' class by adding the 'SelectedPiecesMessage', 'NoPowerCardMessage', 'RequestDieMessage' and 'ReuqestMoveMessage' handling to it.
2024-12-06 08:56:21 +01:00
Daniel Grigencha
a18165bc02 Updated 'Game' class.
Updated the 'Game' class by commenting out the creation of turbo and shield cards. This is only for testing purposes.
2024-12-06 08:55:01 +01:00
12 changed files with 135 additions and 12 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
.run/
.gradle
build/
#!gradle/wrapper/gradle-wrapper.jar

View File

@@ -88,17 +88,17 @@ public void confirm() {
GameView gameView = (GameView) app.getView();
if(a != null && b != null) {
selectPiece(a);
selectPiece(b);
app.getGameLogic().selectPiece(a);
app.getGameLogic().selectPiece(b);
gameView.getBoardHandler().clearSelectable();
} else if (a != null) {
selectPiece(a);
app.getGameLogic().selectPiece(a);
gameView.getBoardHandler().clearSelectable();
} else {
if(null == card) {
selectCard(null);
app.getGameLogic().selectCard(null);
} else {
selectCard(card);
app.getGameLogic().selectCard(card);
gameView.getGuiHandler().clearSelectableCards();
}
}

View File

@@ -33,7 +33,6 @@ public class GameView extends MdgaView {
public GameView(MdgaApp app) {
super(app);
setOwnColor(Color.AIRFORCE);
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);

View File

@@ -47,6 +47,11 @@ public void setState(TurnStates state){
this.state = state;
}
@Override
public void selectDice(){
state.selectDice();
}
@Override
public void selectPiece(Piece piece){
state.selectPiece(piece);

View File

@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
}
@Override
public void received(DiceAgainMessage msg){
public void received(DiceNowMessage msg){
parent.setState(parent.getRollDice());
}

View File

@@ -35,7 +35,7 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
@Override
public void selectAnimationEnd(){
parent.setState(parent.getRollDice());
logic.send(new AnimationEndMessage());
parent.setState(parent.getRollDice());
}
}

View File

@@ -3,6 +3,7 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.TurnState;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.NoTurnMessage;
@@ -37,11 +38,22 @@ public void selectDice(){
logic.send(new RequestDieMessage());
}
@Override
public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece());
logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false));
}
@Override
public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
}
// @Override
// public void received(ChoosePieceStateMessage msg){
// parent.setState(parent.getChoosePiece());
// }
@Override
public void received(NoTurnMessage msg){
parent.getParent().setState(parent.getParent().getWaiting());

View File

@@ -92,9 +92,9 @@ public Game() {
* This method initializes the draw pile with the predefined number of bonus cards.
*/
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 ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
// this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile);
}

View File

@@ -1,6 +1,10 @@
package pp.mdga.server.automaton.game;
import pp.mdga.game.Player;
import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.RequestDieMessage;
import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.GameState;
import pp.mdga.server.automaton.game.turn.ChoosePieceState;
@@ -49,8 +53,9 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
@Override
public void enter() {
LOGGER.log(Level.DEBUG, "Entered TurnState state.");
LOGGER.log(Level.INFO, "Entered TurnState state.");
this.player = this.logic.getGame().getPlayerById(this.logic.getGame().getActivePlayerId());
this.setCurrentState(this.powerCardState);
}
@Override
@@ -58,6 +63,54 @@ public void exit() {
LOGGER.log(Level.DEBUG, "Exited TurnState state.");
}
/**
* This method will be called whenever the server received an SelectedPiecesMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a SelectedPiecesMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(SelectedPiecesMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be called whenever the server received an NoPowerCardMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a NoPowerCardMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(NoPowerCardMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be called whenever the server received a RequestDieMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a RequestDieMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(RequestDieMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be called whenever the server received a RequestMoveMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a RequestMoveMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(RequestMoveMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be used to return currentState attribute of TurnState class.
*

View File

@@ -1,5 +1,6 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.message.client.RequestMoveMessage;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.TurnState;
import pp.mdga.server.automaton.game.turn.choosepiece.*;
@@ -46,6 +47,18 @@ public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered ChoosePieceState state.");
}
/**
* This method will be called whenever the server received a RequestMoveMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a RequestMoveMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(RequestMoveMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be used to return currentState attribute of ChoosePieceState class.
*

View File

@@ -1,15 +1,25 @@
package pp.mdga.server.automaton.game.turn;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.AnimationState;
import pp.mdga.server.automaton.game.TurnState;
import java.util.HashSet;
import java.util.Set;
public class PlayPowerCardState extends TurnAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(PlayPowerCardState.class.getName());
/**
* Create PlayPowerCardState attributes.
*/
private Set<Integer> messageReceived = new HashSet<Integer>();
/**
* Constructs a server state of the specified game logic.
*
@@ -29,4 +39,20 @@ public void enter() {
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited PlayPowerCardState state.");
}
/**
* This method will be called whenever the server received an AnimationEndMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a AnimationEndMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(AnimationEndMessage msg, int from) {
this.messageReceived.add(from);
if (this.messageReceived.size() == this.logic.getGame().getPlayers().size()) {
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new DiceNowMessage());
this.turnAutomaton.setCurrentState(this.turnAutomaton.getRollDiceState());
}
}
}

View File

@@ -2,6 +2,7 @@
import pp.mdga.game.Piece;
import pp.mdga.game.card.PowerCard;
import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PossibleCardsMessage;
import pp.mdga.server.ServerGameLogic;
@@ -85,6 +86,18 @@ public void addSelectedPiece(Piece piece) {
this.selectedPieces.add(piece);
}
/**
* This method will be called whenever the server received an SelectedPiecesMessage message.
* It will also get the client id of the player who send this message.
*
* @param msg as the message which was sent by the player as a SelectedPiecesMessage object.
* @param from as the client id of the player as an Integer.
*/
@Override
public void received(SelectedPiecesMessage msg, int from) {
this.currentState.received(msg, from);
}
/**
* This method will be used to return currentState attribute of PowerCardState class.
*