Updated 'Board' class.

Updated the 'Board' class by removing the 'playerData' attribute and its getter method from it.
This commit is contained in:
Daniel Grigencha
2024-12-04 02:42:16 +01:00
parent c0b72ae4da
commit b8ed5060d6

View File

@@ -2,15 +2,14 @@
import com.jme3.network.serializing.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* This class will be used to hold all Board relevant data.
*/
@Serializable
public class Board {
private Map<Color, PlayerData> playerData = new HashMap<>();
/**
* Create Board attributes.
*/
private final Node[] infield;
/**
@@ -35,23 +34,18 @@ public Board() {
}
/**
* This method will be used to add the given color and playerData parameters to the playerData attribute of
* Board class.
* This method returns the index of a specific piece on the board
*
* @param color as the color of the player as a Color enumeration.
* @param playerData as the playerData of the player as a PlayerData object.
* @param piece the piece to be searched for
* @return the index of the piece
*/
public void addPlayerData(Color color, PlayerData playerData) {
this.playerData.put(color, playerData);
}
/**
* This method returns the playerData
*
* @return the playerData
*/
public Map<Color, PlayerData> getPlayerData() {
return playerData;
public int getInfieldIndexOfPiece(Piece piece) {
for (int i = 0; i < infield.length; i++) {
if (infield[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
/**
@@ -72,19 +66,4 @@ public Node[] getInfield() {
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) {
return i;
}
}
return -1;
}
}