merge the new developmentbranch into the test branch #39
@@ -1,9 +1,11 @@
|
||||
package pp.mdga.message.server;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.card.PowerCard;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A message sent by the server to the active player to play a card.
|
||||
@@ -13,17 +15,12 @@ public class PlayCardMessage extends ServerMessage {
|
||||
/**
|
||||
* The card that should be played.
|
||||
*/
|
||||
private final BonusCard card;
|
||||
private final PowerCard card;
|
||||
|
||||
/**
|
||||
* The identifier of the piece that should be moved.
|
||||
* The list of pieces which will be used.
|
||||
*/
|
||||
private final UUID ownPieceID;
|
||||
|
||||
/**
|
||||
* The identifier of the enemy piece that should be moved.
|
||||
*/
|
||||
private final UUID enemyPieceID;
|
||||
private final List<Piece> pieces;
|
||||
|
||||
/**
|
||||
* The modifier of the dice.
|
||||
@@ -34,15 +31,13 @@ public class PlayCardMessage extends ServerMessage {
|
||||
* Constructs a new PlayCard message.
|
||||
*
|
||||
* @param card the card that should be played
|
||||
* @param ownPieceID the identifier of the piece that should be moved
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be moved
|
||||
* @param pieces as the pieces which should be played as a List of Piece objects.
|
||||
* @param diceModifier the new modifier of the dice
|
||||
*/
|
||||
public PlayCardMessage(BonusCard card, UUID ownPieceID, UUID enemyPieceID, int diceModifier) {
|
||||
public PlayCardMessage(PowerCard card, List<Piece> pieces, int diceModifier) {
|
||||
super();
|
||||
this.card = card;
|
||||
this.ownPieceID = ownPieceID;
|
||||
this.enemyPieceID = enemyPieceID;
|
||||
this.pieces = pieces;
|
||||
this.diceModifier = diceModifier;
|
||||
}
|
||||
|
||||
@@ -50,71 +45,30 @@ public PlayCardMessage(BonusCard card, UUID ownPieceID, UUID enemyPieceID, int d
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayCardMessage() {
|
||||
ownPieceID = null;
|
||||
card = null;
|
||||
enemyPieceID = null;
|
||||
diceModifier = 1;
|
||||
super();
|
||||
this.card = null;
|
||||
this.pieces = new ArrayList<Piece>();
|
||||
this.diceModifier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new PlayCard message for the given card and piece identifier.
|
||||
* This method will be used to return card attribute of PlayCardMessage class.
|
||||
*
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @param enemyPieceID the identifier of the enemy piece that should be affected
|
||||
* @return a new PlayCard message
|
||||
* @return card as a PowerCard object.
|
||||
*/
|
||||
public static PlayCardMessage swap(UUID ownPieceID, UUID enemyPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SWAP, ownPieceID, enemyPieceID, 1);
|
||||
public PowerCard getCard() {
|
||||
return this.card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new PlayCard message for the given card and piece identifier.
|
||||
* This mehtod will be usd to return pieces attribute of PlayCardMessage class.
|
||||
*
|
||||
* @param ownPieceID the identifier of the piece of the player that should be affected
|
||||
* @return a new PlayCard message
|
||||
* @return pieces as a List of Piece objects.
|
||||
*/
|
||||
public static PlayCardMessage shield(UUID ownPieceID) {
|
||||
return new PlayCardMessage(BonusCard.SHIELD, ownPieceID, null, 1);
|
||||
public List<Piece> getPieces() {
|
||||
return this.pieces;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the card that should be played.
|
||||
*
|
||||
* @return the card that should be played
|
||||
*/
|
||||
public BonusCard getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of the piece that should be moved.
|
||||
*
|
||||
* @return the identifier of the piece that should be moved
|
||||
*/
|
||||
public UUID getPieceIdentifier() {
|
||||
return ownPieceID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of the enemy piece that should be moved.
|
||||
*
|
||||
* @return the identifier of the enemy piece that should be moved
|
||||
*/
|
||||
public UUID getPieceIdentifierEnemy() {
|
||||
return enemyPieceID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this method returns the dice modifier
|
||||
*
|
||||
@@ -141,6 +95,15 @@ public void accept(ServerInterpreter interpreter) {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlayCardMessage{" + "card=" + card + ", ownPieceID=" + ownPieceID + ", enemyPieceID=" + enemyPieceID + ", diceModifier=" + diceModifier + '}';
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("PlayCardMessage{card: ").append(this.card).append(" with selected pieces: {");
|
||||
for (Piece piece : this.pieces) {
|
||||
stringBuilder.append(piece).append(", ");
|
||||
}
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||
stringBuilder.append("} and dice modifier: ").append(this.diceModifier);
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user