From b8ed5060d6937b7eb245aea5a4257d756a4079d4 Mon Sep 17 00:00:00 2001 From: Daniel Grigencha Date: Wed, 4 Dec 2024 02:42:16 +0100 Subject: [PATCH] Updated 'Board' class. Updated the 'Board' class by removing the 'playerData' attribute and its getter method from it. --- .../src/main/java/pp/mdga/game/Board.java | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) 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 b46ef62f..b7008403 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 @@ -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 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 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; - } }