added static methods to construct a PlayCard message for each card type
This commit is contained in:
@@ -18,26 +18,60 @@ public class PlayCard extends ServerMessage {
|
|||||||
*/
|
*/
|
||||||
private final String pieceIdentifier;
|
private final String pieceIdentifier;
|
||||||
|
|
||||||
|
private final String pieceIdentifierEnemy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 pieceIdentifier the identifier of the piece that should be moved
|
* @param pieceIdentifier the identifier of the piece that should be moved
|
||||||
*/
|
*/
|
||||||
public PlayCard(BonusCard card, String pieceIdentifier) {
|
public PlayCard(BonusCard card, String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||||
super();
|
super();
|
||||||
this.card = card;
|
this.card = card;
|
||||||
this.pieceIdentifier = pieceIdentifier;
|
this.pieceIdentifier = pieceIdentifier;
|
||||||
|
this.pieceIdentifierEnemy = pieceIdentifierEnemy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
*/
|
*/
|
||||||
private PlayCard() {
|
private PlayCard() {
|
||||||
|
this.pieceIdentifierEnemy = null;
|
||||||
card = null;
|
card = null;
|
||||||
pieceIdentifier = null;
|
pieceIdentifier = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PlayCard message for the given card and piece identifier.
|
||||||
|
*
|
||||||
|
* @param pieceIdentifier the identifier of the piece of the player that should be affected
|
||||||
|
* @param pieceIdentifierEnemy the identifier of the enemy piece that should be affected
|
||||||
|
* @return a new PlayCard message
|
||||||
|
*/
|
||||||
|
public static PlayCard swap(String pieceIdentifier, String pieceIdentifierEnemy) {
|
||||||
|
return new PlayCard(BonusCard.SWAP, pieceIdentifier, pieceIdentifierEnemy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PlayCard message for the given card and piece identifier.
|
||||||
|
*
|
||||||
|
* @return a new PlayCard message
|
||||||
|
*/
|
||||||
|
public static PlayCard turbo() {
|
||||||
|
return new PlayCard(BonusCard.TURBO, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PlayCard message for the given card and piece identifier.
|
||||||
|
*
|
||||||
|
* @param pieceIdentifier the identifier of the piece of the player that should be affected
|
||||||
|
* @return a new PlayCard message
|
||||||
|
*/
|
||||||
|
public static PlayCard shield(String pieceIdentifier) {
|
||||||
|
return new PlayCard(BonusCard.SHIELD, pieceIdentifier, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the card that should be played.
|
* Returns the card that should be played.
|
||||||
*
|
*
|
||||||
@@ -56,6 +90,15 @@ public String getPieceIdentifier() {
|
|||||||
return pieceIdentifier;
|
return pieceIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the identifier of the enemy piece that should be moved.
|
||||||
|
*
|
||||||
|
* @return the identifier of the enemy piece that should be moved
|
||||||
|
*/
|
||||||
|
public String getPieceIdentifierEnemy() {
|
||||||
|
return pieceIdentifierEnemy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a visitor to process this message.
|
* Accepts a visitor to process this message.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user