added an ArrayList of Player in game and added the received methods in clientgamelogic

This commit is contained in:
Hanno Fleischer
2024-11-25 11:19:17 +01:00
parent 7c5720cb9d
commit 15d1c36dad
3 changed files with 196 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ public class Game {
private Board board;
private Color activeColor;
private List<Color> order;
private final ArrayList<Player> playerList = new ArrayList<>(4);
private final ArrayList<Observer> observers = new ArrayList<>();
private Player startPlayer;
@@ -400,4 +401,16 @@ public Piece getPieceThroughIdentifier(String identifier) {
int index = Integer.parseInt(parts[1]);
return board.getPlayerData().get(color).getPieces()[index];
}
public ArrayList<Player> getPlayerList() {
return playerList;
}
public void addPlayerToList(Player player) {
playerList.add(player);
}
public void removePlayerFromList(Player player) {
playerList.remove(player);
}
}

View File

@@ -11,6 +11,7 @@ public class Player {
private Statistic playerStatistic;
private ArrayList<BonusCard> handCards;
private final int id;
private Color color;
/**
* This constructor constructs a new Player object
@@ -88,4 +89,22 @@ public BonusCard removeHandCard(BonusCard card) {
public int getId() {
return id;
}
/**
* This method returns the color of the player
*
* @return the color of the player
*/
public Color getColor() {
return color;
}
/**
* This method sets the color of the player
*
* @param color the new color of the player
*/
public void setColor(Color color) {
this.color = color;
}
}