Updated 'Board' class.
Updated the 'Board' class by removing the 'playerData' attribute and its getter method from it.
This commit is contained in:
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
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.
|
* This class will be used to hold all Board relevant data.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class Board {
|
public class Board {
|
||||||
private Map<Color, PlayerData> playerData = new HashMap<>();
|
/**
|
||||||
|
* Create Board attributes.
|
||||||
|
*/
|
||||||
private final Node[] infield;
|
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
|
* This method returns the index of a specific piece on the board
|
||||||
* Board class.
|
|
||||||
*
|
*
|
||||||
* @param color as the color of the player as a Color enumeration.
|
* @param piece the piece to be searched for
|
||||||
* @param playerData as the playerData of the player as a PlayerData object.
|
* @return the index of the piece
|
||||||
*/
|
*/
|
||||||
public void addPlayerData(Color color, PlayerData playerData) {
|
public int getInfieldIndexOfPiece(Piece piece) {
|
||||||
this.playerData.put(color, playerData);
|
for (int i = 0; i < infield.length; i++) {
|
||||||
|
if (infield[i].getOccupant() == piece) {
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
return -1;
|
||||||
* This method returns the playerData
|
|
||||||
*
|
|
||||||
* @return the playerData
|
|
||||||
*/
|
|
||||||
public Map<Color, PlayerData> getPlayerData() {
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,19 +66,4 @@ public Node[] getInfield() {
|
|||||||
public void setPieceOnBoard(int index, Piece piece) {
|
public void setPieceOnBoard(int index, Piece piece) {
|
||||||
infield[index].setOccupant(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user