Merge dev/model into development
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void received(DiceAgainMessage msg){
|
||||
public void received(DiceNowMessage msg){
|
||||
parent.setState(parent.getRollDice());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user