diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java index 26af00c7..730c9f45 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Board.java @@ -58,6 +58,12 @@ public void setPieceOnBoard(int index, Piece piece) { infield[index].setOccupant(piece); } + /** + * This method returns the index of a specific piece on the board + * + * @param piece the piece to be searched for + * @return the index of the piece + */ public int getInfieldIndexOfPiece(Piece piece) { for (int i = 0; i < infield.length; i++) { if (infield[i].getOccupant() == piece) { diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java index 4b4f5e47..cce4fd98 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusCard.java @@ -1,8 +1,23 @@ package pp.mdga.game; +/** + * Enum representing the different types of bonus cards. + */ public enum BonusCard { + /** + * The hidden bonus card. + */ HIDDEN, + /** + * The shield bonus card. + */ SHIELD, + /** + * The turbo bonus card. + */ TURBO, + /** + * The swap bonus card. + */ SWAP } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java index 8ed4d575..157be2a1 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/BonusNode.java @@ -1,20 +1,7 @@ package pp.mdga.game; +/** + * This class represents a BonusNode + */ public class BonusNode extends Node { - - public BonusNode() {} - - /** - * This method is used to set a new Occupant - * - * @param occupant the new occupant of the node - */ - @Override - public void setOccupant(Piece occupant) { - if (occupant.isSuppressed()){ - occupant.setShield(ShieldState.NONE); - } - //Draw Card Event - this.occupant = occupant; - } } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java index 2150c0a4..8faa06b1 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/HomeNode.java @@ -1,6 +1,7 @@ package pp.mdga.game; +/** + * Represents a home node. + */ public class HomeNode extends Node { - - public HomeNode() {} } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java index f1b0b3d7..6d42092b 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Node.java @@ -6,8 +6,6 @@ public class Node { protected Piece occupant; - public Node() {} - /** * This method is used to get an occupant of the Node. * @@ -23,7 +21,7 @@ public Piece getOccupant() { * @param occupant the new occupant of the node */ public void setOccupant(Piece occupant) { - if (occupant.isSuppressed()){ + if (occupant.isSuppressed()) { occupant.setShield(ShieldState.NONE); } this.occupant = occupant; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java index 04b9d857..15f00498 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Piece.java @@ -6,9 +6,24 @@ * This class will be used to hold all Piece relevant data. */ public class Piece { + /** + * The shield state of the piece. + */ private ShieldState shield; + + /** + * The current state of the piece. + */ private PieceState state; + + /** + * The color of the piece. + */ private final Color color; + + /** + * The unique identifier of the piece. + */ private final UUID uuid = UUID.randomUUID(); /** diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java index 006e6fbd..abab1258 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/PieceState.java @@ -1,8 +1,23 @@ package pp.mdga.game; +/** + * Represents the state of a piece. + */ public enum PieceState { + /** + * The piece is active. + */ ACTIVE, + /** + * The piece is waiting. + */ WAITING, + /** + * The piece is in the home. + */ HOME, + /** + * The piece is finished. + */ HOMEFINISHED } 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 6029e396..7537333b 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,11 +6,34 @@ * This class will be used to handle general PlayerData */ public class Player { + /** + * The name of the player. + */ private String name; + + /** + * The statistics of the player. + */ private Statistic playerStatistic; + + /** + * The hand cards of the player. + */ private ArrayList handCards; + + /** + * The color of the player. + */ private Color color = Color.NONE; + + /** + * Indicates if the player is ready. + */ private boolean isReady; + + /** + * Indicates if the player is active. + */ private boolean active = true; /** @@ -72,7 +95,7 @@ public ArrayList getHandCards() { * * @param card the card to be added to the players hand */ - public void addHandCards(BonusCard card) { + public void addHandCard(BonusCard card) { handCards.add(card); } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java index c68bc8ff..f03559fa 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/PlayerData.java @@ -4,9 +4,24 @@ * This class is used to represent PlayerData related to the board */ public class PlayerData { + /** + * An array of HomeNode objects representing the home nodes of the player. + */ private HomeNode[] homeNodes; + + /** + * The index of the start node for the player. + */ private int startNodeIndex; + + /** + * An array of Piece objects representing the waiting area of the player. + */ private Piece[] waitingArea; + + /** + * An array of Piece objects representing all the pieces of the player. + */ private Piece[] pieces; /** @@ -75,7 +90,7 @@ public Piece[] getPieces() { * @param piece the piece to be added to the waiting area */ public void addWaitingPiece(Piece piece) { - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { if (waitingArea[i] == null) { waitingArea[i] = piece; return; diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java index 71e21c06..6bff3f52 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/ShieldState.java @@ -1,7 +1,19 @@ package pp.mdga.game; +/** + * Represents the state of a piece's shield. + */ public enum ShieldState { + /** + * The shield is not active. + */ NONE, + /** + * The shield is active. + */ ACTIVE, + /** + * The shield is suppressed, when the piece is on a start node. + */ SUPPRESSED } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java index 85e70cb3..4d2de491 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/StartNode.java @@ -1,24 +1,21 @@ package pp.mdga.game; +/** + * Represents a start node. + */ public class StartNode extends Node { - - public StartNode(Color color) { - this.color = color; - } - + /** + * The color of the node. + */ private Color color; /** - * This method is used to set a new Occupant + * Creates a new start node with the given color. * - * @param occupant the new occupant of the node + * @param color the color of the node */ - @Override - public void setOccupant(Piece occupant) { - if (occupant.isShielded()){ - occupant.setShield(ShieldState.SUPPRESSED); - } - this.occupant = occupant; + public StartNode(Color color) { + this.color = color; } /** diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java index 2b5e31aa..40675707 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Statistic.java @@ -4,13 +4,39 @@ * This class will be used to store Statistics during the Game; */ public class Statistic { + /** + * The number of cards played. + */ private int cardsPlayed; + + /** + * The number of pieces thrown. (enemy) + */ private int piecesThrown; + + /** + * The number of pieces being thrown. (own pieces) + */ private int piecesBeingThrown; + + /** + * The number of times a 6 was diced. + */ private int diced6; + + /** + * The number of nodes traveled. + */ private int traveledNodes; + + /** + * The number of bonus nodes activated. + */ private int activatedBonusNodes; + /** + * Constructs a new Statistic object with all values initialized to 0. + */ public Statistic() { cardsPlayed = 0; piecesThrown = 0;