Updated 'Player' class.
Updated the 'Player' class by adding the 'setPieceInHome' method to it.
This commit is contained in:
@@ -48,6 +48,13 @@ public class Player {
|
||||
private Piece[] waitingArea = new Piece[Resources.MAX_PIECES];
|
||||
private Piece[] pieces = new Piece[Resources.MAX_PIECES];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Player() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor constructs a new Player object
|
||||
*
|
||||
@@ -57,13 +64,6 @@ public Player(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Player() {
|
||||
this("");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to initialize all nodes and pieces of the Player class.
|
||||
*/
|
||||
@@ -81,21 +81,17 @@ public void initialize() {
|
||||
* @param card the card to be added to the players hand
|
||||
*/
|
||||
public void addHandCard(BonusCard card) {
|
||||
handCards.add(card);
|
||||
this.handCards.add(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a BonusCard to be removed from the players hand.
|
||||
* This method will be used to remove the given card parameter from the handCards attribute of Player card.
|
||||
*
|
||||
* @param card the cards type to be removed
|
||||
* @param card as the card which should be removed from the handCards attribute as a PowerCard object.
|
||||
* @return the removed card or null if there is none of that card type
|
||||
*/
|
||||
public BonusCard removeHandCard(BonusCard card) {
|
||||
BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
|
||||
if (cardToRemove != null) {
|
||||
handCards.remove(cardToRemove);
|
||||
}
|
||||
return cardToRemove;
|
||||
public void removeHandCard(BonusCard card) {
|
||||
this.handCards.remove(card);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,4 +244,14 @@ public void setReady(boolean ready) {
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets a piece at the given index in the home area
|
||||
*
|
||||
* @param index the index of the node
|
||||
* @param piece the piece to be set at the given index
|
||||
*/
|
||||
public void setPieceInHome(int index, Piece piece) {
|
||||
this.homeNodes[index].setOccupant(piece);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user