merge the new developmentbranch into the test branch #39

Closed
j23f0712 wants to merge 431 commits from development2 into dev/test
12 changed files with 57 additions and 18 deletions
Showing only changes of commit 8b27ccce22 - Show all commits

View File

@@ -275,6 +275,11 @@ public void received(ActivePlayerMessage msg){
state.received(msg); state.received(msg);
} }
@Override
public void received(PossiblePieceMessage msg){
state.received(msg);
}
/** /**
* This method returns the current state * This method returns the current state
* *

View File

@@ -8,10 +8,7 @@
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState; import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState; import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
import pp.mdga.message.client.AnimationEndMessage; import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.ActivePlayerMessage; import pp.mdga.message.server.*;
import pp.mdga.message.server.DieMessage;
import pp.mdga.message.server.RankingResponseMessage;
import pp.mdga.message.server.RankingRollAgainMessage;
public class DetermineStartPlayerState extends GameStates { public class DetermineStartPlayerState extends GameStates {
@@ -80,6 +77,11 @@ public void received(DieMessage msg){
state.received(msg); state.received(msg);
} }
@Override
public void received(DiceNowMessage msg){
state.received(msg);
}
@Override @Override
public void received(RankingRollAgainMessage msg){ public void received(RankingRollAgainMessage msg){
state.received(msg); state.received(msg);

View File

@@ -132,6 +132,11 @@ public void received(DieMessage msg){
state.received(msg); state.received(msg);
} }
@Override
public void received(PossiblePieceMessage msg){
state.received(msg);
}
public ChoosePieceState getChoosePiece() { public ChoosePieceState getChoosePiece() {
return choosePieceState; return choosePieceState;
} }

View File

@@ -106,11 +106,12 @@ public void received(DiceNowMessage msg){
@Override @Override
public void received(PossiblePieceMessage msg){ 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)).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());
} else { } else {
parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new))); System.out.println("Should enter Swap State");
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece)).collect(Collectors.toCollection(ArrayList::new))); parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
parent.getSwap().setPossibleEnemyPieces(msg.getEnemyPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
parent.setState(parent.getSwap()); parent.setState(parent.getSwap());
} }
} }

View File

@@ -5,6 +5,7 @@
import pp.mdga.client.gamestate.turnstate.PowerCardState; import pp.mdga.client.gamestate.turnstate.PowerCardState;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.RequestPlayCardMessage; import pp.mdga.message.client.RequestPlayCardMessage;
import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.notification.SelectableSwapNotification; import pp.mdga.notification.SelectableSwapNotification;
@@ -13,6 +14,8 @@
public class SwapState extends PowerCardStates { public class SwapState extends PowerCardStates {
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
private final PowerCardState parent; private final PowerCardState parent;
private ArrayList<Piece> possibleOwnPieces; private ArrayList<Piece> possibleOwnPieces;
@@ -29,6 +32,7 @@ public SwapState(ClientState parent, ClientGameLogic logic) {
@Override @Override
public void enter() { public void enter() {
LOGGER.log(System.Logger.Level.INFO, "Entering SwapState");
ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList()); ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList()); ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces)); logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
@@ -36,6 +40,7 @@ public void enter() {
@Override @Override
public void exit() { public void exit() {
LOGGER.log(System.Logger.Level.INFO, "Exiting SwapState");
possibleOwnPieces = null; possibleOwnPieces = null;
possibleEnemyPieces = null; possibleEnemyPieces = null;
} }

View File

@@ -1,7 +1,9 @@
package pp.mdga.message.server; package pp.mdga.message.server;
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import pp.mdga.game.Piece;
import java.io.PipedOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -14,12 +16,12 @@ public class PossiblePieceMessage extends ServerMessage {
/** /**
* The list of possible own pieces * The list of possible own pieces
*/ */
private final List<UUID> possibleOwnPieces; private final List<Piece> possibleOwnPieces;
/** /**
* The list of possible enemy pieces * The list of possible enemy pieces
*/ */
private final List<UUID> possibleEnemyPieces; private final List<Piece> possibleEnemyPieces;
/** /**
* Constructor for PossiblePiece * Constructor for PossiblePiece
@@ -37,7 +39,7 @@ public PossiblePieceMessage() {
* @param possibleEnemyPieces the list of possible enemy pieces * @param possibleEnemyPieces the list of possible enemy pieces
* @return the swapped possible pieces * @return the swapped possible pieces
*/ */
public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOwnPieces, ArrayList<UUID> possibleEnemyPieces) { public static PossiblePieceMessage swapPossiblePieces(List<Piece> possibleOwnPieces, List<Piece> possibleEnemyPieces) {
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage(); PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces); possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces); possiblePieceMessage.possibleEnemyPieces.addAll(possibleEnemyPieces);
@@ -50,7 +52,7 @@ public static PossiblePieceMessage swapPossiblePieces(ArrayList<UUID> possibleOw
* @param possibleOwnPieces the list of possible own pieces * @param possibleOwnPieces the list of possible own pieces
* @return the possible pieces for the shield * @return the possible pieces for the shield
*/ */
public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possibleOwnPieces) { public static PossiblePieceMessage shieldPossiblePieces(List<Piece> possibleOwnPieces) {
PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage(); PossiblePieceMessage possiblePieceMessage = new PossiblePieceMessage();
possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces); possiblePieceMessage.possibleOwnPieces.addAll(possibleOwnPieces);
return possiblePieceMessage; return possiblePieceMessage;
@@ -61,7 +63,7 @@ public static PossiblePieceMessage shieldPossiblePieces(ArrayList<UUID> possible
* *
* @param piece the piece to add * @param piece the piece to add
*/ */
public void addOwnPossiblePiece(UUID piece) { public void addOwnPossiblePiece(Piece piece) {
this.possibleOwnPieces.add(piece); this.possibleOwnPieces.add(piece);
} }
@@ -70,7 +72,7 @@ public void addOwnPossiblePiece(UUID piece) {
* *
* @param piece the piece to add * @param piece the piece to add
*/ */
public void addEnemyPossiblePiece(UUID piece) { public void addEnemyPossiblePiece(Piece piece) {
this.possibleEnemyPieces.add(piece); this.possibleEnemyPieces.add(piece);
} }
@@ -79,7 +81,7 @@ public void addEnemyPossiblePiece(UUID piece) {
* *
* @return the list of possible pieces * @return the list of possible pieces
*/ */
public List<UUID> getOwnPossiblePieces() { public List<Piece> getOwnPossiblePieces() {
return possibleOwnPieces; return possibleOwnPieces;
} }
@@ -88,7 +90,7 @@ public List<UUID> getOwnPossiblePieces() {
* *
* @return the list of possible enemy pieces * @return the list of possible enemy pieces
*/ */
public List<UUID> getEnemyPossiblePieces() { public List<Piece> getEnemyPossiblePieces() {
return possibleEnemyPieces; return possibleEnemyPieces;
} }

View File

@@ -90,6 +90,10 @@ public void received(NoPowerCardMessage msg, int from){
this.currentState.received(msg, from); this.currentState.received(msg, from);
} }
public void received(SelectCardMessage msg, int from){
currentState.received(msg, from);
}
/** /**
* This method will be called whenever the server received a RequestDieMessage message. * 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. * It will also get the client id of the player who send this message.

View File

@@ -113,6 +113,10 @@ public void received(AnimationEndMessage msg, int from) {
this.currentState.received(msg, from); this.currentState.received(msg, from);
} }
public void received(SelectCardMessage msg, int from){
currentState.received(msg, from);
}
/** /**
* This method will be used to return currentState attribute of TurnState class. * This method will be used to return currentState attribute of TurnState class.
* *

View File

@@ -3,6 +3,7 @@
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.game.card.PowerCard; import pp.mdga.game.card.PowerCard;
import pp.mdga.message.client.NoPowerCardMessage; import pp.mdga.message.client.NoPowerCardMessage;
import pp.mdga.message.client.SelectCardMessage;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.DiceNowMessage; import pp.mdga.message.server.DiceNowMessage;
import pp.mdga.message.server.PossibleCardsMessage; import pp.mdga.message.server.PossibleCardsMessage;
@@ -92,6 +93,10 @@ public void addSelectedPiece(Piece piece) {
this.selectedPieces.add(piece); this.selectedPieces.add(piece);
} }
public void received(SelectCardMessage msg, int from){
currentState.received(msg, from);
}
/** /**
* This method will be called whenever the server received an SelectedPiecesMessage message. * 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. * It will also get the client id of the player who send this message.

View File

@@ -6,6 +6,7 @@
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.IncorrectRequestMessage; import pp.mdga.message.server.IncorrectRequestMessage;
import pp.mdga.message.server.PlayCardMessage; import pp.mdga.message.server.PlayCardMessage;
import pp.mdga.message.server.PossiblePieceMessage;
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.PowerCardState; import pp.mdga.server.automaton.game.turn.PowerCardState;
@@ -27,7 +28,7 @@ public ShieldCardState(PowerCardState powerCardAutomaton, ServerGameLogic logic)
*/ */
@Override @Override
public void enter() { public void enter() {
logic.getServerSender().send(logic.getGame().getActivePlayerId(), PossiblePieceMessage.shieldPossiblePieces(this.powerCardAutomaton.getVisitor().getShieldPieces()));
} }
/** /**

View File

@@ -3,10 +3,14 @@
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.message.client.SelectedPiecesMessage; import pp.mdga.message.client.SelectedPiecesMessage;
import pp.mdga.message.server.IncorrectRequestMessage; import pp.mdga.message.server.IncorrectRequestMessage;
import pp.mdga.message.server.PossiblePieceMessage;
import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.PowerCardState; import pp.mdga.server.automaton.game.turn.PowerCardState;
public class SwapCardState extends PowerCardAutomatonState { public class SwapCardState extends PowerCardAutomatonState {
private final System.Logger LOGGER = System.getLogger(this.getClass().getName());
/** /**
* Constructs a server state of the specified game logic. * Constructs a server state of the specified game logic.
* *
@@ -22,7 +26,8 @@ public SwapCardState(PowerCardState powerCardAutomaton, ServerGameLogic logic) {
*/ */
@Override @Override
public void enter() { public void enter() {
LOGGER.log(System.Logger.Level.INFO, "Entered SwapCardState");
logic.getServerSender().send(logic.getGame().getActivePlayerId(), PossiblePieceMessage.swapPossiblePieces(this.powerCardAutomaton.getVisitor().getSwapOwnPieces(), this.powerCardAutomaton.getVisitor().getSwapOtherPieces()));
} }
/** /**

View File

@@ -24,7 +24,7 @@ public TurboCardState(PowerCardState powerCardAutomaton, ServerGameLogic logic)
@Override @Override
public void enter() { public void enter() {
this.logic.getGame().getDie().modify(); this.logic.getGame().getDie().modify();
this.logic.getGame().setDiceModifier(this.logic.getGame().getDiceModifier()); this.logic.getGame().setDiceModifier(this.logic.getGame().getDie().getDieModifier());
this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier())); this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier()));
this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState()); this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
} }