merge the new developmentbranch into the test branch #39
@@ -1,9 +1,11 @@
|
|||||||
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.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.
|
* 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.
|
* 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;
|
private final List<Piece> pieces;
|
||||||
|
|
||||||
/**
|
|
||||||
* The identifier of the enemy piece that should be moved.
|
|
||||||
*/
|
|
||||||
private final UUID enemyPieceID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The modifier of the dice.
|
* The modifier of the dice.
|
||||||
@@ -34,15 +31,13 @@ public class PlayCardMessage extends ServerMessage {
|
|||||||
* 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 ownPieceID the identifier of the piece that should be moved
|
* @param pieces as the pieces which should be played as a List of Piece objects.
|
||||||
* @param enemyPieceID the identifier of the enemy piece that should be moved
|
|
||||||
* @param diceModifier the new modifier of the dice
|
* @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();
|
super();
|
||||||
this.card = card;
|
this.card = card;
|
||||||
this.ownPieceID = ownPieceID;
|
this.pieces = pieces;
|
||||||
this.enemyPieceID = enemyPieceID;
|
|
||||||
this.diceModifier = diceModifier;
|
this.diceModifier = diceModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,71 +45,30 @@ public PlayCardMessage(BonusCard card, UUID ownPieceID, UUID enemyPieceID, int d
|
|||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
*/
|
*/
|
||||||
private PlayCardMessage() {
|
private PlayCardMessage() {
|
||||||
ownPieceID = null;
|
super();
|
||||||
card = null;
|
this.card = null;
|
||||||
enemyPieceID = null;
|
this.pieces = new ArrayList<Piece>();
|
||||||
diceModifier = 1;
|
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
|
* @return card as a PowerCard object.
|
||||||
* @param enemyPieceID the identifier of the enemy piece that should be affected
|
|
||||||
* @return a new PlayCard message
|
|
||||||
*/
|
*/
|
||||||
public static PlayCardMessage swap(UUID ownPieceID, UUID enemyPieceID) {
|
public PowerCard getCard() {
|
||||||
return new PlayCardMessage(BonusCard.SWAP, ownPieceID, enemyPieceID, 1);
|
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 pieces as a List of Piece objects.
|
||||||
* @return a new PlayCard message
|
|
||||||
*/
|
*/
|
||||||
public static PlayCardMessage shield(UUID ownPieceID) {
|
public List<Piece> getPieces() {
|
||||||
return new PlayCardMessage(BonusCard.SHIELD, ownPieceID, null, 1);
|
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
|
* this method returns the dice modifier
|
||||||
*
|
*
|
||||||
@@ -141,6 +95,15 @@ public void accept(ServerInterpreter interpreter) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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