diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java index a9254fb6..ec38a06a 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Player.java @@ -6,7 +6,7 @@ import java.util.ArrayList; /** - * This class will be used to handle general PlayerData + * This class represents a player in the game. */ @Serializable public class Player { @@ -44,8 +44,20 @@ public class Player { * Node and piece attributes */ private int startNodeIndex = -1; + + /** + * The home nodes of the player. + */ private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES]; + + /** + * The waiting area of the player. + */ private Piece[] waitingArea = new Piece[Resources.MAX_PIECES]; + + /** + * The pieces of the player. + */ private Piece[] pieces = new Piece[Resources.MAX_PIECES]; /** @@ -88,7 +100,6 @@ public void addHandCard(BonusCard card) { * This method will be used to remove the given card parameter from the handCards attribute of Player card. * * @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 void removeHandCard(BonusCard card) { this.handCards.remove(card); @@ -116,7 +127,12 @@ public void addWaitingPiece(Piece piece) { * @return true or false. */ public boolean isFinished() { - return false; + for (int i = 0; i < Resources.MAX_PIECES; i++) { + if (this.pieces[i].getState() != PieceState.HOMEFINISHED) { + return false; + } + } + return true; } /** @@ -255,8 +271,13 @@ public void setPieceInHome(int index, Piece piece) { this.homeNodes[index].setOccupant(piece); } + /** + * The string representation of the player + * + * @return the string representation of the player + */ @Override - public String toString(){ + public String toString() { return "Player: " + name + " Color: " + color; } }