added JavaDocs for the classes in the package 'game'
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pp.mdga.game;
|
||||
|
||||
/**
|
||||
* Represents a home node.
|
||||
*/
|
||||
public class HomeNode extends Node {
|
||||
|
||||
public HomeNode() {}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<BonusCard> 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<BonusCard> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user